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

Norbert Kiesel nkiesel at tbdnetworks.com
Tue Oct 16 21:09:26 PDT 2007


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


-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20071016/fe950cf4/attachment.bin 


More information about the antlr-interest mailing list