diff options
Diffstat (limited to 'examples/listId2.lua')
-rw-r--r-- | examples/listId2.lua | 19 |
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 @@ | |||
1 | local m = require'lpeglabel' | 1 | local m = require'lpeglabel' |
2 | local re = require'relabel' | 2 | local re = require'relabel' |
3 | 3 | ||
4 | local terror = {} | 4 | local terror = { |
5 | 5 | ErrId = "expecting an identifier", | |
6 | local function newError(s) | 6 | ErrComma = "expecting ','", |
7 | table.insert(terror, s) | 7 | fail = "undefined" |
8 | return #terror | 8 | } |
9 | end | ||
10 | |||
11 | local errUndef = newError("undefined") | ||
12 | local errId = newError("expecting an identifier") | ||
13 | local errComma = newError("expecting ','") | ||
14 | 9 | ||
15 | local id = m.R'az'^1 | 10 | local 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 | ||