github.com/matrixorigin/matrixone@v1.2.0/pkg/sql/parsers/dialect/postgresql/postgresql_sql.y (about) 1 // Copyright 2021 Matrix Origin 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 %{ 16 package postgresql 17 18 import ( 19 "github.com/matrixorigin/matrixone/pkg/sql/parsers/tree" 20 ) 21 %} 22 23 %struct { 24 id int 25 str string 26 item interface{} 27 } 28 29 %union { 30 statement tree.Statement 31 statements []tree.Statement 32 } 33 34 %token LEX_ERROR 35 %nonassoc EMPTY 36 %left <str> UNION 37 %token <str> SELECT STREAM INSERT UPDATE DELETE FROM WHERE GROUP HAVING ORDER BY LIMIT OFFSET FOR 38 %nonassoc LOWER_THAN_SET 39 %nonassoc <str> SET 40 %token <str> ALL DISTINCT DISTINCTROW AS EXISTS ASC DESC INTO DUPLICATE DEFAULT LOCK KEYS 41 %token <str> VALUES 42 %token <str> NEXT VALUE SHARE MODE 43 %token <str> SQL_NO_CACHE SQL_CACHE 44 %left <str> JOIN STRAIGHT_JOIN LEFT RIGHT INNER OUTER CROSS NATURAL USE FORCE 45 %left <str> ON USING 46 %left <str> SUBQUERY_AS_EXPR 47 %left <str> '(' ',' ')' 48 %nonassoc LOWER_THAN_STRING 49 %nonassoc <str> ID AT_ID AT_AT_ID STRING VALUE_ARG LIST_ARG COMMENT COMMENT_KEYWORD 50 %token <item> INTEGRAL HEX BIT_LITERAL FLOAT HEXNUM 51 %token <str> NULL TRUE FALSE 52 %nonassoc LOWER_THAN_CHARSET 53 %nonassoc <str> CHARSET 54 %right <str> UNIQUE KEY 55 %left <str> OR PIPE_CONCAT 56 %left <str> XOR 57 %left <str> AND 58 %right <str> NOT '!' 59 %left <str> BETWEEN CASE WHEN THEN ELSE END 60 %left <str> '=' '<' '>' LE GE NE NULL_SAFE_EQUAL IS LIKE REGEXP IN ASSIGNMENT 61 %left <str> '|' 62 %left <str> '&' 63 %left <str> SHIFT_LEFT SHIFT_RIGHT 64 %left <str> '+' '-' 65 %left <str> '*' '/' DIV '%' MOD 66 %left <str> '^' 67 %right <str> '~' UNARY 68 %left <str> COLLATE 69 %right <str> BINARY UNDERSCORE_BINARY 70 %right <str> INTERVAL 71 %nonassoc <str> '.' 72 73 %type <statement> stmt 74 %type <statements> stmt_list 75 %type <statement> use_stmt 76 77 %start start_command 78 79 %% 80 81 start_command: 82 stmt_list 83 84 stmt_list: 85 stmt 86 { 87 if $1 != nil { 88 yylex.(*Lexer).AppendStmt($1) 89 } 90 } 91 | stmt_list ';' stmt 92 { 93 if $3 != nil { 94 yylex.(*Lexer).AppendStmt($3) 95 } 96 } 97 98 stmt: 99 use_stmt 100 101 use_stmt: 102 USE ID 103 { 104 $$ = &tree.Use{Name: tree.NewCStr($2, 1)} 105 } 106 | USE 107 { 108 $$ = &tree.Use{} 109 } 110 %%