[antlr-interest] ANTLR 3.3 Bug?

David Beckedorff david.beckedorff at gmail.com
Thu Dec 30 19:37:29 PST 2010


Antlr-interest List,

I'm trying to build a parser with the ANTLR IDE 2.1.1 Eclipse plugin and the
ANTLR 3.3 library. I'm getting a bunch of cryptic error messages for some of
my parser rules.

For example, for this rule:

tickSpec
    :   'TICK' '=' INTEGER
    ;

I get:

error(100): /EZM Project 01/src/com/dlb/ezm/ezm01/Ezm01.g:174:14: syntax
error: antlr: unexpected token: ' '
 |---> :   'TICK' '=' INTEGER


and for the rule:

location
    :   ( 'LOC' '=' '(' numericalRange ',' numericalRange ')' )
    |   '$TITLE'
    |   '$LEGEND'
    ;

I get:

error(100): /EZM Project 01/src/com/dlb/ezm/ezm01/Ezm01.g:182:15: syntax
error: antlr: unexpected token: ' '
 |---> :   ( 'LOC' '=' '(' numericalRange ',' numericalRange ')' )

error(100): /EZM Project 01/src/com/dlb/ezm/ezm01/Ezm01.g:182:23: syntax
error: antlr: unexpected token: ' numericalRange '
 |---> :   ( 'LOC' '=' '(' numericalRange ',' numericalRange ')' )



Why do I get an unexpected token ' ' error message for the whitespace
between tokens like 'TICK' or 'LOC' and '=' ? Why doesn't ANTLR just absorb
the whitespace and move on to the '=' token??

I have a whitespace rule in effect, namely:

WS : (' '|'\t'|'\n'|'\r'|'\f')+ { $channel = HIDDEN; } ;


-David Beckedorff


More information about the antlr-interest mailing list