Skip to content

Commit 4eee991

Browse files
committed
Fix date and time literals by reordering grammar rules
1 parent f658751 commit 4eee991

File tree

6 files changed

+11
-489
lines changed

6 files changed

+11
-489
lines changed

custom-parser/grammar-factoring/MySQLParser-factored.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22902,6 +22902,9 @@
2290222902
{
2290322903
"name": "%simpleExpr_factored",
2290422904
"bnf": [
22905+
[
22906+
"literal"
22907+
],
2290522908
[
2290622909
"%%simpleExpr_factored1158"
2290722910
],
@@ -22914,9 +22917,6 @@
2291422917
[
2291522918
"%%simpleExpr_factored1160"
2291622919
],
22917-
[
22918-
"literal"
22919-
],
2292022920
[
2292122921
"PARAM_MARKER"
2292222922
],

custom-parser/grammar-factoring/MySQLParser-manually-factored.ebnf

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -681,5 +681,7 @@ bitExpr ::= simpleExpr %bitExpr_rr*
681681

682682
simpleExpr ::= %simpleExpr_collate (CONCAT_PIPES_SYMBOL %simpleExpr_collate)*
683683
%simpleExpr_collate ::= %simpleExpr_factored (COLLATE_SYMBOL textOrIdentifier)?
684-
%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)
684+
685+
/* In addition to factoring left recursion, reorder to fix date and time literals (DATE '...', TIME '...', TIMESTAMP '...'). */
686+
%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)
685687

custom-parser/grammar-factoring/MySQLParser-manually-factored.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24079,6 +24079,9 @@
2407924079
{
2408024080
"name": "%simpleExpr_factored",
2408124081
"bnf": [
24082+
[
24083+
"literal"
24084+
],
2408224085
[
2408324086
"%%simpleExpr_factored1158"
2408424087
],
@@ -24091,9 +24094,6 @@
2409124094
[
2409224095
"%%simpleExpr_factored1160"
2409324096
],
24094-
[
24095-
"literal"
24096-
],
2409724097
[
2409824098
"PARAM_MARKER"
2409924099
],

custom-parser/parser/grammar.php

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)