-
Notifications
You must be signed in to change notification settings - Fork 146
JDK-8218170: Upgrade antlr to version 4.7.2 (port from antlr3 to antlr4, minimum changes) #372
JDK-8218170: Upgrade antlr to version 4.7.2 (port from antlr3 to antlr4, minimum changes) #372
Conversation
@parrt Any idea if there is a way to trigger a lexer rule in antlr4? In antlr3 it was, for example: https://github.com/javafxports/openjdk-jfx/pull/372/files#diff-c3f9b203d77b3f52ce4e6272bbf82492L53 or if there is a better way of doing the same thing (testing lexing of specific text in the context of a lexer rule)? Thanks! |
Unfortunately, it all goes through a state machine now so no way to jump directly there. |
Okay, great. Thank you. @kevinrushforth So I believe that what I've done to change the test semantics is the best possible approach and shouldn't complicate reviewing. |
f3bd955
to
1ad4ad1
Compare
@brcolow I had previously filed JDK-8218170, but forgot to make it public (sorry about that). I closed JDK-8218764 as a duplicate and assigned JDK-8218170 to you. Also, we now have the legal approval to upgrade to antlr 4.7.2. |
I will review it soon, and have asked @arapte to review as well. |
My initial testing looks good. I'll finish reviewing it next week. @brcolow Can you send an RFR email to openjfx-dev? |
RFR Sent. |
I did a test on all three platforms and all looks good. I can confirm that the generated shader files are identical except for the whitespace diff noted in #360. I also checked the final artifacts. All looks good. I still need to do a review of the code changes, but at first glance they look fine. |
While getting ready to start the code review, I see four main categories of changes:
In order to help us review and understand the changes, can you provide an overview of the changes for at least the JSL grammar file (one change I see is that the tokens needed to be turned into equivalent grammar rules, but there are several less obvious changes)? Also, if there is anything tricky that would fall in category 3, it would be helpful if you could highlight it. |
Changes to JSL.g: 1.) Renamed extension from Change to the tests: As noted by @parrt above (thanks!), It is no longer possible to trigger a lexer rule directly and act from within that state. Therefore we had to change the semantics of the tests to be as close as possible but we have to lex each String as a complete program. Therefore instead of expecting The new error handler mechanism throws a Changes to String templates:
The calls to Rendering the template no longer uses |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes look good to me. Added a minor change comment.
modules/javafx.graphics/src/test/jslc/com/sun/scenario/effect/compiler/lexer/LexerBase.java
Show resolved
Hide resolved
I plan to do a detailed review of
This suggests that one of the transformed rules might produce unexpected behavior as a result. It doesn't make a difference in the parsing of our existing JSL files, but could make the grammar more fragile. I'll try to look for places that could be a problem when I review the grammar file, but it would be worth your looking at this, too. |
Yes, that warning is issue on this bit:
Given that a |
The I can see your point in the .stg file usage. There are embedded shift operators |
As a follow-on to the warning about using a greedy operator, I note that the rules in question didn't change between antlr3 and antlr4, so the behavior will be the same, we just get a warning now. So this is fine. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have no additional comments. This looks good to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me too.
I only noticed this after merging it in... It seems that the JSLC unit tests are not being compiled or run.It looks like they haven't been wired up to the build since the Jigsaw refactoring back in the JDK 9 time frame. Several of them get compilation errors, so what this means is that we don't have any automated way to test any new changes, which is a bit concerning for any future changes. @brcolow How did you verify the changes to the tests that you made (or did you do the same thing I did and assume that if "gradle test" passed, then the changes must be good)? |
As requested in #360 by @kevinrushforth this is a PR that contains the minimum amount of changes to the code necessary to upgrade from antlr3 to antlr4.
One thing to notice is that the tests implementing
fireLexerRule
is removed because I couldn't find a way to fire a lexer rule in antlr4. I tried many things (like setting the current token, etc.) but none worked so I had to alter the semantics of the tests a bit.