diff options
Diffstat (limited to 'examples/listIdCatch.lua')
-rw-r--r-- | examples/listIdCatch.lua | 28 |
1 files changed, 0 insertions, 28 deletions
diff --git a/examples/listIdCatch.lua b/examples/listIdCatch.lua deleted file mode 100644 index 5ad6f2d..0000000 --- a/examples/listIdCatch.lua +++ /dev/null | |||
@@ -1,28 +0,0 @@ | |||
1 | local m = require'lpeglabel' | ||
2 | |||
3 | local terror = {} | ||
4 | |||
5 | local function newError(s) | ||
6 | table.insert(terror, s) | ||
7 | return #terror | ||
8 | end | ||
9 | |||
10 | local errUndef = newError("undefined") | ||
11 | local errId = newError("expecting an identifier") | ||
12 | local errComma = newError("expecting ','") | ||
13 | |||
14 | local g = m.P{ | ||
15 | "S", | ||
16 | S = m.Lc(m.Lc(m.V"Id" * m.V"List", m.V"ErrId", errId), | ||
17 | m.V"ErrComma", errComma), | ||
18 | List = -m.P(1) + (m.V"Comma" + m.T(errComma)) * (m.V"Id" + m.T(errId)) * m.V"List", | ||
19 | Id = m.V"Sp" * m.R'az'^1, | ||
20 | Comma = m.V"Sp" * ",", | ||
21 | Sp = m.S" \n\t"^0, | ||
22 | ErrId = m.Cc(errId) / terror, | ||
23 | ErrComma = m.Cc(errComma) / terror | ||
24 | } | ||
25 | |||
26 | print(m.match(g, "one,two")) | ||
27 | print(m.match(g, "one two")) | ||
28 | print(m.match(g, "one,\n two,\nthree,")) | ||