[antlr-interest] Puzzling Problem

Scott Amort jsamort at rogers.com
Sun Apr 9 08:58:42 PDT 2006


On Sun, 2006-04-09 at 16:20 +0100, Sam Barnett-Cormack wrote:
> The error I get on running it is the slightly odd
> 
> line 1:10: unexpected token: 0
> 
> This is especially odd, as the grammar specifies that the first token it 
> should get *is* "0".

Hi Sam,

I can offer a guess at this, but I am still pretty new to ANTLR.

I believe your lexer is returning a type of INT for the 0, while your
parser is checking for a literal "0".  Although you have turned on
testLiterals in your INT rule in the lexer, the problem is that you have
separate files for the parser and lexer.  So, the lexer has no
definition of the "0" literal.  You need to import the parser vocabulary
into your lexer to make this connection, and of course, this entails
running antlr on the parser first to generate that vocab, then on the
lexer.  It will also mess up your paraphrase= statements (see my email
of a day or so ago), but I don't see that you are using that feature.

HTH,
Scott



More information about the antlr-interest mailing list