aboutsummaryrefslogtreecommitdiff
path: root/examples/listId2.lua
diff options
context:
space:
mode:
authorSergio Queiroz <sqmedeiros@gmail.com>2016-11-14 17:15:27 -0300
committerSergio Queiroz <sqmedeiros@gmail.com>2016-11-14 17:15:27 -0300
commit448762908fd822fbc101a4fe66fac9cd8aa913b5 (patch)
treec7bc865aa66f557be6d3d9d422bcaec42a8be0be /examples/listId2.lua
parentfd28f9d9e54f33bf7ae3a5e12dc71478f9c91aea (diff)
downloadlpeglabel-448762908fd822fbc101a4fe66fac9cd8aa913b5.tar.gz
lpeglabel-448762908fd822fbc101a4fe66fac9cd8aa913b5.tar.bz2
lpeglabel-448762908fd822fbc101a4fe66fac9cd8aa913b5.zip
Changing documentation and examples with recovery
Diffstat (limited to 'examples/listId2.lua')
-rw-r--r--examples/listId2.lua13
1 files changed, 8 insertions, 5 deletions
diff --git a/examples/listId2.lua b/examples/listId2.lua
index 509fda4..46f0063 100644
--- a/examples/listId2.lua
+++ b/examples/listId2.lua
@@ -1,5 +1,5 @@
1local m = require'lpeglabel' 1local m = require'lpeglabelrec'
2local re = require'relabel' 2local re = require'relabelrec'
3 3
4local terror = {} 4local terror = {}
5 5
@@ -12,15 +12,18 @@ local errUndef = newError("undefined")
12local errId = newError("expecting an identifier") 12local errId = newError("expecting an identifier")
13local errComma = newError("expecting ','") 13local errComma = newError("expecting ','")
14 14
15local id = m.R'az'^1
16
15local g = m.P{ 17local g = m.P{
16 "S", 18 "S",
17 S = m.V"Id" * m.V"List", 19 S = m.V"Id" * m.V"List",
18 List = -m.P(1) + (m.V"Comma" + m.T(errComma)) * (m.V"Id" + m.T(errId)) * m.V"List", 20 List = -m.P(1) + m.V"Comma" * m.V"Id" * m.V"List",
19 Id = m.V"Sp" * m.R'az'^1, 21 Id = m.V"Sp" * id + m.T(errId),
20 Comma = m.V"Sp" * ",", 22 Comma = m.V"Sp" * "," + m.T(errComma),
21 Sp = m.S" \n\t"^0, 23 Sp = m.S" \n\t"^0,
22} 24}
23 25
26
24function mymatch (g, s) 27function mymatch (g, s)
25 local r, e, sfail = g:match(s) 28 local r, e, sfail = g:match(s)
26 if not r then 29 if not r then