github.com/matrixorigin/matrixone@v1.2.0/pkg/sql/parsers/dialect/postgresql/postgresql_sql.go (about) 1 // Code generated by goyacc -o postgresql_sql.go postgresql_sql.y. DO NOT EDIT. 2 3 //line postgresql_sql.y:16 4 package postgresql 5 6 import ( 7 __yyfmt__ "fmt" 8 __yyunsafe__ "unsafe" 9 ) 10 11 //line postgresql_sql.y:16 12 13 import ( 14 "github.com/matrixorigin/matrixone/pkg/sql/parsers/tree" 15 ) 16 17 const LEX_ERROR = 57346 18 const EMPTY = 57347 19 const UNION = 57348 20 const SELECT = 57349 21 const STREAM = 57350 22 const INSERT = 57351 23 const UPDATE = 57352 24 const DELETE = 57353 25 const FROM = 57354 26 const WHERE = 57355 27 const GROUP = 57356 28 const HAVING = 57357 29 const ORDER = 57358 30 const BY = 57359 31 const LIMIT = 57360 32 const OFFSET = 57361 33 const FOR = 57362 34 const LOWER_THAN_SET = 57363 35 const SET = 57364 36 const ALL = 57365 37 const DISTINCT = 57366 38 const DISTINCTROW = 57367 39 const AS = 57368 40 const EXISTS = 57369 41 const ASC = 57370 42 const DESC = 57371 43 const INTO = 57372 44 const DUPLICATE = 57373 45 const DEFAULT = 57374 46 const LOCK = 57375 47 const KEYS = 57376 48 const VALUES = 57377 49 const NEXT = 57378 50 const VALUE = 57379 51 const SHARE = 57380 52 const MODE = 57381 53 const SQL_NO_CACHE = 57382 54 const SQL_CACHE = 57383 55 const JOIN = 57384 56 const STRAIGHT_JOIN = 57385 57 const LEFT = 57386 58 const RIGHT = 57387 59 const INNER = 57388 60 const OUTER = 57389 61 const CROSS = 57390 62 const NATURAL = 57391 63 const USE = 57392 64 const FORCE = 57393 65 const ON = 57394 66 const USING = 57395 67 const SUBQUERY_AS_EXPR = 57396 68 const LOWER_THAN_STRING = 57397 69 const ID = 57398 70 const AT_ID = 57399 71 const AT_AT_ID = 57400 72 const STRING = 57401 73 const VALUE_ARG = 57402 74 const LIST_ARG = 57403 75 const COMMENT = 57404 76 const COMMENT_KEYWORD = 57405 77 const INTEGRAL = 57406 78 const HEX = 57407 79 const BIT_LITERAL = 57408 80 const FLOAT = 57409 81 const HEXNUM = 57410 82 const NULL = 57411 83 const TRUE = 57412 84 const FALSE = 57413 85 const LOWER_THAN_CHARSET = 57414 86 const CHARSET = 57415 87 const UNIQUE = 57416 88 const KEY = 57417 89 const OR = 57418 90 const PIPE_CONCAT = 57419 91 const XOR = 57420 92 const AND = 57421 93 const NOT = 57422 94 const BETWEEN = 57423 95 const CASE = 57424 96 const WHEN = 57425 97 const THEN = 57426 98 const ELSE = 57427 99 const END = 57428 100 const LE = 57429 101 const GE = 57430 102 const NE = 57431 103 const NULL_SAFE_EQUAL = 57432 104 const IS = 57433 105 const LIKE = 57434 106 const REGEXP = 57435 107 const IN = 57436 108 const ASSIGNMENT = 57437 109 const SHIFT_LEFT = 57438 110 const SHIFT_RIGHT = 57439 111 const DIV = 57440 112 const MOD = 57441 113 const UNARY = 57442 114 const COLLATE = 57443 115 const BINARY = 57444 116 const UNDERSCORE_BINARY = 57445 117 const INTERVAL = 57446 118 119 var yyToknames = [...]string{ 120 "$end", 121 "error", 122 "$unk", 123 "LEX_ERROR", 124 "EMPTY", 125 "UNION", 126 "SELECT", 127 "STREAM", 128 "INSERT", 129 "UPDATE", 130 "DELETE", 131 "FROM", 132 "WHERE", 133 "GROUP", 134 "HAVING", 135 "ORDER", 136 "BY", 137 "LIMIT", 138 "OFFSET", 139 "FOR", 140 "LOWER_THAN_SET", 141 "SET", 142 "ALL", 143 "DISTINCT", 144 "DISTINCTROW", 145 "AS", 146 "EXISTS", 147 "ASC", 148 "DESC", 149 "INTO", 150 "DUPLICATE", 151 "DEFAULT", 152 "LOCK", 153 "KEYS", 154 "VALUES", 155 "NEXT", 156 "VALUE", 157 "SHARE", 158 "MODE", 159 "SQL_NO_CACHE", 160 "SQL_CACHE", 161 "JOIN", 162 "STRAIGHT_JOIN", 163 "LEFT", 164 "RIGHT", 165 "INNER", 166 "OUTER", 167 "CROSS", 168 "NATURAL", 169 "USE", 170 "FORCE", 171 "ON", 172 "USING", 173 "SUBQUERY_AS_EXPR", 174 "'('", 175 "','", 176 "')'", 177 "LOWER_THAN_STRING", 178 "ID", 179 "AT_ID", 180 "AT_AT_ID", 181 "STRING", 182 "VALUE_ARG", 183 "LIST_ARG", 184 "COMMENT", 185 "COMMENT_KEYWORD", 186 "INTEGRAL", 187 "HEX", 188 "BIT_LITERAL", 189 "FLOAT", 190 "HEXNUM", 191 "NULL", 192 "TRUE", 193 "FALSE", 194 "LOWER_THAN_CHARSET", 195 "CHARSET", 196 "UNIQUE", 197 "KEY", 198 "OR", 199 "PIPE_CONCAT", 200 "XOR", 201 "AND", 202 "NOT", 203 "'!'", 204 "BETWEEN", 205 "CASE", 206 "WHEN", 207 "THEN", 208 "ELSE", 209 "END", 210 "'='", 211 "'<'", 212 "'>'", 213 "LE", 214 "GE", 215 "NE", 216 "NULL_SAFE_EQUAL", 217 "IS", 218 "LIKE", 219 "REGEXP", 220 "IN", 221 "ASSIGNMENT", 222 "'|'", 223 "'&'", 224 "SHIFT_LEFT", 225 "SHIFT_RIGHT", 226 "'+'", 227 "'-'", 228 "'*'", 229 "'/'", 230 "DIV", 231 "'%'", 232 "MOD", 233 "'^'", 234 "'~'", 235 "UNARY", 236 "COLLATE", 237 "BINARY", 238 "UNDERSCORE_BINARY", 239 "INTERVAL", 240 "'.'", 241 "';'", 242 } 243 244 var yyStatenames = [...]string{} 245 246 const yyEofCode = 1 247 const yyErrCode = 2 248 const yyInitialStackSize = 16 249 250 //line postgresql_sql.y:110 251 252 //line yacctab:1 253 var yyExca = [...]int{ 254 -1, 1, 255 1, -1, 256 -2, 0, 257 } 258 259 const yyPrivate = 57344 260 261 const yyLast = 11 262 263 var yyAct = [...]int{ 264 6, 7, 5, 3, 1, 4, 2, 0, 0, 0, 265 8, 266 } 267 268 var yyPact = [...]int{ 269 -48, -1000, -122, -1000, -1000, -58, -48, -1000, -1000, 270 } 271 272 var yyPgo = [...]int{ 273 0, 3, 6, 5, 4, 274 } 275 276 //line postgresql_sql.y:110 277 type yySymType struct { 278 union interface{} 279 id int 280 str string 281 item interface{} 282 yys int 283 } 284 285 func (st *yySymType) statementUnion() tree.Statement { 286 v, _ := st.union.(tree.Statement) 287 return v 288 } 289 290 func (st *yySymType) statementsUnion() []tree.Statement { 291 v, _ := st.union.([]tree.Statement) 292 return v 293 } 294 295 var yyR1 = [...]int{ 296 0, 4, 2, 2, 1, 3, 3, 297 } 298 299 var yyR2 = [...]int{ 300 0, 1, 1, 3, 1, 2, 1, 301 } 302 303 var yyChk = [...]int{ 304 -1000, -4, -2, -1, -3, 50, 122, 59, -1, 305 } 306 307 var yyDef = [...]int{ 308 0, -2, 1, 2, 4, 6, 0, 5, 3, 309 } 310 311 var yyTok1 = [...]int{ 312 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 313 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 314 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 315 3, 3, 3, 84, 3, 3, 3, 112, 104, 3, 316 55, 57, 109, 107, 56, 108, 121, 110, 3, 3, 317 3, 3, 3, 3, 3, 3, 3, 3, 3, 122, 318 92, 91, 93, 3, 3, 3, 3, 3, 3, 3, 319 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 320 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 321 3, 3, 3, 3, 114, 3, 3, 3, 3, 3, 322 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 323 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 324 3, 3, 3, 3, 103, 3, 115, 325 } 326 327 var yyTok2 = [...]int{ 328 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 329 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 330 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 331 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 332 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 333 52, 53, 54, 58, 59, 60, 61, 62, 63, 64, 334 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 335 75, 76, 77, 78, 79, 80, 81, 82, 83, 85, 336 86, 87, 88, 89, 90, 94, 95, 96, 97, 98, 337 99, 100, 101, 102, 105, 106, 111, 113, 116, 117, 338 118, 119, 120, 339 } 340 341 var yyTok3 = [...]int{ 342 0, 343 } 344 345 var yyErrorMessages = [...]struct { 346 state int 347 token int 348 msg string 349 }{} 350 351 //line yaccpar:1 352 353 /* parser for yacc output */ 354 355 func yyIaddr(v interface{}) __yyunsafe__.Pointer { 356 type h struct { 357 t __yyunsafe__.Pointer 358 p __yyunsafe__.Pointer 359 } 360 return (*h)(__yyunsafe__.Pointer(&v)).p 361 } 362 363 var ( 364 yyDebug = 0 365 yyErrorVerbose = false 366 ) 367 368 type yyLexer interface { 369 Lex(lval *yySymType) int 370 Error(s string) 371 } 372 373 type yyParser interface { 374 Parse(yyLexer) int 375 Lookahead() int 376 } 377 378 type yyParserImpl struct { 379 lval yySymType 380 stack [yyInitialStackSize]yySymType 381 char int 382 } 383 384 func (p *yyParserImpl) Lookahead() int { 385 return p.char 386 } 387 388 func yyNewParser() yyParser { 389 return &yyParserImpl{} 390 } 391 392 const yyFlag = -1000 393 394 func yyTokname(c int) string { 395 if c >= 1 && c-1 < len(yyToknames) { 396 if yyToknames[c-1] != "" { 397 return yyToknames[c-1] 398 } 399 } 400 return __yyfmt__.Sprintf("tok-%v", c) 401 } 402 403 func yyStatname(s int) string { 404 if s >= 0 && s < len(yyStatenames) { 405 if yyStatenames[s] != "" { 406 return yyStatenames[s] 407 } 408 } 409 return __yyfmt__.Sprintf("state-%v", s) 410 } 411 412 func yyErrorMessage(state, lookAhead int) string { 413 const TOKSTART = 4 414 415 if !yyErrorVerbose { 416 return "syntax error" 417 } 418 419 for _, e := range yyErrorMessages { 420 if e.state == state && e.token == lookAhead { 421 return "syntax error: " + e.msg 422 } 423 } 424 425 res := "syntax error: unexpected " + yyTokname(lookAhead) 426 427 // To match Bison, suggest at most four expected tokens. 428 expected := make([]int, 0, 4) 429 430 // Look for shiftable tokens. 431 base := yyPact[state] 432 for tok := TOKSTART; tok-1 < len(yyToknames); tok++ { 433 if n := base + tok; n >= 0 && n < yyLast && yyChk[yyAct[n]] == tok { 434 if len(expected) == cap(expected) { 435 return res 436 } 437 expected = append(expected, tok) 438 } 439 } 440 441 if yyDef[state] == -2 { 442 i := 0 443 for yyExca[i] != -1 || yyExca[i+1] != state { 444 i += 2 445 } 446 447 // Look for tokens that we accept or reduce. 448 for i += 2; yyExca[i] >= 0; i += 2 { 449 tok := yyExca[i] 450 if tok < TOKSTART || yyExca[i+1] == 0 { 451 continue 452 } 453 if len(expected) == cap(expected) { 454 return res 455 } 456 expected = append(expected, tok) 457 } 458 459 // If the default action is to accept or reduce, give up. 460 if yyExca[i+1] != 0 { 461 return res 462 } 463 } 464 465 for i, tok := range expected { 466 if i == 0 { 467 res += ", expecting " 468 } else { 469 res += " or " 470 } 471 res += yyTokname(tok) 472 } 473 return res 474 } 475 476 func yylex1(lex yyLexer, lval *yySymType) (char, token int) { 477 token = 0 478 char = lex.Lex(lval) 479 if char <= 0 { 480 token = yyTok1[0] 481 goto out 482 } 483 if char < len(yyTok1) { 484 token = yyTok1[char] 485 goto out 486 } 487 if char >= yyPrivate { 488 if char < yyPrivate+len(yyTok2) { 489 token = yyTok2[char-yyPrivate] 490 goto out 491 } 492 } 493 for i := 0; i < len(yyTok3); i += 2 { 494 token = yyTok3[i+0] 495 if token == char { 496 token = yyTok3[i+1] 497 goto out 498 } 499 } 500 501 out: 502 if token == 0 { 503 token = yyTok2[1] /* unknown char */ 504 } 505 if yyDebug >= 3 { 506 __yyfmt__.Printf("lex %s(%d)\n", yyTokname(token), uint(char)) 507 } 508 return char, token 509 } 510 511 func yyParse(yylex yyLexer) int { 512 return yyNewParser().Parse(yylex) 513 } 514 515 func (yyrcvr *yyParserImpl) Parse(yylex yyLexer) int { 516 var yyn int 517 var yyVAL yySymType 518 var yyDollar []yySymType 519 _ = yyDollar // silence set and not used 520 yyS := yyrcvr.stack[:] 521 522 Nerrs := 0 /* number of errors */ 523 Errflag := 0 /* error recovery flag */ 524 yystate := 0 525 yyrcvr.char = -1 526 yytoken := -1 // yyrcvr.char translated into internal numbering 527 defer func() { 528 // Make sure we report no lookahead when not parsing. 529 yystate = -1 530 yyrcvr.char = -1 531 yytoken = -1 532 }() 533 yyp := -1 534 goto yystack 535 536 ret0: 537 return 0 538 539 ret1: 540 return 1 541 542 yystack: 543 /* put a state and value onto the stack */ 544 if yyDebug >= 4 { 545 __yyfmt__.Printf("char %v in %v\n", yyTokname(yytoken), yyStatname(yystate)) 546 } 547 548 yyp++ 549 if yyp >= len(yyS) { 550 nyys := make([]yySymType, len(yyS)*2) 551 copy(nyys, yyS) 552 yyS = nyys 553 } 554 yyS[yyp] = yyVAL 555 yyS[yyp].yys = yystate 556 557 yynewstate: 558 yyn = yyPact[yystate] 559 if yyn <= yyFlag { 560 goto yydefault /* simple state */ 561 } 562 if yyrcvr.char < 0 { 563 yyrcvr.char, yytoken = yylex1(yylex, &yyrcvr.lval) 564 } 565 yyn += yytoken 566 if yyn < 0 || yyn >= yyLast { 567 goto yydefault 568 } 569 yyn = yyAct[yyn] 570 if yyChk[yyn] == yytoken { /* valid shift */ 571 yyrcvr.char = -1 572 yytoken = -1 573 yyVAL = yyrcvr.lval 574 yystate = yyn 575 if Errflag > 0 { 576 Errflag-- 577 } 578 goto yystack 579 } 580 581 yydefault: 582 /* default state action */ 583 yyn = yyDef[yystate] 584 if yyn == -2 { 585 if yyrcvr.char < 0 { 586 yyrcvr.char, yytoken = yylex1(yylex, &yyrcvr.lval) 587 } 588 589 /* look through exception table */ 590 xi := 0 591 for { 592 if yyExca[xi+0] == -1 && yyExca[xi+1] == yystate { 593 break 594 } 595 xi += 2 596 } 597 for xi += 2; ; xi += 2 { 598 yyn = yyExca[xi+0] 599 if yyn < 0 || yyn == yytoken { 600 break 601 } 602 } 603 yyn = yyExca[xi+1] 604 if yyn < 0 { 605 goto ret0 606 } 607 } 608 if yyn == 0 { 609 /* error ... attempt to resume parsing */ 610 switch Errflag { 611 case 0: /* brand new error */ 612 yylex.Error(yyErrorMessage(yystate, yytoken)) 613 Nerrs++ 614 if yyDebug >= 1 { 615 __yyfmt__.Printf("%s", yyStatname(yystate)) 616 __yyfmt__.Printf(" saw %s\n", yyTokname(yytoken)) 617 } 618 fallthrough 619 620 case 1, 2: /* incompletely recovered error ... try again */ 621 Errflag = 3 622 623 /* find a state where "error" is a legal shift action */ 624 for yyp >= 0 { 625 yyn = yyPact[yyS[yyp].yys] + yyErrCode 626 if yyn >= 0 && yyn < yyLast { 627 yystate = yyAct[yyn] /* simulate a shift of "error" */ 628 if yyChk[yystate] == yyErrCode { 629 goto yystack 630 } 631 } 632 633 /* the current p has no shift on "error", pop stack */ 634 if yyDebug >= 2 { 635 __yyfmt__.Printf("error recovery pops state %d\n", yyS[yyp].yys) 636 } 637 yyp-- 638 } 639 /* there is no state on the stack with an error shift ... abort */ 640 goto ret1 641 642 case 3: /* no shift yet; clobber input char */ 643 if yyDebug >= 2 { 644 __yyfmt__.Printf("error recovery discards %s\n", yyTokname(yytoken)) 645 } 646 if yytoken == yyEofCode { 647 goto ret1 648 } 649 yyrcvr.char = -1 650 yytoken = -1 651 goto yynewstate /* try again in the same state */ 652 } 653 } 654 655 /* reduction by production yyn */ 656 if yyDebug >= 2 { 657 __yyfmt__.Printf("reduce %v in:\n\t%v\n", yyn, yyStatname(yystate)) 658 } 659 660 yynt := yyn 661 yypt := yyp 662 _ = yypt // guard against "declared and not used" 663 664 yyp -= yyR2[yyn] 665 // yyp is now the index of $0. Perform the default action. Iff the 666 // reduced production is ε, $1 is possibly out of range. 667 if yyp+1 >= len(yyS) { 668 nyys := make([]yySymType, len(yyS)*2) 669 copy(nyys, yyS) 670 yyS = nyys 671 } 672 yyVAL = yyS[yyp+1] 673 674 /* consult goto table to find next state */ 675 yyn = yyR1[yyn] 676 yyg := yyPgo[yyn] 677 yyj := yyg + yyS[yyp].yys + 1 678 679 if yyj >= yyLast { 680 yystate = yyAct[yyg] 681 } else { 682 yystate = yyAct[yyj] 683 if yyChk[yystate] != -yyn { 684 yystate = yyAct[yyg] 685 } 686 } 687 // dummy call; replaced with literal code 688 switch yynt { 689 690 case 2: 691 yyDollar = yyS[yypt-1 : yypt+1] 692 //line postgresql_sql.y:86 693 { 694 if yyDollar[1].statementUnion() != nil { 695 yylex.(*Lexer).AppendStmt(yyDollar[1].statementUnion()) 696 } 697 } 698 case 3: 699 yyDollar = yyS[yypt-3 : yypt+1] 700 //line postgresql_sql.y:92 701 { 702 if yyDollar[3].statementUnion() != nil { 703 yylex.(*Lexer).AppendStmt(yyDollar[3].statementUnion()) 704 } 705 } 706 case 5: 707 yyDollar = yyS[yypt-2 : yypt+1] 708 var yyLOCAL tree.Statement 709 //line postgresql_sql.y:103 710 { 711 yyLOCAL = &tree.Use{Name: tree.NewCStr(yyDollar[2].str, 1)} 712 } 713 yyVAL.union = yyLOCAL 714 case 6: 715 yyDollar = yyS[yypt-1 : yypt+1] 716 var yyLOCAL tree.Statement 717 //line postgresql_sql.y:107 718 { 719 yyLOCAL = &tree.Use{} 720 } 721 yyVAL.union = yyLOCAL 722 } 723 goto yystack /* stack new state and value */ 724 }