[antlr-interest] How to specify lexer options without composite grammars

Gavin Lambert antlr at mirality.co.nz
Tue Jun 17 00:51:41 PDT 2008


At 08:03 17/06/2008, Achim Westermann wrote:
 >so what remains open: importing a lexer grammar for java when 
both
 >grammars are not in the root package seems to fail. I am using 
the
 >ANT task for V3. Perhaps this is buggy? At least it works, if I
 >put all grammar files into the root directory. The also the java 

 >file for the lexer is generated.

I'm not all that familiar with Java and packages, but normally 
you'd put the grammar files together regardless of the output 
package.

If you're saying you're having trouble defining the package for 
the lexer half of a combined grammar: you need to use an alternate 
syntax for that:

header {
   package package.name.here;
}
lexer::header {
   package package.name.here;
}

If you have separate lexer and parser, then in order to import the 
vocabulary from the lexer, ANTLR needs to know where the .tokens 
file is when it's building the parser.  The -lib command line 
option controls where it looks for these (and it also looks in the 
output directory as well).



More information about the antlr-interest mailing list