[antlr-interest] Header not copied to lexer file?
Kay Roepke
kroepke at classdump.org
Sat Oct 14 05:34:46 PDT 2006
Hi Brian!
On 14. Oct 2006, at 4:38 Uhr, Brian DeVries wrote:
> In my 3.0b4 grammar file, I have the lines
>
> @header
> {
> package parsing;
> }
>
> The generated Java parsing file contains this line. However, the
> generated lexer grammar and Java files do not, resulting in a compiler
> error.
>
> What can I do to fix this, aside from manually entereing the header in
> the lexer file each time?
In combined grammars everything without prefix goes to the parser by
default.
You can force it to go to the lexer by saying:
@lexer::header {
}
I'm not sure if there is a way to force one header block to go to
both lexer and parser, or if you
have to do:
@header {
package parsing;
}
@lexer::header {
package parsing;
}
I strongly suspect that this is the only way to do it right now.
Maybe we can think of something that forces ANTLR to
write it to both files.
Maybe
@all::header {
//goes to lexer _and_ parser
}
?
HTH,
-k
More information about the antlr-interest
mailing list