[antlr-interest] How to feedback to users the string expected on MismatchedTokenException

John B. Brodie jbb at acm.org
Tue Jun 12 13:59:08 PDT 2007


Benjamin Niemann wrote:

>John B. Brodie wrote:
>
>>>In the java runtime, when the antlr 3.0 encounter a mismatched token
>>>parser error it issue a message like:
>>>
>>>"line 1:7 mismatched input 'update' expecting SELECT"
>>>
>>>What this basically means is that parser got an 'update' string while
>>>expecting the SELECT token.
>>>
>>>The problem is that SELECT token is defined as:
>>>...snipped...
>>>And that I should prefer to respond to such erroneous input with the
>>>string that is expected ('select') and not with the token type (SELECT).
>>>...snipped...
>> 
>> Does the tokenNames array published by the generated parser help you
>> to build your own error reporting method to solve this?
>
>That's where the default error handler is getting the 'SELECT' from ;)

my suggestion to the OP to use tokenNames was completely bogus.
sorry for the noise...


More information about the antlr-interest mailing list