[antlr-interest] Unexpected Token dearly expected...

Kay Roepke kroepke at classdump.org
Thu Dec 14 14:53:43 PST 2006


On 13. Dec 2006, at 16:54 , Chantal Ackermann wrote:

> Hi to all!

Hi Chantal!

> 1. Problem:
> Input like "meine heutigen termine" works but I get a  
> NoViableAltException for "termine die nächsten 2 stunden"
>
[...]
>
> STUNDEN_ANGABE
> 	:	DIGIT " Stunden"
> 	;

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? ;))

> 2. Question:
> How do I handle the case when there really is no input of the  
> expected kind? Say, there actually wasn't any domain information in  
> the input. What is the best way to go about that? Do I just catch  
> the exception or do I specify a custom errorhandler?

Catching the exception should be enough, unless you want to do more  
fine-grained error recovery (this might not be possible/feasible in  
your case).

HTH,

-k

-- 
Kay Röpke
http://classdump.org/






More information about the antlr-interest mailing list