aboutsummaryrefslogtreecommitdiff
path: root/examples/listId2.lua
diff options
context:
space:
mode:
Diffstat (limited to 'examples/listId2.lua')
-rw-r--r--examples/listId2.lua19
1 files changed, 7 insertions, 12 deletions
diff --git a/examples/listId2.lua b/examples/listId2.lua
index 592dae3..322d432 100644
--- a/examples/listId2.lua
+++ b/examples/listId2.lua
@@ -1,16 +1,11 @@
1local m = require'lpeglabel' 1local m = require'lpeglabel'
2local re = require'relabel' 2local re = require'relabel'
3 3
4local terror = {} 4local terror = {
5 5 ErrId = "expecting an identifier",
6local function newError(s) 6 ErrComma = "expecting ','",
7 table.insert(terror, s) 7 fail = "undefined"
8 return #terror 8}
9end
10
11local errUndef = newError("undefined")
12local errId = newError("expecting an identifier")
13local errComma = newError("expecting ','")
14 9
15local id = m.R'az'^1 10local id = m.R'az'^1
16 11
@@ -18,8 +13,8 @@ local g = m.P{
18 "S", 13 "S",
19 S = m.V"Id" * m.V"List", 14 S = m.V"Id" * m.V"List",
20 List = -m.P(1) + m.V"Comma" * m.V"Id" * m.V"List", 15 List = -m.P(1) + m.V"Comma" * m.V"Id" * m.V"List",
21 Id = m.V"Sp" * id + m.T(errId), 16 Id = m.V"Sp" * id + m.T'ErrId',
22 Comma = m.V"Sp" * "," + m.T(errComma), 17 Comma = m.V"Sp" * "," + m.T'ErrComma',
23 Sp = m.S" \n\t"^0, 18 Sp = m.S" \n\t"^0,
24} 19}
25 20