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

Vidar Håkestad vidar at hawkis.com
Sat May 7 06:37:03 PDT 2005


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