[antlr-interest] conditional tree jumping,
Craig Main
craig at palantir.co.za
Sat Feb 18 01:55:04 PST 2006
Hi,
Is there any way of only evaluating the true part when the condition is
true, and the false part if the condition is false in the below tree?
statement {log.Debug(null); object result = null;}
: #(ASSIGN id:ID result=expression {
log.Info(string.Format("{0} = {1}", id.getText(), result)); } )
| #(TOK_CONST cid:ID ASSIGN result=term)
{log.Info("constant decl");}
| {log.Debug("inside");}
#(TOK_IF condition (statement)*
({log.Debug("in-else");} TOK_ELSE (statement)* {log.Debug("out-else");})?)
{log.Debug("outside");}
;
condition
returns [object result] {log.Debug(null); result = null; object
l, r;}
: #(TOK_OR l=condition r=condition)
| #(TOK_AND l=condition r=condition)
| #(NOT_EQUAL l=condition r=condition)
| #(EQUAL l=condition r=condition)
| #(LTHAN l=condition r=condition)
| #(GTHAN l=condition r=condition)
| #(LTE l=condition r=condition)
| #(GTE l=condition r=condition)
| result=expression
{log.Debug("condition->expression");}
;
Regards
Craig
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20060218/44c9b6c0/attachment.html
More information about the antlr-interest
mailing list