aboutsummaryrefslogtreecommitdiff
path: root/examples/listIdCatch.lua
diff options
context:
space:
mode:
Diffstat (limited to 'examples/listIdCatch.lua')
-rw-r--r--examples/listIdCatch.lua28
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 @@
1local m = require'lpeglabel'
2
3local terror = {}
4
5local function newError(s)
6 table.insert(terror, s)
7 return #terror
8end
9
10local errUndef = newError("undefined")
11local errId = newError("expecting an identifier")
12local errComma = newError("expecting ','")
13
14local 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
26print(m.match(g, "one,two"))
27print(m.match(g, "one two"))
28print(m.match(g, "one,\n two,\nthree,"))