aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUndecidable Robot <undecidabot@gmail.com>2016-05-16 17:42:42 +0800
committerUndecidable Robot <undecidabot@gmail.com>2016-05-16 17:42:42 +0800
commitc96e44d5bf5db7ddc58da3cb5454be3544892125 (patch)
treecafb01275a07c23ef730df0d6c5ddd07dcba69c6
parentab140456610fb851248198d22e8fc12b1c82a4ad (diff)
downloadlpeglabel-c96e44d5bf5db7ddc58da3cb5454be3544892125.tar.gz
lpeglabel-c96e44d5bf5db7ddc58da3cb5454be3544892125.tar.bz2
lpeglabel-c96e44d5bf5db7ddc58da3cb5454be3544892125.zip
Adding error recovery to some missing closing tokens
-rw-r--r--relabel.lua7
-rw-r--r--testerrors.lua7
2 files changed, 12 insertions, 2 deletions
diff --git a/relabel.lua b/relabel.lua
index 1ded6b2..2cdf1ad 100644
--- a/relabel.lua
+++ b/relabel.lua
@@ -34,6 +34,10 @@ local function throw(label)
34 return m.Cmt("", record) * m.T(label) 34 return m.Cmt("", record) * m.T(label)
35end 35end
36 36
37local ignore = m.Cmt(any, function (input, pos)
38 return errors[#errors][2], mm.P""
39end)
40
37-- Pre-defined names 41-- Pre-defined names
38local Predef = { nl = m.P"\n" } 42local Predef = { nl = m.P"\n" }
39local tlabels = {} 43local tlabels = {}
@@ -186,7 +190,7 @@ local exp = m.P{ "Exp",
186 Prefix = "&" * S * (m.V"Prefix" + throw(5)) / mt.__len 190 Prefix = "&" * S * (m.V"Prefix" + throw(5)) / mt.__len
187 + "!" * S * (m.V"Prefix" + throw(6)) / mt.__unm 191 + "!" * S * (m.V"Prefix" + throw(6)) / mt.__unm
188 + m.V"Suffix"; 192 + m.V"Suffix";
189 Suffix = m.Cf(m.V"Primary" * S * 193 Suffix = m.Cf(m.V"PrimaryLC" * S *
190 ( ( m.P"+" * m.Cc(1, mt.__pow) 194 ( ( m.P"+" * m.Cc(1, mt.__pow)
191 + m.P"*" * m.Cc(0, mt.__pow) 195 + m.P"*" * m.Cc(0, mt.__pow)
192 + m.P"?" * m.Cc(-1, mt.__pow) 196 + m.P"?" * m.Cc(-1, mt.__pow)
@@ -202,6 +206,7 @@ local exp = m.P{ "Exp",
202 + "=>" * S * (m.Cg(Def / getdef * m.Cc(m.Cmt)) + throw(10)) 206 + "=>" * S * (m.Cg(Def / getdef * m.Cc(m.Cmt)) + throw(10))
203 ) * S 207 ) * S
204 )^0, function (a,b,f) return f(a,b) end ); 208 )^0, function (a,b,f) return f(a,b) end );
209 PrimaryLC = m.Lc(m.V"Primary", ignore, 12, 15, 18, 20, 25, 29, 33);
205 Primary = "(" * (m.V"Exp" + throw(11)) * (")" + throw(12)) 210 Primary = "(" * (m.V"Exp" + throw(11)) * (")" + throw(12))
206 + String / mm.P 211 + String / mm.P
207 + Class 212 + Class
diff --git a/testerrors.lua b/testerrors.lua
index 7ffcd04..dff35df 100644
--- a/testerrors.lua
+++ b/testerrors.lua
@@ -102,7 +102,12 @@ local patterns = {
102 -- 71-73 102 -- 71-73
103 [['a'/{1}'b'/'c']], 103 [['a'/{1}'b'/'c']],
104 [[x <- {:x:}]], 104 [[x <- {:x:}]],
105 [[&'p'/&/!/'p'^'q']] 105 [[&'p'/&/!/'p'^'q']],
106 [[
107 A <- 'a' (B 'b'
108 B <- 'x' / !
109 C <- 'c'
110 ]]
106} 111}
107 112
108for i, patt in ipairs(patterns) do 113for i, patt in ipairs(patterns) do