Repository navigation
Conversation
captureRest() collapsed a dot into the token in front of it whenever the
previous token ended with a dot or the current token was a dot, without
looking at what followed. A dot which starts a number was therefore glued
to its neighbour, and the captured token stream no longer read back the
same way once it was rendered and parsed again:
REPLACE( . 5 captured as REPLACE ( .5
REPLACE( INTO t VALUES (1, . 5) REPLACE ( INTO t VALUES ( 1 ,.5 )
REPLACE( x . 1 . 2 captured as REPLACE ( x.1.2
toString() of such a statement is not a fixpoint, and the token stream it
prints is not what the input contained.
The dot is now only used to collapse a qualified name when it is a
qualifier. A dot which is followed by a number, and a number in front of
a dot, keep the tokens apart. A qualified name still collapses:
REPLACE( t . a . b captured as REPLACE ( t.a.b
REPLACE( a . b captured as REPLACE ( a.b
|
One token-preservation case remains on this head: |
Contributor
|
I don't see the benefit in adding the complexity. Do you have any practical relevant use-case? |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
captureRest()collapses a dot into the token in front of it whenever the previous token ends with a dot or the token is a dot, without looking at what follows. A dot which starts a number is therefore glued to its neighbour, and the captured token stream no longer reads back the same way once the statement is rendered and parsed again.The lexer reads
.5and5.as single doubles, so joining a dot in that position changes the token stream that the statement was built from.Fix
captureRest()now only uses a dot to collapse a qualified name when the dot is a qualifier (src/main/jjtree/net/sf/jsqlparser/parser/JSqlParserCC.jjt). A dot which is followed by a number is kept as its own token, and a number in front of a dot is not extended:Tests
Two tests in
UnsupportedStatementTest:testCaptureRestKeepsADotInFrontOfANumberchecks that the captured tokens read back the same way, and that the rendered statement parses to itself.testCaptureRestStillCollapsesAQualifiedNamepins the qualified name case, including the quoted"inter"."inter_user_rec"fromtestCaptureRestIssue1993.On the parent commit the new test fails with
and with the fix the suite passes:
mvn verifywas run locally on JDK 17 with-Dtoolchain.jdk.version=[17,26). The change is confined toJAVACODEmethods, so no grammar production is altered and no choice conflict is introduced.Ref #386 and #1993, which are about the same token echo.