[antlr-interest] NoViableAltException in argumentList

Steve Bennett stevagewp at gmail.com
Fri Nov 23 22:02:43 PST 2007


On 11/24/07, Lucas Ontivero <lucasontivero at hotmail.com> wrote:
> Somebody could help me with this? I have the following rule:
<snip>

It worked fine for me. Here's the complete code I used:
----
grammar ontiverocode ;
options {output = AST;}

tokens {
ARGUMENT_LIST;
ARGUMENT;
}

argumentList
    : argument (',' argument)* -> ^(ARGUMENT_LIST argument+)
    ;

argument
    : typeName IDENTIFIER -> ^(ARGUMENT typeName IDENTIFIER)
    ;

typeName
    : 'char'
    | 'bool'
    | 'int'
    ;

 IDENTIFIER: 'a'..'z'+;
 WS: ' '+ {skip();};
----

Also, you probably want to use the debugger rather than the
interpreter so you can actually see the AST you're building...

Steve


More information about the antlr-interest mailing list