Your construct will fail if the mutant rule is empty as it will not be a
node. You want:

body : ^(MUTANTSNODE mutant+)
     | MUTANTSNODE // No children
     ;

That's a guess without looking at your tree though. If you debug the
parser grammar in AntlrWorks, you can see the tree that you are actually
building. This will help. You can also produce a dot spec for the tree
(search the list) and produce an image of it.

Jim

> -----Original Message-----
> From: [email protected] [mailto:antlr-interest-
> [email protected]] On Behalf Of Vinicius Durelli
> Sent: Friday, February 18, 2011 7:35 AM
> To: [email protected]
> Subject: [antlr-interest] Tree Grammar (Beginner doubt/problem)
>
> Hi, I have created a lexer and a parser for a rather simple DSL. A
> snippet of this DSL that I am using for testing my lexer/parser is
> attached (snippet.txt).
> However, when it comes to evaluating the AST generated by my parser, my
> tree grammar does not work properly. To be more specific, it stops
> parsing at
> rule:
>
> body : ^(MUTANTSNODE mutant*)
> ;
>
> I have created grammars for lexers and parsers before, but tree
> grammars are pretty new to my. Thus, any help on how to fix this
> problem (I am sure it must be something quite simple, I do not have a
> clue though) would be appreciated.
> Attached you will find both grammars and the foregoing snippet that I
> am using for testing purposes.
>
> I can provide more details if needed.
> For your time, thanks.
>
> Regards,
> Vinicius Durelli

List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

-- 
You received this message because you are subscribed to the Google Groups 
"il-antlr-interest" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en.

Reply via email to