-
Notifications
You must be signed in to change notification settings - Fork 243
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix parser failure for
character
alias (#201)
This PR fixes a parser failure that occurs when an SQL string contains a `character` alias. Example query: ``` SELECT student.id AS character FROM student; ``` The fault is related to the data type `CHARACTER VARYING`, which is a synonym for `VARCHAR`. Before this PR, the scanner (Flex) matched the strings `CHARACTER` and `VARYING` to support `CHARACTER VARYING`. However, having `CHARACTER` as a token, the `character` identifier in the query above is matched with the `CHARACTER` token. Thus, parsing the query fails since the corresponding parser rule expects the `IDENTIFIER` token rather than the `CHARACTER` token. >Most flex programs are quite ambiguous, with multiple patterns that can match the same input. Flex resolves the ambiguity with two simple rules: • Match the longest possible string every time the scanner matches input. • In the case of a tie, use the pattern that appears first in the program. Levine, J. (2009). Flex & Bison: Text Processing Tools. "O'Reilly Media, Inc.". Page 22. For the above query, both the `CHARACTER` token and the `IDENTIFIER` token would match the longest possible string, which is `character`. `CHARACTER` is chosen over `IDENTIFIER` since it appears first in the program. This PR removes the `CHARACTER` and `VARYING` tokens and adds a `CHARACTER_VARTING` token. This token matches strings with the following pattern: `CHARACTER<whitespace>*VARYING`
- Loading branch information
Showing
6 changed files
with
2,099 additions
and
2,094 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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
This file contains 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
Oops, something went wrong.