我是ANTLR4的新手,看起来没有v4的Eclipse插件。所以它很适合从.g4文件自动构建Java源代码。我有一个简单的,空的Maven项目,具有src/main/java,src/test/java。在哪里放置.g4文件?我如何使用Maven自动构建语法?如何使用ANTLR4和Maven自动生成词法分析器+解析器?
我自己POM-测试失败:
<repository>
<id>mvn-public</id>
<name>MVNRepository</name>
<url>http://mvnrepository.com</url>
</repository>
...
<build>
<plugins>
<plugin>
<groupId>org.antlr</groupId>
<artifactId>antlr4-maven-plugin</artifactId>
<version>4.0.0</version>
<executions>
<execution>
<goals>
<goal>antlr</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
Eclipse中说:
Failure to find org.antlr:antlr4-maven-plugin:pom:4.0.0 in http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of
central has elapsed or updates are forced
谢谢!当我在pom.xml中注释build-helper-maven-plugin时,ANTLR为放置的语法构建词法分析器和解析器。但是使用build-helper-maven-plugin Eclipse说:“插件执行没有被生命周期配置所覆盖:org.codehaus.mojo:build-helper-maven-plugin:1.7:add-source(执行:默认,阶段:生成源)”。如果没有手动添加target/generatet-sources/antlr4作为src文件夹,我无法使用生成的词法分析器/解析器。还有一个问题:如何提出论据? ' org.example configuration>'不起作用。 –
Vertex
2013-02-18 20:31:25
如果您告诉它,Eclipse将自动下载适当的扩展以使用构建助手插件。 package子句总是基于源结构中.g4文件的位置由antlr4目标自动添加。要更改生成的代码包,请将语法本身移至源树中的所需包。 – 2013-02-18 20:39:34
是的,你是对的!我忽略了快速修复。 – Vertex 2013-02-18 21:36:15