[antlr-interest] Parsers in different directories?

Bryan Ewbank ewbank at gmail.com
Sat May 28 10:21:19 PDT 2005


I use the same technique; you can also compare the generated *.txt
files to make sure that a typo didn't introduce another token (been
there, done that).

So long as all *.txt files have the same content, any of them should work.

There is a disabled (commented out, I think) option to make ANTLR
generate a warning if new tokens are defined by the grammar, rather
than just using the imported set of tokens.  You should be able to
find it - I don't have the sources handy...

On 5/28/05, Susan Jolly <easjolly at ix.netcom.com> wrote:
> 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