[antlr-interest] C# Just starting with Parsers, Trees

Haralambi Haralambiev hharalambiev at gmail.com
Thu May 22 08:28:39 PDT 2008


Hello,

I was wondering - what is the purpose of collecting all the nodes into one?
What difficulties do you encounter in the current state of the tree - maybe
this could be solved in an eaiser way?

For example, if you just need the name of the function, you could always use
$funcname.text and this will get everything in one place.

Best Regards,
Hari

On 5/22/08, Doc In Nuke <docinnuke at gmail.com> wrote:
>
> 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,
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080522/f875b83f/attachment-0001.html 


More information about the antlr-interest mailing list