我正在尝试将我的ANTLR4语法分割到多个文件中,以便更轻松地测试它们,我正在使用gradle作为java项目中的构建工具。
这两种语法都通过separate正确编译,但当我将导入添加到主语法时,我会出现下一个编译错误
inherited
语法看起来像:
grammar SpecflowScenario;
@header {
package kanekotic.specflow.rider;
}
scenario
: 'Scenario: ';
和
main
语法看起来像:
grammar SpecflowFeature;
import SpecflowScenario;
@header {
package kanekotic.specflow.rider;
}
file returns [List<String> values]
@init { $values = new ArrayList<String>(); }
: 'Feature: ' EOF;
这个
gradle.build
看起来像:
plugins {
id "org.jetbrains.intellij" version "0.1.10"
}
apply plugin: 'org.jetbrains.intellij'
apply plugin: 'java'
apply plugin: 'antlr'
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
intellij {
version '143.2370.31'
pluginName 'Specflow Rider'
}
group 'kanekotic.specflow.rider'
version '0.1'
repositories {
mavenCentral()
jcenter()
}
dependencies {
antlr "org.antlr:antlr4:4.5"
testCompile 'junit:junit:4.12'
testCompile "org.mockito:mockito-core:2.+"
}
所有开源代码都在下一个链接中:
https://github.com/kanekotic/Specflow.Rider/tree/antlr4_multiple_grammar