[antlr-interest] Can't figure out the ambiguity leading to this unreachable token def

Dan th30dan at gmail.com
Sun Apr 6 00:31:26 PDT 2008


Hello all.

I've come close to tearing my hair out.  This seems like a simple problem,
but I can't figure out what the issue is.  I've even thoroughly perused the
"Ambiguities and Nondeterminisms" section of a friend's copy of "The
Definitive ANTLR Reference".  But none of the described ambiguities or
nondeterminisms seems to cover this simple case.

Here's my small test grammar:

=======================
grammar Test;

expr: '@' NAME '=' '\'' VALUE '\'';

NAME: ('a'..'z' | 'A'..'Z' | '0'..'9')+;

VALUE: ('a'..'z' | 'A'..'Z')+;
=======================

When I compile it on the command line, I get the following warning:

=======================
warning(208): Test.g:11:1: The following token definitions are unreachable:
VALUE
=======================

Then, when I try debugging it in ANTLRWorks v1.1.7 on this input:

=======================
@blah='hi'
=======================

I get the following error:

=======================
recoverFromMismatchedToken
BR.recoverFromMismatchedToken
line 1:7 mismatched input 'hi' expecting VALUE

=======================

Any help would be greatly appreciated.

Thanks,
-Dan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080406/3c4e8b42/attachment.html 


More information about the antlr-interest mailing list