From dc19cc915c712137ad631c027ca6376d535df30a Mon Sep 17 00:00:00 2001 From: Undecidable Robot Date: Sun, 22 May 2016 00:04:01 +0800 Subject: Cleaning up dummy patterns --- relabel.lua | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'relabel.lua') 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 local any = m.P(1) +local dummy = mm.P(false) local errinfo = { @@ -92,7 +93,7 @@ local function expect(pattern, labelname) end local ignore = m.Cmt(any, function (input, pos) - return errfound[#errfound][2], mm.P"" + return errfound[#errfound][2], dummy end) local function adderror(message) @@ -194,7 +195,7 @@ local defined = "%" * Def / function (c,Defs) local cat = Defs and Defs[c] or Predef[c] if not cat then adderror ("name '" .. c .. "' undefined") - return mm.P"" + return dummy end return cat end @@ -225,7 +226,7 @@ local function firstdef (n, r) return adddef({n}, n, r) end local function NT (n, b) if not b then adderror("rule '"..n.."' used outside a grammar") - return mm.P"" + return dummy else return mm.V(n) end end @@ -267,7 +268,7 @@ local exp = m.P{ "Exp", * m.Lc(expect(m.V"SeqLC", "ExpPatt1"), m.V"SkipToSlash", labels["ExpPatt1"]))^0) / labchoice ); Labels = m.P"{" * S * expect(m.V"Label", "ExpLab1") * (S * "," * S * expect(m.V"Label", "ExpLab2"))^0 * S * expect("}", "MisClose7"); - SkipToSlash = (-m.P"/" * m.V"Stuff")^0 * m.Cc(mm.P""); + SkipToSlash = (-m.P"/" * m.V"Stuff")^0 * m.Cc(dummy); Stuff = m.V"GroupedStuff" + any; GroupedStuff = "(" * (-m.P")" * m.V"Stuff")^0 * ")" + "{" * (-m.P"}" * m.V"Stuff")^0 * "}"; -- cgit v1.2.3-55-g6feb