[antlr-interest] (no subject)

Gavin Lambert antlr at mirality.co.nz
Thu Sep 17 13:58:32 PDT 2009


At 04:00 18/09/2009, David Marín Carreño wrote:
 >^(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.

Match the tree and skip the statements:

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

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



More information about the antlr-interest mailing list