[antlr-interest] "unexpected token" error

jbb at acm.org jbb at acm.org
Wed Mar 9 07:17:40 PST 2005


Pardon me for butting in...

>togol machillan wrote:
>...snip
>Some input files and the corresponding error messages generated are as follows. 
>
>Input file: 
>FLOWSHEET 
>    BLOCK B1 IN=1 2 OUT=3
>
>Output error message:
><cin>:1:11: unexpected token: 
>
>Input file:
>DATABANKS PURE12  / AQUEOUS  / SOLIDS  / INORGANIC  /  &
>        NOASPENPCD
>
>Output error message:
><cin>:1:19: unexpected token: /
>
>...snip


For the first error, your posted lexer rule NEWLINE does not set the token
type to SKIP and so newlines are not ignored.  The newline appearing after
the "FLOWSHEET" VALUE token is the unexpected culprit here, I believe.
Do any of your parser rules handle NEWLINE tokens?

For the second error, none of your posted lexer fragments have dealt with the
'/' character. Do you have any lexer rules that consume a '/' character?
Perhaps your lexer ASSIGNMENT rule should really be a rule in the parser and
should be updated to permit a '/' separated list of items on the right hand
side of the '='?

Hope this helps...
   -jbb


More information about the antlr-interest mailing list