Skip to content

Commit

Permalink
Fix date and time literals by reordering grammar rules
Browse files Browse the repository at this point in the history
  • Loading branch information
JanJakes committed Oct 3, 2024
1 parent f658751 commit 4eee991
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 489 deletions.
6 changes: 3 additions & 3 deletions custom-parser/grammar-factoring/MySQLParser-factored.json
Original file line number Diff line number Diff line change
Expand Up @@ -22902,6 +22902,9 @@
{
"name": "%simpleExpr_factored",
"bnf": [
[
"literal"
],
[
"%%simpleExpr_factored1158"
],
Expand All @@ -22914,9 +22917,6 @@
[
"%%simpleExpr_factored1160"
],
[
"literal"
],
[
"PARAM_MARKER"
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -681,5 +681,7 @@ bitExpr ::= simpleExpr %bitExpr_rr*

simpleExpr ::= %simpleExpr_collate (CONCAT_PIPES_SYMBOL %simpleExpr_collate)*
%simpleExpr_collate ::= %simpleExpr_factored (COLLATE_SYMBOL textOrIdentifier)?
%simpleExpr_factored ::= (variable (equal expr)?) | functionCall | runtimeFunctionCall | (columnRef jsonOperator?) | literal | PARAM_MARKER | sumExpr | groupingOperation | windowFunctionCall | ((PLUS_OPERATOR | MINUS_OPERATOR | BITWISE_NOT_OPERATOR) simpleExpr) | (not2Rule simpleExpr) | (ROW_SYMBOL? OPEN_PAR_SYMBOL exprList CLOSE_PAR_SYMBOL) | (EXISTS_SYMBOL? subquery) | (OPEN_CURLY_SYMBOL identifier expr CLOSE_CURLY_SYMBOL) | (MATCH_SYMBOL identListArg AGAINST_SYMBOL OPEN_PAR_SYMBOL bitExpr fulltextOptions? CLOSE_PAR_SYMBOL) | (BINARY_SYMBOL simpleExpr) | (CAST_SYMBOL OPEN_PAR_SYMBOL expr AS_SYMBOL castType arrayCast? CLOSE_PAR_SYMBOL) | (CASE_SYMBOL expr? (whenExpression thenExpression)+ elseExpression? END_SYMBOL) | (CONVERT_SYMBOL OPEN_PAR_SYMBOL expr COMMA_SYMBOL castType CLOSE_PAR_SYMBOL) | (CONVERT_SYMBOL OPEN_PAR_SYMBOL expr USING_SYMBOL charsetName CLOSE_PAR_SYMBOL) | (DEFAULT_SYMBOL OPEN_PAR_SYMBOL simpleIdentifier CLOSE_PAR_SYMBOL) | (VALUES_SYMBOL OPEN_PAR_SYMBOL simpleIdentifier CLOSE_PAR_SYMBOL) | (INTERVAL_SYMBOL expr interval PLUS_OPERATOR expr)

/* In addition to factoring left recursion, reorder to fix date and time literals (DATE '...', TIME '...', TIMESTAMP '...'). */
%simpleExpr_factored ::= literal | (variable (equal expr)?) | functionCall | runtimeFunctionCall | (columnRef jsonOperator?) | PARAM_MARKER | sumExpr | groupingOperation | windowFunctionCall | ((PLUS_OPERATOR | MINUS_OPERATOR | BITWISE_NOT_OPERATOR) simpleExpr) | (not2Rule simpleExpr) | (ROW_SYMBOL? OPEN_PAR_SYMBOL exprList CLOSE_PAR_SYMBOL) | (EXISTS_SYMBOL? subquery) | (OPEN_CURLY_SYMBOL identifier expr CLOSE_CURLY_SYMBOL) | (MATCH_SYMBOL identListArg AGAINST_SYMBOL OPEN_PAR_SYMBOL bitExpr fulltextOptions? CLOSE_PAR_SYMBOL) | (BINARY_SYMBOL simpleExpr) | (CAST_SYMBOL OPEN_PAR_SYMBOL expr AS_SYMBOL castType arrayCast? CLOSE_PAR_SYMBOL) | (CASE_SYMBOL expr? (whenExpression thenExpression)+ elseExpression? END_SYMBOL) | (CONVERT_SYMBOL OPEN_PAR_SYMBOL expr COMMA_SYMBOL castType CLOSE_PAR_SYMBOL) | (CONVERT_SYMBOL OPEN_PAR_SYMBOL expr USING_SYMBOL charsetName CLOSE_PAR_SYMBOL) | (DEFAULT_SYMBOL OPEN_PAR_SYMBOL simpleIdentifier CLOSE_PAR_SYMBOL) | (VALUES_SYMBOL OPEN_PAR_SYMBOL simpleIdentifier CLOSE_PAR_SYMBOL) | (INTERVAL_SYMBOL expr interval PLUS_OPERATOR expr)

Original file line number Diff line number Diff line change
Expand Up @@ -24079,6 +24079,9 @@
{
"name": "%simpleExpr_factored",
"bnf": [
[
"literal"
],
[
"%%simpleExpr_factored1158"
],
Expand All @@ -24091,9 +24094,6 @@
[
"%%simpleExpr_factored1160"
],
[
"literal"
],
[
"PARAM_MARKER"
],
Expand Down
2 changes: 1 addition & 1 deletion custom-parser/parser/grammar.php

Large diffs are not rendered by default.

Loading

0 comments on commit 4eee991

Please sign in to comment.