[antlr-interest] ANTLR code generator suggestion

Keith Whittingham kwhittingham at gmail.com
Sun Nov 25 23:37:25 PST 2007


Hi ANTLR people,

In certain circumstances the code generator generates:

         public int specialStateTransition(int s, IntStream input) throws  
NoViableAltException {
         	int _s = s;
             switch ( s ) {
		...set s to different values depeing on what is encountered...
             }
             NoViableAltException nvae =
                 new NoViableAltException(getDescription(), 1, _s, input);
             error(nvae);
             throw nvae;
         }
     }

It would be better to manipulate the variable "_s" rather than the  
argument "s". I compile with a lint option that flags changing the values  
of arguments as this is quite bad practice. When you throw the exception  
it's nice to know that the argument has still the same value and the  
variable is the latest value.

Thanks for the great work!
Keith


More information about the antlr-interest mailing list