Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4724fab

Browse files
committed
feat: union grammar, to resolve grammar conflicts.#2
1 parentc2decc0 commit4724fab

File tree

1 file changed

+27
-2
lines changed

1 file changed

+27
-2
lines changed

‎src/sqlParser.jison

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ SHARE return 'SHARE'
8989
MODEreturn'MODE'
9090
OJreturn'OJ'
9191
LIMITreturn'LIMIT'
92+
UNIONreturn'UNION'
9293

9394
","return','
9495
"="return'='
@@ -159,8 +160,32 @@ LIMIT return 'LIMIT'
159160
%%/* language grammar*/
160161

161162
main
162-
: selectClauseEOF {return {nodeType:'Main', value:$1};}
163-
| selectClause';'EOF {return {nodeType:'Main', value:$1, hasSemicolon:true};}
163+
: selectClause semicolonOptEOF {return {nodeType:'Main', value:$1, hasSemicolon:$2};}
164+
| unionClause semicolonOptEOF {return {nodeType:'Main', value:$1, hasSemicolon:$2};}
165+
;
166+
167+
semicolonOpt
168+
:';' {$$=true}
169+
| {$$=false}
170+
;
171+
172+
unionClause
173+
: unionClauseNotParenthesized {$$=$1}
174+
| unionClauseParenthesized {$$=$1}
175+
;
176+
177+
unionClauseParenthesized
178+
: selectClauseParenthesized UNION distinctOpt selectClauseParenthesized order_by_opt limit_opt {$$= { type:'Union', left:$1, distinctOpt:$3, right:$4, orderBy:$5, limit:$6 };}
179+
| selectClauseParenthesized UNION distinctOpt unionClauseParenthesized order_by_opt limit_opt {$$= { type:'Union', left:$1, distinctOpt:$3, right:$4, orderBy:$5, limit:$6 }}
180+
;
181+
182+
selectClauseParenthesized
183+
:'(' selectClause')' {$$= { type:'SelectParenthesized', value:$2 }}
184+
;
185+
186+
unionClauseNotParenthesized
187+
: selectClause UNION distinctOpt selectClause {$$= { type:'Union', left:$1, distinctOpt:$3, right:$4 }}
188+
| selectClause UNION distinctOpt unionClauseNotParenthesized {$$= { type:'Union', left:$1, distinctOpt:$3, right:$4 }}
164189
;
165190

166191
selectClause

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp