[antlr-interest] NoViableAltException
Jim Idle
jimi at temporal-wave.com
Sun Dec 13 12:01:22 PST 2009
You need to left factor the common introduction to both lays and
decide what it us when you hit ';' or don't.
Jim
On Dec 13, 2009, at 11:49, Johannes Bittner
<johannes.bittner at gmail.com> wrote:
> Hello,
>
> The Java code generated for the following grammar produces a
> NoViableAltException when using "void foo (int a, int b) { foo }" as
> input, i.e. when the second token is "foo", it works otherwise. I
> tried this with antlrworks 1.3.1. Could somebody clearify why this
> happens?
>
> Thanks, Johannes
>
> method
> : type ID '(' args ')' ';'
> | type ID '(' args ')' '{' 'foo' '}'
> ;
>
> type: 'void' | 'int';
> args: arg (',' arg)*;
> arg: 'int' ID;
>
> ID : ('a'..'z'|'A'..'Z')+ ;
> INT : '0'..'9'+ ;
> WS : (' '|'\t'|'\r'|'\n')+ {skip();} ;
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
More information about the antlr-interest
mailing list