Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As reported on the mailing list in 2007 and also in the Gradle forums in the last years, it is currently impossible to define two different grammars in different packages using separate lexer and parser files and import the lexer files using
tokenVocab
.Ultimately the problem is that the referenced
tokenVocab
cannot be resolved when processing a grammar that does not reside in the default package. Using the-lib
makes it possible to work around this problem for a single package, but this fails to work for multiple grammars in different packages because-lib
can only be specified once.This patch allows the
tokenVocab
to specify paths instead of only file names, i.e. it is then possible to writetokenVocab='com/test/html/HTMLLexer';
The ANTLR parser allows quoted strings for the
tokenVocab
already, and resolving the files just works when specifying a path. However, processing the fileset can still fail because the dependency graph is not built correctly. (Because the dependency graph builder does not identify thatHTMLLexer
and'com/test/html/HTMLLexer';
are references to the same thing.To make the dependency graph builder work, I added some code that removes the quotes and extracts only the filename from the specified
tokenVocab
.I have created a testing repository that demonstrates the new behavior of the
Tool
for two example grammars from the grammars-v4 repository, that have been moved to packages to fit the use case.