[antlr-interest] Not possible to specify the Java package statementin the grammar?

Scott Stanchfield scott at javadude.com
Sat May 7 07:18:11 PDT 2005


at the top of the file add

header {
  package your.pkg.name; 
}

Later,
-- Scott


> -----Original Message-----
> From: antlr-interest-bounces at antlr.org 
> [mailto:antlr-interest-bounces at antlr.org] On Behalf Of Vidar Håkestad
> Sent: Saturday, May 07, 2005 9:37 AM
> To: antlr-interest at antlr.org
> Subject: [antlr-interest] Not possible to specify the Java 
> package statementin the grammar?
> 
> Hello
> Using ANTLR 2.7.5.
> I cannot see how I can get the generated code to be part of a 
> particular Java package.
> If I specify a {...} clause before the declaration of the 
> parser class, the code gets included *AFTER* the imports (but 
> before the generated class). If I specify a package (e.g. 
> package com.hawkis.xyzparser;) before the parser definition I 
> get a grammar syntax error.
> 
> Would it be possible to allow for a package specification 
> directly in the grammar file?
> 
> As it is now, I have to insert the package statement every 
> time i generate new code. Using Eclipse with its ANTLR plugin 
> means pasting in the package statement into the generated 
> files each time I've pressed Ctrl+S.
> 
> Regards
> Vidar
> 




More information about the antlr-interest mailing list