[antlr-interest] errors in embedding grammar files in maven project - regd.

Jared Bunting jared.bunting at peachjean.com
Wed Dec 3 21:17:32 PST 2008


I guess I'm a bit confused about the issue you're having then.  Between
having the package statement "package dot.grammar" and having your source
code in a "dot/grammar" folder structure, your classes should be in the
package.  Do you actually have folders named "dot.grammar" ?  But basically,
whatever directory you want the output source to be in (underneath
"target/generated-sources/antlr"), put it in that directory underneath
"src/main/antlr".

If this doesn't help, maybe you could zip up a project and send it to me?
I'm pretty sure I do what you're trying to do fairly often and I haven't had
any trouble with it.

-Jared

On Wed, Dec 3, 2008 at 10:36 PM, Ashok Varikuti <asoka250 at gmail.com> wrote:

> Jared Bunting wrote:
>
>> Not sure how your files are setup, but if I recall correctly, the maven
>> plugin places the output files in folders based on where your input files
>> are.  So, place your dot.g file in src/main/antlr/dot/grammar (just like you
>> would *.java files in a package) - then the output should end up in
>> target/generated-sources/antlr/dot/grammar.  Also, I would check to be sure
>> you are using the new version of the maven plugin (3.1.1.1 <
>> http://3.1.1.1>) - I believe I recall that version 3.1.1 had some
>> consistency issues with output directories.
>>
>> -Jared
>>
>>
>> On Wed, Dec 3, 2008 at 9:29 PM, Ashok Varikuti <asoka250 at gmail.com<mailto:
>> asoka250 at gmail.com>> wrote:
>>
>>    Ashok Varikuti wrote:
>>    > Hi List,
>>    >
>>    > I encapsulated antlr grammar files in a eclipse maven project. The
>>    > compilation task of grammar files is done at maven compile time. I
>>    > specified the output directory to be the following :-
>>    >
>>    >    * target/generated-sources/antlr
>>    >        * dot.grammar
>>    >              o dot.tokens
>>    >              o dotlexer.java
>>    >              o dotparser.java
>>    >
>>    >    where *dot.grammar* is the package name I specified in the
>>    dot.g file
>>    >    @header {
>>    >    package prefuse.parser.dotparser;
>>    >    }
>>    >    @lexer::header {
>>    >      package prefuse.parser.dotparser;
>>    >    }
>>    >
>>    >    But when I did a maven compile, the generated files are
>>    generated in
>>    >    the output folder but with no package name.
>>    >
>>    >        * target/generated-sources/antlr              o dot.tokens
>>    >              o dotlexer.java
>>    >              o dotparser.java
>>    >
>>    >    The geenrated files are not part of any package anymore. Can
>>    anyone
>>    >    help me with this. All the configuration instructions in a maven
>>    >    project are specified in a pom.xml file.
>>    >
>>    >
>>    >
>>    Sorry substitute the package name as below:-
>>
>>    @header {
>>      package dot.grammar;
>>      }
>>      @lexer::header {
>>        package dot.grammar;
>>      }
>>
>>    --
>>    Ashok R Varikuti
>>    Graduate Research Assistant
>>    CIS Dept, Kansas State University
>>    785-304-2401
>>    ashokv at ksu.edu <mailto:ashokv at ksu.edu>
>>
>>
>>
>>    List: http://www.antlr.org/mailman/listinfo/antlr-interest
>>    Unsubscribe:
>>
>> http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>>
>>
>>  Hi Jared,
>
> Thank you for the answer. You are right on target when u said that the
> *output should end up in target/generated-sources/antlr/dot/grammar.* But I
> needed the output files to be part of package rather. For now this is how
> its generated:-
>
>   * target/generated-sources/antlr/dot/grammar
>         o (default package)
>               + dot.tokens
>               + dotparser.java
>               + dotlexer.java
>
> I want the structure to be something like this :-
>   * target/generated-sources/antlr
>         o dot.grammar
>               + dot.tokens
>               + dotparser.java
>               + dotlexer.java
>
>
>   * src/main/java
>         o dot.util.grammar
>               + dotOp.java --> here I need to use dotparser.java,
>                 which is not possible when  --> the file is generated
>                 in a default package.
>
>
>
> As you can observe, the main difference being the output files are part of
> package "dot.grammar" as I mentioned in the grammar file. When the files are
> generated are generated in a default package, I have no way to import them
> and use elsewhere since I can't refer to them and they aren't even part of a
> source folder either. I need to import the java
> files(dotparser.java,dotlexer.java) into my packages in src/main/java.
>
> --
> Ashok R Varikuti
> Graduate Research Assistant
> CIS Dept, Kansas State University
> 785-304-2401
> ashokv at ksu.edu
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20081203/b07880bc/attachment.html 


More information about the antlr-interest mailing list