[antlr-interest] (no subject)

David Marín Carreño dmarin at sice.com
Thu Sep 17 09:00:31 PDT 2009


Hi all.

I am developing a tree parser, and I have a problem with the if/then/else
construction.

My AST tree has the following formats for conditional statements:

^(IF condition ^(THEN statements)) |
^(IFELSE condition ^(THEN then_s=statements) ^(ELSE else_s=statements))


I don't know how to skip THEN statements when the condition is false.
I am trying the following:

conditionalifthen: 
  ^(IF expression ( { $expression.value != 0 }? => ^(THEN statements) | .));
     
conditionalifthenelse: 
  ^(IFELSE expression
    ( { $expression.value != 0 }? => ^(THEN statements) . |
                                    . ^(ELSE statements) ));

without success, until now.

Any clue of how can I solve this problem, or which documentation can I
follow?

Thanks a lot.

Greetings,
-- 
David Marín Carreño 
S.I.C.E. 
Dirección Técnica. 
Tfno 91 623 22 30
E-mail: dmarin at sice.com
 





More information about the antlr-interest mailing list