[antlr-interest] ANTLR 3.3 Bug?

Sam Harwell sharwell at pixelminegames.com
Thu Dec 30 20:28:45 PST 2010


It sounds like you have a stray apostrophe somewhere (mismatched string
literal). It should be very easy to find if you open the grammar in a text
editor that supports syntax highlighting for ANTLR grammars.

Sam

-----Original Message-----
From: antlr-interest-bounces at antlr.org
[mailto:antlr-interest-bounces at antlr.org] On Behalf Of David Beckedorff
Sent: Thursday, December 30, 2010 9:37 PM
To: antlr-interest at antlr.org
Subject: [antlr-interest] ANTLR 3.3 Bug?

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

List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org/mailman/options/antlr-interest/your-email-address



More information about the antlr-interest mailing list