[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: lpeg: use captures as part of the pattern
- From: Benjamin Kober <kober@...>
- Date: Thu, 06 Dec 2012 14:49:41 +0100
Hello list,
I want to implement an asciidoc parser with lpeg. Now I got stuck with
the `ifdef`-macro. It is defined
ifdef::<attribute>[]
...
endif::<attribute>[]
in the asciidoc documentation. Now I've got
start = lpeg.P"ifdef::" * attribute * "[]"
stop = lpeg.P"endif::" * attribute * "[]"
patt = start * (any-stop)^0 * stop
but to support nested `ifdef` I need to make sure that `attribute` is
exactly the same and does not just match the same pattern.
Can I use something like
att2 = attribute / lepeg.P
stop = lpeg.P"endif::" * att2 * "[]"
Any ideas?
Thx, Benjamin