[antlr-interest] C# Just starting with Parsers, Trees
Doc In Nuke
docinnuke at gmail.com
Thu May 22 08:12:32 PDT 2008
Hi @ all
First of all let me apologize for the english mistakes you will surely
find in this message.
So, I just started working with ANTLR a few days ago.
I was able to generate a parser and lexer for the lua grammar provided
on the site.
Now I also was able to create nodes / sub trees using the ^ parameter in
the grammar.
I also modified the grammar a bit to try to generate what i really
wanted in the end.
One of the rule i added for exemple is the following one:
globalfuncdec : 'function' ^ funcname funcbody ;
so for every global function (declaration not starting with local) i get
a subtree with the funcname and funcbody block.
Now what would really be nice is a way to get the funcname as 1 token
and not more.
funcname is the following rule:
funcname : NAME ('.' NAME)* (':' NAME)? ;
in the same way having just a childnode named funcbody with all the
stuff related to funcbody under it would be great.
So i would have something like that:
function
/ \
funcname/value funcbody
/ \
stuff_1 ... stuff_n
So I was wondering if one can do such a thing, and if yes, how ?
Best Regards,
More information about the antlr-interest
mailing list