[antlr-interest] newbie question - mismatched input/token

Gavin Lambert antlr at mirality.co.nz
Fri Jan 18 00:17:41 PST 2008


At 12:15 18/01/2008, Ashish wrote:
>I'm trying to come up with a custom select statement. However, 
>for the
>simple grammar and input I get a mismatched-token error - see 
>details below.
[...]
>//Input
>SELECT a FROM b
>
>//Error message:
>recoverFromMismatchedToken
>BR.recoverFromMismatchedToken
>line 1:0 mismatched input 'SELECT' expecting FROM

The grammar all looks fine to me.  Are you sure you're choosing 
"prog" as your start rule?  (Also, generally speaking, your start 
rule should have EOF at the end to make it give an error if it 
can't match the entire input.)

>SELECT : 'select'|'SELECT';
>FROM : 'from'|'FROM';
>WHERE : 'where'|'WHERE';

Note that these are insufficient for true case insensitivity.  It 
won't match "Select" or "sELeCt", for example.



More information about the antlr-interest mailing list