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

Jim Idle jimi at temporal-wave.com
Wed Dec 3 20:30:02 PST 2008


On Wed, 2008-12-03 at 20:26 -0600, 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 :-


Here is a sample configuration for antlr3-maven-plugin version 3.1.1.1,
which is now synced with Maven central (because I just used it ;-).



            <plugin>
                <groupId>org.antlr</groupId>
                <artifactId>antlr3-maven-plugin</artifactId>
                <version>3.1.1.1</version>
                <configuration>
                    <sourceDirectory>src/main/java/com/temporalwave/parsers/aspdotnet</sourceDirectory>
                    <outputDirectory>target/generated-sources/aspdotnetjava/com/temporalwave/parsers/aspdotnet</outputDirectory>
                    <libDirectory>src/main/java/com/temporalwave/parsers/aspdotnet</libDirectory>
                    <excludes>
                        <exclude>commonwalker.g</exclude>
                    </excludes>
                </configuration>
                
                <executions>

                    <execution>
                        <goals>
                            <goal>antlr</goal>
                        </goals>
                    </execution>
                </executions>

            </plugin>


If you do not specify a source and output directory then it looks for
grammar in the ./antlr directory and the output files should be in:

target/generated-sources/nameofyourartifact/antlr

But your package is:


    @header {
    package prefuse.parser.dotparser;
    }
    @lexer::header {
      package prefuse.parser.dotparser;
    }


So you want your grammar files to be in the directory:


   <sourceDirectory>src/main/java/prefuse/parser/dotparser</sourceDirectory>


and your output files should be:


   <outputDirectory>target/generated-sources/yourartifactname/prefuse/parser/dotparser</outputDirectory>


Then it will all work. Be sure to use version 3.1.1.1 of the plugin if
you have dependent grammars (tokenVocab option) as the 3.1.1 version and
below do not calculate dependencies correctly.

Jim
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20081203/9604bd52/attachment.html 


More information about the antlr-interest mailing list