I have two parser grammars (lets call them A.g and B.g). Now I want to import the Grammar B into the Grammar A. Here is what they two grammars look like: GRAMMAR A:
parser grammar A;
options {
tokenVocab = testLexer;
}
import B;
@header {
package com.splendit.pli2uct;
}
rule
: ImpLexRule1 | subRule ;
GRAMMAR B:
parser grammar B;
@header {
package com.splendit.pli2uct;
}
subRule: ImpLexRule2 ;
But when I build the java Classes from the grammar files (no matter if i do this with antlr ide or with the antlr-maven-plugin) I'm getting the following error: error(144): B.g:11:2: redefinition of header action
But when I leave the header Definition in the B.g Grammar then the generated Java Class has an error because there is noch package Definition at the beginning of the file. Can anybody help me with this problem? I have really no idea what I'm doing wrong.
Thnaks in advance Bernhard