lua-users home
lua-l archive

lpeg: use captures as part of the pattern

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


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

AltStyle によって変換されたページ (->オリジナル) /