[antlr-interest] strange code generated?

Terence Parr parrt at cs.usfca.edu
Fri Aug 31 08:06:45 PDT 2007


That true is me collapsing pred1||!pred1 stuff.
Ter
On Aug 31, 2007, at 7:26 AM, Martin Kohl wrote:

> Hello,
>
> Looking at the generated Parser.java, I've stumbled across the  
> following code:
>
> if ( (synpred1()) ) {
>    alt1=1;
> }
> else if ( (true) ) {
>    alt1=2;
> }
> else {
>    if (backtracking>0) {failed=true; return ;}
>    NoViableAltException nvae =
>                         new NoViableAltException(...);
>    throw nvae;
> }
>
> I think the if(true){statement} can be replaced by statement, the if 
> (true){}else{} can be shortened to if(true){}.
>
> Kind Regards,
> Martin



More information about the antlr-interest mailing list