With
- ANTLR 4.7
- ANTLR 4.7 maven plugin
- Eclipse Neon 4.6.2
i am trying to use the grammar import feature of ANTLR4. see
with the example iri grammar https://github.com/BITPlan/com.bitplan.antlr/tree/master/src/main/antlr4/com/bitplan/iri
That grammar is basically the attempt to split the https://github.com/antlr/grammars-v4/blob/master/iri/IRI.g4 into three parts:
- parser
- lexer
- imported basic lexer parts
At this point I am getting the error message:
can't find or load grammar LexBasic
I checked
and filed a bug report with https://github.com/antlr/antlr4/issues/2061
and wrote a wiki article at: http://wiki.bitplan.com/index.php/ANTLR_maven_plugin
I then put the LexBasic.g4 file into the src/main/antlr4/imports directory and the error persisted. Only when i put LexBasic.g4 into src/main/antlr4 on the command line things would work nicely. But that seems to be different then what the documentation at http://www.antlr.org/api/maven-plugin/latest/ says.
In https://gist.github.com/sharwell/4979017 I found a comment that the build-helper maven plugin is not needed any more. I'll still have to try this.
During my trials of the last few days I had lots of quirks with different pom.xml configurations. I would get error messages like:
can't find or load grammar LexBasic
reference to undefined rule
or the eclipse environment would start regenerating the java source files from the .g4 files in a non ending loop. I would have to call maven build from the menu to stop such a loop.
I am still not sure what the correct way to setup a project with parser lexer and imported lexer file would be using antlr4, maven and eclipse.
- What would be the right way to set this up?
- Where can I find an example project?