[antlr-interest] Exported vocabularies not matching up

Bocek, Timothy (RDM) timothy.bocek at guidant.com
Fri Jul 7 14:34:16 PDT 2006


I'm working on a simple set of grammars in ANTLR version 2.7.5.  I am exporting lexers and grammars for Python.  My problem arises when I export the vocabulary from my lexer definition, then import the vocabulary into my parser definitions (I am using the same lexer with two different parsers, so having the lexer and parsers in one file is not an option).  The vocabulary exported from the lexer looks like this:

IF="if"=4
THEN="then"=5
ELSE="else"=6
RETURN="return"=7
TRUE="true"=8
FALSE="false"=9
APPLICABLE="applicable"=10
NOT_APPLICABLE="not_applicable"=11
ENUM_ITEMS="enum_items"=12
AND="and"=13
OR="or"=14
NOT="not"=15
ABS="abs"=16
MIN="min"=17
MAX="max"=18
ROUND="round"=19
WS=20
COMMENT=21
LETTER=22
DIGIT=23
SIMPLE_IDENTIFIER=24
IDENTIFIER=25
INTEGER=26
LPAREN=27
RPAREN=28
LBRACK=29
RBRACK=30
COMMA=31
DOT=32
SEMICOLON=33
PLUS=34
MINUS=35
TIMES=36
DIVIDE=37
EQ=38
NE=39
GT=40
LT=41
GE=42
LE=43

However, the vocabulary exported from the parsers looks like this:

IF="if"=4
THEN="then"=5
ELSE="else"=6
TRUE="true"=7
FALSE="false"=8
APPLICABLE="applicable"=9
NOT_APPLICABLE="not_applicable"=10
AND="and"=11
OR="or"=12
NOT="not"=13
WS=14
COMMENT=15
LETTER=16
DIGIT=17
SIMPLE_IDENTIFIER=18
IDENTIFIER=19
INTEGER=20
LPAREN=21
RPAREN=22
LBRACK=23
RBRACK=24
COMMA=25
DOT=26
SEMICOLON=27
PLUS=28
MINUS=29
TIMES=30
DIVIDE=31
EQ=32
NE=33
GT=34
LT=35
GE=36
LE=37
RETURN="return"=38
ENUM_ITEMS="enum_items"=39
ABS="abs"=40
MIN="min"=41
MAX="max"=42
ROUND="round"=43

As you can see, although the same tokens appear in both the lexer and the parser, the numerical identifiers have changed!  I have checked the import and export statements in my lexer and parsers and they look like they should be working.  Does anyone have an idea as to what might be causing this?  I am new to ANTLR, so help would be appreciated greatly!

Thanks,
Tim Bocek

"Any views expressed in this e-mail are not those of Guidant Corporation."


More information about the antlr-interest mailing list