◐ Shell
reader mode source ↗
Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
File filter
Conversations
Jump to
Diff view
Apply and reload
Show whitespace
Diff view
Apply and reload
16 changes: 10 additions & 6 deletions src/sqlParser.jison
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@
[-][-]\s.*\n /* skip sql comments */
[#]\s.*\n /* skip sql comments */
\s+ /* skip whitespace */
[`][a-zA-Z_\u4e00-\u9fa5][a-zA-Z0-9_\u4e00-\u9fa5]*[`] return 'IDENTIFIER'
[\w]+[\u4e00-\u9fa5]+[0-9a-zA-Z_\u4e00-\u9fa5]* return 'IDENTIFIER'
[\u4e00-\u9fa5][0-9a-zA-Z_\u4e00-\u9fa5]* return 'IDENTIFIER'
SELECT return 'SELECT'
ALL return 'ALL'
ANY return 'ANY'
Expand Down @@ -116,7 +118,7 @@ LIMIT return 'LIMIT'
"{" return '{'
"}" return '}'
";" return ';'
['](\\.|[^'])*['] return 'STRING'
["](\\.|[^"])*["] return 'STRING'
[0][x][0-9a-fA-F]+ return 'HEX_NUMERIC'
Expand All @@ -126,7 +128,7 @@ LIMIT return 'LIMIT'
[a-zA-Z_\u4e00-\u9fa5][a-zA-Z0-9_\u4e00-\u9fa5]* return 'IDENTIFIER'
\. return 'DOT'
['"][a-zA-Z_\u4e00-\u9fa5][a-zA-Z0-9_\u4e00-\u9fa5]*["'] return 'QUOTED_IDENTIFIER'
<<EOF>> return 'EOF'
. return 'INVALID'

Expand Down Expand Up @@ -164,7 +166,7 @@ main
;

selectClause
: SELECT
distinctOpt
highPriorityOpt
maxStateMentTimeOpt
Expand Down Expand Up @@ -203,7 +205,7 @@ selectClause
;

distinctOpt
: ALL { $$ = $1 }
| DISTINCT { $$ = $1 }
| DISTINCTROW { $$ = $1 }
| { $$ = null }
Expand Down Expand Up @@ -295,6 +297,7 @@ function_call_param
identifier
: IDENTIFIER { $$ = { type: 'Identifier', value: $1 } }
| identifier DOT IDENTIFIER { $$ = $1; $1.value += '.' + $3 }
;
identifier_list
: identifier { $$ = { type: 'IdentifierList', value: [ $1 ] } }
Expand Down Expand Up @@ -336,7 +339,7 @@ simple_expr
;
bit_expr
: simple_expr { $$ = $1 }
| bit_expr '|' bit_expr { $$ = { type: 'BitExpression', operator: '|', left: $1, right: $3 } }
| bit_expr '&' bit_expr { $$ = { type: 'BitExpression', operator: '&', left: $1, right: $3 } }
| bit_expr '<<' bit_expr { $$ = { type: 'BitExpression', operator: '<<', left: $1, right: $3 } }
| bit_expr '>>' bit_expr { $$ = { type: 'BitExpression', operator: '>>', left: $1, right: $3 } }
Expand Down Expand Up @@ -446,6 +449,7 @@ limit
: LIMIT NUMERIC { $$ = { type: 'Limit', value: [ $2 ] } }
| LIMIT NUMERIC ',' NUMERIC { $$ = { type: 'Limit', value: [ $2, $4 ] } }
| LIMIT NUMERIC OFFSET NUMERIC { $$ = { type: 'Limit', value: [ $4, $2 ], offsetMode: true } }
;
limit_opt
: { $$ = null }
Expand Down
Toggle all file notes Toggle all file annotations