diff options
author | Sérgio Queiroz <sqmedeiros@gmail.com> | 2017-12-08 10:11:50 -0300 |
---|---|---|
committer | Sérgio Queiroz <sqmedeiros@gmail.com> | 2017-12-08 10:11:50 -0300 |
commit | 5ffef3da93ad53069d2510a75b11ecbb1b6e8aa7 (patch) | |
tree | e98c59a9e0aae891638eca25a25558d933fdf44f /relabel.lua | |
parent | 030df9b4a4f4dc3a2cc5775e032f83e92d3c0097 (diff) | |
download | lpeglabel-5ffef3da93ad53069d2510a75b11ecbb1b6e8aa7.tar.gz lpeglabel-5ffef3da93ad53069d2510a75b11ecbb1b6e8aa7.tar.bz2 lpeglabel-5ffef3da93ad53069d2510a75b11ecbb1b6e8aa7.zip |
Updating the examples since lpeglabel now returns an error position instead of a string and p^lab is syntatic sugar
Diffstat (limited to 'relabel.lua')
-rw-r--r-- | relabel.lua | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/relabel.lua b/relabel.lua index 642b0fe..abb3c7f 100644 --- a/relabel.lua +++ b/relabel.lua | |||
@@ -45,7 +45,7 @@ local errinfo = { | |||
45 | 45 | ||
46 | {"ExpPattOrClose", "expected a pattern or closing '}' after '{'"}, | 46 | {"ExpPattOrClose", "expected a pattern or closing '}' after '{'"}, |
47 | 47 | ||
48 | {"ExpNum", "expected a number after '^', '+' or '-' (no space)"}, | 48 | {"ExpNumName", "expected a number, '+', '-' or a name (no space) after '^'"}, |
49 | {"ExpCap", "expected a string, number, '{}' or name after '->'"}, | 49 | {"ExpCap", "expected a string, number, '{}' or name after '->'"}, |
50 | 50 | ||
51 | {"ExpName1", "expected the name of a rule after '=>'"}, | 51 | {"ExpName1", "expected the name of a rule after '=>'"}, |
@@ -245,7 +245,7 @@ local function getlab (f) | |||
245 | if not tlabels[f] then | 245 | if not tlabels[f] then |
246 | error("undefined label: " .. f) | 246 | error("undefined label: " .. f) |
247 | end | 247 | end |
248 | return mm.T(tlabels[f]) | 248 | return tlabels[f] |
249 | end | 249 | end |
250 | 250 | ||
251 | local exp = m.P{ "Exp", | 251 | local exp = m.P{ "Exp", |
@@ -269,7 +269,7 @@ local exp = m.P{ "Exp", | |||
269 | + m.Cg(m.C(m.S"+-" * m.R"09"^1) * m.Cc(mt.__pow) | 269 | + m.Cg(m.C(m.S"+-" * m.R"09"^1) * m.Cc(mt.__pow) |
270 | + name * m.Cc"lab" | 270 | + name * m.Cc"lab" |
271 | ), | 271 | ), |
272 | "ExpNum") | 272 | "ExpNumName") |
273 | + "->" * expect(S * ( m.Cg((String + num) * m.Cc(mt.__div)) | 273 | + "->" * expect(S * ( m.Cg((String + num) * m.Cc(mt.__div)) |
274 | + m.P"{}" * m.Cc(nil, m.Ct) | 274 | + m.P"{}" * m.Cc(nil, m.Ct) |
275 | + m.Cg(Def / getdef * m.Cc(mt.__div)) | 275 | + m.Cg(Def / getdef * m.Cc(mt.__div)) |
@@ -278,7 +278,7 @@ local exp = m.P{ "Exp", | |||
278 | + "=>" * expect(S * m.Cg(Def / getdef * m.Cc(m.Cmt)), | 278 | + "=>" * expect(S * m.Cg(Def / getdef * m.Cc(m.Cmt)), |
279 | "ExpName1") | 279 | "ExpName1") |
280 | ) | 280 | ) |
281 | )^0, function (a,b,f) if f == "lab" then return a + getlab(b) else return f(a,b) end end ); | 281 | )^0, function (a,b,f) if f == "lab" then return a + mm.T(getlab(b)) else return f(a,b) end end ); |
282 | Primary = "(" * expect(m.V"Exp", "ExpPatt4") * expect(S * ")", "MisClose1") | 282 | Primary = "(" * expect(m.V"Exp", "ExpPatt4") * expect(S * ")", "MisClose1") |
283 | + String / mm.P | 283 | + String / mm.P |
284 | + Class | 284 | + Class |