[antlr-interest] Unexpected Token dearly expected...
Chantal Ackermann
chantal.ackermann at web.de
Wed Dec 20 07:44:14 PST 2006
Hello Kay, hello Dominik, hello all,
thanks for your help!
Case sensitivity really was the problem, oh my...
> Is case sensitivity turned on or off in the lexer? If it is case
> sensitive, that might explain the no viable alt exception.
> You're probably better off by specifying everything in lowercase in
> the recognizer and normalize the input (as you already seem to do
> with umlauts) (klingt immer irgendwie komisch auf Englisch, nicht
> wahr? ;))
>
actually, I do normalize the input to lowercase and break up the
"umlaute", but I did comment the line where I set caseSensitive=false.
I did specify all the other tokens in lowercase, and obviously I forgot
about that while playing around with new expressions...
I might just remove the comment at caseSensitive=false, but I think I
had some reason to put it there even though I can't remember it
anymore. So for now I just changed "Stunden" to "stunden". ;-D
Ok, thanks a lot, in any case. This was just the stupid mistake I
suspected I'd have missed.
Am 14.12.2006 um 14:00 schrieb Dominik Holenstein:
> Just one idea:
>
> Your code snippet:
>
> STUNDEN_ANGABE
> : DIGIT " Stunden"
> ;
>
> Try this (not tested yet):
>
> STUNDEN_ANGABE
> : (DIGIT)* HOURS
> ;
>
> WS
> : (' ' | '\t') {$setType(Token.SKIP);}
> ;
>
> protected HOURS
> : "Stunden"
> ;
>
As the problem was the uppercase letter in "Stunden" this would not
have solved the problem. But it's always good to have some neat example
code to get some inspiration from. :-)
Thanks again for your help!
Enjoy your Christmas Holidays!
Chantal
More information about the antlr-interest
mailing list