[antlr-interest] if-then-else rule design question

Fridi fridi70 at gmx.de
Mon Jun 16 02:07:16 PDT 2008


I have to parse a simple specification like

    if condition then <then-action> (else <else-action>)?

If have build lexer, parser and tree parser for C# using AntlrWorks 
1.1.7. For now, that works perfect. But looking at the tree parser, it 
always runs into the the else-action if the else-part is given, although 
the condition is true and the then-action is done.

I have tried to exit the then-action, but that leeds to mismatched 
tokens exceptions - I think that is because the tree parser is kicked 
out of his AST if I manually jump out of the tree.

How can I create a tree parser that conditionally runs into specific 
leaves of the tree only? I have studied the great ANTLR book, but I did 
not find a similar example right now. Thanks in advance for any advise 
or example!

- fridi -


More information about the antlr-interest mailing list