diff options
Diffstat (limited to 'examples/listId2Rec2Cap.lua')
-rw-r--r-- | examples/listId2Rec2Cap.lua | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/examples/listId2Rec2Cap.lua b/examples/listId2Rec2Cap.lua index 7fbe700..952540a 100644 --- a/examples/listId2Rec2Cap.lua +++ b/examples/listId2Rec2Cap.lua | |||
@@ -3,7 +3,9 @@ local re = require'relabel' | |||
3 | 3 | ||
4 | local terror = { | 4 | local terror = { |
5 | ErrId = "expecting an identifier", | 5 | ErrId = "expecting an identifier", |
6 | ErrComma = "expecting ','" | 6 | ErrComma = "expecting ','", |
7 | ErrList = "expecting a list of identifiers", | ||
8 | fail = "undefined" | ||
7 | } | 9 | } |
8 | 10 | ||
9 | local subject, errors | 11 | local subject, errors |
@@ -29,16 +31,16 @@ local id = m.R'az'^1 | |||
29 | 31 | ||
30 | local g = m.P{ | 32 | local g = m.P{ |
31 | "S", | 33 | "S", |
32 | S = m.V"Id" * m.V"List", | 34 | S = m.V"List" + (m.P(1) * m.T'ErrList'), |
33 | List = -m.P(1) + m.V"Comma" * m.V"Id" * m.V"List", | 35 | List = m.V'Id' * (#m.P(1) * m.V'Comma' * (m.V'Id' + m.T'ErrId'))^0, |
34 | Id = m.V"Sp" * m.C(id) + m.T'ErrId', | 36 | Id = m.V'Sp' * m.C(id), |
35 | Comma = m.V"Sp" * "," + m.T'ErrComma', | 37 | Comma = m.V'Sp' * ',' + m.T'ErrComma', |
36 | Sp = m.S" \n\t"^0, | 38 | Sp = m.S' \n\t'^0, |
37 | ErrId = record('ErrId') * sync(m.P",") * defaultValue(), | 39 | ErrId = record'ErrId' * sync(m.P",") * defaultValue(), |
38 | ErrComma = record('ErrComma') * sync(id), | 40 | ErrComma = record'ErrComma' * sync(id), |
41 | ErrList = record'ErrList' * sync(m.P(-1)) * defaultValue() | ||
39 | } | 42 | } |
40 | 43 | ||
41 | |||
42 | function mymatch (g, s) | 44 | function mymatch (g, s) |
43 | errors = {} | 45 | errors = {} |
44 | subject = s | 46 | subject = s |