[antlr-interest] separating lexer and parser rules

Mark Volkmann r.mark.volkmann at gmail.com
Fri Dec 21 09:52:33 PST 2007


On Dec 21, 2007 11:45 AM, Johannes Luber <jaluber at gmx.de> wrote:
> Mark Volkmann schrieb:
> > If I put my lexer and parser rules in separate grammar files, what do
> > I have to do in the parser grammar so it is aware of the lexer rules?
> > When I try to generate the parser class I get lots of error messages
> > that say "literal has no associated lexer rule".
> >
>
> Add in the parser options:
>
> tokenVocab=LexerName;
>
> LexerName has to be the names of the .tokens file of your lexer with the
> file ending.

Thanks! Now I need to decide what to name the grammar files so that
reasonable class names are generated. I'd love to name my grammar
files something like MathLexer.g, MathParser.g and MathTree.g. If I do
that though then my generated Lexer class will be MathLexerLexer.java
and my generated Parser class will be MathParserParser.java. Is there
a common convention for grammar file names?

-- 
R. Mark Volkmann
Object Computing, Inc.


More information about the antlr-interest mailing list