[antlr-interest] Imports + headers with ANTLR-3.1.1
Laurent Caillette
laurent.caillette at gmail.com
Mon Oct 27 12:49:36 PDT 2008
Hi all again,
I've discovered a strange behavior with imports and headers.
Considering the two following grammars:
- - - - - - - - - - - - -
parser grammar P1 ;
...
- - - - - - - - - - - - -
grammar P2 ;
import P1 ;
@parser::header {
package acme ;
}
...
- - - - - - - - - - - - -
As expected, ANTLR generates three java files:
P2.java: header present.
P2_P1.java: header present.
P1.java: missing header!
If I add the missing header to P1.g then ANTLR doesn't like it:
>> error(144): P1.g:27:10: redefinition of header action
I guess that two possibly different headers make the choice hard for
generating the P2_P1.java file. Would it be reasonable to "propagate"
the header of the root grammar to all the imported ones?
ANTLR rocks,
c.
More information about the antlr-interest
mailing list