[antlr-interest] ANTLR 3.1, headers in imported grammars
Dimitrios Kolovos
dskolovos at gmail.com
Wed Jun 18 09:12:53 PDT 2008
In the composite-java example that demonstrates the new "import" feature
of 3.1 none of the parsers/lexers define @header or @lexer::header and
as a result all generated classes do not contain a package declaration.
Now, if I add
@header{package demo;}
and
@lexer::header{package demo;}
in Java.g, the JavaLexer and JavaParser contain the "package demo;"
declaration but all the other files that are generated from sub-grammars
(e.g. Java_JavaAnnotations, Java_JavaDecl) do not contain a package
declaration. To add a package declaration to them I need to go in each
sub-grammar and add a @header{package demo;}.
Is there a way to get package declarations in files generated by
sub-grammars only by setting @header{}/@lexer::header{} in the top-level
grammar?
Cheers,
Dimitrios
More information about the antlr-interest
mailing list