Initial ANTLR4 integration attempt using XML grammar from ANTLR book #61
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.
This patch is NOT meant to be ready4integration, but as an assistance to finish the integration of ANTLR4 to GumTree.
The added Java code is based on the ANTLR4 related pull request for PHP by Mikulas
#47
I exchanged the PHP grammar with the reference XML grammar from the book
https://pragprog.com/book/tpantlr2/the-definitive-antlr-4-reference
which can be found under
https://github.com/antlr/grammars-v4/tree/master/xml
to have no doubt on the ANTLR side.
The only thing altered on the above XML ANTLR4 grammars are the GumTree package names.
What is in addition working for ANTLR in this patch (and took me hours of config combinations) is to compile the two distinct lexer and parser grammar with Gradle.
As glue between ANTLR4 Java files and GumTree I used the tree generators of Mikulas, which is unfortunately not working correctly and my knowledge of GumTree is too low to do a good job here in reasonable time. Therefore I would like to ask for some assistance.
In addition, I suggest adding to all new ANTLR grammars some mandatory regression tests (proof of concept) directly to the ANTLR4 grammar module.
The initial test attached to this patch tries to diff two XML files from the book and fails with the adopted code from Mikulas.
A final adjustment of the test would have to be done when the exact test result is known from a running application.
PS: Note: I started with JSON but I would rather do a joint of the existing GumTree grammar
https://github.com/GumTreeDiff/gumtree/blob/develop/gen.antlr3-json/src/main/antlr/com/github/gumtreediff/gen/antlr3/json/JSON.g
(which seems erroneous as a '+' is missing for exponents, but more readable)
and the one beyond
https://github.com/antlr/grammars-v4/tree/master/json
Therefore I used XML instead, as the grammar was taken as an example in the book and therefore well reviewed and tested.
Thanks in advance for your help,
Svante