lua-users home
lua-l archive

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


After watching the talk about LPeg I was inspired to use it to
describe the grammar of my DSL.
I now have a complete PEG grammar (LPEG.RE) of about 300 lines, but
can't find a good pointer on how to generate an AST or parse tree with
callbacks from it.
Other PEG implementations do offer this functionality (e.g.

My manual work-around currently looks like this:

Constant                <- {<String> / <Integer> / <Float> / <Symbol>
/ <InstanceName>} -> constant

grammar = re.compile(dsl, {
       constant           = function(c) return {"constant", c} end,

Do I have to do this for every non-terminal I specified? Is there
a better way to do this?