lua-users home
lua-l archive

[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