At 22:59 17/09/2009, Gavin Lambert wrote:
> 
> 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) ));

OK. I've tried this code, but both ANTLR 3.1.2 and 3.1.3 generate a faulty
tree parser, as they don't declare a "expression" variable in the
corresponding specialStateTransition function. 

I think this is a bug. How can I report it?


But, finally, for the record, I have a functional solution.

First of all, I have defined a new private member for the Tree Parser class.

@members {
        ...
        private boolean lastCondExp = false;
        ...
}

And I use it for save the last conditional expression:

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


Thanks all for your help!
--
David Marín Carreño


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