[antlr-interest] importVocab question

Scott Amort jsamort at rogers.com
Sat Apr 8 14:48:54 PDT 2006


Hi All,

I have my ANTLR lexer and parser grammars separated into two files.
Now, my lexer scans identifiers and tests them against the literals
table.  The problem here is that there is not a literals table yet, as
they are all defined in the parser.  To solve this, I import my parser
vocabulary into the lexer (with importVocab), which also necessitates
running antlr on the parser first.  This seems to work and everything
runs fine, except one thing.  Within the lexer, I have numerous
paraphrase="x" statements to make any error output a bit more
understandable.  These statements do not make it to the parser, as the
parser is not inputting the vocabulary from the lexer, but it is instead
operating the other way around.  If I do try to input the lexer
vocabulary, I end up with a circular dependency - the parser must
generate its vocab first, but in order to do so it needs the lexer
vocab, but the lexer needs the parser's vocab to work, and so on.  Is
there a way to fix this?  I can't see where I can add this sort of
option to the parser.  Thanks for any assistance!

Best,
Scott

PS Also, thanks again to those who participated in my earlier discussion
about unit testing - after implementing a pretty basic test suite, I
have already come across and fixed several bugs.



More information about the antlr-interest mailing list