1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687
|
%{
//TODO Put your favorite license here
// yacc source generated by ebnf2y[1]
// at 2016-07-29 15:22:15.327246133 +0200 CEST
//
// $ ebnf2y -o ql.y -oe ql.ebnf -start StatementList -pkg ql -p _
//
// CAUTION: If this file is a Go source file (*.go), it was generated
// automatically by '$ go tool yacc' from a *.y file - DO NOT EDIT in that case!
//
// [1]: http://github.com/cznic/ebnf2y
package ql //TODO real package name
//TODO required only be the demo _dump function
import (
"bytes"
"fmt"
"strings"
"github.com/cznic/strutil"
)
%}
%union {
item interface{} //TODO insert real field(s)
}
%token _ANDAND
%token _ANDNOT
%token _EQ
%token _FLOAT_LIT
%token _GE
%token _IDENTIFIER
%token _IMAGINARY_LIT
%token _INT_LIT
%token _LE
%token _LSH
%token _NEQ
%token _OROR
%token _QL_PARAMETER
%token _RSH
%token _RUNE_LIT
%token _STRING_LIT
%type <item> /*TODO real type(s), if/where applicable */
_ANDAND
_ANDNOT
_EQ
_FLOAT_LIT
_GE
_IDENTIFIER
_IMAGINARY_LIT
_INT_LIT
_LE
_LSH
_NEQ
_OROR
_QL_PARAMETER
_RSH
_RUNE_LIT
_STRING_LIT
%token _ADD
%token _ALTER
%token _AND
%token _AS
%token _ASC
%token _BEGIN
%token _BETWEEN
%token _BIGINT
%token _BIGRAT
%token _BLOB
%token _BOOL
%token _BY
%token _BYTE
%token _COLUMN
%token _COMMIT
%token _COMPLEX128
%token _COMPLEX64
%token _CREATE
%token _DEFAULT
%token _DELETE
%token _DESC
%token _DISTINCT
%token _DROP
%token _DURATION
%token _EXISTS
%token _EXPLAIN
%token _FALSE
%token _FLOAT
%token _FLOAT32
%token _FLOAT64
%token _FROM
%token _FULL
%token _GROUPBY
%token _IF
%token _IN
%token _INDEX
%token _INSERT
%token _INT
%token _INT16
%token _INT32
%token _INT64
%token _INT8
%token _INTO
%token _IS
%token _JOIN
%token _LEFT
%token _LIKE
%token _LIMIT
%token _NOT
%token _NULL
%token _OFFSET
%token _ON
%token _OR
%token _ORDER
%token _OUTER
%token _RIGHT
%token _ROLLBACK
%token _RUNE
%token _SELECT
%token _SET
%token _STRING
%token _TABLE
%token _TIME
%token _TRANSACTION
%token _TRUE
%token _TRUNCATE
%token _UINT
%token _UINT16
%token _UINT32
%token _UINT64
%token _UINT8
%token _UNIQUE
%token _UPDATE
%token _VALUES
%token _WHERE
%type <item> /*TODO real type(s), if/where applicable */
AlterTableStmt
AlterTableStmt1
Assignment
AssignmentList
AssignmentList1
AssignmentList2
BeginTransactionStmt
Call
Call1
Call11
ColumnDef
ColumnDef1
ColumnDef11
ColumnDef2
ColumnName
ColumnNameList
ColumnNameList1
ColumnNameList2
CommitStmt
Conversion
CreateIndexStmt
CreateIndexStmt1
CreateIndexStmt2
CreateTableStmt
CreateTableStmt1
CreateTableStmt2
CreateTableStmt3
DeleteFromStmt
DeleteFromStmt1
DropIndexStmt
DropIndexStmt1
DropTableStmt
DropTableStmt1
EmptyStmt
ExplainStmt
Expression
Expression1
Expression11
ExpressionList
ExpressionList1
ExpressionList2
Factor
Factor1
Factor11
Factor2
Field
Field1
FieldList
FieldList1
FieldList2
GroupByClause
Index
IndexName
InsertIntoStmt
InsertIntoStmt1
InsertIntoStmt2
JoinClause
JoinClause1
JoinClause2
Limit
Literal
Offset
Operand
OrderBy
OrderBy1
OrderBy11
Predicate
Predicate1
Predicate11
Predicate12
Predicate121
Predicate13
PrimaryExpression
PrimaryFactor
PrimaryFactor1
PrimaryFactor11
PrimaryTerm
PrimaryTerm1
PrimaryTerm11
QualifiedIdent
QualifiedIdent1
RecordSet
RecordSet1
RecordSet11
RecordSet2
RecordSetList
RecordSetList1
RecordSetList2
RollbackStmt
SelectStmt
SelectStmt1
SelectStmt2
SelectStmt3
SelectStmt4
SelectStmt5
SelectStmt6
SelectStmt7
SelectStmt8
Slice
Slice1
Slice2
Start
Statement
StatementList
StatementList1
TableName
Term
Term1
Term11
TruncateTableStmt
Type
UnaryExpr
UnaryExpr1
UnaryExpr11
UpdateStmt
UpdateStmt1
UpdateStmt2
Values
Values1
Values2
WhereClause
/*TODO %left, %right, ... declarations */
%start Start
%%
AlterTableStmt:
_ALTER _TABLE TableName AlterTableStmt1
{
$$ = []AlterTableStmt{"ALTER", "TABLE", $3, $4} //TODO 1
}
AlterTableStmt1:
_ADD ColumnDef
{
$$ = []AlterTableStmt1{"ADD", $2} //TODO 2
}
| _DROP _COLUMN ColumnName
{
$$ = []AlterTableStmt1{"DROP", "COLUMN", $3} //TODO 3
}
Assignment:
ColumnName '=' Expression
{
$$ = []Assignment{$1, "=", $3} //TODO 4
}
AssignmentList:
Assignment AssignmentList1 AssignmentList2
{
$$ = []AssignmentList{$1, $2, $3} //TODO 5
}
AssignmentList1:
/* EMPTY */
{
$$ = []AssignmentList1(nil) //TODO 6
}
| AssignmentList1 ',' Assignment
{
$$ = append($1.([]AssignmentList1), ",", $3) //TODO 7
}
AssignmentList2:
/* EMPTY */
{
$$ = nil //TODO 8
}
| ','
{
$$ = "," //TODO 9
}
BeginTransactionStmt:
_BEGIN _TRANSACTION
{
$$ = []BeginTransactionStmt{"BEGIN", "TRANSACTION"} //TODO 10
}
Call:
'(' Call1 ')'
{
$$ = []Call{"(", $2, ")"} //TODO 11
}
Call1:
/* EMPTY */
{
$$ = nil //TODO 12
}
| Call11
{
$$ = $1 //TODO 13
}
Call11:
'*'
{
$$ = "*" //TODO 14
}
| ExpressionList
{
$$ = $1 //TODO 15
}
ColumnDef:
ColumnName Type ColumnDef1 ColumnDef2
{
$$ = []ColumnDef{$1, $2, $3, $4} //TODO 16
}
ColumnDef1:
/* EMPTY */
{
$$ = nil //TODO 17
}
| ColumnDef11
{
$$ = $1 //TODO 18
}
ColumnDef11:
_NOT _NULL
{
$$ = []ColumnDef11{"NOT", "NULL"} //TODO 19
}
| Expression
{
$$ = $1 //TODO 20
}
ColumnDef2:
/* EMPTY */
{
$$ = nil //TODO 21
}
| _DEFAULT Expression
{
$$ = []ColumnDef2{"DEFAULT", $2} //TODO 22
}
ColumnName:
_IDENTIFIER
{
$$ = $1 //TODO 23
}
ColumnNameList:
ColumnName ColumnNameList1 ColumnNameList2
{
$$ = []ColumnNameList{$1, $2, $3} //TODO 24
}
ColumnNameList1:
/* EMPTY */
{
$$ = []ColumnNameList1(nil) //TODO 25
}
| ColumnNameList1 ',' ColumnName
{
$$ = append($1.([]ColumnNameList1), ",", $3) //TODO 26
}
ColumnNameList2:
/* EMPTY */
{
$$ = nil //TODO 27
}
| ','
{
$$ = "," //TODO 28
}
CommitStmt:
_COMMIT
{
$$ = "COMMIT" //TODO 29
}
Conversion:
Type '(' Expression ')'
{
$$ = []Conversion{$1, "(", $3, ")"} //TODO 30
}
CreateIndexStmt:
_CREATE CreateIndexStmt1 _INDEX CreateIndexStmt2 IndexName _ON TableName '(' ExpressionList ')'
{
$$ = []CreateIndexStmt{"CREATE", $2, "INDEX", $4, $5, "ON", $7, "(", $9, ")"} //TODO 31
}
CreateIndexStmt1:
/* EMPTY */
{
$$ = nil //TODO 32
}
| _UNIQUE
{
$$ = "UNIQUE" //TODO 33
}
CreateIndexStmt2:
/* EMPTY */
{
$$ = nil //TODO 34
}
| _IF _NOT _EXISTS
{
$$ = []CreateIndexStmt2{"IF", "NOT", "EXISTS"} //TODO 35
}
CreateTableStmt:
_CREATE _TABLE CreateTableStmt1 TableName '(' ColumnDef CreateTableStmt2 CreateTableStmt3 ')'
{
$$ = []CreateTableStmt{"CREATE", "TABLE", $3, $4, "(", $6, $7, $8, ")"} //TODO 36
}
CreateTableStmt1:
/* EMPTY */
{
$$ = nil //TODO 37
}
| _IF _NOT _EXISTS
{
$$ = []CreateTableStmt1{"IF", "NOT", "EXISTS"} //TODO 38
}
CreateTableStmt2:
/* EMPTY */
{
$$ = []CreateTableStmt2(nil) //TODO 39
}
| CreateTableStmt2 ',' ColumnDef
{
$$ = append($1.([]CreateTableStmt2), ",", $3) //TODO 40
}
CreateTableStmt3:
/* EMPTY */
{
$$ = nil //TODO 41
}
| ','
{
$$ = "," //TODO 42
}
DeleteFromStmt:
_DELETE _FROM TableName DeleteFromStmt1
{
$$ = []DeleteFromStmt{"DELETE", "FROM", $3, $4} //TODO 43
}
DeleteFromStmt1:
/* EMPTY */
{
$$ = nil //TODO 44
}
| WhereClause
{
$$ = $1 //TODO 45
}
DropIndexStmt:
_DROP _INDEX DropIndexStmt1 IndexName
{
$$ = []DropIndexStmt{"DROP", "INDEX", $3, $4} //TODO 46
}
DropIndexStmt1:
/* EMPTY */
{
$$ = nil //TODO 47
}
| _IF _EXISTS
{
$$ = []DropIndexStmt1{"IF", "EXISTS"} //TODO 48
}
DropTableStmt:
_DROP _TABLE DropTableStmt1 TableName
{
$$ = []DropTableStmt{"DROP", "TABLE", $3, $4} //TODO 49
}
DropTableStmt1:
/* EMPTY */
{
$$ = nil //TODO 50
}
| _IF _EXISTS
{
$$ = []DropTableStmt1{"IF", "EXISTS"} //TODO 51
}
EmptyStmt:
/* EMPTY */
{
$$ = nil //TODO 52
}
ExplainStmt:
_EXPLAIN Statement
{
$$ = []ExplainStmt{"EXPLAIN", $2} //TODO 53
}
Expression:
Term Expression1
{
$$ = []Expression{$1, $2} //TODO 54
}
Expression1:
/* EMPTY */
{
$$ = []Expression1(nil) //TODO 55
}
| Expression1 Expression11 Term
{
$$ = append($1.([]Expression1), $2, $3) //TODO 56
}
Expression11:
_OROR
{
$$ = $1 //TODO 57
}
| _OR
{
$$ = "OR" //TODO 58
}
ExpressionList:
Expression ExpressionList1 ExpressionList2
{
$$ = []ExpressionList{$1, $2, $3} //TODO 59
}
ExpressionList1:
/* EMPTY */
{
$$ = []ExpressionList1(nil) //TODO 60
}
| ExpressionList1 ',' Expression
{
$$ = append($1.([]ExpressionList1), ",", $3) //TODO 61
}
ExpressionList2:
/* EMPTY */
{
$$ = nil //TODO 62
}
| ','
{
$$ = "," //TODO 63
}
Factor:
PrimaryFactor Factor1 Factor2
{
$$ = []Factor{$1, $2, $3} //TODO 64
}
Factor1:
/* EMPTY */
{
$$ = []Factor1(nil) //TODO 65
}
| Factor1 Factor11 PrimaryFactor
{
$$ = append($1.([]Factor1), $2, $3) //TODO 66
}
Factor11:
_GE
{
$$ = $1 //TODO 67
}
| '>'
{
$$ = ">" //TODO 68
}
| _LE
{
$$ = $1 //TODO 69
}
| '<'
{
$$ = "<" //TODO 70
}
| _NEQ
{
$$ = $1 //TODO 71
}
| _EQ
{
$$ = $1 //TODO 72
}
| _LIKE
{
$$ = "LIKE" //TODO 73
}
Factor2:
/* EMPTY */
{
$$ = nil //TODO 74
}
| Predicate
{
$$ = $1 //TODO 75
}
Field:
Expression Field1
{
$$ = []Field{$1, $2} //TODO 76
}
Field1:
/* EMPTY */
{
$$ = nil //TODO 77
}
| _AS _IDENTIFIER
{
$$ = []Field1{"AS", $2} //TODO 78
}
FieldList:
Field FieldList1 FieldList2
{
$$ = []FieldList{$1, $2, $3} //TODO 79
}
FieldList1:
/* EMPTY */
{
$$ = []FieldList1(nil) //TODO 80
}
| FieldList1 ',' Field
{
$$ = append($1.([]FieldList1), ",", $3) //TODO 81
}
FieldList2:
/* EMPTY */
{
$$ = nil //TODO 82
}
| ','
{
$$ = "," //TODO 83
}
GroupByClause:
_GROUPBY ColumnNameList
{
$$ = []GroupByClause{"GROUP BY", $2} //TODO 84
}
Index:
'[' Expression ']'
{
$$ = []Index{"[", $2, "]"} //TODO 85
}
IndexName:
_IDENTIFIER
{
$$ = $1 //TODO 86
}
InsertIntoStmt:
_INSERT _INTO TableName InsertIntoStmt1 InsertIntoStmt2
{
$$ = []InsertIntoStmt{"INSERT", "INTO", $3, $4, $5} //TODO 87
}
InsertIntoStmt1:
/* EMPTY */
{
$$ = nil //TODO 88
}
| '(' ColumnNameList ')'
{
$$ = []InsertIntoStmt1{"(", $2, ")"} //TODO 89
}
InsertIntoStmt2:
Values
{
$$ = $1 //TODO 90
}
| SelectStmt
{
$$ = $1 //TODO 91
}
JoinClause:
JoinClause1 JoinClause2 _JOIN RecordSet _ON Expression
{
$$ = []JoinClause{$1, $2, "JOIN", $4, "ON", $6} //TODO 92
}
JoinClause1:
_LEFT
{
$$ = "LEFT" //TODO 93
}
| _RIGHT
{
$$ = "RIGHT" //TODO 94
}
| _FULL
{
$$ = "FULL" //TODO 95
}
JoinClause2:
/* EMPTY */
{
$$ = nil //TODO 96
}
| _OUTER
{
$$ = "OUTER" //TODO 97
}
Limit:
_LIMIT Expression
{
$$ = []Limit{"Limit", $2} //TODO 98
}
Literal:
_FALSE
{
$$ = "FALSE" //TODO 99
}
| _NULL
{
$$ = "NULL" //TODO 100
}
| _TRUE
{
$$ = "TRUE" //TODO 101
}
| _FLOAT_LIT
{
$$ = $1 //TODO 102
}
| _IMAGINARY_LIT
{
$$ = $1 //TODO 103
}
| _INT_LIT
{
$$ = $1 //TODO 104
}
| _RUNE_LIT
{
$$ = $1 //TODO 105
}
| _STRING_LIT
{
$$ = $1 //TODO 106
}
| _QL_PARAMETER
{
$$ = $1 //TODO 107
}
Offset:
_OFFSET Expression
{
$$ = []Offset{"OFFSET", $2} //TODO 108
}
Operand:
Literal
{
$$ = $1 //TODO 109
}
| QualifiedIdent
{
$$ = $1 //TODO 110
}
| '(' Expression ')'
{
$$ = []Operand{"(", $2, ")"} //TODO 111
}
OrderBy:
_ORDER _BY ExpressionList OrderBy1
{
$$ = []OrderBy{"ORDER", "BY", $3, $4} //TODO 112
}
OrderBy1:
/* EMPTY */
{
$$ = nil //TODO 113
}
| OrderBy11
{
$$ = $1 //TODO 114
}
OrderBy11:
_ASC
{
$$ = "ASC" //TODO 115
}
| _DESC
{
$$ = "DESC" //TODO 116
}
Predicate:
Predicate1
{
$$ = $1 //TODO 117
}
Predicate1:
Predicate11 Predicate12
{
$$ = []Predicate1{$1, $2} //TODO 118
}
| _IS Predicate13 _NULL
{
$$ = []Predicate1{"IS", $2, "NULL"} //TODO 119
}
Predicate11:
/* EMPTY */
{
$$ = nil //TODO 120
}
| _NOT
{
$$ = "NOT" //TODO 121
}
Predicate12:
_IN '(' ExpressionList ')'
{
$$ = []Predicate12{"IN", "(", $3, ")"} //TODO 122
}
| _IN '(' SelectStmt Predicate121 ')'
{
$$ = []Predicate12{"IN", "(", $3, $4, ")"} //TODO 123
}
| _BETWEEN PrimaryFactor _AND PrimaryFactor
{
$$ = []Predicate12{"BETWEEN", $2, "AND", $4} //TODO 124
}
Predicate121:
/* EMPTY */
{
$$ = nil //TODO 125
}
| ';'
{
$$ = ";" //TODO 126
}
Predicate13:
/* EMPTY */
{
$$ = nil //TODO 127
}
| _NOT
{
$$ = "NOT" //TODO 128
}
PrimaryExpression:
Operand
{
$$ = $1 //TODO 129
}
| Conversion
{
$$ = $1 //TODO 130
}
| PrimaryExpression Index
{
$$ = []PrimaryExpression{$1, $2} //TODO 131
}
| PrimaryExpression Slice
{
$$ = []PrimaryExpression{$1, $2} //TODO 132
}
| PrimaryExpression Call
{
$$ = []PrimaryExpression{$1, $2} //TODO 133
}
PrimaryFactor:
PrimaryTerm PrimaryFactor1
{
$$ = []PrimaryFactor{$1, $2} //TODO 134
}
PrimaryFactor1:
/* EMPTY */
{
$$ = []PrimaryFactor1(nil) //TODO 135
}
| PrimaryFactor1 PrimaryFactor11 PrimaryTerm
{
$$ = append($1.([]PrimaryFactor1), $2, $3) //TODO 136
}
PrimaryFactor11:
'^'
{
$$ = "^" //TODO 137
}
| '|'
{
$$ = "|" //TODO 138
}
| '-'
{
$$ = "-" //TODO 139
}
| '+'
{
$$ = "+" //TODO 140
}
PrimaryTerm:
UnaryExpr PrimaryTerm1
{
$$ = []PrimaryTerm{$1, $2} //TODO 141
}
PrimaryTerm1:
/* EMPTY */
{
$$ = []PrimaryTerm1(nil) //TODO 142
}
| PrimaryTerm1 PrimaryTerm11 UnaryExpr
{
$$ = append($1.([]PrimaryTerm1), $2, $3) //TODO 143
}
PrimaryTerm11:
_ANDNOT
{
$$ = $1 //TODO 144
}
| '&'
{
$$ = "&" //TODO 145
}
| _LSH
{
$$ = $1 //TODO 146
}
| _RSH
{
$$ = $1 //TODO 147
}
| '%'
{
$$ = "%" //TODO 148
}
| '/'
{
$$ = "/" //TODO 149
}
| '*'
{
$$ = "*" //TODO 150
}
QualifiedIdent:
_IDENTIFIER QualifiedIdent1
{
$$ = []QualifiedIdent{$1, $2} //TODO 151
}
QualifiedIdent1:
/* EMPTY */
{
$$ = nil //TODO 152
}
| '.' _IDENTIFIER
{
$$ = []QualifiedIdent1{".", $2} //TODO 153
}
RecordSet:
RecordSet1 RecordSet2
{
$$ = []RecordSet{$1, $2} //TODO 154
}
RecordSet1:
TableName
{
$$ = $1 //TODO 155
}
| '(' SelectStmt RecordSet11 ')'
{
$$ = []RecordSet1{"(", $2, $3, ")"} //TODO 156
}
RecordSet11:
/* EMPTY */
{
$$ = nil //TODO 157
}
| ';'
{
$$ = ";" //TODO 158
}
RecordSet2:
/* EMPTY */
{
$$ = nil //TODO 159
}
| _AS _IDENTIFIER
{
$$ = []RecordSet2{"AS", $2} //TODO 160
}
RecordSetList:
RecordSet RecordSetList1 RecordSetList2
{
$$ = []RecordSetList{$1, $2, $3} //TODO 161
}
RecordSetList1:
/* EMPTY */
{
$$ = []RecordSetList1(nil) //TODO 162
}
| RecordSetList1 ',' RecordSet
{
$$ = append($1.([]RecordSetList1), ",", $3) //TODO 163
}
RecordSetList2:
/* EMPTY */
{
$$ = nil //TODO 164
}
| ','
{
$$ = "," //TODO 165
}
RollbackStmt:
_ROLLBACK
{
$$ = "ROLLBACK" //TODO 166
}
SelectStmt:
_SELECT SelectStmt1 SelectStmt2 _FROM RecordSetList SelectStmt3 SelectStmt4 SelectStmt5 SelectStmt6 SelectStmt7 SelectStmt8
{
$$ = []SelectStmt{"SELECT", $2, $3, "FROM", $5, $6, $7, $8, $9, $10, $11} //TODO 167
}
SelectStmt1:
/* EMPTY */
{
$$ = nil //TODO 168
}
| _DISTINCT
{
$$ = "DISTINCT" //TODO 169
}
SelectStmt2:
'*'
{
$$ = "*" //TODO 170
}
| FieldList
{
$$ = $1 //TODO 171
}
SelectStmt3:
/* EMPTY */
{
$$ = nil //TODO 172
}
| JoinClause
{
$$ = $1 //TODO 173
}
SelectStmt4:
/* EMPTY */
{
$$ = nil //TODO 174
}
| WhereClause
{
$$ = $1 //TODO 175
}
SelectStmt5:
/* EMPTY */
{
$$ = nil //TODO 176
}
| GroupByClause
{
$$ = $1 //TODO 177
}
SelectStmt6:
/* EMPTY */
{
$$ = nil //TODO 178
}
| OrderBy
{
$$ = $1 //TODO 179
}
SelectStmt7:
/* EMPTY */
{
$$ = nil //TODO 180
}
| Limit
{
$$ = $1 //TODO 181
}
SelectStmt8:
/* EMPTY */
{
$$ = nil //TODO 182
}
| Offset
{
$$ = $1 //TODO 183
}
Slice:
'[' Slice1 ':' Slice2 ']'
{
$$ = []Slice{"[", $2, ":", $4, "]"} //TODO 184
}
Slice1:
/* EMPTY */
{
$$ = nil //TODO 185
}
| Expression
{
$$ = $1 //TODO 186
}
Slice2:
/* EMPTY */
{
$$ = nil //TODO 187
}
| Expression
{
$$ = $1 //TODO 188
}
Start:
StatementList
{
_parserResult = $1 //TODO 189
}
Statement:
EmptyStmt
{
$$ = $1 //TODO 190
}
| AlterTableStmt
{
$$ = $1 //TODO 191
}
| BeginTransactionStmt
{
$$ = $1 //TODO 192
}
| CommitStmt
{
$$ = $1 //TODO 193
}
| CreateIndexStmt
{
$$ = $1 //TODO 194
}
| CreateTableStmt
{
$$ = $1 //TODO 195
}
| DeleteFromStmt
{
$$ = $1 //TODO 196
}
| DropIndexStmt
{
$$ = $1 //TODO 197
}
| DropTableStmt
{
$$ = $1 //TODO 198
}
| InsertIntoStmt
{
$$ = $1 //TODO 199
}
| RollbackStmt
{
$$ = $1 //TODO 200
}
| SelectStmt
{
$$ = $1 //TODO 201
}
| TruncateTableStmt
{
$$ = $1 //TODO 202
}
| UpdateStmt
{
$$ = $1 //TODO 203
}
| ExplainStmt
{
$$ = $1 //TODO 204
}
StatementList:
Statement StatementList1
{
$$ = []StatementList{$1, $2} //TODO 205
}
StatementList1:
/* EMPTY */
{
$$ = []StatementList1(nil) //TODO 206
}
| StatementList1 ';' Statement
{
$$ = append($1.([]StatementList1), ";", $3) //TODO 207
}
TableName:
_IDENTIFIER
{
$$ = $1 //TODO 208
}
Term:
Factor Term1
{
$$ = []Term{$1, $2} //TODO 209
}
Term1:
/* EMPTY */
{
$$ = []Term1(nil) //TODO 210
}
| Term1 Term11 Factor
{
$$ = append($1.([]Term1), $2, $3) //TODO 211
}
Term11:
_ANDAND
{
$$ = $1 //TODO 212
}
| _AND
{
$$ = "AND" //TODO 213
}
TruncateTableStmt:
_TRUNCATE _TABLE TableName
{
$$ = []TruncateTableStmt{"TRUNCATE", "TABLE", $3} //TODO 214
}
Type:
_BIGINT
{
$$ = "bigint" //TODO 215
}
| _BIGRAT
{
$$ = "bigrat" //TODO 216
}
| _BLOB
{
$$ = "blob" //TODO 217
}
| _BOOL
{
$$ = "bool" //TODO 218
}
| _BYTE
{
$$ = "byte" //TODO 219
}
| _COMPLEX128
{
$$ = "complex128" //TODO 220
}
| _COMPLEX64
{
$$ = "complex64" //TODO 221
}
| _DURATION
{
$$ = "duration" //TODO 222
}
| _FLOAT
{
$$ = "float" //TODO 223
}
| _FLOAT32
{
$$ = "float32" //TODO 224
}
| _FLOAT64
{
$$ = "float64" //TODO 225
}
| _INT
{
$$ = "int" //TODO 226
}
| _INT16
{
$$ = "int16" //TODO 227
}
| _INT32
{
$$ = "int32" //TODO 228
}
| _INT64
{
$$ = "int64" //TODO 229
}
| _INT8
{
$$ = "int8" //TODO 230
}
| _RUNE
{
$$ = "rune" //TODO 231
}
| _STRING
{
$$ = "string" //TODO 232
}
| _TIME
{
$$ = "time" //TODO 233
}
| _UINT
{
$$ = "uint" //TODO 234
}
| _UINT16
{
$$ = "uint16" //TODO 235
}
| _UINT32
{
$$ = "uint32" //TODO 236
}
| _UINT64
{
$$ = "uint64" //TODO 237
}
| _UINT8
{
$$ = "uint8" //TODO 238
}
UnaryExpr:
UnaryExpr1 PrimaryExpression
{
$$ = []UnaryExpr{$1, $2} //TODO 239
}
UnaryExpr1:
/* EMPTY */
{
$$ = nil //TODO 240
}
| UnaryExpr11
{
$$ = $1 //TODO 241
}
UnaryExpr11:
'^'
{
$$ = "^" //TODO 242
}
| '!'
{
$$ = "!" //TODO 243
}
| '-'
{
$$ = "-" //TODO 244
}
| '+'
{
$$ = "+" //TODO 245
}
UpdateStmt:
_UPDATE TableName UpdateStmt1 AssignmentList UpdateStmt2
{
$$ = []UpdateStmt{"UPDATE", $2, $3, $4, $5} //TODO 246
}
UpdateStmt1:
/* EMPTY */
{
$$ = nil //TODO 247
}
| _SET
{
$$ = "SET" //TODO 248
}
UpdateStmt2:
/* EMPTY */
{
$$ = nil //TODO 249
}
| WhereClause
{
$$ = $1 //TODO 250
}
Values:
_VALUES '(' ExpressionList ')' Values1 Values2
{
$$ = []Values{"VALUES", "(", $3, ")", $5, $6} //TODO 251
}
Values1:
/* EMPTY */
{
$$ = []Values1(nil) //TODO 252
}
| Values1 ',' '(' ExpressionList ')'
{
$$ = append($1.([]Values1), ",", "(", $4, ")") //TODO 253
}
Values2:
/* EMPTY */
{
$$ = nil //TODO 254
}
| ','
{
$$ = "," //TODO 255
}
WhereClause:
_WHERE Expression
{
$$ = []WhereClause{"WHERE", $2} //TODO 256
}
%%
//TODO remove demo stuff below
var _parserResult interface{}
type (
AlterTableStmt interface{}
AlterTableStmt1 interface{}
Assignment interface{}
AssignmentList interface{}
AssignmentList1 interface{}
AssignmentList2 interface{}
BeginTransactionStmt interface{}
Call interface{}
Call1 interface{}
Call11 interface{}
ColumnDef interface{}
ColumnDef1 interface{}
ColumnDef11 interface{}
ColumnDef2 interface{}
ColumnName interface{}
ColumnNameList interface{}
ColumnNameList1 interface{}
ColumnNameList2 interface{}
CommitStmt interface{}
Conversion interface{}
CreateIndexStmt interface{}
CreateIndexStmt1 interface{}
CreateIndexStmt2 interface{}
CreateTableStmt interface{}
CreateTableStmt1 interface{}
CreateTableStmt2 interface{}
CreateTableStmt3 interface{}
DeleteFromStmt interface{}
DeleteFromStmt1 interface{}
DropIndexStmt interface{}
DropIndexStmt1 interface{}
DropTableStmt interface{}
DropTableStmt1 interface{}
EmptyStmt interface{}
ExplainStmt interface{}
Expression interface{}
Expression1 interface{}
Expression11 interface{}
ExpressionList interface{}
ExpressionList1 interface{}
ExpressionList2 interface{}
Factor interface{}
Factor1 interface{}
Factor11 interface{}
Factor2 interface{}
Field interface{}
Field1 interface{}
FieldList interface{}
FieldList1 interface{}
FieldList2 interface{}
GroupByClause interface{}
Index interface{}
IndexName interface{}
InsertIntoStmt interface{}
InsertIntoStmt1 interface{}
InsertIntoStmt2 interface{}
JoinClause interface{}
JoinClause1 interface{}
JoinClause2 interface{}
Limit interface{}
Literal interface{}
Offset interface{}
Operand interface{}
OrderBy interface{}
OrderBy1 interface{}
OrderBy11 interface{}
Predicate interface{}
Predicate1 interface{}
Predicate11 interface{}
Predicate12 interface{}
Predicate121 interface{}
Predicate13 interface{}
PrimaryExpression interface{}
PrimaryFactor interface{}
PrimaryFactor1 interface{}
PrimaryFactor11 interface{}
PrimaryTerm interface{}
PrimaryTerm1 interface{}
PrimaryTerm11 interface{}
QualifiedIdent interface{}
QualifiedIdent1 interface{}
RecordSet interface{}
RecordSet1 interface{}
RecordSet11 interface{}
RecordSet2 interface{}
RecordSetList interface{}
RecordSetList1 interface{}
RecordSetList2 interface{}
RollbackStmt interface{}
SelectStmt interface{}
SelectStmt1 interface{}
SelectStmt2 interface{}
SelectStmt3 interface{}
SelectStmt4 interface{}
SelectStmt5 interface{}
SelectStmt6 interface{}
SelectStmt7 interface{}
SelectStmt8 interface{}
Slice interface{}
Slice1 interface{}
Slice2 interface{}
Start interface{}
Statement interface{}
StatementList interface{}
StatementList1 interface{}
TableName interface{}
Term interface{}
Term1 interface{}
Term11 interface{}
TruncateTableStmt interface{}
Type interface{}
UnaryExpr interface{}
UnaryExpr1 interface{}
UnaryExpr11 interface{}
UpdateStmt interface{}
UpdateStmt1 interface{}
UpdateStmt2 interface{}
Values interface{}
Values1 interface{}
Values2 interface{}
WhereClause interface{}
)
func _dump() {
s := fmt.Sprintf("%#v", _parserResult)
s = strings.Replace(s, "%", "%%", -1)
s = strings.Replace(s, "{", "{%i\n", -1)
s = strings.Replace(s, "}", "%u\n}", -1)
s = strings.Replace(s, ", ", ",\n", -1)
var buf bytes.Buffer
strutil.IndentFormatter(&buf, ". ").Format(s)
buf.WriteString("\n")
a := strings.Split(buf.String(), "\n")
for _, v := range a {
if strings.HasSuffix(v, "(nil)") || strings.HasSuffix(v, "(nil),") {
continue
}
fmt.Println(v)
}
}
// End of demo stuff
|