[antlr-interest] specialStateTransition() in Java-generated lexer
Bart J. Geraci
bjg at modelsoftware.com
Thu Jul 23 13:53:33 PDT 2009
When ANTLR generates my lexer, I get this method:
***********
@Override
public int specialStateTransition(int s, IntStream _input)
throws NoViableAltException {
IntStream input = _input;
int _s = s;
switch (s) {
case 0:
int LA26_16 = input.LA(1);
s = -1;
if ((LA26_16 == '\"')) {
s = 77;
} else if (((LA26_16 >= '\u0000' && LA26_16 <= '\t')
|| (LA26_16 >= '\u000B' && LA26_16 <= '\f')
|| (LA26_16 >= '\u000E' && LA26_16 <= '!')
|| (LA26_16 >= '#' && LA26_16 <= '\u2027')
|| (LA26_16 >= '\u202A' && LA26_16 <= '\uFFFF'))) {
s = 36;
}
if (s >= 0)
return s;
break;
}
NoViableAltException nvae =
new NoViableAltException(getDescription(), 26, _s, input);
error(nvae);
throw nvae;
}
***********
What strikes me is that the method argument "s" is modified and
returned. There is a similarly named local variable "_s" that is
assigned, but is not modified.
Is this correct or should some of these "s" be "_s" ?
--
-bj-
Bart J. Geraci
bjg at modelsoftware.com
More information about the antlr-interest
mailing list