[antlr-interest] New Maven artifact for compiling antlr grammars
Jim Idle
jimi at temporal-wave.com
Fri Dec 5 11:53:10 PST 2008
On Fri, 2008-12-05 at 11:47 -0800, Howard Lewis Ship wrote:
> I'm having a problem; I need to split my grammar into a lexer grammar
> and a parser grammar so I can specify a superClass option for the
> lexer grammar.
>
> My source files are
> src/main/antlr/org/apache/tapestry5/internal/antlr/PropertyTokens.g
> and PropertyExpression.g.
>
> The plugin generates a PropertyTokens.tokens file as
> target/generated-sources/antlr/org/apache/tapestry5/internal/antlr/PropertyTokens.token
>
> So far, so good.
>
> However, in my PropertyExpression.g file I've tried
>
> options { tokenVocab=PropertyTokens; }
>
> and
>
> options {
> tokenVocab="org/apache/tapestry5/internal/antlr/PropertyTokens";
> }
>
> and both fail. The first should work, but gets:
>
> [INFO] [antlr3:antlr {execution: default}]
> org/apache/tapestry5/internal/antlr/PropertyTokens.g
> org/apache/tapestry5/internal/antlr/PropertyExpression.g
> [ERROR] error(3): cannot find tokens file
> /Users/Howard/work/tapestry5/tapestry-core/target/generated-sources/antlr/PropertyTokens.tokens
If you are using an IDE like Netbeans, then when you edit pom.xml, and
type a '<' inside the configuration, you will see that it gives you all
the options. In this case, as your grammar files are in a package, it
cannot infer the lib directory. So you need:
<plugin>
<groupId>org.antlr</groupId>
<artifactId>antlr3-maven-plugin</artifactId>
<version>3.1.1.2</version>
<configuration>
<libDirectory>${basedir}/target/generated-sources/antlr/org/apache/tapestry5/internal/antlr</libDirectory>
</configuration>
<executions>
<execution>
<goals>
<goal>antlr</goal>
</goals>
</execution>
</executions>
</plugin>
I was playing with trying to make the plugin perform a better guess for
the lib directory and may come up with something yet, but for now, you
must specify it if it is not antlr/
Jim
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20081205/6b3c00f5/attachment.html
More information about the antlr-interest
mailing list