[antlr-interest] Not possible to specify the Java package
statementin the grammar?
Geir Ove Skjaervik
geiroves at online.no
Sat May 7 23:43:12 PDT 2005
Hello,
I do not know if this will do the trick for you, but you could use the
import statement in the .g file as this:
header {
package no.oss.gos;
import antlr.CommonToken;
import no.oss.gos.MyPackage;
import java.util.*;
}
class YourParser extends Parser;
......
Geir Ove
Norway
-----Original Message-----
From: antlr-interest-bounces at antlr.org
[mailto:antlr-interest-bounces at antlr.org] On Behalf Of Vidar Håkestad
Sent: 7. mai 2005 15:37
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