From 5ffef3da93ad53069d2510a75b11ecbb1b6e8aa7 Mon Sep 17 00:00:00 2001 From: Sérgio Queiroz Date: Fri, 8 Dec 2017 10:11:50 -0300 Subject: Updating the examples since lpeglabel now returns an error position instead of a string and p^lab is syntatic sugar --- relabel.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'relabel.lua') diff --git a/relabel.lua b/relabel.lua index 642b0fe..abb3c7f 100644 --- a/relabel.lua +++ b/relabel.lua @@ -45,7 +45,7 @@ local errinfo = { {"ExpPattOrClose", "expected a pattern or closing '}' after '{'"}, - {"ExpNum", "expected a number after '^', '+' or '-' (no space)"}, + {"ExpNumName", "expected a number, '+', '-' or a name (no space) after '^'"}, {"ExpCap", "expected a string, number, '{}' or name after '->'"}, {"ExpName1", "expected the name of a rule after '=>'"}, @@ -245,7 +245,7 @@ local function getlab (f) if not tlabels[f] then error("undefined label: " .. f) end - return mm.T(tlabels[f]) + return tlabels[f] end local exp = m.P{ "Exp", @@ -269,7 +269,7 @@ local exp = m.P{ "Exp", + m.Cg(m.C(m.S"+-" * m.R"09"^1) * m.Cc(mt.__pow) + name * m.Cc"lab" ), - "ExpNum") + "ExpNumName") + "->" * expect(S * ( m.Cg((String + num) * m.Cc(mt.__div)) + m.P"{}" * m.Cc(nil, m.Ct) + m.Cg(Def / getdef * m.Cc(mt.__div)) @@ -278,7 +278,7 @@ local exp = m.P{ "Exp", + "=>" * expect(S * m.Cg(Def / getdef * m.Cc(m.Cmt)), "ExpName1") ) - )^0, function (a,b,f) if f == "lab" then return a + getlab(b) else return f(a,b) end end ); + )^0, function (a,b,f) if f == "lab" then return a + mm.T(getlab(b)) else return f(a,b) end end ); Primary = "(" * expect(m.V"Exp", "ExpPatt4") * expect(S * ")", "MisClose1") + String / mm.P + Class -- cgit v1.2.3-55-g6feb