I am trying to break my ANTLR4 grammar into multiple files, so I can test them easier, I use gradle as a build tool in a java project.
Both grammar compiles separately correctly, but when I add import to my main grammar, I get the following compilation error
error (110): kanekotic / specflow / rider / SpecflowFeature.g4: 3: 7: cannot find or load SpecflowScenario grammar
inherited grammar is as follows:
grammar SpecflowScenario; @header { package kanekotic.specflow.rider; } scenario : 'Scenario: ';
and the main grammar is as follows:
grammar SpecflowFeature; import SpecflowScenario; @header { package kanekotic.specflow.rider; } file returns [List<String> values] @init { $values = new ArrayList<String>(); } : 'Feature: ' EOF;
What am I doing wrong? is this not allowed?
edit:
gradle.build as follows:
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.+" }
all the code, since it is open, is located in the following link: https://github.com/kanekotic/Specflow.Rider/tree/antlr4_multiple_grammar
source share