[antlr-interest] newbie problem with mismatched token in antr v3

Austin Hastings Austin_Hastings at Yahoo.com
Tue Oct 16 21:20:23 PDT 2007


Norbert,

There's a solitary apostrophe in your ITFNAME rule that probably doesn't 
belong.  Also, you're defining ITFNAME as something with spaces in the 
middle. Is that what you intended?

=Austin


Norbert Kiesel wrote:
> Hi,
>
> I have problems with "keywords vs. identifiers" in my grammar, and even
> the "grammar CommandLanguage;" from the "Quick  Starter on Parser
> Grammars" does not work for me. The latter gives me a
> "MismatchedTokenException" for "get data from xxx".
>
> My smallest test grammar looks like this:
>
> grammar itf;
> @members { // main method that calls parser.itf() }
> itf	  	: 'interface' itfname EOF ;
> WS		: ( ' '+ ) { $channel = HIDDEN; } ;
> itfname		:  ITFNAME ;
> ITFNAME		: ( 'a'..'z' )+ ' WS ( '0' | '9' | '/' )+ ;
>
> When I run that against "interface xx 9", I get
>
> line 1:10 required (...)+ loop did not match anything at character 'x'
> line 1:14 no viable alternative at character '\n'
> BR.recoverFromMismatchedToken
> line 1:11 mismatched input 'x 9' expecting 'interface'
>
> Can someone please tell me what I'm doing wrong?
>
> Best,
>   Norbert
>
>
>   



More information about the antlr-interest mailing list