aboutsummaryrefslogtreecommitdiff
path: root/relabel.lua
diff options
context:
space:
mode:
authorUndecidable Robot <undecidabot@gmail.com>2016-05-22 00:04:01 +0800
committerUndecidable Robot <undecidabot@gmail.com>2016-05-22 00:04:01 +0800
commitdc19cc915c712137ad631c027ca6376d535df30a (patch)
treead98e032af8355e28fa9f4feee8e42a40f19728c /relabel.lua
parentb668d2f31234854bf509e3d32ddaaff9ad61a151 (diff)
downloadlpeglabel-dc19cc915c712137ad631c027ca6376d535df30a.tar.gz
lpeglabel-dc19cc915c712137ad631c027ca6376d535df30a.tar.bz2
lpeglabel-dc19cc915c712137ad631c027ca6376d535df30a.zip
Cleaning up dummy patterns
Diffstat (limited to '')
-rw-r--r--relabel.lua9
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
25local any = m.P(1) 25local any = m.P(1)
26local dummy = mm.P(false)
26 27
27 28
28local errinfo = { 29local errinfo = {
@@ -92,7 +93,7 @@ local function expect(pattern, labelname)
92end 93end
93 94
94local ignore = m.Cmt(any, function (input, pos) 95local ignore = m.Cmt(any, function (input, pos)
95 return errfound[#errfound][2], mm.P"" 96 return errfound[#errfound][2], dummy
96end) 97end)
97 98
98local function adderror(message) 99local 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
200end 201end
@@ -225,7 +226,7 @@ local function firstdef (n, r) return adddef({n}, n, r) end
225local function NT (n, b) 226local 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
231end 232end
@@ -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 * "}";