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  
<[email protected]> 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

List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

--

You received this message because you are subscribed to the Google Groups 
"il-antlr-interest" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en.


Reply via email to