Fix parser failure for character
alias
#201
Merged
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 PR fixes a parser failure that occurs when an SQL string contains a
character
alias.Example query:
The fault is related to the data type
CHARACTER VARYING
, which is a synonym forVARCHAR
.Before this PR, the scanner (Flex) matched the strings
CHARACTER
andVARYING
to supportCHARACTER VARYING
. However, havingCHARACTER
as a token, thecharacter
identifier in the query above is matched with theCHARACTER
token. Thus, parsing the query fails since the corresponding parser rule expects theIDENTIFIER
token rather than theCHARACTER
token.Levine, J. (2009). Flex & Bison: Text Processing Tools. "O'Reilly Media, Inc.". Page 22.
For the above query, both the
CHARACTER
token and theIDENTIFIER
token would match the longest possible string, which ischaracter
.CHARACTER
is chosen overIDENTIFIER
since it appears first in the program.This PR removes the
CHARACTER
andVARYING
tokens and adds aCHARACTER_VARTING
token. This token matches strings with the following pattern:CHARACTER<whitespace>*VARYING