[antlr-interest] Re: doubt in java grammar,

micheal_jor <open.zone at virgin.net> open.zone at virgin.net
Mon Feb 10 10:29:48 PST 2003


> > > hi,
> > >  in the java grammar i found this rule ..
> > > 
> > > // conditional test (level 12)
> > > conditionalExpression
> > > 	:	logicalOrExpression
> > > 		( QUESTION^ assignmentExpression COLON! 
> > conditionalExpression )?
> > > 	;
> > > 
> > > is it not true that (expr)? { s1;} : {s2} ;
> > > is same as if(expr)
> > >              {s1;}
> > >             else
> > >              {s2;}
> > > 
> > > in which case both of them should be statement|blockstatement
> > > 
> > > ; also could some one explain why the existing choice was made?

<SNIPPED>

> im sorry you missed the point; it is not abt the equivalence of the
> two constructs that i was asking, but it was abt using
> assignmentExpression and conditionalExpression , where i thought
> statement could have been used ;
> cheers
> ram

My mistake. The conditionalExpression is an expression not a 
statement. It has a type unlike statements.

INCORRECT: cond ? stmt1 : stmt2
CORRECT  : cond ? expr1 : expr2

Cheers,

Micheal



 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 



More information about the antlr-interest mailing list