-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lexer and Parser in different maven modules #1779
Comments
Apart from incorporating the changes I've proposed, users should add the following to their <build>
<resources>
<resource>
<directory>target/generated-sources/antlr4</directory>
<includes>
<include>*.tokens</include>
</includes>
</resource>
</resources>
</build> So that the generated Everything else (packaging, classpath handling and so on) would be handled by maven itself. |
Personally I think a more reasonable path to store the Although changes to antlr4 code to lookup on that folder would be easy to do, actually moving the file there is a difficult task in maven (ok, not that it is really hard, but adds a lot more lines than just a single and simple |
If you want to try it on a pet-project, rslemos/pet-grammars@640118e, contains the modules |
Perhaps linked to #638. |
For sufficiently complex lexer and/or parser, with lots of supporting code or automated testcases, it would be reasonable to have them at separate maven modules, and have the
parser-module
compile-depend onlexer-module
.ANTLR4 (and its maven plugin) supports this mostly, with exception of tokenVocab file, which would be written in
lexer-module/target/generated-sources/antlr4
, but when generating the parser would be searched for inparser-module/target/generated-sources/antlr4
.Complicating the matters a bit, a maven build can be invoked in two ways:
Maven deals with both ways very nicely, adding either
~/.m2/repository/..../lexer-module.jar
or../lexer-module/target/classes
toparser-module
compilation classpath.I wonder if it would be reasonable to look for
.tokens
files also in the classpath. Conceptually it would mean that a lexer package could provide the full information to be used either at runtime (generated and compiled class files) and at compile-time (tokens file, to be consumed by antlr4 generating a parser).The only change needed in antlr4 itself would be:
I have the done those changes at rslemos@b698019.
I would like to hear from you both about the concept and the proposed patch.
The text was updated successfully, but these errors were encountered: