I am using one .g file for both lexer and parser. I have the following lines in the grammar file:
@header {
package foo.bar;
}
However I found that package line is only put into the generated parser source file, and missing in the FooLexer.java file. Anyone know how to deal with this?
is short for:
To put a package declaration in the lexer, do:
The same goes for
@members { ... }, which is short for@parser::members { ... }. There’s also@lexer::members { ... }to put variables/methods etc. in the lexer.