aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUndecidable Robot <undecidabot@gmail.com>2016-05-24 12:57:49 +0800
committerUndecidable Robot <undecidabot@gmail.com>2016-05-24 13:20:52 +0800
commit572cd748572d2b0bc91727a6164b2a031e0e129f (patch)
tree477a87109ad8f10d6e4ef234e5a1d97024954463
parentd9a9cbdaadcecee63b7d7a47c5fa856e97d21950 (diff)
downloadlpeglabel-572cd748572d2b0bc91727a6164b2a031e0e129f.tar.gz
lpeglabel-572cd748572d2b0bc91727a6164b2a031e0e129f.tar.bz2
lpeglabel-572cd748572d2b0bc91727a6164b2a031e0e129f.zip
Improving error recovery via skipping
-rw-r--r--relabel.lua13
1 files changed, 8 insertions, 5 deletions
diff --git a/relabel.lua b/relabel.lua
index 797e094..f8ab4e7 100644
--- a/relabel.lua
+++ b/relabel.lua
@@ -280,18 +280,21 @@ local exp = m.P{ "Exp",
280 Exp = S * ( m.V"Grammar" 280 Exp = S * ( m.V"Grammar"
281 + (m.V"SeqLC" * (S * "/" * m.Lc((m.Ct(m.V"Labels") + m.Cc(nil)) 281 + (m.V"SeqLC" * (S * "/" * m.Lc((m.Ct(m.V"Labels") + m.Cc(nil))
282 * expect(S * m.V"SeqLC", "ExpPatt1"), 282 * expect(S * m.V"SeqLC", "ExpPatt1"),
283 m.Cc(nil) * m.V"SkipToSlash", 283 m.Cc(nil) * m.V"Skip",
284 unpack(labelset3)) 284 unpack(labelset3))
285 )^0 285 )^0
286 ) / labchoice); 286 ) / labchoice);
287 Labels = m.P"{" * expect(S * m.V"Label", "ExpLab1") 287 Labels = m.P"{" * expect(S * m.V"Label", "ExpLab1")
288 * (S * "," * expect(S * m.V"Label", "ExpLab2"))^0 288 * (S * "," * expect(S * m.V"Label", "ExpLab2"))^0
289 * expect(S * "}", "MisClose7"); 289 * expect(S * "}", "MisClose7");
290 SkipToSlash = (-m.P"/" * m.V"Stuff")^0 * m.Cc(dummy); 290 Skip = (-m.P"/" * -m.P(name * arrow) * m.V"Stuff")^0 * m.Cc(dummy);
291 Stuff = m.V"Group" + any; 291 Stuff = m.V"Group" + any;
292 Group = "(" * (-m.P")" * m.V"Stuff")^0 * ")" 292 Group = "(" * (-m.P")" * m.V"Stuff")^0 * ")"
293 + "{" * (-m.P"}" * m.V"Stuff")^0 * "}"; 293 + "{" * (-m.P"}" * m.V"Stuff")^0 * "}"
294 SeqLC = m.Lc(m.V"Seq", m.V"SkipToSlash", unpack(labelset1)); 294 + "[" * (-m.P"]" * m.V"Stuff")^0 * "]"
295 + "'" * (-m.P"'" * m.V"Stuff")^0 * "'"
296 + '"' * (-m.P'"' * m.V"Stuff")^0 * '"';
297 SeqLC = m.Lc(m.V"Seq", m.V"Skip", unpack(labelset1));
295 Seq = m.Cf(m.Cc(m.P"") * m.V"Prefix" * (S * m.V"Prefix")^0, mt.__mul); 298 Seq = m.Cf(m.Cc(m.P"") * m.V"Prefix" * (S * m.V"Prefix")^0, mt.__mul);
296 Prefix = "&" * expect(S * m.V"Prefix", "ExpPatt2") / mt.__len 299 Prefix = "&" * expect(S * m.V"Prefix", "ExpPatt2") / mt.__len
297 + "!" * expect(S * m.V"Prefix", "ExpPatt3") / mt.__unm 300 + "!" * expect(S * m.V"Prefix", "ExpPatt3") / mt.__unm
@@ -350,7 +353,7 @@ local function lineno (s, i)
350 local adjust = 0 353 local adjust = 0
351 if s:sub(i,i) == '\n' then 354 if s:sub(i,i) == '\n' then
352 i = i-1 355 i = i-1
353 adjust = 1 356 adjust = 1
354 end 357 end
355 local rest, num = s:sub(1,i):gsub("[^\n]*\n", "") 358 local rest, num = s:sub(1,i):gsub("[^\n]*\n", "")
356 local r = #rest 359 local r = #rest