我有一个旧项目,其中同时使用了ANTLR3和ANTLR4语法。我们要将ant
构建系统更新为gradle
。有antlr plugin for gradle支持ANTLR2 / 3/4。但是,显然它一次仅支持这三个之一(取决于所添加的依赖项)。
在我们的项目中,antlr3文件的后缀为.g
,而antlr4语法的后缀为.g4
。
该插件是否有一个选项或一个替代插件,允许我一次使用两个ANTLR版本的语法?
感谢任何提示。
plugins {
id 'java-library'
id 'antlr'
}
dependencies {
// ...
// If both are mentioned, then "X.g" is also treated as antlr4
antlr "org.antlr:antlr:3.5.2" // use ANTLR version 3
antlr "org.antlr:antlr4:4.5" // use ANTLR version 4
}
答案 0 :(得分:1)
当前,antlr插件不支持多个版本。一种解决方法是使用@using (Html.BeginForm("Create", "Controller", FormMethod.Post))
任务来调用antlr3或antlr4。这是一种方法。
JavaExec
configurations{
antlr3,
antlr4
}
dependencies {
antlr3 "org.antlr:antlr:3.5.2"
antlr4 "org.antlr:antlr4:4.7.1"
compile "org.antlr:antlr-runtime:3.5.2"
compile "org.antlr:antlr4-runtime:4.7.1"
}
task runAntlr4(type:JavaExec) {
//see incremental task api, prevents rerun if nothing has changed.
inputs.dir "src/main/antlr4/"
ouptuts.dir "$projectDir/build/generated/antlr/main/"
classpath = configurations.antlr4
main = "org.antlr4.Tool"
args = [ "-verbose", "-visitor",
"-o", "$projectDir/build/generated/antlr/main/",
"-package", <my-package>,
"src/main/antlr4/MyLanguage.g4"]
}
compilesJava.dependsOn runAntlr4
和“ org.antlr.Tool”的antlr3
的模拟。configurations.antlr3