[antlr-interest] Parsers in different directories?

Susan Jolly easjolly at ix.netcom.com
Sat May 28 08:18:37 PDT 2005


I am attempting to use the same large lexer with several different trial
parsers that each only handle a subset of the lexer tokens. I am using this
approach as a means of modularizing the parser development. I may also end
up using two pipelined parsers.

I'd really like to have these different parsers in different directories
(and different Java packages) from each other and from their common lexer.

Meanwhile there is common supporting code in another directory/package that
needs to implement what should be a common xParserTokenTypes interface. 

The problem is how to ensure consistency in the token vocabularies,
especially given that the supporting code makes use of the token types.

The solution I've found so far is to have an exportVocab SHARED option in
the lexer and to copy  SHAREDTokenTypes.txt to each of the directories where
a parser is located. Then I use importVocab  SHARED (but no exportVocab)
with each parser so that each of the XParserTokenTypes interfaces is
equivalent with respect to the assignments. I then pick one of these to be
used by the shared supporting code.  Is there a better way?

Thanks,
Susan





More information about the antlr-interest mailing list