diff options
author | Undecidable Robot <undecidabot@gmail.com> | 2016-05-16 21:00:02 +0800 |
---|---|---|
committer | Undecidable Robot <undecidabot@gmail.com> | 2016-05-16 21:00:02 +0800 |
commit | 977213610df9ca3065de4ae60c7cf012c46f2834 (patch) | |
tree | e6ac723d3dd19f24570805ae3fd584500953df1c | |
parent | 2c9d40dc6a23a55f6c67b59735606e3511a2c6ad (diff) | |
download | lpeglabel-977213610df9ca3065de4ae60c7cf012c46f2834.tar.gz lpeglabel-977213610df9ca3065de4ae60c7cf012c46f2834.tar.bz2 lpeglabel-977213610df9ca3065de4ae60c7cf012c46f2834.zip |
Making skips in error recovery more intelligent
-rw-r--r-- | relabel.lua | 9 | ||||
-rw-r--r-- | testerrors.lua | 11 |
2 files changed, 15 insertions, 5 deletions
diff --git a/relabel.lua b/relabel.lua index 7055eaa..e3b7d48 100644 --- a/relabel.lua +++ b/relabel.lua | |||
@@ -188,9 +188,14 @@ end | |||
188 | 188 | ||
189 | local exp = m.P{ "Exp", | 189 | local exp = m.P{ "Exp", |
190 | Exp = S * ( m.V"Grammar" | 190 | Exp = S * ( m.V"Grammar" |
191 | + (m.V"Seq" * ("/" * (m.V"Labels" + m.Cc(nil)) * S | 191 | + (m.V"SeqLC" * ("/" * (m.V"Labels" + m.Cc(nil)) * S |
192 | * m.Lc(m.V"Seq" + throw(4), (-m.P"/" * any)^0, 4, 5, 6, 7, 8, 9, 10))^0) / labchoice ); | 192 | * m.Lc(m.V"SeqLC" + throw(4), m.V"SkipToSlash", 4))^0) / labchoice ); |
193 | Labels = m.Ct(m.P"{" * S * (m.V"Label" + throw(27)) * (S * "," * S * (m.V"Label" + throw(28)))^0 * S * ("}" + throw(29))); | 193 | Labels = m.Ct(m.P"{" * S * (m.V"Label" + throw(27)) * (S * "," * S * (m.V"Label" + throw(28)))^0 * S * ("}" + throw(29))); |
194 | SkipToSlash = (-m.P"/" * m.V"Stuff")^0 * m.Cc(mm.P""); | ||
195 | Stuff = m.V"GroupedStuff" + any; | ||
196 | GroupedStuff = "(" * (-m.P")" * m.V"Stuff")^0 * ")" | ||
197 | + "{" * (-m.P"}" * m.V"Stuff")^0 * "}"; | ||
198 | SeqLC = m.Lc(m.V"Seq", m.V"SkipToSlash", 5, 6, 7, 8, 9, 10); | ||
194 | Seq = m.Cf(m.Cc(m.P"") * m.V"Prefix"^1 , mt.__mul); | 199 | Seq = m.Cf(m.Cc(m.P"") * m.V"Prefix"^1 , mt.__mul); |
195 | Prefix = "&" * S * (m.V"Prefix" + throw(5)) / mt.__len | 200 | Prefix = "&" * S * (m.V"Prefix" + throw(5)) / mt.__len |
196 | + "!" * S * (m.V"Prefix" + throw(6)) / mt.__unm | 201 | + "!" * S * (m.V"Prefix" + throw(6)) / mt.__unm |
diff --git a/testerrors.lua b/testerrors.lua index ab1c665..bcab65f 100644 --- a/testerrors.lua +++ b/testerrors.lua | |||
@@ -100,7 +100,7 @@ local patterns = { | |||
100 | [[{|@|}]], | 100 | [[{|@|}]], |
101 | [['p' {| 'q' / 'r' }]], | 101 | [['p' {| 'q' / 'r' }]], |
102 | -- 71-75 | 102 | -- 71-75 |
103 | [['a'/{1}'b'/'c']], | 103 | [['a'/{1}'b'/'c']], -- should not fail anymore |
104 | [[x <- {:x:}]], | 104 | [[x <- {:x:}]], |
105 | [[&'p'/&/!/'p'^'q']], | 105 | [[&'p'/&/!/'p'^'q']], |
106 | [[ | 106 | [[ |
@@ -113,7 +113,7 @@ local patterns = { | |||
113 | A <- 'A again' | 113 | A <- 'A again' |
114 | A <- 'and again' | 114 | A <- 'and again' |
115 | ]], | 115 | ]], |
116 | -- 76 - 79 | 116 | -- 76 - 80 |
117 | [[names not in grammar]], | 117 | [[names not in grammar]], |
118 | [[ | 118 | [[ |
119 | A <- %nosuch %def | 119 | A <- %nosuch %def |
@@ -121,7 +121,12 @@ local patterns = { | |||
121 | A <- 'and again' | 121 | A <- 'and again' |
122 | ]], | 122 | ]], |
123 | [[ A <- %nosuch ('error' ]], | 123 | [[ A <- %nosuch ('error' ]], |
124 | [[A <- Unknown Rules]] | 124 | [[A <- Unknown Rules]], |
125 | [['a' / &@ ('c' / 'd')]], | ||
126 | -- 81 - 83 | ||
127 | [['x' / & / 'y']], | ||
128 | [[&/'p'/!/'q']], | ||
129 | [['p'//'q']], | ||
125 | } | 130 | } |
126 | 131 | ||
127 | for i, patt in ipairs(patterns) do | 132 | for i, patt in ipairs(patterns) do |