diff options
author | Undecidable Robot <undecidabot@gmail.com> | 2016-05-16 17:42:42 +0800 |
---|---|---|
committer | Undecidable Robot <undecidabot@gmail.com> | 2016-05-16 17:42:42 +0800 |
commit | c96e44d5bf5db7ddc58da3cb5454be3544892125 (patch) | |
tree | cafb01275a07c23ef730df0d6c5ddd07dcba69c6 | |
parent | ab140456610fb851248198d22e8fc12b1c82a4ad (diff) | |
download | lpeglabel-c96e44d5bf5db7ddc58da3cb5454be3544892125.tar.gz lpeglabel-c96e44d5bf5db7ddc58da3cb5454be3544892125.tar.bz2 lpeglabel-c96e44d5bf5db7ddc58da3cb5454be3544892125.zip |
Adding error recovery to some missing closing tokens
-rw-r--r-- | relabel.lua | 7 | ||||
-rw-r--r-- | testerrors.lua | 7 |
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) |
35 | end | 35 | end |
36 | 36 | ||
37 | local ignore = m.Cmt(any, function (input, pos) | ||
38 | return errors[#errors][2], mm.P"" | ||
39 | end) | ||
40 | |||
37 | -- Pre-defined names | 41 | -- Pre-defined names |
38 | local Predef = { nl = m.P"\n" } | 42 | local Predef = { nl = m.P"\n" } |
39 | local tlabels = {} | 43 | local 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 | ||
108 | for i, patt in ipairs(patterns) do | 113 | for i, patt in ipairs(patterns) do |