[antlr-interest] How do I get a parser and lexer to work together

Johannes Luber jaluber at gmx.de
Mon Feb 4 15:19:24 PST 2008


Benjamin Shropshire schrieb:
> I have a lex.g and a parse.g. Both run through antlr just fine and then 
> link, however the parser is generating it's own enumerations for the 
> lexical tokens. I need it to use the definitions generated by antlr when 
> it makes the lexer. I need the lexer in a different file because I need 
> to be able to use it in more than one grammar. I don't want to resort to 
> using cpp or sed to make this work.
> 
> How do I tell antlr to do this?
Use the tokenVocab option to do that. In your case:

option {
tokenVocab=lex;
}

> Where is this documented? (a.k.a. how could I have found this out my self?)

In the book or probably on the wiki.

Johannes


More information about the antlr-interest mailing list