diff options
author | Undecidable Robot <undecidabot@gmail.com> | 2016-05-22 00:04:01 +0800 |
---|---|---|
committer | Undecidable Robot <undecidabot@gmail.com> | 2016-05-22 00:04:01 +0800 |
commit | dc19cc915c712137ad631c027ca6376d535df30a (patch) | |
tree | ad98e032af8355e28fa9f4feee8e42a40f19728c /relabel.lua | |
parent | b668d2f31234854bf509e3d32ddaaff9ad61a151 (diff) | |
download | lpeglabel-dc19cc915c712137ad631c027ca6376d535df30a.tar.gz lpeglabel-dc19cc915c712137ad631c027ca6376d535df30a.tar.bz2 lpeglabel-dc19cc915c712137ad631c027ca6376d535df30a.zip |
Cleaning up dummy patterns
Diffstat (limited to '')
-rw-r--r-- | relabel.lua | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/relabel.lua b/relabel.lua index ca15555..aaed25c 100644 --- a/relabel.lua +++ b/relabel.lua | |||
@@ -23,6 +23,7 @@ if version == "Lua 5.2" then _ENV = nil end | |||
23 | 23 | ||
24 | 24 | ||
25 | local any = m.P(1) | 25 | local any = m.P(1) |
26 | local dummy = mm.P(false) | ||
26 | 27 | ||
27 | 28 | ||
28 | local errinfo = { | 29 | local errinfo = { |
@@ -92,7 +93,7 @@ local function expect(pattern, labelname) | |||
92 | end | 93 | end |
93 | 94 | ||
94 | local ignore = m.Cmt(any, function (input, pos) | 95 | local ignore = m.Cmt(any, function (input, pos) |
95 | return errfound[#errfound][2], mm.P"" | 96 | return errfound[#errfound][2], dummy |
96 | end) | 97 | end) |
97 | 98 | ||
98 | local function adderror(message) | 99 | local function adderror(message) |
@@ -194,7 +195,7 @@ local defined = "%" * Def / function (c,Defs) | |||
194 | local cat = Defs and Defs[c] or Predef[c] | 195 | local cat = Defs and Defs[c] or Predef[c] |
195 | if not cat then | 196 | if not cat then |
196 | adderror ("name '" .. c .. "' undefined") | 197 | adderror ("name '" .. c .. "' undefined") |
197 | return mm.P"" | 198 | return dummy |
198 | end | 199 | end |
199 | return cat | 200 | return cat |
200 | end | 201 | end |
@@ -225,7 +226,7 @@ local function firstdef (n, r) return adddef({n}, n, r) end | |||
225 | local function NT (n, b) | 226 | local function NT (n, b) |
226 | if not b then | 227 | if not b then |
227 | adderror("rule '"..n.."' used outside a grammar") | 228 | adderror("rule '"..n.."' used outside a grammar") |
228 | return mm.P"" | 229 | return dummy |
229 | else return mm.V(n) | 230 | else return mm.V(n) |
230 | end | 231 | end |
231 | end | 232 | end |
@@ -267,7 +268,7 @@ local exp = m.P{ "Exp", | |||
267 | * m.Lc(expect(m.V"SeqLC", "ExpPatt1"), m.V"SkipToSlash", labels["ExpPatt1"]))^0) / labchoice ); | 268 | * m.Lc(expect(m.V"SeqLC", "ExpPatt1"), m.V"SkipToSlash", labels["ExpPatt1"]))^0) / labchoice ); |
268 | Labels = m.P"{" * S * expect(m.V"Label", "ExpLab1") * (S * "," * S | 269 | Labels = m.P"{" * S * expect(m.V"Label", "ExpLab1") * (S * "," * S |
269 | * expect(m.V"Label", "ExpLab2"))^0 * S * expect("}", "MisClose7"); | 270 | * expect(m.V"Label", "ExpLab2"))^0 * S * expect("}", "MisClose7"); |
270 | SkipToSlash = (-m.P"/" * m.V"Stuff")^0 * m.Cc(mm.P""); | 271 | SkipToSlash = (-m.P"/" * m.V"Stuff")^0 * m.Cc(dummy); |
271 | Stuff = m.V"GroupedStuff" + any; | 272 | Stuff = m.V"GroupedStuff" + any; |
272 | GroupedStuff = "(" * (-m.P")" * m.V"Stuff")^0 * ")" | 273 | GroupedStuff = "(" * (-m.P")" * m.V"Stuff")^0 * ")" |
273 | + "{" * (-m.P"}" * m.V"Stuff")^0 * "}"; | 274 | + "{" * (-m.P"}" * m.V"Stuff")^0 * "}"; |