aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorwmin0 <wmin0@cobinhood.com>2019-01-17 15:51:56 +0800
committerJhih-Ming Huang <jm.huang@cobinhood.com>2019-05-06 10:44:03 +0800
commit1c850cdf326ce37a98ad25cb3c42442ca1eec907 (patch)
treee0cb8e42ccbc4c9dc019e322ca99ab54feb42cd2 /core
parent9b8cd76237318e173147a7c32763b6b9d9759951 (diff)
downloaddexon-1c850cdf326ce37a98ad25cb3c42442ca1eec907.tar
dexon-1c850cdf326ce37a98ad25cb3c42442ca1eec907.tar.gz
dexon-1c850cdf326ce37a98ad25cb3c42442ca1eec907.tar.bz2
dexon-1c850cdf326ce37a98ad25cb3c42442ca1eec907.tar.lz
dexon-1c850cdf326ce37a98ad25cb3c42442ca1eec907.tar.xz
dexon-1c850cdf326ce37a98ad25cb3c42442ca1eec907.tar.zst
dexon-1c850cdf326ce37a98ad25cb3c42442ca1eec907.zip
core: vm: sqlvm: add sql language parser prototyping
Add sql language parser prototyping along with 1. grammar file implemented with github.com/mna/pigeon 2. ast node struct definition 3. simple parser test which only test if error existed 4. ast printer utility for visualizing parsing result
Diffstat (limited to 'core')
-rw-r--r--core/vm/sqlvm/cmd/ast-printer/main.go16
-rw-r--r--core/vm/sqlvm/grammar.go7505
-rw-r--r--core/vm/sqlvm/grammar.peg763
-rw-r--r--core/vm/sqlvm/parser.go125
-rw-r--r--core/vm/sqlvm/parser_test.go82
-rw-r--r--core/vm/sqlvm/type.go408
6 files changed, 8899 insertions, 0 deletions
diff --git a/core/vm/sqlvm/cmd/ast-printer/main.go b/core/vm/sqlvm/cmd/ast-printer/main.go
new file mode 100644
index 000000000..ad10a54ce
--- /dev/null
+++ b/core/vm/sqlvm/cmd/ast-printer/main.go
@@ -0,0 +1,16 @@
+package main
+
+import (
+ "fmt"
+ "os"
+
+ "github.com/dexon-foundation/dexon/core/vm/sqlvm"
+)
+
+func main() {
+ n, err := sqlvm.ParseString(os.Args[1])
+ fmt.Printf("err: %+v\n", err)
+ if err == nil {
+ sqlvm.PrintAST(n, "")
+ }
+}
diff --git a/core/vm/sqlvm/grammar.go b/core/vm/sqlvm/grammar.go
new file mode 100644
index 000000000..dad07b1eb
--- /dev/null
+++ b/core/vm/sqlvm/grammar.go
@@ -0,0 +1,7505 @@
+// Code generated by pigeon; DO NOT EDIT.
+
+package sqlvm
+
+import (
+ "bytes"
+ "errors"
+ "fmt"
+ "io"
+ "io/ioutil"
+ "math"
+ "os"
+ "sort"
+ "strconv"
+ "strings"
+ "unicode"
+ "unicode/utf8"
+)
+
+var g = &grammar{
+ rules: []*rule{
+ {
+ name: "S",
+ pos: position{line: 5, col: 1, offset: 19},
+ expr: &actionExpr{
+ pos: position{line: 6, col: 5, offset: 25},
+ run: (*parser).callonS1,
+ expr: &seqExpr{
+ pos: position{line: 6, col: 5, offset: 25},
+ exprs: []interface{}{
+ &ruleRefExpr{
+ pos: position{line: 6, col: 5, offset: 25},
+ name: "_",
+ },
+ &labeledExpr{
+ pos: position{line: 6, col: 7, offset: 27},
+ label: "x",
+ expr: &zeroOrOneExpr{
+ pos: position{line: 6, col: 9, offset: 29},
+ expr: &ruleRefExpr{
+ pos: position{line: 6, col: 9, offset: 29},
+ name: "Stmt",
+ },
+ },
+ },
+ &ruleRefExpr{
+ pos: position{line: 6, col: 15, offset: 35},
+ name: "_",
+ },
+ &labeledExpr{
+ pos: position{line: 6, col: 17, offset: 37},
+ label: "xs",
+ expr: &zeroOrMoreExpr{
+ pos: position{line: 6, col: 20, offset: 40},
+ expr: &actionExpr{
+ pos: position{line: 6, col: 22, offset: 42},
+ run: (*parser).callonS10,
+ expr: &seqExpr{
+ pos: position{line: 6, col: 22, offset: 42},
+ exprs: []interface{}{
+ &litMatcher{
+ pos: position{line: 6, col: 22, offset: 42},
+ val: ";",
+ ignoreCase: false,
+ },
+ &ruleRefExpr{
+ pos: position{line: 6, col: 26, offset: 46},
+ name: "_",
+ },
+ &labeledExpr{
+ pos: position{line: 6, col: 28, offset: 48},
+ label: "s",
+ expr: &zeroOrOneExpr{
+ pos: position{line: 6, col: 30, offset: 50},
+ expr: &ruleRefExpr{
+ pos: position{line: 6, col: 30, offset: 50},
+ name: "Stmt",
+ },
+ },
+ },
+ &ruleRefExpr{
+ pos: position{line: 6, col: 36, offset: 56},
+ name: "_",
+ },
+ },
+ },
+ },
+ },
+ },
+ &ruleRefExpr{
+ pos: position{line: 6, col: 59, offset: 79},
+ name: "EOF",
+ },
+ },
+ },
+ },
+ },
+ {
+ name: "Stmt",
+ pos: position{line: 10, col: 1, offset: 131},
+ expr: &choiceExpr{
+ pos: position{line: 11, col: 4, offset: 139},
+ alternatives: []interface{}{
+ &ruleRefExpr{
+ pos: position{line: 11, col: 4, offset: 139},
+ name: "SelectStmt",
+ },
+ &ruleRefExpr{
+ pos: position{line: 12, col: 4, offset: 153},
+ name: "UpdateStmt",
+ },
+ &ruleRefExpr{
+ pos: position{line: 13, col: 4, offset: 167},
+ name: "DeleteStmt",
+ },
+ &ruleRefExpr{
+ pos: position{line: 14, col: 4, offset: 181},
+ name: "InsertStmt",
+ },
+ &ruleRefExpr{
+ pos: position{line: 15, col: 4, offset: 195},
+ name: "CreateTableStmt",
+ },
+ &ruleRefExpr{
+ pos: position{line: 16, col: 4, offset: 214},
+ name: "CreateIndexStmt",
+ },
+ },
+ },
+ },
+ {
+ name: "SelectStmt",
+ pos: position{line: 18, col: 1, offset: 231},
+ expr: &actionExpr{
+ pos: position{line: 19, col: 4, offset: 245},
+ run: (*parser).callonSelectStmt1,
+ expr: &seqExpr{
+ pos: position{line: 19, col: 4, offset: 245},
+ exprs: []interface{}{
+ &ruleRefExpr{
+ pos: position{line: 19, col: 4, offset: 245},
+ name: "SelectToken",
+ },
+ &ruleRefExpr{
+ pos: position{line: 20, col: 2, offset: 258},
+ name: "_",
+ },
+ &labeledExpr{
+ pos: position{line: 20, col: 4, offset: 260},
+ label: "f",
+ expr: &ruleRefExpr{
+ pos: position{line: 20, col: 6, offset: 262},
+ name: "SelectColumn",
+ },
+ },
+ &labeledExpr{
+ pos: position{line: 20, col: 19, offset: 275},
+ label: "fs",
+ expr: &zeroOrMoreExpr{
+ pos: position{line: 20, col: 22, offset: 278},
+ expr: &actionExpr{
+ pos: position{line: 20, col: 24, offset: 280},
+ run: (*parser).callonSelectStmt9,
+ expr: &seqExpr{
+ pos: position{line: 20, col: 24, offset: 280},
+ exprs: []interface{}{
+ &ruleRefExpr{
+ pos: position{line: 20, col: 24, offset: 280},
+ name: "_",
+ },
+ &ruleRefExpr{
+ pos: position{line: 20, col: 26, offset: 282},
+ name: "SeparatorToken",
+ },
+ &ruleRefExpr{
+ pos: position{line: 20, col: 41, offset: 297},
+ name: "_",
+ },
+ &labeledExpr{
+ pos: position{line: 20, col: 43, offset: 299},
+ label: "s",
+ expr: &ruleRefExpr{
+ pos: position{line: 20, col: 45, offset: 301},
+ name: "SelectColumn",
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ &labeledExpr{
+ pos: position{line: 21, col: 2, offset: 336},
+ label: "table",
+ expr: &zeroOrOneExpr{
+ pos: position{line: 21, col: 8, offset: 342},
+ expr: &actionExpr{
+ pos: position{line: 21, col: 10, offset: 344},
+ run: (*parser).callonSelectStmt18,
+ expr: &seqExpr{
+ pos: position{line: 21, col: 10, offset: 344},
+ exprs: []interface{}{
+ &ruleRefExpr{
+ pos: position{line: 21, col: 10, offset: 344},
+ name: "_",
+ },
+ &ruleRefExpr{
+ pos: position{line: 21, col: 12, offset: 346},
+ name: "FromToken",
+ },
+ &ruleRefExpr{
+ pos: position{line: 21, col: 22, offset: 356},
+ name: "_",
+ },
+ &labeledExpr{
+ pos: position{line: 21, col: 24, offset: 358},
+ label: "i",
+ expr: &ruleRefExpr{
+ pos: position{line: 21, col: 26, offset: 360},
+ name: "Identifier",
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ &labeledExpr{
+ pos: position{line: 22, col: 2, offset: 393},
+ label: "where",
+ expr: &zeroOrOneExpr{
+ pos: position{line: 22, col: 8, offset: 399},
+ expr: &actionExpr{
+ pos: position{line: 22, col: 10, offset: 401},
+ run: (*parser).callonSelectStmt27,
+ expr: &seqExpr{
+ pos: position{line: 22, col: 10, offset: 401},
+ exprs: []interface{}{
+ &ruleRefExpr{
+ pos: position{line: 22, col: 10, offset: 401},
+ name: "_",
+ },
+ &labeledExpr{
+ pos: position{line: 22, col: 12, offset: 403},
+ label: "w",
+ expr: &ruleRefExpr{
+ pos: position{line: 22, col: 14, offset: 405},
+ name: "WhereClause",
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ &labeledExpr{
+ pos: position{line: 23, col: 2, offset: 439},
+ label: "group",
+ expr: &zeroOrOneExpr{
+ pos: position{line: 23, col: 8, offset: 445},
+ expr: &actionExpr{
+ pos: position{line: 23, col: 10, offset: 447},
+ run: (*parser).callonSelectStmt34,
+ expr: &seqExpr{
+ pos: position{line: 23, col: 10, offset: 447},
+ exprs: []interface{}{
+ &ruleRefExpr{
+ pos: position{line: 23, col: 10, offset: 447},
+ name: "_",
+ },
+ &labeledExpr{
+ pos: position{line: 23, col: 12, offset: 449},
+ label: "g",
+ expr: &ruleRefExpr{
+ pos: position{line: 23, col: 14, offset: 451},
+ name: "GroupByClause",
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ &labeledExpr{
+ pos: position{line: 24, col: 2, offset: 487},
+ label: "order",
+ expr: &zeroOrOneExpr{
+ pos: position{line: 24, col: 8, offset: 493},
+ expr: &actionExpr{
+ pos: position{line: 24, col: 10, offset: 495},
+ run: (*parser).callonSelectStmt41,
+ expr: &seqExpr{
+ pos: position{line: 24, col: 10, offset: 495},
+ exprs: []interface{}{
+ &ruleRefExpr{
+ pos: position{line: 24, col: 10, offset: 495},
+ name: "_",
+ },
+ &labeledExpr{
+ pos: position{line: 24, col: 12, offset: 497},
+ label: "or",
+ expr: &ruleRefExpr{
+ pos: position{line: 24, col: 15, offset: 500},
+ name: "OrderByClause",
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ &labeledExpr{
+ pos: position{line: 25, col: 2, offset: 537},
+ label: "limit",
+ expr: &zeroOrOneExpr{
+ pos: position{line: 25, col: 8, offset: 543},
+ expr: &actionExpr{
+ pos: position{line: 25, col: 10, offset: 545},
+ run: (*parser).callonSelectStmt48,
+ expr: &seqExpr{
+ pos: position{line: 25, col: 10, offset: 545},
+ exprs: []interface{}{
+ &ruleRefExpr{
+ pos: position{line: 25, col: 10, offset: 545},
+ name: "_",
+ },
+ &labeledExpr{
+ pos: position{line: 25, col: 12, offset: 547},
+ label: "l",
+ expr: &ruleRefExpr{
+ pos: position{line: 25, col: 14, offset: 549},
+ name: "LimitClause",
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ &labeledExpr{
+ pos: position{line: 26, col: 2, offset: 583},
+ label: "offset",
+ expr: &zeroOrOneExpr{
+ pos: position{line: 26, col: 9, offset: 590},
+ expr: &actionExpr{
+ pos: position{line: 26, col: 11, offset: 592},
+ run: (*parser).callonSelectStmt55,
+ expr: &seqExpr{
+ pos: position{line: 26, col: 11, offset: 592},
+ exprs: []interface{}{
+ &ruleRefExpr{
+ pos: position{line: 26, col: 11, offset: 592},
+ name: "_",
+ },
+ &labeledExpr{
+ pos: position{line: 26, col: 13, offset: 594},
+ label: "of",
+ expr: &ruleRefExpr{
+ pos: position{line: 26, col: 16, offset: 597},
+ name: "OffsetClause",
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ {
+ name: "SelectColumn",
+ pos: position{line: 61, col: 1, offset: 1247},
+ expr: &choiceExpr{
+ pos: position{line: 62, col: 4, offset: 1263},
+ alternatives: []interface{}{
+ &ruleRefExpr{
+ pos: position{line: 62, col: 4, offset: 1263},
+ name: "AnyLiteral",
+ },
+ &ruleRefExpr{
+ pos: position{line: 63, col: 4, offset: 1277},
+ name: "Expr",
+ },
+ },
+ },
+ },
+ {
+ name: "UpdateStmt",
+ pos: position{line: 65, col: 1, offset: 1283},
+ expr: &actionExpr{
+ pos: position{line: 66, col: 4, offset: 1297},
+ run: (*parser).callonUpdateStmt1,
+ expr: &seqExpr{
+ pos: position{line: 66, col: 4, offset: 1297},
+ exprs: []interface{}{
+ &ruleRefExpr{
+ pos: position{line: 66, col: 4, offset: 1297},
+ name: "UpdateToken",
+ },
+ &ruleRefExpr{
+ pos: position{line: 67, col: 2, offset: 1310},
+ name: "_",
+ },
+ &labeledExpr{
+ pos: position{line: 67, col: 4, offset: 1312},
+ label: "table",
+ expr: &ruleRefExpr{
+ pos: position{line: 67, col: 10, offset: 1318},
+ name: "Identifier",
+ },
+ },
+ &ruleRefExpr{
+ pos: position{line: 68, col: 2, offset: 1330},
+ name: "_",
+ },
+ &ruleRefExpr{
+ pos: position{line: 68, col: 4, offset: 1332},
+ name: "SetToken",
+ },
+ &ruleRefExpr{
+ pos: position{line: 69, col: 2, offset: 1342},
+ name: "_",
+ },
+ &labeledExpr{
+ pos: position{line: 69, col: 4, offset: 1344},
+ label: "a",
+ expr: &ruleRefExpr{
+ pos: position{line: 69, col: 6, offset: 1346},
+ name: "Assignment",
+ },
+ },
+ &labeledExpr{
+ pos: position{line: 69, col: 17, offset: 1357},
+ label: "as",
+ expr: &zeroOrMoreExpr{
+ pos: position{line: 69, col: 20, offset: 1360},
+ expr: &actionExpr{
+ pos: position{line: 69, col: 22, offset: 1362},
+ run: (*parser).callonUpdateStmt14,
+ expr: &seqExpr{
+ pos: position{line: 69, col: 22, offset: 1362},
+ exprs: []interface{}{
+ &ruleRefExpr{
+ pos: position{line: 69, col: 22, offset: 1362},
+ name: "_",
+ },
+ &ruleRefExpr{
+ pos: position{line: 69, col: 24, offset: 1364},
+ name: "SeparatorToken",
+ },
+ &ruleRefExpr{
+ pos: position{line: 69, col: 39, offset: 1379},
+ name: "_",
+ },
+ &labeledExpr{
+ pos: position{line: 69, col: 41, offset: 1381},
+ label: "s",
+ expr: &ruleRefExpr{
+ pos: position{line: 69, col: 43, offset: 1383},
+ name: "Assignment",
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ &labeledExpr{
+ pos: position{line: 70, col: 2, offset: 1416},
+ label: "where",
+ expr: &zeroOrOneExpr{
+ pos: position{line: 70, col: 8, offset: 1422},
+ expr: &actionExpr{
+ pos: position{line: 70, col: 10, offset: 1424},
+ run: (*parser).callonUpdateStmt23,
+ expr: &seqExpr{
+ pos: position{line: 70, col: 10, offset: 1424},
+ exprs: []interface{}{
+ &ruleRefExpr{
+ pos: position{line: 70, col: 10, offset: 1424},
+ name: "_",
+ },
+ &labeledExpr{
+ pos: position{line: 70, col: 12, offset: 1426},
+ label: "w",
+ expr: &ruleRefExpr{
+ pos: position{line: 70, col: 14, offset: 1428},
+ name: "WhereClause",
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ {
+ name: "DeleteStmt",
+ pos: position{line: 86, col: 1, offset: 1700},
+ expr: &actionExpr{
+ pos: position{line: 87, col: 4, offset: 1714},
+ run: (*parser).callonDeleteStmt1,
+ expr: &seqExpr{
+ pos: position{line: 87, col: 4, offset: 1714},
+ exprs: []interface{}{
+ &ruleRefExpr{
+ pos: position{line: 87, col: 4, offset: 1714},
+ name: "DeleteToken",
+ },
+ &ruleRefExpr{
+ pos: position{line: 88, col: 2, offset: 1727},
+ name: "_",
+ },
+ &ruleRefExpr{
+ pos: position{line: 88, col: 4, offset: 1729},
+ name: "FromToken",
+ },
+ &ruleRefExpr{
+ pos: position{line: 89, col: 2, offset: 1740},
+ name: "_",
+ },
+ &labeledExpr{
+ pos: position{line: 89, col: 4, offset: 1742},
+ label: "table",
+ expr: &ruleRefExpr{
+ pos: position{line: 89, col: 10, offset: 1748},
+ name: "Identifier",
+ },
+ },
+ &labeledExpr{
+ pos: position{line: 90, col: 2, offset: 1760},
+ label: "where",
+ expr: &zeroOrOneExpr{
+ pos: position{line: 90, col: 8, offset: 1766},
+ expr: &actionExpr{
+ pos: position{line: 90, col: 10, offset: 1768},
+ run: (*parser).callonDeleteStmt11,
+ expr: &seqExpr{
+ pos: position{line: 90, col: 10, offset: 1768},
+ exprs: []interface{}{
+ &ruleRefExpr{
+ pos: position{line: 90, col: 10, offset: 1768},
+ name: "_",
+ },
+ &labeledExpr{
+ pos: position{line: 90, col: 12, offset: 1770},
+ label: "w",
+ expr: &ruleRefExpr{
+ pos: position{line: 90, col: 14, offset: 1772},
+ name: "WhereClause",
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ {
+ name: "InsertStmt",
+ pos: position{line: 105, col: 1, offset: 2004},
+ expr: &actionExpr{
+ pos: position{line: 106, col: 4, offset: 2018},
+ run: (*parser).callonInsertStmt1,
+ expr: &seqExpr{
+ pos: position{line: 106, col: 4, offset: 2018},
+ exprs: []interface{}{
+ &ruleRefExpr{
+ pos: position{line: 106, col: 4, offset: 2018},
+ name: "InsertToken",
+ },
+ &ruleRefExpr{
+ pos: position{line: 107, col: 2, offset: 2031},
+ name: "_",
+ },
+ &ruleRefExpr{
+ pos: position{line: 107, col: 4, offset: 2033},
+ name: "IntoToken",
+ },
+ &ruleRefExpr{
+ pos: position{line: 108, col: 2, offset: 2044},
+ name: "_",
+ },
+ &labeledExpr{
+ pos: position{line: 108, col: 4, offset: 2046},
+ label: "table",
+ expr: &ruleRefExpr{
+ pos: position{line: 108, col: 10, offset: 2052},
+ name: "Identifier",
+ },
+ },
+ &ruleRefExpr{
+ pos: position{line: 109, col: 2, offset: 2064},
+ name: "_",
+ },
+ &labeledExpr{
+ pos: position{line: 109, col: 4, offset: 2066},
+ label: "insert",
+ expr: &choiceExpr{
+ pos: position{line: 109, col: 13, offset: 2075},
+ alternatives: []interface{}{
+ &ruleRefExpr{
+ pos: position{line: 109, col: 13, offset: 2075},
+ name: "InsertWithColumnClause",
+ },
+ &ruleRefExpr{
+ pos: position{line: 109, col: 38, offset: 2100},
+ name: "InsertWithDefaultClause",
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ {
+ name: "InsertValue",
+ pos: position{line: 117, col: 1, offset: 2215},
+ expr: &actionExpr{
+ pos: position{line: 118, col: 4, offset: 2230},
+ run: (*parser).callonInsertValue1,
+ expr: &seqExpr{
+ pos: position{line: 118, col: 4, offset: 2230},
+ exprs: []interface{}{
+ &litMatcher{
+ pos: position{line: 118, col: 4, offset: 2230},
+ val: "(",
+ ignoreCase: false,
+ },
+ &ruleRefExpr{
+ pos: position{line: 118, col: 8, offset: 2234},
+ name: "_",
+ },
+ &labeledExpr{
+ pos: position{line: 118, col: 10, offset: 2236},
+ label: "e",
+ expr: &ruleRefExpr{
+ pos: position{line: 118, col: 12, offset: 2238},
+ name: "MultiExprWithDefault",
+ },
+ },
+ &ruleRefExpr{
+ pos: position{line: 118, col: 33, offset: 2259},
+ name: "_",
+ },
+ &litMatcher{
+ pos: position{line: 118, col: 35, offset: 2261},
+ val: ")",
+ ignoreCase: false,
+ },
+ },
+ },
+ },
+ },
+ {
+ name: "CreateTableStmt",
+ pos: position{line: 121, col: 1, offset: 2284},
+ expr: &actionExpr{
+ pos: position{line: 122, col: 4, offset: 2303},
+ run: (*parser).callonCreateTableStmt1,
+ expr: &seqExpr{
+ pos: position{line: 122, col: 4, offset: 2303},
+ exprs: []interface{}{
+ &ruleRefExpr{
+ pos: position{line: 122, col: 4, offset: 2303},
+ name: "CreateToken",
+ },
+ &ruleRefExpr{
+ pos: position{line: 123, col: 2, offset: 2316},
+ name: "_",
+ },
+ &ruleRefExpr{
+ pos: position{line: 123, col: 4, offset: 2318},
+ name: "TableToken",
+ },
+ &ruleRefExpr{
+ pos: position{line: 124, col: 2, offset: 2330},
+ name: "_",
+ },
+ &labeledExpr{
+ pos: position{line: 124, col: 4, offset: 2332},
+ label: "table",
+ expr: &ruleRefExpr{
+ pos: position{line: 124, col: 10, offset: 2338},
+ name: "Identifier",
+ },
+ },
+ &ruleRefExpr{
+ pos: position{line: 125, col: 2, offset: 2350},
+ name: "_",
+ },
+ &litMatcher{
+ pos: position{line: 125, col: 4, offset: 2352},
+ val: "(",
+ ignoreCase: false,
+ },
+ &ruleRefExpr{
+ pos: position{line: 126, col: 2, offset: 2357},
+ name: "_",
+ },
+ &labeledExpr{
+ pos: position{line: 126, col: 4, offset: 2359},
+ label: "column",
+ expr: &zeroOrOneExpr{
+ pos: position{line: 126, col: 11, offset: 2366},
+ expr: &actionExpr{
+ pos: position{line: 127, col: 3, offset: 2370},
+ run: (*parser).callonCreateTableStmt14,
+ expr: &seqExpr{
+ pos: position{line: 127, col: 3, offset: 2370},
+ exprs: []interface{}{
+ &labeledExpr{
+ pos: position{line: 127, col: 3, offset: 2370},
+ label: "s",
+ expr: &ruleRefExpr{
+ pos: position{line: 127, col: 5, offset: 2372},
+ name: "ColumnSchema",
+ },
+ },
+ &labeledExpr{
+ pos: position{line: 128, col: 3, offset: 2387},
+ label: "ss",
+ expr: &zeroOrMoreExpr{
+ pos: position{line: 128, col: 6, offset: 2390},
+ expr: &actionExpr{
+ pos: position{line: 128, col: 8, offset: 2392},
+ run: (*parser).callonCreateTableStmt20,
+ expr: &seqExpr{
+ pos: position{line: 128, col: 8, offset: 2392},
+ exprs: []interface{}{
+ &ruleRefExpr{
+ pos: position{line: 128, col: 8, offset: 2392},
+ name: "_",
+ },
+ &ruleRefExpr{
+ pos: position{line: 128, col: 10, offset: 2394},
+ name: "SeparatorToken",
+ },
+ &ruleRefExpr{
+ pos: position{line: 128, col: 25, offset: 2409},
+ name: "_",
+ },
+ &labeledExpr{
+ pos: position{line: 128, col: 27, offset: 2411},
+ label: "t",
+ expr: &ruleRefExpr{
+ pos: position{line: 128, col: 29, offset: 2413},
+ name: "ColumnSchema",
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ &ruleRefExpr{
+ pos: position{line: 131, col: 2, offset: 2485},
+ name: "_",
+ },
+ &litMatcher{
+ pos: position{line: 131, col: 4, offset: 2487},
+ val: ")",
+ ignoreCase: false,
+ },
+ },
+ },
+ },
+ },
+ {
+ name: "ColumnSchema",
+ pos: position{line: 139, col: 1, offset: 2594},
+ expr: &actionExpr{
+ pos: position{line: 140, col: 4, offset: 2610},
+ run: (*parser).callonColumnSchema1,
+ expr: &seqExpr{
+ pos: position{line: 140, col: 4, offset: 2610},
+ exprs: []interface{}{
+ &labeledExpr{
+ pos: position{line: 140, col: 4, offset: 2610},
+ label: "i",
+ expr: &ruleRefExpr{
+ pos: position{line: 140, col: 6, offset: 2612},
+ name: "Identifier",
+ },
+ },
+ &ruleRefExpr{
+ pos: position{line: 141, col: 2, offset: 2624},
+ name: "_",
+ },
+ &labeledExpr{
+ pos: position{line: 141, col: 4, offset: 2626},
+ label: "t",
+ expr: &ruleRefExpr{
+ pos: position{line: 141, col: 6, offset: 2628},
+ name: "DataType",
+ },
+ },
+ &labeledExpr{
+ pos: position{line: 142, col: 2, offset: 2638},
+ label: "cs",
+ expr: &zeroOrMoreExpr{
+ pos: position{line: 142, col: 5, offset: 2641},
+ expr: &actionExpr{
+ pos: position{line: 142, col: 7, offset: 2643},
+ run: (*parser).callonColumnSchema10,
+ expr: &seqExpr{
+ pos: position{line: 142, col: 7, offset: 2643},
+ exprs: []interface{}{
+ &ruleRefExpr{
+ pos: position{line: 142, col: 7, offset: 2643},
+ name: "_",
+ },
+ &labeledExpr{
+ pos: position{line: 142, col: 9, offset: 2645},
+ label: "s",
+ expr: &ruleRefExpr{
+ pos: position{line: 142, col: 11, offset: 2647},
+ name: "ColumnConstraint",
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ {
+ name: "ColumnConstraint",
+ pos: position{line: 151, col: 1, offset: 2802},
+ expr: &choiceExpr{
+ pos: position{line: 152, col: 4, offset: 2822},
+ alternatives: []interface{}{
+ &ruleRefExpr{
+ pos: position{line: 152, col: 4, offset: 2822},
+ name: "PrimaryKeyClause",
+ },
+ &ruleRefExpr{
+ pos: position{line: 153, col: 4, offset: 2842},
+ name: "NotNullClause",
+ },
+ &ruleRefExpr{
+ pos: position{line: 154, col: 4, offset: 2859},
+ name: "UniqueClause",
+ },
+ &ruleRefExpr{
+ pos: position{line: 155, col: 4, offset: 2875},
+ name: "DefaultClause",
+ },
+ &ruleRefExpr{
+ pos: position{line: 156, col: 4, offset: 2892},
+ name: "ForeignClause",
+ },
+ &ruleRefExpr{
+ pos: position{line: 157, col: 4, offset: 2909},
+ name: "AutoincrementClause",
+ },
+ },
+ },
+ },
+ {
+ name: "CreateIndexStmt",
+ pos: position{line: 159, col: 1, offset: 2930},
+ expr: &actionExpr{
+ pos: position{line: 160, col: 4, offset: 2949},
+ run: (*parser).callonCreateIndexStmt1,
+ expr: &seqExpr{
+ pos: position{line: 160, col: 4, offset: 2949},
+ exprs: []interface{}{
+ &ruleRefExpr{
+ pos: position{line: 160, col: 4, offset: 2949},
+ name: "CreateToken",
+ },
+ &labeledExpr{
+ pos: position{line: 161, col: 2, offset: 2962},
+ label: "unique",
+ expr: &zeroOrOneExpr{
+ pos: position{line: 161, col: 9, offset: 2969},
+ expr: &actionExpr{
+ pos: position{line: 161, col: 11, offset: 2971},
+ run: (*parser).callonCreateIndexStmt6,
+ expr: &seqExpr{
+ pos: position{line: 161, col: 11, offset: 2971},
+ exprs: []interface{}{
+ &ruleRefExpr{
+ pos: position{line: 161, col: 11, offset: 2971},
+ name: "_",
+ },
+ &labeledExpr{
+ pos: position{line: 161, col: 13, offset: 2973},
+ label: "u",
+ expr: &ruleRefExpr{
+ pos: position{line: 161, col: 15, offset: 2975},
+ name: "UniqueClause",
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ &ruleRefExpr{
+ pos: position{line: 162, col: 2, offset: 3010},
+ name: "_",
+ },
+ &ruleRefExpr{
+ pos: position{line: 162, col: 4, offset: 3012},
+ name: "IndexToken",
+ },
+ &ruleRefExpr{
+ pos: position{line: 163, col: 2, offset: 3024},
+ name: "_",
+ },
+ &labeledExpr{
+ pos: position{line: 163, col: 4, offset: 3026},
+ label: "index",
+ expr: &ruleRefExpr{
+ pos: position{line: 163, col: 10, offset: 3032},
+ name: "Identifier",
+ },
+ },
+ &ruleRefExpr{
+ pos: position{line: 164, col: 2, offset: 3044},
+ name: "_",
+ },
+ &ruleRefExpr{
+ pos: position{line: 164, col: 4, offset: 3046},
+ name: "OnToken",
+ },
+ &ruleRefExpr{
+ pos: position{line: 165, col: 2, offset: 3055},
+ name: "_",
+ },
+ &labeledExpr{
+ pos: position{line: 165, col: 4, offset: 3057},
+ label: "table",
+ expr: &ruleRefExpr{
+ pos: position{line: 165, col: 10, offset: 3063},
+ name: "Identifier",
+ },
+ },
+ &ruleRefExpr{
+ pos: position{line: 166, col: 2, offset: 3075},
+ name: "_",
+ },
+ &litMatcher{
+ pos: position{line: 166, col: 4, offset: 3077},
+ val: "(",
+ ignoreCase: false,
+ },
+ &ruleRefExpr{
+ pos: position{line: 166, col: 8, offset: 3081},
+ name: "_",
+ },
+ &labeledExpr{
+ pos: position{line: 166, col: 10, offset: 3083},
+ label: "i",
+ expr: &ruleRefExpr{
+ pos: position{line: 166, col: 12, offset: 3085},
+ name: "Identifier",
+ },
+ },
+ &labeledExpr{
+ pos: position{line: 166, col: 23, offset: 3096},
+ label: "is",
+ expr: &zeroOrMoreExpr{
+ pos: position{line: 166, col: 26, offset: 3099},
+ expr: &actionExpr{
+ pos: position{line: 166, col: 28, offset: 3101},
+ run: (*parser).callonCreateIndexStmt28,
+ expr: &seqExpr{
+ pos: position{line: 166, col: 28, offset: 3101},
+ exprs: []interface{}{
+ &ruleRefExpr{
+ pos: position{line: 166, col: 28, offset: 3101},
+ name: "_",
+ },
+ &ruleRefExpr{
+ pos: position{line: 166, col: 30, offset: 3103},
+ name: "SeparatorToken",
+ },
+ &ruleRefExpr{
+ pos: position{line: 166, col: 45, offset: 3118},
+ name: "_",
+ },
+ &labeledExpr{
+ pos: position{line: 166, col: 47, offset: 3120},
+ label: "x",
+ expr: &ruleRefExpr{
+ pos: position{line: 166, col: 49, offset: 3122},
+ name: "Identifier",
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ &ruleRefExpr{
+ pos: position{line: 166, col: 81, offset: 3154},
+ name: "_",
+ },
+ &litMatcher{
+ pos: position{line: 166, col: 83, offset: 3156},
+ val: ")",
+ ignoreCase: false,
+ },
+ },
+ },
+ },
+ },
+ {
+ name: "WhereClause",
+ pos: position{line: 184, col: 1, offset: 3446},
+ expr: &actionExpr{
+ pos: position{line: 185, col: 4, offset: 3461},
+ run: (*parser).callonWhereClause1,
+ expr: &seqExpr{
+ pos: position{line: 185, col: 4, offset: 3461},
+ exprs: []interface{}{
+ &ruleRefExpr{
+ pos: position{line: 185, col: 4, offset: 3461},
+ name: "WhereToken",
+ },
+ &ruleRefExpr{
+ pos: position{line: 185, col: 15, offset: 3472},
+ name: "_",
+ },
+ &labeledExpr{
+ pos: position{line: 185, col: 17, offset: 3474},
+ label: "e",
+ expr: &ruleRefExpr{
+ pos: position{line: 185, col: 19, offset: 3476},
+ name: "Expr",
+ },
+ },
+ },
+ },
+ },
+ },
+ {
+ name: "OrderByClause",
+ pos: position{line: 188, col: 1, offset: 3528},
+ expr: &actionExpr{
+ pos: position{line: 189, col: 4, offset: 3545},
+ run: (*parser).callonOrderByClause1,
+ expr: &seqExpr{
+ pos: position{line: 189, col: 4, offset: 3545},
+ exprs: []interface{}{
+ &ruleRefExpr{
+ pos: position{line: 189, col: 4, offset: 3545},
+ name: "OrderToken",
+ },
+ &ruleRefExpr{
+ pos: position{line: 190, col: 2, offset: 3557},
+ name: "_",
+ },
+ &ruleRefExpr{
+ pos: position{line: 190, col: 4, offset: 3559},
+ name: "ByToken",
+ },
+ &ruleRefExpr{
+ pos: position{line: 191, col: 2, offset: 3568},
+ name: "_",
+ },
+ &labeledExpr{
+ pos: position{line: 191, col: 4, offset: 3570},
+ label: "f",
+ expr: &ruleRefExpr{
+ pos: position{line: 191, col: 6, offset: 3572},
+ name: "OrderColumn",
+ },
+ },
+ &labeledExpr{
+ pos: position{line: 192, col: 2, offset: 3585},
+ label: "fs",
+ expr: &zeroOrMoreExpr{
+ pos: position{line: 192, col: 5, offset: 3588},
+ expr: &actionExpr{
+ pos: position{line: 192, col: 7, offset: 3590},
+ run: (*parser).callonOrderByClause11,
+ expr: &seqExpr{
+ pos: position{line: 192, col: 7, offset: 3590},
+ exprs: []interface{}{
+ &ruleRefExpr{
+ pos: position{line: 192, col: 7, offset: 3590},
+ name: "_",
+ },
+ &ruleRefExpr{
+ pos: position{line: 192, col: 9, offset: 3592},
+ name: "SeparatorToken",
+ },
+ &ruleRefExpr{
+ pos: position{line: 192, col: 24, offset: 3607},
+ name: "_",
+ },
+ &labeledExpr{
+ pos: position{line: 192, col: 26, offset: 3609},
+ label: "s",
+ expr: &ruleRefExpr{
+ pos: position{line: 192, col: 28, offset: 3611},
+ name: "OrderColumn",
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ {
+ name: "OrderColumn",
+ pos: position{line: 195, col: 1, offset: 3676},
+ expr: &actionExpr{
+ pos: position{line: 196, col: 4, offset: 3691},
+ run: (*parser).callonOrderColumn1,
+ expr: &seqExpr{
+ pos: position{line: 196, col: 4, offset: 3691},
+ exprs: []interface{}{
+ &labeledExpr{
+ pos: position{line: 196, col: 4, offset: 3691},
+ label: "i",
+ expr: &ruleRefExpr{
+ pos: position{line: 196, col: 6, offset: 3693},
+ name: "Expr",
+ },
+ },
+ &labeledExpr{
+ pos: position{line: 197, col: 2, offset: 3699},
+ label: "s",
+ expr: &zeroOrOneExpr{
+ pos: position{line: 197, col: 4, offset: 3701},
+ expr: &actionExpr{
+ pos: position{line: 197, col: 6, offset: 3703},
+ run: (*parser).callonOrderColumn7,
+ expr: &seqExpr{
+ pos: position{line: 197, col: 6, offset: 3703},
+ exprs: []interface{}{
+ &ruleRefExpr{
+ pos: position{line: 197, col: 6, offset: 3703},
+ name: "_",
+ },
+ &labeledExpr{
+ pos: position{line: 197, col: 8, offset: 3705},
+ label: "t",
+ expr: &choiceExpr{
+ pos: position{line: 197, col: 12, offset: 3709},
+ alternatives: []interface{}{
+ &ruleRefExpr{
+ pos: position{line: 197, col: 12, offset: 3709},
+ name: "AscToken",
+ },
+ &ruleRefExpr{
+ pos: position{line: 197, col: 23, offset: 3720},
+ name: "DescToken",
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ &labeledExpr{
+ pos: position{line: 198, col: 2, offset: 3754},
+ label: "n",
+ expr: &zeroOrOneExpr{
+ pos: position{line: 198, col: 4, offset: 3756},
+ expr: &actionExpr{
+ pos: position{line: 198, col: 6, offset: 3758},
+ run: (*parser).callonOrderColumn16,
+ expr: &seqExpr{
+ pos: position{line: 198, col: 6, offset: 3758},
+ exprs: []interface{}{
+ &ruleRefExpr{
+ pos: position{line: 198, col: 6, offset: 3758},
+ name: "_",
+ },
+ &ruleRefExpr{
+ pos: position{line: 198, col: 8, offset: 3760},
+ name: "NullsToken",
+ },
+ &ruleRefExpr{
+ pos: position{line: 198, col: 19, offset: 3771},
+ name: "_",
+ },
+ &labeledExpr{
+ pos: position{line: 198, col: 21, offset: 3773},
+ label: "l",
+ expr: &choiceExpr{
+ pos: position{line: 198, col: 25, offset: 3777},
+ alternatives: []interface{}{
+ &ruleRefExpr{
+ pos: position{line: 198, col: 25, offset: 3777},
+ name: "LastToken",
+ },
+ &ruleRefExpr{
+ pos: position{line: 198, col: 37, offset: 3789},
+ name: "FirstToken",
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ {
+ name: "GroupByClause",
+ pos: position{line: 207, col: 1, offset: 3988},
+ expr: &actionExpr{
+ pos: position{line: 208, col: 4, offset: 4005},
+ run: (*parser).callonGroupByClause1,
+ expr: &seqExpr{
+ pos: position{line: 208, col: 4, offset: 4005},
+ exprs: []interface{}{
+ &ruleRefExpr{
+ pos: position{line: 208, col: 4, offset: 4005},
+ name: "GroupToken",
+ },
+ &ruleRefExpr{
+ pos: position{line: 209, col: 2, offset: 4017},
+ name: "_",
+ },
+ &ruleRefExpr{
+ pos: position{line: 209, col: 4, offset: 4019},
+ name: "ByToken",
+ },
+ &ruleRefExpr{
+ pos: position{line: 210, col: 2, offset: 4028},
+ name: "_",
+ },
+ &labeledExpr{
+ pos: position{line: 210, col: 4, offset: 4030},
+ label: "i",
+ expr: &ruleRefExpr{
+ pos: position{line: 210, col: 6, offset: 4032},
+ name: "Expr",
+ },
+ },
+ &labeledExpr{
+ pos: position{line: 211, col: 2, offset: 4038},
+ label: "is",
+ expr: &zeroOrMoreExpr{
+ pos: position{line: 211, col: 5, offset: 4041},
+ expr: &actionExpr{
+ pos: position{line: 211, col: 7, offset: 4043},
+ run: (*parser).callonGroupByClause11,
+ expr: &seqExpr{
+ pos: position{line: 211, col: 7, offset: 4043},
+ exprs: []interface{}{
+ &ruleRefExpr{
+ pos: position{line: 211, col: 7, offset: 4043},
+ name: "_",
+ },
+ &ruleRefExpr{
+ pos: position{line: 211, col: 9, offset: 4045},
+ name: "SeparatorToken",
+ },
+ &ruleRefExpr{
+ pos: position{line: 211, col: 24, offset: 4060},
+ name: "_",
+ },
+ &labeledExpr{
+ pos: position{line: 211, col: 26, offset: 4062},
+ label: "s",
+ expr: &ruleRefExpr{
+ pos: position{line: 211, col: 28, offset: 4064},
+ name: "Expr",
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ {
+ name: "OffsetClause",
+ pos: position{line: 214, col: 1, offset: 4168},
+ expr: &actionExpr{
+ pos: position{line: 215, col: 4, offset: 4184},
+ run: (*parser).callonOffsetClause1,
+ expr: &seqExpr{
+ pos: position{line: 215, col: 4, offset: 4184},
+ exprs: []interface{}{
+ &ruleRefExpr{
+ pos: position{line: 215, col: 4, offset: 4184},
+ name: "OffsetToken",
+ },
+ &ruleRefExpr{
+ pos: position{line: 215, col: 16, offset: 4196},
+ name: "_",
+ },
+ &labeledExpr{
+ pos: position{line: 215, col: 18, offset: 4198},
+ label: "i",
+ expr: &ruleRefExpr{
+ pos: position{line: 215, col: 20, offset: 4200},
+ name: "Integer",
+ },
+ },
+ },
+ },
+ },
+ },
+ {
+ name: "LimitClause",
+ pos: position{line: 218, col: 1, offset: 4271},
+ expr: &actionExpr{
+ pos: position{line: 219, col: 4, offset: 4286},
+ run: (*parser).callonLimitClause1,
+ expr: &seqExpr{
+ pos: position{line: 219, col: 4, offset: 4286},
+ exprs: []interface{}{
+ &ruleRefExpr{
+ pos: position{line: 219, col: 4, offset: 4286},
+ name: "LimitToken",
+ },
+ &ruleRefExpr{
+ pos: position{line: 219, col: 15, offset: 4297},
+ name: "_",
+ },
+ &labeledExpr{
+ pos: position{line: 219, col: 17, offset: 4299},
+ label: "i",
+ expr: &ruleRefExpr{
+ pos: position{line: 219, col: 19, offset: 4301},
+ name: "Integer",
+ },
+ },
+ },
+ },
+ },
+ },
+ {
+ name: "InsertWithColumnClause",
+ pos: position{line: 222, col: 1, offset: 4371},
+ expr: &actionExpr{
+ pos: position{line: 223, col: 4, offset: 4397},
+ run: (*parser).callonInsertWithColumnClause1,
+ expr: &seqExpr{
+ pos: position{line: 223, col: 4, offset: 4397},
+ exprs: []interface{}{
+ &labeledExpr{
+ pos: position{line: 223, col: 4, offset: 4397},
+ label: "cs",
+ expr: &zeroOrOneExpr{
+ pos: position{line: 223, col: 7, offset: 4400},
+ expr: &actionExpr{
+ pos: position{line: 223, col: 9, offset: 4402},
+ run: (*parser).callonInsertWithColumnClause5,
+ expr: &seqExpr{
+ pos: position{line: 223, col: 9, offset: 4402},
+ exprs: []interface{}{
+ &litMatcher{
+ pos: position{line: 223, col: 9, offset: 4402},
+ val: "(",
+ ignoreCase: false,
+ },
+ &ruleRefExpr{
+ pos: position{line: 224, col: 4, offset: 4409},
+ name: "_",
+ },
+ &labeledExpr{
+ pos: position{line: 224, col: 6, offset: 4411},
+ label: "f",
+ expr: &ruleRefExpr{
+ pos: position{line: 224, col: 8, offset: 4413},
+ name: "Identifier",
+ },
+ },
+ &labeledExpr{
+ pos: position{line: 225, col: 4, offset: 4427},
+ label: "fs",
+ expr: &zeroOrMoreExpr{
+ pos: position{line: 225, col: 7, offset: 4430},
+ expr: &actionExpr{
+ pos: position{line: 225, col: 9, offset: 4432},
+ run: (*parser).callonInsertWithColumnClause13,
+ expr: &seqExpr{
+ pos: position{line: 225, col: 9, offset: 4432},
+ exprs: []interface{}{
+ &ruleRefExpr{
+ pos: position{line: 225, col: 9, offset: 4432},
+ name: "_",
+ },
+ &ruleRefExpr{
+ pos: position{line: 225, col: 11, offset: 4434},
+ name: "SeparatorToken",
+ },
+ &ruleRefExpr{
+ pos: position{line: 225, col: 26, offset: 4449},
+ name: "_",
+ },
+ &labeledExpr{
+ pos: position{line: 225, col: 28, offset: 4451},
+ label: "x",
+ expr: &ruleRefExpr{
+ pos: position{line: 225, col: 30, offset: 4453},
+ name: "Identifier",
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ &ruleRefExpr{
+ pos: position{line: 226, col: 4, offset: 4488},
+ name: "_",
+ },
+ &litMatcher{
+ pos: position{line: 226, col: 6, offset: 4490},
+ val: ")",
+ ignoreCase: false,
+ },
+ &ruleRefExpr{
+ pos: position{line: 227, col: 4, offset: 4497},
+ name: "_",
+ },
+ },
+ },
+ },
+ },
+ },
+ &ruleRefExpr{
+ pos: position{line: 229, col: 3, offset: 4537},
+ name: "ValuesToken",
+ },
+ &ruleRefExpr{
+ pos: position{line: 230, col: 2, offset: 4550},
+ name: "_",
+ },
+ &labeledExpr{
+ pos: position{line: 230, col: 4, offset: 4552},
+ label: "v",
+ expr: &ruleRefExpr{
+ pos: position{line: 230, col: 6, offset: 4554},
+ name: "InsertValue",
+ },
+ },
+ &labeledExpr{
+ pos: position{line: 231, col: 2, offset: 4567},
+ label: "vs",
+ expr: &zeroOrMoreExpr{
+ pos: position{line: 231, col: 5, offset: 4570},
+ expr: &actionExpr{
+ pos: position{line: 231, col: 7, offset: 4572},
+ run: (*parser).callonInsertWithColumnClause29,
+ expr: &seqExpr{
+ pos: position{line: 231, col: 7, offset: 4572},
+ exprs: []interface{}{
+ &ruleRefExpr{
+ pos: position{line: 231, col: 7, offset: 4572},
+ name: "_",
+ },
+ &ruleRefExpr{
+ pos: position{line: 231, col: 9, offset: 4574},
+ name: "SeparatorToken",
+ },
+ &ruleRefExpr{
+ pos: position{line: 231, col: 24, offset: 4589},
+ name: "_",
+ },
+ &labeledExpr{
+ pos: position{line: 231, col: 26, offset: 4591},
+ label: "y",
+ expr: &ruleRefExpr{
+ pos: position{line: 231, col: 28, offset: 4593},
+ name: "InsertValue",
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ {
+ name: "InsertWithDefaultClause",
+ pos: position{line: 239, col: 1, offset: 4724},
+ expr: &actionExpr{
+ pos: position{line: 240, col: 4, offset: 4751},
+ run: (*parser).callonInsertWithDefaultClause1,
+ expr: &seqExpr{
+ pos: position{line: 240, col: 4, offset: 4751},
+ exprs: []interface{}{
+ &ruleRefExpr{
+ pos: position{line: 240, col: 4, offset: 4751},
+ name: "DefaultToken",
+ },
+ &ruleRefExpr{
+ pos: position{line: 240, col: 17, offset: 4764},
+ name: "_",
+ },
+ &ruleRefExpr{
+ pos: position{line: 240, col: 19, offset: 4766},
+ name: "ValuesToken",
+ },
+ },
+ },
+ },
+ },
+ {
+ name: "PrimaryKeyClause",
+ pos: position{line: 243, col: 1, offset: 4825},
+ expr: &actionExpr{
+ pos: position{line: 244, col: 4, offset: 4845},
+ run: (*parser).callonPrimaryKeyClause1,
+ expr: &seqExpr{
+ pos: position{line: 244, col: 4, offset: 4845},
+ exprs: []interface{}{
+ &ruleRefExpr{
+ pos: position{line: 244, col: 4, offset: 4845},
+ name: "PrimaryToken",
+ },
+ &ruleRefExpr{
+ pos: position{line: 244, col: 17, offset: 4858},
+ name: "_",
+ },
+ &ruleRefExpr{
+ pos: position{line: 244, col: 19, offset: 4860},
+ name: "KeyToken",
+ },
+ },
+ },
+ },
+ },
+ {
+ name: "NotNullClause",
+ pos: position{line: 247, col: 1, offset: 4906},
+ expr: &actionExpr{
+ pos: position{line: 248, col: 4, offset: 4923},
+ run: (*parser).callonNotNullClause1,
+ expr: &seqExpr{
+ pos: position{line: 248, col: 4, offset: 4923},
+ exprs: []interface{}{
+ &ruleRefExpr{
+ pos: position{line: 248, col: 4, offset: 4923},
+ name: "NotToken",
+ },
+ &ruleRefExpr{
+ pos: position{line: 248, col: 13, offset: 4932},
+ name: "_",
+ },
+ &ruleRefExpr{
+ pos: position{line: 248, col: 15, offset: 4934},
+ name: "NullToken",
+ },
+ },
+ },
+ },
+ },
+ {
+ name: "UniqueClause",
+ pos: position{line: 251, col: 1, offset: 4981},
+ expr: &actionExpr{
+ pos: position{line: 252, col: 4, offset: 4997},
+ run: (*parser).callonUniqueClause1,
+ expr: &ruleRefExpr{
+ pos: position{line: 252, col: 4, offset: 4997},
+ name: "UniqueToken",
+ },
+ },
+ },
+ {
+ name: "DefaultClause",
+ pos: position{line: 255, col: 1, offset: 5045},
+ expr: &actionExpr{
+ pos: position{line: 256, col: 4, offset: 5062},
+ run: (*parser).callonDefaultClause1,
+ expr: &seqExpr{
+ pos: position{line: 256, col: 4, offset: 5062},
+ exprs: []interface{}{
+ &ruleRefExpr{
+ pos: position{line: 256, col: 4, offset: 5062},
+ name: "DefaultToken",
+ },
+ &ruleRefExpr{
+ pos: position{line: 256, col: 17, offset: 5075},
+ name: "_",
+ },
+ &labeledExpr{
+ pos: position{line: 256, col: 19, offset: 5077},
+ label: "e",
+ expr: &ruleRefExpr{
+ pos: position{line: 256, col: 21, offset: 5079},
+ name: "Expr",
+ },
+ },
+ },
+ },
+ },
+ },
+ {
+ name: "ForeignClause",
+ pos: position{line: 259, col: 1, offset: 5129},
+ expr: &actionExpr{
+ pos: position{line: 260, col: 4, offset: 5146},
+ run: (*parser).callonForeignClause1,
+ expr: &seqExpr{
+ pos: position{line: 260, col: 4, offset: 5146},
+ exprs: []interface{}{
+ &ruleRefExpr{
+ pos: position{line: 260, col: 4, offset: 5146},
+ name: "ReferencesToken",
+ },
+ &ruleRefExpr{
+ pos: position{line: 260, col: 20, offset: 5162},
+ name: "_",
+ },
+ &labeledExpr{
+ pos: position{line: 260, col: 22, offset: 5164},
+ label: "t",
+ expr: &ruleRefExpr{
+ pos: position{line: 260, col: 24, offset: 5166},
+ name: "Identifier",
+ },
+ },
+ &ruleRefExpr{
+ pos: position{line: 260, col: 35, offset: 5177},
+ name: "_",
+ },
+ &litMatcher{
+ pos: position{line: 260, col: 37, offset: 5179},
+ val: "(",
+ ignoreCase: false,
+ },
+ &ruleRefExpr{
+ pos: position{line: 260, col: 41, offset: 5183},
+ name: "_",
+ },
+ &labeledExpr{
+ pos: position{line: 260, col: 43, offset: 5185},
+ label: "f",
+ expr: &ruleRefExpr{
+ pos: position{line: 260, col: 45, offset: 5187},
+ name: "Identifier",
+ },
+ },
+ &ruleRefExpr{
+ pos: position{line: 260, col: 56, offset: 5198},
+ name: "_",
+ },
+ &litMatcher{
+ pos: position{line: 260, col: 58, offset: 5200},
+ val: ")",
+ ignoreCase: false,
+ },
+ },
+ },
+ },
+ },
+ {
+ name: "AutoincrementClause",
+ pos: position{line: 268, col: 1, offset: 5304},
+ expr: &actionExpr{
+ pos: position{line: 269, col: 4, offset: 5327},
+ run: (*parser).callonAutoincrementClause1,
+ expr: &ruleRefExpr{
+ pos: position{line: 269, col: 4, offset: 5327},
+ name: "AutoincrementToken",
+ },
+ },
+ },
+ {
+ name: "Expr",
+ pos: position{line: 273, col: 1, offset: 5406},
+ expr: &ruleRefExpr{
+ pos: position{line: 274, col: 4, offset: 5414},
+ name: "LogicExpr",
+ },
+ },
+ {
+ name: "ExprWithDefault",
+ pos: position{line: 276, col: 1, offset: 5425},
+ expr: &choiceExpr{
+ pos: position{line: 277, col: 4, offset: 5444},
+ alternatives: []interface{}{
+ &actionExpr{
+ pos: position{line: 277, col: 4, offset: 5444},
+ run: (*parser).callonExprWithDefault2,
+ expr: &seqExpr{
+ pos: position{line: 277, col: 4, offset: 5444},
+ exprs: []interface{}{
+ &andExpr{
+ pos: position{line: 277, col: 4, offset: 5444},
+ expr: &ruleRefExpr{
+ pos: position{line: 277, col: 6, offset: 5446},
+ name: "DefaultLiteral",
+ },
+ },
+ &labeledExpr{
+ pos: position{line: 277, col: 22, offset: 5462},
+ label: "d",
+ expr: &ruleRefExpr{
+ pos: position{line: 277, col: 24, offset: 5464},
+ name: "DefaultLiteral",
+ },
+ },
+ },
+ },
+ },
+ &ruleRefExpr{
+ pos: position{line: 278, col: 4, offset: 5500},
+ name: "Expr",
+ },
+ },
+ },
+ },
+ {
+ name: "LogicExpr",
+ pos: position{line: 280, col: 1, offset: 5506},
+ expr: &ruleRefExpr{
+ pos: position{line: 281, col: 4, offset: 5519},
+ name: "LogicExpr4",
+ },
+ },
+ {
+ name: "LogicExpr4",
+ pos: position{line: 283, col: 1, offset: 5531},
+ expr: &actionExpr{
+ pos: position{line: 284, col: 4, offset: 5545},
+ run: (*parser).callonLogicExpr41,
+ expr: &seqExpr{
+ pos: position{line: 284, col: 4, offset: 5545},
+ exprs: []interface{}{
+ &labeledExpr{
+ pos: position{line: 284, col: 4, offset: 5545},
+ label: "o",
+ expr: &ruleRefExpr{
+ pos: position{line: 284, col: 6, offset: 5547},
+ name: "LogicExpr3",
+ },
+ },
+ &labeledExpr{
+ pos: position{line: 285, col: 3, offset: 5560},
+ label: "os",
+ expr: &zeroOrMoreExpr{
+ pos: position{line: 285, col: 6, offset: 5563},
+ expr: &actionExpr{
+ pos: position{line: 285, col: 8, offset: 5565},
+ run: (*parser).callonLogicExpr47,
+ expr: &seqExpr{
+ pos: position{line: 285, col: 8, offset: 5565},
+ exprs: []interface{}{
+ &ruleRefExpr{
+ pos: position{line: 285, col: 8, offset: 5565},
+ name: "_",
+ },
+ &labeledExpr{
+ pos: position{line: 285, col: 10, offset: 5567},
+ label: "op",
+ expr: &ruleRefExpr{
+ pos: position{line: 285, col: 13, offset: 5570},
+ name: "OrOperator",
+ },
+ },
+ &ruleRefExpr{
+ pos: position{line: 285, col: 24, offset: 5581},
+ name: "_",
+ },
+ &labeledExpr{
+ pos: position{line: 285, col: 26, offset: 5583},
+ label: "s",
+ expr: &ruleRefExpr{
+ pos: position{line: 285, col: 28, offset: 5585},
+ name: "LogicExpr3",
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ {
+ name: "LogicExpr3",
+ pos: position{line: 288, col: 1, offset: 5678},
+ expr: &actionExpr{
+ pos: position{line: 289, col: 4, offset: 5692},
+ run: (*parser).callonLogicExpr31,
+ expr: &seqExpr{
+ pos: position{line: 289, col: 4, offset: 5692},
+ exprs: []interface{}{
+ &labeledExpr{
+ pos: position{line: 289, col: 4, offset: 5692},
+ label: "o",
+ expr: &ruleRefExpr{
+ pos: position{line: 289, col: 6, offset: 5694},
+ name: "LogicExpr2",
+ },
+ },
+ &labeledExpr{
+ pos: position{line: 290, col: 3, offset: 5707},
+ label: "os",
+ expr: &zeroOrMoreExpr{
+ pos: position{line: 290, col: 6, offset: 5710},
+ expr: &actionExpr{
+ pos: position{line: 290, col: 8, offset: 5712},
+ run: (*parser).callonLogicExpr37,
+ expr: &seqExpr{
+ pos: position{line: 290, col: 8, offset: 5712},
+ exprs: []interface{}{
+ &ruleRefExpr{
+ pos: position{line: 290, col: 8, offset: 5712},
+ name: "_",
+ },
+ &labeledExpr{
+ pos: position{line: 290, col: 10, offset: 5714},
+ label: "op",
+ expr: &ruleRefExpr{
+ pos: position{line: 290, col: 13, offset: 5717},
+ name: "AndOperator",
+ },
+ },
+ &ruleRefExpr{
+ pos: position{line: 290, col: 25, offset: 5729},
+ name: "_",
+ },
+ &labeledExpr{
+ pos: position{line: 290, col: 27, offset: 5731},
+ label: "s",
+ expr: &ruleRefExpr{
+ pos: position{line: 290, col: 29, offset: 5733},
+ name: "LogicExpr2",
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ {
+ name: "LogicExpr2",
+ pos: position{line: 293, col: 1, offset: 5826},
+ expr: &choiceExpr{
+ pos: position{line: 294, col: 4, offset: 5840},
+ alternatives: []interface{}{
+ &actionExpr{
+ pos: position{line: 294, col: 4, offset: 5840},
+ run: (*parser).callonLogicExpr22,
+ expr: &seqExpr{
+ pos: position{line: 294, col: 4, offset: 5840},
+ exprs: []interface{}{
+ &labeledExpr{
+ pos: position{line: 294, col: 4, offset: 5840},
+ label: "op",
+ expr: &ruleRefExpr{
+ pos: position{line: 294, col: 7, offset: 5843},
+ name: "NotOperator",
+ },
+ },
+ &ruleRefExpr{
+ pos: position{line: 294, col: 19, offset: 5855},
+ name: "_",
+ },
+ &labeledExpr{
+ pos: position{line: 294, col: 21, offset: 5857},
+ label: "s",
+ expr: &ruleRefExpr{
+ pos: position{line: 294, col: 23, offset: 5859},
+ name: "LogicExpr2",
+ },
+ },
+ },
+ },
+ },
+ &ruleRefExpr{
+ pos: position{line: 296, col: 4, offset: 5909},
+ name: "LogicExpr1",
+ },
+ },
+ },
+ },
+ {
+ name: "LogicExpr1",
+ pos: position{line: 298, col: 1, offset: 5921},
+ expr: &actionExpr{
+ pos: position{line: 299, col: 4, offset: 5935},
+ run: (*parser).callonLogicExpr11,
+ expr: &seqExpr{
+ pos: position{line: 299, col: 4, offset: 5935},
+ exprs: []interface{}{
+ &labeledExpr{
+ pos: position{line: 299, col: 4, offset: 5935},
+ label: "o",
+ expr: &ruleRefExpr{
+ pos: position{line: 299, col: 6, offset: 5937},
+ name: "ArithmeticExpr",
+ },
+ },
+ &labeledExpr{
+ pos: position{line: 299, col: 21, offset: 5952},
+ label: "os",
+ expr: &zeroOrMoreExpr{
+ pos: position{line: 299, col: 24, offset: 5955},
+ expr: &actionExpr{
+ pos: position{line: 299, col: 26, offset: 5957},
+ run: (*parser).callonLogicExpr17,
+ expr: &seqExpr{
+ pos: position{line: 299, col: 26, offset: 5957},
+ exprs: []interface{}{
+ &ruleRefExpr{
+ pos: position{line: 299, col: 26, offset: 5957},
+ name: "_",
+ },
+ &labeledExpr{
+ pos: position{line: 299, col: 28, offset: 5959},
+ label: "l",
+ expr: &ruleRefExpr{
+ pos: position{line: 299, col: 30, offset: 5961},
+ name: "LogicExpr1Op",
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ {
+ name: "LogicExpr1Op",
+ pos: position{line: 302, col: 1, offset: 6038},
+ expr: &choiceExpr{
+ pos: position{line: 303, col: 4, offset: 6054},
+ alternatives: []interface{}{
+ &ruleRefExpr{
+ pos: position{line: 303, col: 4, offset: 6054},
+ name: "LogicExpr1In",
+ },
+ &ruleRefExpr{
+ pos: position{line: 304, col: 4, offset: 6070},
+ name: "LogicExpr1Null",
+ },
+ &ruleRefExpr{
+ pos: position{line: 305, col: 4, offset: 6088},
+ name: "LogicExpr1Like",
+ },
+ &ruleRefExpr{
+ pos: position{line: 306, col: 4, offset: 6106},
+ name: "LogicExpr1Cmp",
+ },
+ },
+ },
+ },
+ {
+ name: "LogicExpr1In",
+ pos: position{line: 308, col: 1, offset: 6121},
+ expr: &actionExpr{
+ pos: position{line: 309, col: 4, offset: 6137},
+ run: (*parser).callonLogicExpr1In1,
+ expr: &seqExpr{
+ pos: position{line: 309, col: 4, offset: 6137},
+ exprs: []interface{}{
+ &labeledExpr{
+ pos: position{line: 309, col: 4, offset: 6137},
+ label: "n",
+ expr: &zeroOrOneExpr{
+ pos: position{line: 309, col: 6, offset: 6139},
+ expr: &actionExpr{
+ pos: position{line: 309, col: 8, offset: 6141},
+ run: (*parser).callonLogicExpr1In5,
+ expr: &seqExpr{
+ pos: position{line: 309, col: 8, offset: 6141},
+ exprs: []interface{}{
+ &labeledExpr{
+ pos: position{line: 309, col: 8, offset: 6141},
+ label: "t",
+ expr: &ruleRefExpr{
+ pos: position{line: 309, col: 10, offset: 6143},
+ name: "NotOperator",
+ },
+ },
+ &ruleRefExpr{
+ pos: position{line: 309, col: 22, offset: 6155},
+ name: "_",
+ },
+ },
+ },
+ },
+ },
+ },
+ &ruleRefExpr{
+ pos: position{line: 309, col: 45, offset: 6178},
+ name: "InToken",
+ },
+ &ruleRefExpr{
+ pos: position{line: 309, col: 53, offset: 6186},
+ name: "_",
+ },
+ &litMatcher{
+ pos: position{line: 309, col: 55, offset: 6188},
+ val: "(",
+ ignoreCase: false,
+ },
+ &ruleRefExpr{
+ pos: position{line: 309, col: 59, offset: 6192},
+ name: "_",
+ },
+ &labeledExpr{
+ pos: position{line: 309, col: 61, offset: 6194},
+ label: "s",
+ expr: &ruleRefExpr{
+ pos: position{line: 309, col: 63, offset: 6196},
+ name: "MultiExpr",
+ },
+ },
+ &ruleRefExpr{
+ pos: position{line: 309, col: 73, offset: 6206},
+ name: "_",
+ },
+ &litMatcher{
+ pos: position{line: 309, col: 75, offset: 6208},
+ val: ")",
+ ignoreCase: false,
+ },
+ },
+ },
+ },
+ },
+ {
+ name: "LogicExpr1Null",
+ pos: position{line: 318, col: 1, offset: 6326},
+ expr: &actionExpr{
+ pos: position{line: 319, col: 4, offset: 6344},
+ run: (*parser).callonLogicExpr1Null1,
+ expr: &seqExpr{
+ pos: position{line: 319, col: 4, offset: 6344},
+ exprs: []interface{}{
+ &ruleRefExpr{
+ pos: position{line: 319, col: 4, offset: 6344},
+ name: "IsToken",
+ },
+ &labeledExpr{
+ pos: position{line: 319, col: 12, offset: 6352},
+ label: "n",
+ expr: &zeroOrOneExpr{
+ pos: position{line: 319, col: 14, offset: 6354},
+ expr: &actionExpr{
+ pos: position{line: 319, col: 16, offset: 6356},
+ run: (*parser).callonLogicExpr1Null6,
+ expr: &seqExpr{
+ pos: position{line: 319, col: 16, offset: 6356},
+ exprs: []interface{}{
+ &ruleRefExpr{
+ pos: position{line: 319, col: 16, offset: 6356},
+ name: "_",
+ },
+ &labeledExpr{
+ pos: position{line: 319, col: 18, offset: 6358},
+ label: "t",
+ expr: &ruleRefExpr{
+ pos: position{line: 319, col: 20, offset: 6360},
+ name: "NotOperator",
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ &ruleRefExpr{
+ pos: position{line: 319, col: 53, offset: 6393},
+ name: "_",
+ },
+ &ruleRefExpr{
+ pos: position{line: 319, col: 55, offset: 6395},
+ name: "NullToken",
+ },
+ },
+ },
+ },
+ },
+ {
+ name: "LogicExpr1Like",
+ pos: position{line: 328, col: 1, offset: 6533},
+ expr: &actionExpr{
+ pos: position{line: 329, col: 4, offset: 6551},
+ run: (*parser).callonLogicExpr1Like1,
+ expr: &seqExpr{
+ pos: position{line: 329, col: 4, offset: 6551},
+ exprs: []interface{}{
+ &labeledExpr{
+ pos: position{line: 329, col: 4, offset: 6551},
+ label: "n",
+ expr: &zeroOrOneExpr{
+ pos: position{line: 329, col: 6, offset: 6553},
+ expr: &actionExpr{
+ pos: position{line: 329, col: 8, offset: 6555},
+ run: (*parser).callonLogicExpr1Like5,
+ expr: &seqExpr{
+ pos: position{line: 329, col: 8, offset: 6555},
+ exprs: []interface{}{
+ &labeledExpr{
+ pos: position{line: 329, col: 8, offset: 6555},
+ label: "t",
+ expr: &ruleRefExpr{
+ pos: position{line: 329, col: 10, offset: 6557},
+ name: "NotOperator",
+ },
+ },
+ &ruleRefExpr{
+ pos: position{line: 329, col: 22, offset: 6569},
+ name: "_",
+ },
+ },
+ },
+ },
+ },
+ },
+ &ruleRefExpr{
+ pos: position{line: 329, col: 45, offset: 6592},
+ name: "LikeToken",
+ },
+ &ruleRefExpr{
+ pos: position{line: 329, col: 55, offset: 6602},
+ name: "_",
+ },
+ &labeledExpr{
+ pos: position{line: 329, col: 57, offset: 6604},
+ label: "s",
+ expr: &ruleRefExpr{
+ pos: position{line: 329, col: 59, offset: 6606},
+ name: "Expr",
+ },
+ },
+ },
+ },
+ },
+ },
+ {
+ name: "LogicExpr1Cmp",
+ pos: position{line: 338, col: 1, offset: 6727},
+ expr: &actionExpr{
+ pos: position{line: 339, col: 4, offset: 6744},
+ run: (*parser).callonLogicExpr1Cmp1,
+ expr: &seqExpr{
+ pos: position{line: 339, col: 4, offset: 6744},
+ exprs: []interface{}{
+ &labeledExpr{
+ pos: position{line: 339, col: 4, offset: 6744},
+ label: "op",
+ expr: &ruleRefExpr{
+ pos: position{line: 339, col: 7, offset: 6747},
+ name: "CmpOperator",
+ },
+ },
+ &ruleRefExpr{
+ pos: position{line: 339, col: 19, offset: 6759},
+ name: "_",
+ },
+ &labeledExpr{
+ pos: position{line: 339, col: 21, offset: 6761},
+ label: "s",
+ expr: &ruleRefExpr{
+ pos: position{line: 339, col: 23, offset: 6763},
+ name: "ArithmeticExpr",
+ },
+ },
+ },
+ },
+ },
+ },
+ {
+ name: "ArithmeticExpr",
+ pos: position{line: 342, col: 1, offset: 6815},
+ expr: &ruleRefExpr{
+ pos: position{line: 343, col: 4, offset: 6833},
+ name: "ArithmeticExpr3",
+ },
+ },
+ {
+ name: "ArithmeticExpr3",
+ pos: position{line: 345, col: 1, offset: 6850},
+ expr: &actionExpr{
+ pos: position{line: 346, col: 4, offset: 6869},
+ run: (*parser).callonArithmeticExpr31,
+ expr: &seqExpr{
+ pos: position{line: 346, col: 4, offset: 6869},
+ exprs: []interface{}{
+ &labeledExpr{
+ pos: position{line: 346, col: 4, offset: 6869},
+ label: "o",
+ expr: &ruleRefExpr{
+ pos: position{line: 346, col: 6, offset: 6871},
+ name: "ArithmeticExpr2",
+ },
+ },
+ &labeledExpr{
+ pos: position{line: 346, col: 22, offset: 6887},
+ label: "os",
+ expr: &zeroOrMoreExpr{
+ pos: position{line: 346, col: 25, offset: 6890},
+ expr: &actionExpr{
+ pos: position{line: 346, col: 27, offset: 6892},
+ run: (*parser).callonArithmeticExpr37,
+ expr: &seqExpr{
+ pos: position{line: 346, col: 27, offset: 6892},
+ exprs: []interface{}{
+ &ruleRefExpr{
+ pos: position{line: 346, col: 27, offset: 6892},
+ name: "_",
+ },
+ &labeledExpr{
+ pos: position{line: 346, col: 29, offset: 6894},
+ label: "op",
+ expr: &ruleRefExpr{
+ pos: position{line: 346, col: 32, offset: 6897},
+ name: "ConcatOperator",
+ },
+ },
+ &ruleRefExpr{
+ pos: position{line: 346, col: 47, offset: 6912},
+ name: "_",
+ },
+ &labeledExpr{
+ pos: position{line: 346, col: 49, offset: 6914},
+ label: "s",
+ expr: &ruleRefExpr{
+ pos: position{line: 346, col: 51, offset: 6916},
+ name: "ArithmeticExpr2",
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ {
+ name: "ArithmeticExpr2",
+ pos: position{line: 349, col: 1, offset: 7014},
+ expr: &actionExpr{
+ pos: position{line: 350, col: 4, offset: 7033},
+ run: (*parser).callonArithmeticExpr21,
+ expr: &seqExpr{
+ pos: position{line: 350, col: 4, offset: 7033},
+ exprs: []interface{}{
+ &labeledExpr{
+ pos: position{line: 350, col: 4, offset: 7033},
+ label: "o",
+ expr: &ruleRefExpr{
+ pos: position{line: 350, col: 6, offset: 7035},
+ name: "ArithmeticExpr1",
+ },
+ },
+ &labeledExpr{
+ pos: position{line: 350, col: 22, offset: 7051},
+ label: "os",
+ expr: &zeroOrMoreExpr{
+ pos: position{line: 350, col: 25, offset: 7054},
+ expr: &actionExpr{
+ pos: position{line: 350, col: 27, offset: 7056},
+ run: (*parser).callonArithmeticExpr27,
+ expr: &seqExpr{
+ pos: position{line: 350, col: 27, offset: 7056},
+ exprs: []interface{}{
+ &ruleRefExpr{
+ pos: position{line: 350, col: 27, offset: 7056},
+ name: "_",
+ },
+ &labeledExpr{
+ pos: position{line: 350, col: 29, offset: 7058},
+ label: "op",
+ expr: &ruleRefExpr{
+ pos: position{line: 350, col: 32, offset: 7061},
+ name: "AddSubOperator",
+ },
+ },
+ &ruleRefExpr{
+ pos: position{line: 350, col: 47, offset: 7076},
+ name: "_",
+ },
+ &labeledExpr{
+ pos: position{line: 350, col: 49, offset: 7078},
+ label: "s",
+ expr: &ruleRefExpr{
+ pos: position{line: 350, col: 51, offset: 7080},
+ name: "ArithmeticExpr1",
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ {
+ name: "ArithmeticExpr1",
+ pos: position{line: 353, col: 1, offset: 7178},
+ expr: &actionExpr{
+ pos: position{line: 354, col: 4, offset: 7197},
+ run: (*parser).callonArithmeticExpr11,
+ expr: &seqExpr{
+ pos: position{line: 354, col: 4, offset: 7197},
+ exprs: []interface{}{
+ &labeledExpr{
+ pos: position{line: 354, col: 4, offset: 7197},
+ label: "o",
+ expr: &ruleRefExpr{
+ pos: position{line: 354, col: 6, offset: 7199},
+ name: "Operand",
+ },
+ },
+ &labeledExpr{
+ pos: position{line: 354, col: 14, offset: 7207},
+ label: "os",
+ expr: &zeroOrMoreExpr{
+ pos: position{line: 354, col: 17, offset: 7210},
+ expr: &actionExpr{
+ pos: position{line: 354, col: 19, offset: 7212},
+ run: (*parser).callonArithmeticExpr17,
+ expr: &seqExpr{
+ pos: position{line: 354, col: 19, offset: 7212},
+ exprs: []interface{}{
+ &ruleRefExpr{
+ pos: position{line: 354, col: 19, offset: 7212},
+ name: "_",
+ },
+ &labeledExpr{
+ pos: position{line: 354, col: 21, offset: 7214},
+ label: "op",
+ expr: &ruleRefExpr{
+ pos: position{line: 354, col: 24, offset: 7217},
+ name: "MulDivModOperator",
+ },
+ },
+ &ruleRefExpr{
+ pos: position{line: 354, col: 42, offset: 7235},
+ name: "_",
+ },
+ &labeledExpr{
+ pos: position{line: 354, col: 44, offset: 7237},
+ label: "s",
+ expr: &ruleRefExpr{
+ pos: position{line: 354, col: 46, offset: 7239},
+ name: "Operand",
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ {
+ name: "MultiExpr",
+ pos: position{line: 357, col: 1, offset: 7329},
+ expr: &actionExpr{
+ pos: position{line: 358, col: 4, offset: 7342},
+ run: (*parser).callonMultiExpr1,
+ expr: &seqExpr{
+ pos: position{line: 358, col: 4, offset: 7342},
+ exprs: []interface{}{
+ &labeledExpr{
+ pos: position{line: 358, col: 4, offset: 7342},
+ label: "x",
+ expr: &ruleRefExpr{
+ pos: position{line: 358, col: 6, offset: 7344},
+ name: "Expr",
+ },
+ },
+ &labeledExpr{
+ pos: position{line: 358, col: 11, offset: 7349},
+ label: "xs",
+ expr: &zeroOrMoreExpr{
+ pos: position{line: 358, col: 14, offset: 7352},
+ expr: &actionExpr{
+ pos: position{line: 358, col: 16, offset: 7354},
+ run: (*parser).callonMultiExpr7,
+ expr: &seqExpr{
+ pos: position{line: 358, col: 16, offset: 7354},
+ exprs: []interface{}{
+ &ruleRefExpr{
+ pos: position{line: 358, col: 16, offset: 7354},
+ name: "_",
+ },
+ &ruleRefExpr{
+ pos: position{line: 358, col: 18, offset: 7356},
+ name: "SeparatorToken",
+ },
+ &ruleRefExpr{
+ pos: position{line: 358, col: 33, offset: 7371},
+ name: "_",
+ },
+ &labeledExpr{
+ pos: position{line: 358, col: 35, offset: 7373},
+ label: "e",
+ expr: &ruleRefExpr{
+ pos: position{line: 358, col: 37, offset: 7375},
+ name: "Expr",
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ {
+ name: "MultiExprWithDefault",
+ pos: position{line: 361, col: 1, offset: 7433},
+ expr: &actionExpr{
+ pos: position{line: 362, col: 4, offset: 7457},
+ run: (*parser).callonMultiExprWithDefault1,
+ expr: &seqExpr{
+ pos: position{line: 362, col: 4, offset: 7457},
+ exprs: []interface{}{
+ &labeledExpr{
+ pos: position{line: 362, col: 4, offset: 7457},
+ label: "x",
+ expr: &ruleRefExpr{
+ pos: position{line: 362, col: 6, offset: 7459},
+ name: "ExprWithDefault",
+ },
+ },
+ &labeledExpr{
+ pos: position{line: 362, col: 22, offset: 7475},
+ label: "xs",
+ expr: &zeroOrMoreExpr{
+ pos: position{line: 362, col: 25, offset: 7478},
+ expr: &actionExpr{
+ pos: position{line: 362, col: 27, offset: 7480},
+ run: (*parser).callonMultiExprWithDefault7,
+ expr: &seqExpr{
+ pos: position{line: 362, col: 27, offset: 7480},
+ exprs: []interface{}{
+ &ruleRefExpr{
+ pos: position{line: 362, col: 27, offset: 7480},
+ name: "_",
+ },
+ &ruleRefExpr{
+ pos: position{line: 362, col: 29, offset: 7482},
+ name: "SeparatorToken",
+ },
+ &ruleRefExpr{
+ pos: position{line: 362, col: 44, offset: 7497},
+ name: "_",
+ },
+ &labeledExpr{
+ pos: position{line: 362, col: 46, offset: 7499},
+ label: "e",
+ expr: &ruleRefExpr{
+ pos: position{line: 362, col: 48, offset: 7501},
+ name: "ExprWithDefault",
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ {
+ name: "Operand",
+ pos: position{line: 365, col: 1, offset: 7570},
+ expr: &choiceExpr{
+ pos: position{line: 366, col: 4, offset: 7581},
+ alternatives: []interface{}{
+ &actionExpr{
+ pos: position{line: 366, col: 4, offset: 7581},
+ run: (*parser).callonOperand2,
+ expr: &seqExpr{
+ pos: position{line: 366, col: 4, offset: 7581},
+ exprs: []interface{}{
+ &labeledExpr{
+ pos: position{line: 366, col: 4, offset: 7581},
+ label: "op",
+ expr: &ruleRefExpr{
+ pos: position{line: 366, col: 7, offset: 7584},
+ name: "UnaryOperator",
+ },
+ },
+ &ruleRefExpr{
+ pos: position{line: 366, col: 21, offset: 7598},
+ name: "_",
+ },
+ &labeledExpr{
+ pos: position{line: 366, col: 23, offset: 7600},
+ label: "s",
+ expr: &ruleRefExpr{
+ pos: position{line: 366, col: 25, offset: 7602},
+ name: "Operand",
+ },
+ },
+ },
+ },
+ },
+ &actionExpr{
+ pos: position{line: 367, col: 4, offset: 7648},
+ run: (*parser).callonOperand9,
+ expr: &seqExpr{
+ pos: position{line: 367, col: 4, offset: 7648},
+ exprs: []interface{}{
+ &litMatcher{
+ pos: position{line: 367, col: 4, offset: 7648},
+ val: "(",
+ ignoreCase: false,
+ },
+ &ruleRefExpr{
+ pos: position{line: 367, col: 8, offset: 7652},
+ name: "_",
+ },
+ &labeledExpr{
+ pos: position{line: 367, col: 10, offset: 7654},
+ label: "e",
+ expr: &ruleRefExpr{
+ pos: position{line: 367, col: 12, offset: 7656},
+ name: "Expr",
+ },
+ },
+ &ruleRefExpr{
+ pos: position{line: 367, col: 17, offset: 7661},
+ name: "_",
+ },
+ &litMatcher{
+ pos: position{line: 367, col: 19, offset: 7663},
+ val: ")",
+ ignoreCase: false,
+ },
+ },
+ },
+ },
+ &actionExpr{
+ pos: position{line: 368, col: 4, offset: 7688},
+ run: (*parser).callonOperand17,
+ expr: &seqExpr{
+ pos: position{line: 368, col: 4, offset: 7688},
+ exprs: []interface{}{
+ &andExpr{
+ pos: position{line: 368, col: 4, offset: 7688},
+ expr: &ruleRefExpr{
+ pos: position{line: 368, col: 6, offset: 7690},
+ name: "CastToken",
+ },
+ },
+ &labeledExpr{
+ pos: position{line: 368, col: 17, offset: 7701},
+ label: "t",
+ expr: &ruleRefExpr{
+ pos: position{line: 368, col: 19, offset: 7703},
+ name: "TypeCast",
+ },
+ },
+ },
+ },
+ },
+ &ruleRefExpr{
+ pos: position{line: 369, col: 4, offset: 7733},
+ name: "FunctionCall",
+ },
+ &ruleRefExpr{
+ pos: position{line: 370, col: 4, offset: 7749},
+ name: "Value",
+ },
+ &ruleRefExpr{
+ pos: position{line: 371, col: 4, offset: 7758},
+ name: "Identifier",
+ },
+ },
+ },
+ },
+ {
+ name: "TypeCast",
+ pos: position{line: 373, col: 1, offset: 7770},
+ expr: &actionExpr{
+ pos: position{line: 374, col: 4, offset: 7782},
+ run: (*parser).callonTypeCast1,
+ expr: &seqExpr{
+ pos: position{line: 374, col: 4, offset: 7782},
+ exprs: []interface{}{
+ &ruleRefExpr{
+ pos: position{line: 374, col: 4, offset: 7782},
+ name: "CastToken",
+ },
+ &ruleRefExpr{
+ pos: position{line: 374, col: 14, offset: 7792},
+ name: "_",
+ },
+ &litMatcher{
+ pos: position{line: 374, col: 16, offset: 7794},
+ val: "(",
+ ignoreCase: false,
+ },
+ &ruleRefExpr{
+ pos: position{line: 374, col: 20, offset: 7798},
+ name: "_",
+ },
+ &labeledExpr{
+ pos: position{line: 374, col: 22, offset: 7800},
+ label: "o",
+ expr: &ruleRefExpr{
+ pos: position{line: 374, col: 24, offset: 7802},
+ name: "Expr",
+ },
+ },
+ &ruleRefExpr{
+ pos: position{line: 374, col: 29, offset: 7807},
+ name: "_",
+ },
+ &ruleRefExpr{
+ pos: position{line: 374, col: 31, offset: 7809},
+ name: "AsToken",
+ },
+ &ruleRefExpr{
+ pos: position{line: 374, col: 39, offset: 7817},
+ name: "_",
+ },
+ &labeledExpr{
+ pos: position{line: 374, col: 41, offset: 7819},
+ label: "s",
+ expr: &ruleRefExpr{
+ pos: position{line: 374, col: 43, offset: 7821},
+ name: "DataType",
+ },
+ },
+ &ruleRefExpr{
+ pos: position{line: 374, col: 52, offset: 7830},
+ name: "_",
+ },
+ &litMatcher{
+ pos: position{line: 374, col: 54, offset: 7832},
+ val: ")",
+ ignoreCase: false,
+ },
+ },
+ },
+ },
+ },
+ {
+ name: "FunctionCall",
+ pos: position{line: 377, col: 1, offset: 7906},
+ expr: &actionExpr{
+ pos: position{line: 378, col: 4, offset: 7922},
+ run: (*parser).callonFunctionCall1,
+ expr: &seqExpr{
+ pos: position{line: 378, col: 4, offset: 7922},
+ exprs: []interface{}{
+ &labeledExpr{
+ pos: position{line: 378, col: 4, offset: 7922},
+ label: "i",
+ expr: &ruleRefExpr{
+ pos: position{line: 378, col: 6, offset: 7924},
+ name: "Identifier",
+ },
+ },
+ &ruleRefExpr{
+ pos: position{line: 378, col: 17, offset: 7935},
+ name: "_",
+ },
+ &litMatcher{
+ pos: position{line: 378, col: 19, offset: 7937},
+ val: "(",
+ ignoreCase: false,
+ },
+ &ruleRefExpr{
+ pos: position{line: 378, col: 23, offset: 7941},
+ name: "_",
+ },
+ &labeledExpr{
+ pos: position{line: 378, col: 25, offset: 7943},
+ label: "r",
+ expr: &zeroOrOneExpr{
+ pos: position{line: 378, col: 27, offset: 7945},
+ expr: &ruleRefExpr{
+ pos: position{line: 378, col: 27, offset: 7945},
+ name: "FunctionArgs",
+ },
+ },
+ },
+ &ruleRefExpr{
+ pos: position{line: 378, col: 41, offset: 7959},
+ name: "_",
+ },
+ &litMatcher{
+ pos: position{line: 378, col: 43, offset: 7961},
+ val: ")",
+ ignoreCase: false,
+ },
+ },
+ },
+ },
+ },
+ {
+ name: "FunctionArgs",
+ pos: position{line: 381, col: 1, offset: 8039},
+ expr: &choiceExpr{
+ pos: position{line: 382, col: 4, offset: 8055},
+ alternatives: []interface{}{
+ &actionExpr{
+ pos: position{line: 382, col: 4, offset: 8055},
+ run: (*parser).callonFunctionArgs2,
+ expr: &labeledExpr{
+ pos: position{line: 382, col: 4, offset: 8055},
+ label: "a",
+ expr: &ruleRefExpr{
+ pos: position{line: 382, col: 6, offset: 8057},
+ name: "AnyLiteral",
+ },
+ },
+ },
+ &ruleRefExpr{
+ pos: position{line: 383, col: 4, offset: 8104},
+ name: "MultiExpr",
+ },
+ },
+ },
+ },
+ {
+ name: "Assignment",
+ pos: position{line: 385, col: 1, offset: 8115},
+ expr: &actionExpr{
+ pos: position{line: 386, col: 4, offset: 8129},
+ run: (*parser).callonAssignment1,
+ expr: &seqExpr{
+ pos: position{line: 386, col: 4, offset: 8129},
+ exprs: []interface{}{
+ &labeledExpr{
+ pos: position{line: 386, col: 4, offset: 8129},
+ label: "i",
+ expr: &ruleRefExpr{
+ pos: position{line: 386, col: 6, offset: 8131},
+ name: "Identifier",
+ },
+ },
+ &ruleRefExpr{
+ pos: position{line: 386, col: 17, offset: 8142},
+ name: "_",
+ },
+ &litMatcher{
+ pos: position{line: 386, col: 19, offset: 8144},
+ val: "=",
+ ignoreCase: false,
+ },
+ &ruleRefExpr{
+ pos: position{line: 386, col: 23, offset: 8148},
+ name: "_",
+ },
+ &labeledExpr{
+ pos: position{line: 386, col: 25, offset: 8150},
+ label: "e",
+ expr: &ruleRefExpr{
+ pos: position{line: 386, col: 27, offset: 8152},
+ name: "ExprWithDefault",
+ },
+ },
+ },
+ },
+ },
+ },
+ {
+ name: "UnaryOperator",
+ pos: position{line: 390, col: 1, offset: 8255},
+ expr: &ruleRefExpr{
+ pos: position{line: 391, col: 4, offset: 8272},
+ name: "SignOperator",
+ },
+ },
+ {
+ name: "SignOperator",
+ pos: position{line: 393, col: 1, offset: 8286},
+ expr: &actionExpr{
+ pos: position{line: 394, col: 4, offset: 8302},
+ run: (*parser).callonSignOperator1,
+ expr: &ruleRefExpr{
+ pos: position{line: 394, col: 4, offset: 8302},
+ name: "Sign",
+ },
+ },
+ },
+ {
+ name: "NotOperator",
+ pos: position{line: 405, col: 1, offset: 8468},
+ expr: &actionExpr{
+ pos: position{line: 406, col: 4, offset: 8483},
+ run: (*parser).callonNotOperator1,
+ expr: &ruleRefExpr{
+ pos: position{line: 406, col: 4, offset: 8483},
+ name: "NotToken",
+ },
+ },
+ },
+ {
+ name: "AndOperator",
+ pos: position{line: 409, col: 1, offset: 8528},
+ expr: &actionExpr{
+ pos: position{line: 410, col: 4, offset: 8543},
+ run: (*parser).callonAndOperator1,
+ expr: &ruleRefExpr{
+ pos: position{line: 410, col: 4, offset: 8543},
+ name: "AndToken",
+ },
+ },
+ },
+ {
+ name: "OrOperator",
+ pos: position{line: 413, col: 1, offset: 8588},
+ expr: &actionExpr{
+ pos: position{line: 414, col: 4, offset: 8602},
+ run: (*parser).callonOrOperator1,
+ expr: &ruleRefExpr{
+ pos: position{line: 414, col: 4, offset: 8602},
+ name: "OrToken",
+ },
+ },
+ },
+ {
+ name: "CmpOperator",
+ pos: position{line: 417, col: 1, offset: 8645},
+ expr: &actionExpr{
+ pos: position{line: 418, col: 4, offset: 8660},
+ run: (*parser).callonCmpOperator1,
+ expr: &choiceExpr{
+ pos: position{line: 418, col: 6, offset: 8662},
+ alternatives: []interface{}{
+ &litMatcher{
+ pos: position{line: 418, col: 6, offset: 8662},
+ val: "<=",
+ ignoreCase: false,
+ },
+ &litMatcher{
+ pos: position{line: 418, col: 13, offset: 8669},
+ val: ">=",
+ ignoreCase: false,
+ },
+ &litMatcher{
+ pos: position{line: 418, col: 20, offset: 8676},
+ val: "<>",
+ ignoreCase: false,
+ },
+ &litMatcher{
+ pos: position{line: 418, col: 27, offset: 8683},
+ val: "!=",
+ ignoreCase: false,
+ },
+ &charClassMatcher{
+ pos: position{line: 418, col: 34, offset: 8690},
+ val: "[<>=]",
+ chars: []rune{'<', '>', '='},
+ ignoreCase: false,
+ inverted: false,
+ },
+ },
+ },
+ },
+ },
+ {
+ name: "ConcatOperator",
+ pos: position{line: 439, col: 1, offset: 9118},
+ expr: &actionExpr{
+ pos: position{line: 440, col: 4, offset: 9136},
+ run: (*parser).callonConcatOperator1,
+ expr: &litMatcher{
+ pos: position{line: 440, col: 4, offset: 9136},
+ val: "||",
+ ignoreCase: false,
+ },
+ },
+ },
+ {
+ name: "AddSubOperator",
+ pos: position{line: 443, col: 1, offset: 9180},
+ expr: &actionExpr{
+ pos: position{line: 444, col: 4, offset: 9198},
+ run: (*parser).callonAddSubOperator1,
+ expr: &charClassMatcher{
+ pos: position{line: 444, col: 4, offset: 9198},
+ val: "[+-]",
+ chars: []rune{'+', '-'},
+ ignoreCase: false,
+ inverted: false,
+ },
+ },
+ },
+ {
+ name: "MulDivModOperator",
+ pos: position{line: 455, col: 1, offset: 9367},
+ expr: &actionExpr{
+ pos: position{line: 456, col: 4, offset: 9388},
+ run: (*parser).callonMulDivModOperator1,
+ expr: &charClassMatcher{
+ pos: position{line: 456, col: 4, offset: 9388},
+ val: "[*/%]",
+ chars: []rune{'*', '/', '%'},
+ ignoreCase: false,
+ inverted: false,
+ },
+ },
+ },
+ {
+ name: "DataType",
+ pos: position{line: 470, col: 1, offset: 9617},
+ expr: &choiceExpr{
+ pos: position{line: 471, col: 4, offset: 9629},
+ alternatives: []interface{}{
+ &ruleRefExpr{
+ pos: position{line: 471, col: 4, offset: 9629},
+ name: "UIntType",
+ },
+ &ruleRefExpr{
+ pos: position{line: 472, col: 4, offset: 9641},
+ name: "IntType",
+ },
+ &ruleRefExpr{
+ pos: position{line: 473, col: 4, offset: 9652},
+ name: "UFixedType",
+ },
+ &ruleRefExpr{
+ pos: position{line: 474, col: 4, offset: 9666},
+ name: "FixedType",
+ },
+ &ruleRefExpr{
+ pos: position{line: 475, col: 4, offset: 9679},
+ name: "FixedBytesType",
+ },
+ &ruleRefExpr{
+ pos: position{line: 476, col: 4, offset: 9697},
+ name: "DynamicBytesType",
+ },
+ &ruleRefExpr{
+ pos: position{line: 477, col: 4, offset: 9717},
+ name: "BoolType",
+ },
+ &ruleRefExpr{
+ pos: position{line: 478, col: 4, offset: 9729},
+ name: "AddressType",
+ },
+ },
+ },
+ },
+ {
+ name: "UIntType",
+ pos: position{line: 480, col: 1, offset: 9742},
+ expr: &actionExpr{
+ pos: position{line: 481, col: 4, offset: 9754},
+ run: (*parser).callonUIntType1,
+ expr: &seqExpr{
+ pos: position{line: 481, col: 4, offset: 9754},
+ exprs: []interface{}{
+ &litMatcher{
+ pos: position{line: 481, col: 4, offset: 9754},
+ val: "uint",
+ ignoreCase: true,
+ },
+ &labeledExpr{
+ pos: position{line: 481, col: 12, offset: 9762},
+ label: "s",
+ expr: &ruleRefExpr{
+ pos: position{line: 481, col: 14, offset: 9764},
+ name: "NonZeroLeadingInteger",
+ },
+ },
+ &notExpr{
+ pos: position{line: 481, col: 36, offset: 9786},
+ expr: &ruleRefExpr{
+ pos: position{line: 481, col: 37, offset: 9787},
+ name: "NormalIdentifierRest",
+ },
+ },
+ },
+ },
+ },
+ },
+ {
+ name: "IntType",
+ pos: position{line: 484, col: 1, offset: 9878},
+ expr: &actionExpr{
+ pos: position{line: 485, col: 4, offset: 9889},
+ run: (*parser).callonIntType1,
+ expr: &seqExpr{
+ pos: position{line: 485, col: 4, offset: 9889},
+ exprs: []interface{}{
+ &litMatcher{
+ pos: position{line: 485, col: 4, offset: 9889},
+ val: "int",
+ ignoreCase: true,
+ },
+ &labeledExpr{
+ pos: position{line: 485, col: 11, offset: 9896},
+ label: "s",
+ expr: &ruleRefExpr{
+ pos: position{line: 485, col: 13, offset: 9898},
+ name: "NonZeroLeadingInteger",
+ },
+ },
+ &notExpr{
+ pos: position{line: 485, col: 35, offset: 9920},
+ expr: &ruleRefExpr{
+ pos: position{line: 485, col: 36, offset: 9921},
+ name: "NormalIdentifierRest",
+ },
+ },
+ },
+ },
+ },
+ },
+ {
+ name: "UFixedType",
+ pos: position{line: 488, col: 1, offset: 9996},
+ expr: &actionExpr{
+ pos: position{line: 489, col: 4, offset: 10010},
+ run: (*parser).callonUFixedType1,
+ expr: &seqExpr{
+ pos: position{line: 489, col: 4, offset: 10010},
+ exprs: []interface{}{
+ &litMatcher{
+ pos: position{line: 489, col: 4, offset: 10010},
+ val: "ufixed",
+ ignoreCase: true,
+ },
+ &labeledExpr{
+ pos: position{line: 489, col: 14, offset: 10020},
+ label: "s",
+ expr: &ruleRefExpr{
+ pos: position{line: 489, col: 16, offset: 10022},
+ name: "NonZeroLeadingInteger",
+ },
+ },
+ &litMatcher{
+ pos: position{line: 489, col: 38, offset: 10044},
+ val: "x",
+ ignoreCase: true,
+ },
+ &labeledExpr{
+ pos: position{line: 489, col: 43, offset: 10049},
+ label: "t",
+ expr: &ruleRefExpr{
+ pos: position{line: 489, col: 45, offset: 10051},
+ name: "NonZeroLeadingInteger",
+ },
+ },
+ &notExpr{
+ pos: position{line: 489, col: 67, offset: 10073},
+ expr: &ruleRefExpr{
+ pos: position{line: 489, col: 68, offset: 10074},
+ name: "NormalIdentifierRest",
+ },
+ },
+ },
+ },
+ },
+ },
+ {
+ name: "FixedType",
+ pos: position{line: 498, col: 1, offset: 10229},
+ expr: &actionExpr{
+ pos: position{line: 499, col: 4, offset: 10242},
+ run: (*parser).callonFixedType1,
+ expr: &seqExpr{
+ pos: position{line: 499, col: 4, offset: 10242},
+ exprs: []interface{}{
+ &litMatcher{
+ pos: position{line: 499, col: 4, offset: 10242},
+ val: "fixed",
+ ignoreCase: true,
+ },
+ &labeledExpr{
+ pos: position{line: 499, col: 13, offset: 10251},
+ label: "s",
+ expr: &ruleRefExpr{
+ pos: position{line: 499, col: 15, offset: 10253},
+ name: "NonZeroLeadingInteger",
+ },
+ },
+ &litMatcher{
+ pos: position{line: 499, col: 37, offset: 10275},
+ val: "x",
+ ignoreCase: true,
+ },
+ &labeledExpr{
+ pos: position{line: 499, col: 42, offset: 10280},
+ label: "t",
+ expr: &ruleRefExpr{
+ pos: position{line: 499, col: 44, offset: 10282},
+ name: "NonZeroLeadingInteger",
+ },
+ },
+ &notExpr{
+ pos: position{line: 499, col: 66, offset: 10304},
+ expr: &ruleRefExpr{
+ pos: position{line: 499, col: 67, offset: 10305},
+ name: "NormalIdentifierRest",
+ },
+ },
+ },
+ },
+ },
+ },
+ {
+ name: "FixedBytesType",
+ pos: position{line: 507, col: 1, offset: 10436},
+ expr: &choiceExpr{
+ pos: position{line: 508, col: 4, offset: 10454},
+ alternatives: []interface{}{
+ &actionExpr{
+ pos: position{line: 508, col: 4, offset: 10454},
+ run: (*parser).callonFixedBytesType2,
+ expr: &seqExpr{
+ pos: position{line: 508, col: 4, offset: 10454},
+ exprs: []interface{}{
+ &litMatcher{
+ pos: position{line: 508, col: 4, offset: 10454},
+ val: "bytes",
+ ignoreCase: true,
+ },
+ &labeledExpr{
+ pos: position{line: 508, col: 13, offset: 10463},
+ label: "s",
+ expr: &ruleRefExpr{
+ pos: position{line: 508, col: 15, offset: 10465},
+ name: "NonZeroLeadingInteger",
+ },
+ },
+ &notExpr{
+ pos: position{line: 508, col: 37, offset: 10487},
+ expr: &ruleRefExpr{
+ pos: position{line: 508, col: 38, offset: 10488},
+ name: "NormalIdentifierRest",
+ },
+ },
+ },
+ },
+ },
+ &actionExpr{
+ pos: position{line: 510, col: 4, offset: 10572},
+ run: (*parser).callonFixedBytesType9,
+ expr: &seqExpr{
+ pos: position{line: 510, col: 4, offset: 10572},
+ exprs: []interface{}{
+ &litMatcher{
+ pos: position{line: 510, col: 4, offset: 10572},
+ val: "byte",
+ ignoreCase: true,
+ },
+ &notExpr{
+ pos: position{line: 510, col: 12, offset: 10580},
+ expr: &ruleRefExpr{
+ pos: position{line: 510, col: 13, offset: 10581},
+ name: "NormalIdentifierRest",
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ {
+ name: "DynamicBytesType",
+ pos: position{line: 513, col: 1, offset: 10647},
+ expr: &actionExpr{
+ pos: position{line: 514, col: 4, offset: 10667},
+ run: (*parser).callonDynamicBytesType1,
+ expr: &choiceExpr{
+ pos: position{line: 514, col: 6, offset: 10669},
+ alternatives: []interface{}{
+ &seqExpr{
+ pos: position{line: 514, col: 6, offset: 10669},
+ exprs: []interface{}{
+ &litMatcher{
+ pos: position{line: 514, col: 6, offset: 10669},
+ val: "bytes",
+ ignoreCase: true,
+ },
+ &notExpr{
+ pos: position{line: 514, col: 15, offset: 10678},
+ expr: &ruleRefExpr{
+ pos: position{line: 514, col: 16, offset: 10679},
+ name: "NormalIdentifierRest",
+ },
+ },
+ },
+ },
+ &seqExpr{
+ pos: position{line: 515, col: 5, offset: 10704},
+ exprs: []interface{}{
+ &litMatcher{
+ pos: position{line: 515, col: 5, offset: 10704},
+ val: "string",
+ ignoreCase: true,
+ },
+ &notExpr{
+ pos: position{line: 515, col: 15, offset: 10714},
+ expr: &ruleRefExpr{
+ pos: position{line: 515, col: 16, offset: 10715},
+ name: "NormalIdentifierRest",
+ },
+ },
+ },
+ },
+ &seqExpr{
+ pos: position{line: 516, col: 5, offset: 10740},
+ exprs: []interface{}{
+ &litMatcher{
+ pos: position{line: 516, col: 5, offset: 10740},
+ val: "text",
+ ignoreCase: true,
+ },
+ &notExpr{
+ pos: position{line: 516, col: 13, offset: 10748},
+ expr: &ruleRefExpr{
+ pos: position{line: 516, col: 14, offset: 10749},
+ name: "NormalIdentifierRest",
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ {
+ name: "AddressType",
+ pos: position{line: 520, col: 1, offset: 10813},
+ expr: &actionExpr{
+ pos: position{line: 521, col: 4, offset: 10828},
+ run: (*parser).callonAddressType1,
+ expr: &seqExpr{
+ pos: position{line: 521, col: 4, offset: 10828},
+ exprs: []interface{}{
+ &litMatcher{
+ pos: position{line: 521, col: 4, offset: 10828},
+ val: "address",
+ ignoreCase: true,
+ },
+ &notExpr{
+ pos: position{line: 521, col: 15, offset: 10839},
+ expr: &ruleRefExpr{
+ pos: position{line: 521, col: 16, offset: 10840},
+ name: "NormalIdentifierRest",
+ },
+ },
+ },
+ },
+ },
+ },
+ {
+ name: "BoolType",
+ pos: position{line: 524, col: 1, offset: 10896},
+ expr: &actionExpr{
+ pos: position{line: 525, col: 4, offset: 10908},
+ run: (*parser).callonBoolType1,
+ expr: &choiceExpr{
+ pos: position{line: 525, col: 6, offset: 10910},
+ alternatives: []interface{}{
+ &seqExpr{
+ pos: position{line: 525, col: 6, offset: 10910},
+ exprs: []interface{}{
+ &litMatcher{
+ pos: position{line: 525, col: 6, offset: 10910},
+ val: "bool",
+ ignoreCase: true,
+ },
+ &notExpr{
+ pos: position{line: 525, col: 14, offset: 10918},
+ expr: &ruleRefExpr{
+ pos: position{line: 525, col: 15, offset: 10919},
+ name: "NormalIdentifierRest",
+ },
+ },
+ },
+ },
+ &seqExpr{
+ pos: position{line: 526, col: 5, offset: 10944},
+ exprs: []interface{}{
+ &litMatcher{
+ pos: position{line: 526, col: 5, offset: 10944},
+ val: "boolean",
+ ignoreCase: true,
+ },
+ &notExpr{
+ pos: position{line: 526, col: 16, offset: 10955},
+ expr: &ruleRefExpr{
+ pos: position{line: 526, col: 17, offset: 10956},
+ name: "NormalIdentifierRest",
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ {
+ name: "Value",
+ pos: position{line: 531, col: 1, offset: 11024},
+ expr: &choiceExpr{
+ pos: position{line: 532, col: 4, offset: 11033},
+ alternatives: []interface{}{
+ &ruleRefExpr{
+ pos: position{line: 532, col: 4, offset: 11033},
+ name: "NumberLiteral",
+ },
+ &ruleRefExpr{
+ pos: position{line: 533, col: 4, offset: 11050},
+ name: "StringLiteral",
+ },
+ &ruleRefExpr{
+ pos: position{line: 534, col: 4, offset: 11067},
+ name: "BoolLiteral",
+ },
+ &ruleRefExpr{
+ pos: position{line: 535, col: 4, offset: 11082},
+ name: "NullLiteral",
+ },
+ },
+ },
+ },
+ {
+ name: "AnyLiteral",
+ pos: position{line: 537, col: 1, offset: 11095},
+ expr: &actionExpr{
+ pos: position{line: 538, col: 4, offset: 11109},
+ run: (*parser).callonAnyLiteral1,
+ expr: &ruleRefExpr{
+ pos: position{line: 538, col: 4, offset: 11109},
+ name: "AnyToken",
+ },
+ },
+ },
+ {
+ name: "DefaultLiteral",
+ pos: position{line: 541, col: 1, offset: 11150},
+ expr: &actionExpr{
+ pos: position{line: 542, col: 4, offset: 11168},
+ run: (*parser).callonDefaultLiteral1,
+ expr: &ruleRefExpr{
+ pos: position{line: 542, col: 4, offset: 11168},
+ name: "DefaultToken",
+ },
+ },
+ },
+ {
+ name: "BoolLiteral",
+ pos: position{line: 545, col: 1, offset: 11217},
+ expr: &actionExpr{
+ pos: position{line: 546, col: 4, offset: 11232},
+ run: (*parser).callonBoolLiteral1,
+ expr: &labeledExpr{
+ pos: position{line: 546, col: 4, offset: 11232},
+ label: "b",
+ expr: &choiceExpr{
+ pos: position{line: 546, col: 8, offset: 11236},
+ alternatives: []interface{}{
+ &ruleRefExpr{
+ pos: position{line: 546, col: 8, offset: 11236},
+ name: "TrueToken",
+ },
+ &ruleRefExpr{
+ pos: position{line: 546, col: 20, offset: 11248},
+ name: "FalseToken",
+ },
+ },
+ },
+ },
+ },
+ },
+ {
+ name: "NullLiteral",
+ pos: position{line: 549, col: 1, offset: 11322},
+ expr: &actionExpr{
+ pos: position{line: 550, col: 4, offset: 11337},
+ run: (*parser).callonNullLiteral1,
+ expr: &ruleRefExpr{
+ pos: position{line: 550, col: 4, offset: 11337},
+ name: "NullToken",
+ },
+ },
+ },
+ {
+ name: "NumberLiteral",
+ pos: position{line: 553, col: 1, offset: 11380},
+ expr: &choiceExpr{
+ pos: position{line: 554, col: 4, offset: 11397},
+ alternatives: []interface{}{
+ &actionExpr{
+ pos: position{line: 554, col: 4, offset: 11397},
+ run: (*parser).callonNumberLiteral2,
+ expr: &seqExpr{
+ pos: position{line: 554, col: 4, offset: 11397},
+ exprs: []interface{}{
+ &andExpr{
+ pos: position{line: 554, col: 4, offset: 11397},
+ expr: &seqExpr{
+ pos: position{line: 554, col: 6, offset: 11399},
+ exprs: []interface{}{
+ &litMatcher{
+ pos: position{line: 554, col: 6, offset: 11399},
+ val: "0",
+ ignoreCase: false,
+ },
+ &litMatcher{
+ pos: position{line: 554, col: 10, offset: 11403},
+ val: "x",
+ ignoreCase: true,
+ },
+ },
+ },
+ },
+ &labeledExpr{
+ pos: position{line: 554, col: 16, offset: 11409},
+ label: "h",
+ expr: &ruleRefExpr{
+ pos: position{line: 554, col: 18, offset: 11411},
+ name: "Hex",
+ },
+ },
+ },
+ },
+ },
+ &ruleRefExpr{
+ pos: position{line: 555, col: 4, offset: 11436},
+ name: "Decimal",
+ },
+ },
+ },
+ },
+ {
+ name: "Sign",
+ pos: position{line: 557, col: 1, offset: 11445},
+ expr: &charClassMatcher{
+ pos: position{line: 558, col: 4, offset: 11453},
+ val: "[-+]",
+ chars: []rune{'-', '+'},
+ ignoreCase: false,
+ inverted: false,
+ },
+ },
+ {
+ name: "Integer",
+ pos: position{line: 560, col: 1, offset: 11459},
+ expr: &actionExpr{
+ pos: position{line: 561, col: 4, offset: 11470},
+ run: (*parser).callonInteger1,
+ expr: &oneOrMoreExpr{
+ pos: position{line: 561, col: 4, offset: 11470},
+ expr: &charClassMatcher{
+ pos: position{line: 561, col: 4, offset: 11470},
+ val: "[0-9]",
+ ranges: []rune{'0', '9'},
+ ignoreCase: false,
+ inverted: false,
+ },
+ },
+ },
+ },
+ {
+ name: "NonZeroLeadingInteger",
+ pos: position{line: 564, col: 1, offset: 11533},
+ expr: &actionExpr{
+ pos: position{line: 565, col: 4, offset: 11558},
+ run: (*parser).callonNonZeroLeadingInteger1,
+ expr: &choiceExpr{
+ pos: position{line: 565, col: 6, offset: 11560},
+ alternatives: []interface{}{
+ &litMatcher{
+ pos: position{line: 565, col: 6, offset: 11560},
+ val: "0",
+ ignoreCase: false,
+ },
+ &seqExpr{
+ pos: position{line: 565, col: 12, offset: 11566},
+ exprs: []interface{}{
+ &charClassMatcher{
+ pos: position{line: 565, col: 12, offset: 11566},
+ val: "[1-9]",
+ ranges: []rune{'1', '9'},
+ ignoreCase: false,
+ inverted: false,
+ },
+ &zeroOrMoreExpr{
+ pos: position{line: 565, col: 17, offset: 11571},
+ expr: &charClassMatcher{
+ pos: position{line: 565, col: 17, offset: 11571},
+ val: "[0-9]",
+ ranges: []rune{'0', '9'},
+ ignoreCase: false,
+ inverted: false,
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ {
+ name: "Fixnum",
+ pos: position{line: 568, col: 1, offset: 11604},
+ expr: &choiceExpr{
+ pos: position{line: 569, col: 4, offset: 11614},
+ alternatives: []interface{}{
+ &seqExpr{
+ pos: position{line: 569, col: 4, offset: 11614},
+ exprs: []interface{}{
+ &ruleRefExpr{
+ pos: position{line: 569, col: 4, offset: 11614},
+ name: "Integer",
+ },
+ &litMatcher{
+ pos: position{line: 569, col: 12, offset: 11622},
+ val: ".",
+ ignoreCase: false,
+ },
+ &ruleRefExpr{
+ pos: position{line: 569, col: 16, offset: 11626},
+ name: "Integer",
+ },
+ },
+ },
+ &seqExpr{
+ pos: position{line: 570, col: 4, offset: 11637},
+ exprs: []interface{}{
+ &ruleRefExpr{
+ pos: position{line: 570, col: 4, offset: 11637},
+ name: "Integer",
+ },
+ &zeroOrOneExpr{
+ pos: position{line: 570, col: 12, offset: 11645},
+ expr: &litMatcher{
+ pos: position{line: 570, col: 12, offset: 11645},
+ val: ".",
+ ignoreCase: false,
+ },
+ },
+ },
+ },
+ &seqExpr{
+ pos: position{line: 571, col: 4, offset: 11653},
+ exprs: []interface{}{
+ &litMatcher{
+ pos: position{line: 571, col: 4, offset: 11653},
+ val: ".",
+ ignoreCase: false,
+ },
+ &ruleRefExpr{
+ pos: position{line: 571, col: 8, offset: 11657},
+ name: "Integer",
+ },
+ },
+ },
+ },
+ },
+ },
+ {
+ name: "Decimal",
+ pos: position{line: 573, col: 1, offset: 11666},
+ expr: &actionExpr{
+ pos: position{line: 574, col: 4, offset: 11677},
+ run: (*parser).callonDecimal1,
+ expr: &seqExpr{
+ pos: position{line: 574, col: 4, offset: 11677},
+ exprs: []interface{}{
+ &ruleRefExpr{
+ pos: position{line: 574, col: 4, offset: 11677},
+ name: "Fixnum",
+ },
+ &zeroOrOneExpr{
+ pos: position{line: 574, col: 11, offset: 11684},
+ expr: &seqExpr{
+ pos: position{line: 574, col: 13, offset: 11686},
+ exprs: []interface{}{
+ &litMatcher{
+ pos: position{line: 574, col: 13, offset: 11686},
+ val: "e",
+ ignoreCase: true,
+ },
+ &zeroOrOneExpr{
+ pos: position{line: 574, col: 18, offset: 11691},
+ expr: &ruleRefExpr{
+ pos: position{line: 574, col: 18, offset: 11691},
+ name: "Sign",
+ },
+ },
+ &ruleRefExpr{
+ pos: position{line: 574, col: 24, offset: 11697},
+ name: "Integer",
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ {
+ name: "Hex",
+ pos: position{line: 577, col: 1, offset: 11761},
+ expr: &actionExpr{
+ pos: position{line: 578, col: 4, offset: 11768},
+ run: (*parser).callonHex1,
+ expr: &seqExpr{
+ pos: position{line: 578, col: 4, offset: 11768},
+ exprs: []interface{}{
+ &litMatcher{
+ pos: position{line: 578, col: 4, offset: 11768},
+ val: "0",
+ ignoreCase: false,
+ },
+ &litMatcher{
+ pos: position{line: 578, col: 8, offset: 11772},
+ val: "x",
+ ignoreCase: true,
+ },
+ &labeledExpr{
+ pos: position{line: 578, col: 13, offset: 11777},
+ label: "s",
+ expr: &oneOrMoreExpr{
+ pos: position{line: 578, col: 15, offset: 11779},
+ expr: &charClassMatcher{
+ pos: position{line: 578, col: 17, offset: 11781},
+ val: "[0-9A-Fa-f]",
+ ranges: []rune{'0', '9', 'A', 'F', 'a', 'f'},
+ ignoreCase: false,
+ inverted: false,
+ },
+ },
+ },
+ &notExpr{
+ pos: position{line: 578, col: 32, offset: 11796},
+ expr: &ruleRefExpr{
+ pos: position{line: 578, col: 33, offset: 11797},
+ name: "NormalIdentifierRest",
+ },
+ },
+ },
+ },
+ },
+ },
+ {
+ name: "StringLiteral",
+ pos: position{line: 581, col: 1, offset: 11862},
+ expr: &choiceExpr{
+ pos: position{line: 582, col: 4, offset: 11879},
+ alternatives: []interface{}{
+ &ruleRefExpr{
+ pos: position{line: 582, col: 4, offset: 11879},
+ name: "HexString",
+ },
+ &ruleRefExpr{
+ pos: position{line: 583, col: 4, offset: 11892},
+ name: "NormalString",
+ },
+ },
+ },
+ },
+ {
+ name: "HexString",
+ pos: position{line: 585, col: 1, offset: 11906},
+ expr: &actionExpr{
+ pos: position{line: 586, col: 4, offset: 11919},
+ run: (*parser).callonHexString1,
+ expr: &seqExpr{
+ pos: position{line: 586, col: 4, offset: 11919},
+ exprs: []interface{}{
+ &choiceExpr{
+ pos: position{line: 586, col: 6, offset: 11921},
+ alternatives: []interface{}{
+ &litMatcher{
+ pos: position{line: 586, col: 6, offset: 11921},
+ val: "hex",
+ ignoreCase: true,
+ },
+ &litMatcher{
+ pos: position{line: 586, col: 15, offset: 11930},
+ val: "x",
+ ignoreCase: true,
+ },
+ },
+ },
+ &litMatcher{
+ pos: position{line: 586, col: 22, offset: 11937},
+ val: "'",
+ ignoreCase: false,
+ },
+ &labeledExpr{
+ pos: position{line: 586, col: 26, offset: 11941},
+ label: "s",
+ expr: &zeroOrMoreExpr{
+ pos: position{line: 586, col: 28, offset: 11943},
+ expr: &actionExpr{
+ pos: position{line: 586, col: 29, offset: 11944},
+ run: (*parser).callonHexString9,
+ expr: &seqExpr{
+ pos: position{line: 586, col: 29, offset: 11944},
+ exprs: []interface{}{
+ &charClassMatcher{
+ pos: position{line: 586, col: 29, offset: 11944},
+ val: "[0-9a-fA-F]",
+ ranges: []rune{'0', '9', 'a', 'f', 'A', 'F'},
+ ignoreCase: false,
+ inverted: false,
+ },
+ &charClassMatcher{
+ pos: position{line: 586, col: 40, offset: 11955},
+ val: "[0-9a-fA-F]",
+ ranges: []rune{'0', '9', 'a', 'f', 'A', 'F'},
+ ignoreCase: false,
+ inverted: false,
+ },
+ },
+ },
+ },
+ },
+ },
+ &litMatcher{
+ pos: position{line: 586, col: 78, offset: 11993},
+ val: "'",
+ ignoreCase: false,
+ },
+ },
+ },
+ },
+ },
+ {
+ name: "NormalString",
+ pos: position{line: 589, col: 1, offset: 12055},
+ expr: &actionExpr{
+ pos: position{line: 590, col: 4, offset: 12071},
+ run: (*parser).callonNormalString1,
+ expr: &seqExpr{
+ pos: position{line: 590, col: 4, offset: 12071},
+ exprs: []interface{}{
+ &litMatcher{
+ pos: position{line: 590, col: 4, offset: 12071},
+ val: "'",
+ ignoreCase: false,
+ },
+ &labeledExpr{
+ pos: position{line: 590, col: 8, offset: 12075},
+ label: "s",
+ expr: &zeroOrMoreExpr{
+ pos: position{line: 590, col: 10, offset: 12077},
+ expr: &actionExpr{
+ pos: position{line: 590, col: 12, offset: 12079},
+ run: (*parser).callonNormalString6,
+ expr: &choiceExpr{
+ pos: position{line: 590, col: 14, offset: 12081},
+ alternatives: []interface{}{
+ &charClassMatcher{
+ pos: position{line: 590, col: 14, offset: 12081},
+ val: "[^'\\r\\n\\\\]",
+ chars: []rune{'\'', '\r', '\n', '\\'},
+ ignoreCase: false,
+ inverted: true,
+ },
+ &seqExpr{
+ pos: position{line: 590, col: 27, offset: 12094},
+ exprs: []interface{}{
+ &litMatcher{
+ pos: position{line: 590, col: 27, offset: 12094},
+ val: "\\",
+ ignoreCase: false,
+ },
+ &anyMatcher{
+ line: 590, col: 32, offset: 12099,
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ &litMatcher{
+ pos: position{line: 590, col: 62, offset: 12129},
+ val: "'",
+ ignoreCase: false,
+ },
+ },
+ },
+ },
+ },
+ {
+ name: "SelectToken",
+ pos: position{line: 594, col: 1, offset: 12206},
+ expr: &seqExpr{
+ pos: position{line: 595, col: 4, offset: 12221},
+ exprs: []interface{}{
+ &litMatcher{
+ pos: position{line: 595, col: 4, offset: 12221},
+ val: "select",
+ ignoreCase: true,
+ },
+ &notExpr{
+ pos: position{line: 595, col: 14, offset: 12231},
+ expr: &ruleRefExpr{
+ pos: position{line: 595, col: 15, offset: 12232},
+ name: "NormalIdentifierRest",
+ },
+ },
+ },
+ },
+ },
+ {
+ name: "FromToken",
+ pos: position{line: 597, col: 1, offset: 12254},
+ expr: &seqExpr{
+ pos: position{line: 598, col: 4, offset: 12267},
+ exprs: []interface{}{
+ &litMatcher{
+ pos: position{line: 598, col: 4, offset: 12267},
+ val: "from",
+ ignoreCase: true,
+ },
+ &notExpr{
+ pos: position{line: 598, col: 12, offset: 12275},
+ expr: &ruleRefExpr{
+ pos: position{line: 598, col: 13, offset: 12276},
+ name: "NormalIdentifierRest",
+ },
+ },
+ },
+ },
+ },
+ {
+ name: "WhereToken",
+ pos: position{line: 600, col: 1, offset: 12298},
+ expr: &seqExpr{
+ pos: position{line: 601, col: 4, offset: 12312},
+ exprs: []interface{}{
+ &litMatcher{
+ pos: position{line: 601, col: 4, offset: 12312},
+ val: "where",
+ ignoreCase: true,
+ },
+ &notExpr{
+ pos: position{line: 601, col: 13, offset: 12321},
+ expr: &ruleRefExpr{
+ pos: position{line: 601, col: 14, offset: 12322},
+ name: "NormalIdentifierRest",
+ },
+ },
+ },
+ },
+ },
+ {
+ name: "OrderToken",
+ pos: position{line: 603, col: 1, offset: 12344},
+ expr: &seqExpr{
+ pos: position{line: 604, col: 4, offset: 12358},
+ exprs: []interface{}{
+ &litMatcher{
+ pos: position{line: 604, col: 4, offset: 12358},
+ val: "order",
+ ignoreCase: true,
+ },
+ &notExpr{
+ pos: position{line: 604, col: 13, offset: 12367},
+ expr: &ruleRefExpr{
+ pos: position{line: 604, col: 14, offset: 12368},
+ name: "NormalIdentifierRest",
+ },
+ },
+ },
+ },
+ },
+ {
+ name: "ByToken",
+ pos: position{line: 606, col: 1, offset: 12390},
+ expr: &seqExpr{
+ pos: position{line: 607, col: 4, offset: 12401},
+ exprs: []interface{}{
+ &litMatcher{
+ pos: position{line: 607, col: 4, offset: 12401},
+ val: "by",
+ ignoreCase: true,
+ },
+ &notExpr{
+ pos: position{line: 607, col: 10, offset: 12407},
+ expr: &ruleRefExpr{
+ pos: position{line: 607, col: 11, offset: 12408},
+ name: "NormalIdentifierRest",
+ },
+ },
+ },
+ },
+ },
+ {
+ name: "GroupToken",
+ pos: position{line: 609, col: 1, offset: 12430},
+ expr: &seqExpr{
+ pos: position{line: 610, col: 4, offset: 12444},
+ exprs: []interface{}{
+ &litMatcher{
+ pos: position{line: 610, col: 4, offset: 12444},
+ val: "group",
+ ignoreCase: true,
+ },
+ &notExpr{
+ pos: position{line: 610, col: 13, offset: 12453},
+ expr: &ruleRefExpr{
+ pos: position{line: 610, col: 14, offset: 12454},
+ name: "NormalIdentifierRest",
+ },
+ },
+ },
+ },
+ },
+ {
+ name: "LimitToken",
+ pos: position{line: 612, col: 1, offset: 12476},
+ expr: &seqExpr{
+ pos: position{line: 613, col: 4, offset: 12490},
+ exprs: []interface{}{
+ &litMatcher{
+ pos: position{line: 613, col: 4, offset: 12490},
+ val: "limit",
+ ignoreCase: true,
+ },
+ &notExpr{
+ pos: position{line: 613, col: 13, offset: 12499},
+ expr: &ruleRefExpr{
+ pos: position{line: 613, col: 14, offset: 12500},
+ name: "NormalIdentifierRest",
+ },
+ },
+ },
+ },
+ },
+ {
+ name: "OffsetToken",
+ pos: position{line: 615, col: 1, offset: 12522},
+ expr: &seqExpr{
+ pos: position{line: 616, col: 4, offset: 12537},
+ exprs: []interface{}{
+ &litMatcher{
+ pos: position{line: 616, col: 4, offset: 12537},
+ val: "offset",
+ ignoreCase: true,
+ },
+ &notExpr{
+ pos: position{line: 616, col: 14, offset: 12547},
+ expr: &ruleRefExpr{
+ pos: position{line: 616, col: 15, offset: 12548},
+ name: "NormalIdentifierRest",
+ },
+ },
+ },
+ },
+ },
+ {
+ name: "UpdateToken",
+ pos: position{line: 618, col: 1, offset: 12570},
+ expr: &seqExpr{
+ pos: position{line: 619, col: 4, offset: 12585},
+ exprs: []interface{}{
+ &litMatcher{
+ pos: position{line: 619, col: 4, offset: 12585},
+ val: "update",
+ ignoreCase: true,
+ },
+ &notExpr{
+ pos: position{line: 619, col: 14, offset: 12595},
+ expr: &ruleRefExpr{
+ pos: position{line: 619, col: 15, offset: 12596},
+ name: "NormalIdentifierRest",
+ },
+ },
+ },
+ },
+ },
+ {
+ name: "SetToken",
+ pos: position{line: 621, col: 1, offset: 12618},
+ expr: &seqExpr{
+ pos: position{line: 622, col: 4, offset: 12630},
+ exprs: []interface{}{
+ &litMatcher{
+ pos: position{line: 622, col: 4, offset: 12630},
+ val: "set",
+ ignoreCase: true,
+ },
+ &notExpr{
+ pos: position{line: 622, col: 11, offset: 12637},
+ expr: &ruleRefExpr{
+ pos: position{line: 622, col: 12, offset: 12638},
+ name: "NormalIdentifierRest",
+ },
+ },
+ },
+ },
+ },
+ {
+ name: "DeleteToken",
+ pos: position{line: 624, col: 1, offset: 12660},
+ expr: &seqExpr{
+ pos: position{line: 625, col: 4, offset: 12675},
+ exprs: []interface{}{
+ &litMatcher{
+ pos: position{line: 625, col: 4, offset: 12675},
+ val: "delete",
+ ignoreCase: true,
+ },
+ &notExpr{
+ pos: position{line: 625, col: 14, offset: 12685},
+ expr: &ruleRefExpr{
+ pos: position{line: 625, col: 15, offset: 12686},
+ name: "NormalIdentifierRest",
+ },
+ },
+ },
+ },
+ },
+ {
+ name: "InsertToken",
+ pos: position{line: 627, col: 1, offset: 12708},
+ expr: &seqExpr{
+ pos: position{line: 628, col: 4, offset: 12723},
+ exprs: []interface{}{
+ &litMatcher{
+ pos: position{line: 628, col: 4, offset: 12723},
+ val: "insert",
+ ignoreCase: true,
+ },
+ &notExpr{
+ pos: position{line: 628, col: 14, offset: 12733},
+ expr: &ruleRefExpr{
+ pos: position{line: 628, col: 15, offset: 12734},
+ name: "NormalIdentifierRest",
+ },
+ },
+ },
+ },
+ },
+ {
+ name: "IntoToken",
+ pos: position{line: 630, col: 1, offset: 12756},
+ expr: &seqExpr{
+ pos: position{line: 631, col: 4, offset: 12769},
+ exprs: []interface{}{
+ &litMatcher{
+ pos: position{line: 631, col: 4, offset: 12769},
+ val: "into",
+ ignoreCase: true,
+ },
+ &notExpr{
+ pos: position{line: 631, col: 12, offset: 12777},
+ expr: &ruleRefExpr{
+ pos: position{line: 631, col: 13, offset: 12778},
+ name: "NormalIdentifierRest",
+ },
+ },
+ },
+ },
+ },
+ {
+ name: "ValuesToken",
+ pos: position{line: 633, col: 1, offset: 12800},
+ expr: &seqExpr{
+ pos: position{line: 634, col: 4, offset: 12815},
+ exprs: []interface{}{
+ &litMatcher{
+ pos: position{line: 634, col: 4, offset: 12815},
+ val: "values",
+ ignoreCase: true,
+ },
+ &notExpr{
+ pos: position{line: 634, col: 14, offset: 12825},
+ expr: &ruleRefExpr{
+ pos: position{line: 634, col: 15, offset: 12826},
+ name: "NormalIdentifierRest",
+ },
+ },
+ },
+ },
+ },
+ {
+ name: "CreateToken",
+ pos: position{line: 636, col: 1, offset: 12848},
+ expr: &seqExpr{
+ pos: position{line: 637, col: 4, offset: 12863},
+ exprs: []interface{}{
+ &litMatcher{
+ pos: position{line: 637, col: 4, offset: 12863},
+ val: "create",
+ ignoreCase: true,
+ },
+ &notExpr{
+ pos: position{line: 637, col: 14, offset: 12873},
+ expr: &ruleRefExpr{
+ pos: position{line: 637, col: 15, offset: 12874},
+ name: "NormalIdentifierRest",
+ },
+ },
+ },
+ },
+ },
+ {
+ name: "TableToken",
+ pos: position{line: 639, col: 1, offset: 12896},
+ expr: &seqExpr{
+ pos: position{line: 640, col: 4, offset: 12910},
+ exprs: []interface{}{
+ &litMatcher{
+ pos: position{line: 640, col: 4, offset: 12910},
+ val: "table",
+ ignoreCase: true,
+ },
+ &notExpr{
+ pos: position{line: 640, col: 13, offset: 12919},
+ expr: &ruleRefExpr{
+ pos: position{line: 640, col: 14, offset: 12920},
+ name: "NormalIdentifierRest",
+ },
+ },
+ },
+ },
+ },
+ {
+ name: "IndexToken",
+ pos: position{line: 642, col: 1, offset: 12942},
+ expr: &seqExpr{
+ pos: position{line: 643, col: 4, offset: 12956},
+ exprs: []interface{}{
+ &litMatcher{
+ pos: position{line: 643, col: 4, offset: 12956},
+ val: "index",
+ ignoreCase: true,
+ },
+ &notExpr{
+ pos: position{line: 643, col: 13, offset: 12965},
+ expr: &ruleRefExpr{
+ pos: position{line: 643, col: 14, offset: 12966},
+ name: "NormalIdentifierRest",
+ },
+ },
+ },
+ },
+ },
+ {
+ name: "UniqueToken",
+ pos: position{line: 645, col: 1, offset: 12988},
+ expr: &seqExpr{
+ pos: position{line: 646, col: 4, offset: 13003},
+ exprs: []interface{}{
+ &litMatcher{
+ pos: position{line: 646, col: 4, offset: 13003},
+ val: "unique",
+ ignoreCase: true,
+ },
+ &notExpr{
+ pos: position{line: 646, col: 14, offset: 13013},
+ expr: &ruleRefExpr{
+ pos: position{line: 646, col: 15, offset: 13014},
+ name: "NormalIdentifierRest",
+ },
+ },
+ },
+ },
+ },
+ {
+ name: "DefaultToken",
+ pos: position{line: 648, col: 1, offset: 13036},
+ expr: &seqExpr{
+ pos: position{line: 649, col: 4, offset: 13052},
+ exprs: []interface{}{
+ &litMatcher{
+ pos: position{line: 649, col: 4, offset: 13052},
+ val: "default",
+ ignoreCase: true,
+ },
+ &notExpr{
+ pos: position{line: 649, col: 15, offset: 13063},
+ expr: &ruleRefExpr{
+ pos: position{line: 649, col: 16, offset: 13064},
+ name: "NormalIdentifierRest",
+ },
+ },
+ },
+ },
+ },
+ {
+ name: "PrimaryToken",
+ pos: position{line: 651, col: 1, offset: 13086},
+ expr: &seqExpr{
+ pos: position{line: 652, col: 4, offset: 13102},
+ exprs: []interface{}{
+ &litMatcher{
+ pos: position{line: 652, col: 4, offset: 13102},
+ val: "primary",
+ ignoreCase: true,
+ },
+ &notExpr{
+ pos: position{line: 652, col: 15, offset: 13113},
+ expr: &ruleRefExpr{
+ pos: position{line: 652, col: 16, offset: 13114},
+ name: "NormalIdentifierRest",
+ },
+ },
+ },
+ },
+ },
+ {
+ name: "KeyToken",
+ pos: position{line: 654, col: 1, offset: 13136},
+ expr: &seqExpr{
+ pos: position{line: 655, col: 4, offset: 13148},
+ exprs: []interface{}{
+ &litMatcher{
+ pos: position{line: 655, col: 4, offset: 13148},
+ val: "key",
+ ignoreCase: true,
+ },
+ &notExpr{
+ pos: position{line: 655, col: 11, offset: 13155},
+ expr: &ruleRefExpr{
+ pos: position{line: 655, col: 12, offset: 13156},
+ name: "NormalIdentifierRest",
+ },
+ },
+ },
+ },
+ },
+ {
+ name: "ReferencesToken",
+ pos: position{line: 657, col: 1, offset: 13178},
+ expr: &seqExpr{
+ pos: position{line: 658, col: 4, offset: 13197},
+ exprs: []interface{}{
+ &litMatcher{
+ pos: position{line: 658, col: 4, offset: 13197},
+ val: "references",
+ ignoreCase: true,
+ },
+ &notExpr{
+ pos: position{line: 658, col: 18, offset: 13211},
+ expr: &ruleRefExpr{
+ pos: position{line: 658, col: 19, offset: 13212},
+ name: "NormalIdentifierRest",
+ },
+ },
+ },
+ },
+ },
+ {
+ name: "AutoincrementToken",
+ pos: position{line: 660, col: 1, offset: 13234},
+ expr: &seqExpr{
+ pos: position{line: 661, col: 4, offset: 13256},
+ exprs: []interface{}{
+ &litMatcher{
+ pos: position{line: 661, col: 4, offset: 13256},
+ val: "autoincrement",
+ ignoreCase: true,
+ },
+ &notExpr{
+ pos: position{line: 661, col: 21, offset: 13273},
+ expr: &ruleRefExpr{
+ pos: position{line: 661, col: 22, offset: 13274},
+ name: "NormalIdentifierRest",
+ },
+ },
+ },
+ },
+ },
+ {
+ name: "OnToken",
+ pos: position{line: 663, col: 1, offset: 13296},
+ expr: &seqExpr{
+ pos: position{line: 664, col: 4, offset: 13307},
+ exprs: []interface{}{
+ &litMatcher{
+ pos: position{line: 664, col: 4, offset: 13307},
+ val: "on",
+ ignoreCase: true,
+ },
+ &notExpr{
+ pos: position{line: 664, col: 10, offset: 13313},
+ expr: &ruleRefExpr{
+ pos: position{line: 664, col: 11, offset: 13314},
+ name: "NormalIdentifierRest",
+ },
+ },
+ },
+ },
+ },
+ {
+ name: "TrueToken",
+ pos: position{line: 666, col: 1, offset: 13336},
+ expr: &actionExpr{
+ pos: position{line: 667, col: 4, offset: 13349},
+ run: (*parser).callonTrueToken1,
+ expr: &seqExpr{
+ pos: position{line: 667, col: 4, offset: 13349},
+ exprs: []interface{}{
+ &litMatcher{
+ pos: position{line: 667, col: 4, offset: 13349},
+ val: "true",
+ ignoreCase: true,
+ },
+ &notExpr{
+ pos: position{line: 667, col: 12, offset: 13357},
+ expr: &ruleRefExpr{
+ pos: position{line: 667, col: 13, offset: 13358},
+ name: "NormalIdentifierRest",
+ },
+ },
+ },
+ },
+ },
+ },
+ {
+ name: "FalseToken",
+ pos: position{line: 670, col: 1, offset: 13412},
+ expr: &actionExpr{
+ pos: position{line: 671, col: 4, offset: 13426},
+ run: (*parser).callonFalseToken1,
+ expr: &seqExpr{
+ pos: position{line: 671, col: 4, offset: 13426},
+ exprs: []interface{}{
+ &litMatcher{
+ pos: position{line: 671, col: 4, offset: 13426},
+ val: "false",
+ ignoreCase: true,
+ },
+ &notExpr{
+ pos: position{line: 671, col: 13, offset: 13435},
+ expr: &ruleRefExpr{
+ pos: position{line: 671, col: 14, offset: 13436},
+ name: "NormalIdentifierRest",
+ },
+ },
+ },
+ },
+ },
+ },
+ {
+ name: "NullToken",
+ pos: position{line: 674, col: 1, offset: 13490},
+ expr: &seqExpr{
+ pos: position{line: 675, col: 4, offset: 13503},
+ exprs: []interface{}{
+ &litMatcher{
+ pos: position{line: 675, col: 4, offset: 13503},
+ val: "null",
+ ignoreCase: true,
+ },
+ &notExpr{
+ pos: position{line: 675, col: 12, offset: 13511},
+ expr: &ruleRefExpr{
+ pos: position{line: 675, col: 13, offset: 13512},
+ name: "NormalIdentifierRest",
+ },
+ },
+ },
+ },
+ },
+ {
+ name: "IsToken",
+ pos: position{line: 677, col: 1, offset: 13534},
+ expr: &seqExpr{
+ pos: position{line: 678, col: 4, offset: 13545},
+ exprs: []interface{}{
+ &litMatcher{
+ pos: position{line: 678, col: 4, offset: 13545},
+ val: "is",
+ ignoreCase: true,
+ },
+ &notExpr{
+ pos: position{line: 678, col: 10, offset: 13551},
+ expr: &ruleRefExpr{
+ pos: position{line: 678, col: 11, offset: 13552},
+ name: "NormalIdentifierRest",
+ },
+ },
+ },
+ },
+ },
+ {
+ name: "NullsToken",
+ pos: position{line: 680, col: 1, offset: 13574},
+ expr: &seqExpr{
+ pos: position{line: 681, col: 4, offset: 13588},
+ exprs: []interface{}{
+ &litMatcher{
+ pos: position{line: 681, col: 4, offset: 13588},
+ val: "nulls",
+ ignoreCase: true,
+ },
+ &notExpr{
+ pos: position{line: 681, col: 13, offset: 13597},
+ expr: &ruleRefExpr{
+ pos: position{line: 681, col: 14, offset: 13598},
+ name: "NormalIdentifierRest",
+ },
+ },
+ },
+ },
+ },
+ {
+ name: "LastToken",
+ pos: position{line: 683, col: 1, offset: 13620},
+ expr: &actionExpr{
+ pos: position{line: 684, col: 4, offset: 13633},
+ run: (*parser).callonLastToken1,
+ expr: &seqExpr{
+ pos: position{line: 684, col: 4, offset: 13633},
+ exprs: []interface{}{
+ &litMatcher{
+ pos: position{line: 684, col: 4, offset: 13633},
+ val: "last",
+ ignoreCase: true,
+ },
+ &notExpr{
+ pos: position{line: 684, col: 12, offset: 13641},
+ expr: &ruleRefExpr{
+ pos: position{line: 684, col: 13, offset: 13642},
+ name: "NormalIdentifierRest",
+ },
+ },
+ },
+ },
+ },
+ },
+ {
+ name: "FirstToken",
+ pos: position{line: 687, col: 1, offset: 13696},
+ expr: &actionExpr{
+ pos: position{line: 688, col: 4, offset: 13710},
+ run: (*parser).callonFirstToken1,
+ expr: &seqExpr{
+ pos: position{line: 688, col: 4, offset: 13710},
+ exprs: []interface{}{
+ &litMatcher{
+ pos: position{line: 688, col: 4, offset: 13710},
+ val: "first",
+ ignoreCase: true,
+ },
+ &notExpr{
+ pos: position{line: 688, col: 13, offset: 13719},
+ expr: &ruleRefExpr{
+ pos: position{line: 688, col: 14, offset: 13720},
+ name: "NormalIdentifierRest",
+ },
+ },
+ },
+ },
+ },
+ },
+ {
+ name: "AndToken",
+ pos: position{line: 691, col: 1, offset: 13774},
+ expr: &seqExpr{
+ pos: position{line: 692, col: 4, offset: 13786},
+ exprs: []interface{}{
+ &litMatcher{
+ pos: position{line: 692, col: 4, offset: 13786},
+ val: "and",
+ ignoreCase: true,
+ },
+ &notExpr{
+ pos: position{line: 692, col: 11, offset: 13793},
+ expr: &ruleRefExpr{
+ pos: position{line: 692, col: 12, offset: 13794},
+ name: "NormalIdentifierRest",
+ },
+ },
+ },
+ },
+ },
+ {
+ name: "OrToken",
+ pos: position{line: 694, col: 1, offset: 13816},
+ expr: &seqExpr{
+ pos: position{line: 695, col: 4, offset: 13827},
+ exprs: []interface{}{
+ &litMatcher{
+ pos: position{line: 695, col: 4, offset: 13827},
+ val: "or",
+ ignoreCase: true,
+ },
+ &notExpr{
+ pos: position{line: 695, col: 10, offset: 13833},
+ expr: &ruleRefExpr{
+ pos: position{line: 695, col: 11, offset: 13834},
+ name: "NormalIdentifierRest",
+ },
+ },
+ },
+ },
+ },
+ {
+ name: "NotToken",
+ pos: position{line: 697, col: 1, offset: 13856},
+ expr: &seqExpr{
+ pos: position{line: 698, col: 4, offset: 13868},
+ exprs: []interface{}{
+ &litMatcher{
+ pos: position{line: 698, col: 4, offset: 13868},
+ val: "not",
+ ignoreCase: true,
+ },
+ &notExpr{
+ pos: position{line: 698, col: 11, offset: 13875},
+ expr: &ruleRefExpr{
+ pos: position{line: 698, col: 12, offset: 13876},
+ name: "NormalIdentifierRest",
+ },
+ },
+ },
+ },
+ },
+ {
+ name: "InToken",
+ pos: position{line: 700, col: 1, offset: 13898},
+ expr: &seqExpr{
+ pos: position{line: 701, col: 4, offset: 13909},
+ exprs: []interface{}{
+ &litMatcher{
+ pos: position{line: 701, col: 4, offset: 13909},
+ val: "in",
+ ignoreCase: true,
+ },
+ &notExpr{
+ pos: position{line: 701, col: 10, offset: 13915},
+ expr: &ruleRefExpr{
+ pos: position{line: 701, col: 11, offset: 13916},
+ name: "NormalIdentifierRest",
+ },
+ },
+ },
+ },
+ },
+ {
+ name: "LikeToken",
+ pos: position{line: 703, col: 1, offset: 13938},
+ expr: &seqExpr{
+ pos: position{line: 704, col: 4, offset: 13951},
+ exprs: []interface{}{
+ &litMatcher{
+ pos: position{line: 704, col: 4, offset: 13951},
+ val: "like",
+ ignoreCase: true,
+ },
+ &notExpr{
+ pos: position{line: 704, col: 12, offset: 13959},
+ expr: &ruleRefExpr{
+ pos: position{line: 704, col: 13, offset: 13960},
+ name: "NormalIdentifierRest",
+ },
+ },
+ },
+ },
+ },
+ {
+ name: "AscToken",
+ pos: position{line: 706, col: 1, offset: 13982},
+ expr: &actionExpr{
+ pos: position{line: 707, col: 4, offset: 13994},
+ run: (*parser).callonAscToken1,
+ expr: &seqExpr{
+ pos: position{line: 707, col: 4, offset: 13994},
+ exprs: []interface{}{
+ &litMatcher{
+ pos: position{line: 707, col: 4, offset: 13994},
+ val: "asc",
+ ignoreCase: true,
+ },
+ &notExpr{
+ pos: position{line: 707, col: 11, offset: 14001},
+ expr: &ruleRefExpr{
+ pos: position{line: 707, col: 12, offset: 14002},
+ name: "NormalIdentifierRest",
+ },
+ },
+ },
+ },
+ },
+ },
+ {
+ name: "DescToken",
+ pos: position{line: 710, col: 1, offset: 14056},
+ expr: &actionExpr{
+ pos: position{line: 711, col: 4, offset: 14069},
+ run: (*parser).callonDescToken1,
+ expr: &seqExpr{
+ pos: position{line: 711, col: 4, offset: 14069},
+ exprs: []interface{}{
+ &litMatcher{
+ pos: position{line: 711, col: 4, offset: 14069},
+ val: "desc",
+ ignoreCase: true,
+ },
+ &notExpr{
+ pos: position{line: 711, col: 12, offset: 14077},
+ expr: &ruleRefExpr{
+ pos: position{line: 711, col: 13, offset: 14078},
+ name: "NormalIdentifierRest",
+ },
+ },
+ },
+ },
+ },
+ },
+ {
+ name: "CastToken",
+ pos: position{line: 714, col: 1, offset: 14132},
+ expr: &seqExpr{
+ pos: position{line: 715, col: 4, offset: 14145},
+ exprs: []interface{}{
+ &litMatcher{
+ pos: position{line: 715, col: 4, offset: 14145},
+ val: "cast",
+ ignoreCase: true,
+ },
+ &notExpr{
+ pos: position{line: 715, col: 12, offset: 14153},
+ expr: &ruleRefExpr{
+ pos: position{line: 715, col: 13, offset: 14154},
+ name: "NormalIdentifierRest",
+ },
+ },
+ },
+ },
+ },
+ {
+ name: "AsToken",
+ pos: position{line: 717, col: 1, offset: 14176},
+ expr: &seqExpr{
+ pos: position{line: 718, col: 4, offset: 14187},
+ exprs: []interface{}{
+ &litMatcher{
+ pos: position{line: 718, col: 4, offset: 14187},
+ val: "as",
+ ignoreCase: true,
+ },
+ &notExpr{
+ pos: position{line: 718, col: 10, offset: 14193},
+ expr: &ruleRefExpr{
+ pos: position{line: 718, col: 11, offset: 14194},
+ name: "NormalIdentifierRest",
+ },
+ },
+ },
+ },
+ },
+ {
+ name: "SeparatorToken",
+ pos: position{line: 720, col: 1, offset: 14216},
+ expr: &litMatcher{
+ pos: position{line: 721, col: 4, offset: 14234},
+ val: ",",
+ ignoreCase: false,
+ },
+ },
+ {
+ name: "AnyToken",
+ pos: position{line: 723, col: 1, offset: 14239},
+ expr: &litMatcher{
+ pos: position{line: 724, col: 4, offset: 14251},
+ val: "*",
+ ignoreCase: false,
+ },
+ },
+ {
+ name: "Identifier",
+ pos: position{line: 727, col: 1, offset: 14273},
+ expr: &choiceExpr{
+ pos: position{line: 728, col: 4, offset: 14287},
+ alternatives: []interface{}{
+ &ruleRefExpr{
+ pos: position{line: 728, col: 4, offset: 14287},
+ name: "NormalIdentifier",
+ },
+ &ruleRefExpr{
+ pos: position{line: 729, col: 4, offset: 14307},
+ name: "StringIdentifier",
+ },
+ },
+ },
+ },
+ {
+ name: "NormalIdentifier",
+ pos: position{line: 731, col: 1, offset: 14325},
+ expr: &actionExpr{
+ pos: position{line: 732, col: 4, offset: 14345},
+ run: (*parser).callonNormalIdentifier1,
+ expr: &seqExpr{
+ pos: position{line: 732, col: 4, offset: 14345},
+ exprs: []interface{}{
+ &ruleRefExpr{
+ pos: position{line: 732, col: 4, offset: 14345},
+ name: "NormalIdentifierStart",
+ },
+ &zeroOrMoreExpr{
+ pos: position{line: 732, col: 26, offset: 14367},
+ expr: &ruleRefExpr{
+ pos: position{line: 732, col: 26, offset: 14367},
+ name: "NormalIdentifierRest",
+ },
+ },
+ },
+ },
+ },
+ },
+ {
+ name: "NormalIdentifierStart",
+ pos: position{line: 735, col: 1, offset: 14429},
+ expr: &charClassMatcher{
+ pos: position{line: 736, col: 4, offset: 14454},
+ val: "[a-zA-Z@#_\\u0080-\\uffff]",
+ chars: []rune{'@', '#', '_'},
+ ranges: []rune{'a', 'z', 'A', 'Z', '\u0080', '\uffff'},
+ ignoreCase: false,
+ inverted: false,
+ },
+ },
+ {
+ name: "NormalIdentifierRest",
+ pos: position{line: 738, col: 1, offset: 14480},
+ expr: &charClassMatcher{
+ pos: position{line: 739, col: 4, offset: 14504},
+ val: "[a-zA-Z0-9@#$_\\u0080-\\uffff]",
+ chars: []rune{'@', '#', '$', '_'},
+ ranges: []rune{'a', 'z', 'A', 'Z', '0', '9', '\u0080', '\uffff'},
+ ignoreCase: false,
+ inverted: false,
+ },
+ },
+ {
+ name: "StringIdentifier",
+ pos: position{line: 741, col: 1, offset: 14534},
+ expr: &actionExpr{
+ pos: position{line: 742, col: 4, offset: 14554},
+ run: (*parser).callonStringIdentifier1,
+ expr: &seqExpr{
+ pos: position{line: 742, col: 4, offset: 14554},
+ exprs: []interface{}{
+ &litMatcher{
+ pos: position{line: 742, col: 4, offset: 14554},
+ val: "\"",
+ ignoreCase: false,
+ },
+ &labeledExpr{
+ pos: position{line: 742, col: 9, offset: 14559},
+ label: "s",
+ expr: &zeroOrMoreExpr{
+ pos: position{line: 742, col: 11, offset: 14561},
+ expr: &actionExpr{
+ pos: position{line: 742, col: 13, offset: 14563},
+ run: (*parser).callonStringIdentifier6,
+ expr: &choiceExpr{
+ pos: position{line: 742, col: 15, offset: 14565},
+ alternatives: []interface{}{
+ &charClassMatcher{
+ pos: position{line: 742, col: 15, offset: 14565},
+ val: "[^\"\\r\\n\\\\]",
+ chars: []rune{'"', '\r', '\n', '\\'},
+ ignoreCase: false,
+ inverted: true,
+ },
+ &seqExpr{
+ pos: position{line: 742, col: 28, offset: 14578},
+ exprs: []interface{}{
+ &litMatcher{
+ pos: position{line: 742, col: 28, offset: 14578},
+ val: "\\",
+ ignoreCase: false,
+ },
+ &anyMatcher{
+ line: 742, col: 33, offset: 14583,
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ &litMatcher{
+ pos: position{line: 742, col: 63, offset: 14613},
+ val: "\"",
+ ignoreCase: false,
+ },
+ },
+ },
+ },
+ },
+ {
+ name: "_",
+ pos: position{line: 748, col: 1, offset: 14691},
+ expr: &zeroOrMoreExpr{
+ pos: position{line: 749, col: 4, offset: 14696},
+ expr: &choiceExpr{
+ pos: position{line: 749, col: 6, offset: 14698},
+ alternatives: []interface{}{
+ &ruleRefExpr{
+ pos: position{line: 749, col: 6, offset: 14698},
+ name: "Whitespace",
+ },
+ &ruleRefExpr{
+ pos: position{line: 749, col: 19, offset: 14711},
+ name: "Newline",
+ },
+ },
+ },
+ },
+ },
+ {
+ name: "Newline",
+ pos: position{line: 751, col: 1, offset: 14723},
+ expr: &choiceExpr{
+ pos: position{line: 752, col: 4, offset: 14734},
+ alternatives: []interface{}{
+ &litMatcher{
+ pos: position{line: 752, col: 4, offset: 14734},
+ val: "\r\n",
+ ignoreCase: false,
+ },
+ &litMatcher{
+ pos: position{line: 753, col: 4, offset: 14744},
+ val: "\r",
+ ignoreCase: false,
+ },
+ &litMatcher{
+ pos: position{line: 754, col: 4, offset: 14752},
+ val: "\n",
+ ignoreCase: false,
+ },
+ },
+ },
+ },
+ {
+ name: "Whitespace",
+ pos: position{line: 756, col: 1, offset: 14758},
+ expr: &choiceExpr{
+ pos: position{line: 757, col: 4, offset: 14772},
+ alternatives: []interface{}{
+ &litMatcher{
+ pos: position{line: 757, col: 4, offset: 14772},
+ val: " ",
+ ignoreCase: false,
+ },
+ &litMatcher{
+ pos: position{line: 758, col: 4, offset: 14779},
+ val: "\t",
+ ignoreCase: false,
+ },
+ &litMatcher{
+ pos: position{line: 759, col: 4, offset: 14787},
+ val: "\v",
+ ignoreCase: false,
+ },
+ &litMatcher{
+ pos: position{line: 760, col: 4, offset: 14795},
+ val: "\f",
+ ignoreCase: false,
+ },
+ },
+ },
+ },
+ {
+ name: "EOF",
+ pos: position{line: 762, col: 1, offset: 14801},
+ expr: &notExpr{
+ pos: position{line: 763, col: 4, offset: 14808},
+ expr: &anyMatcher{
+ line: 763, col: 5, offset: 14809,
+ },
+ },
+ },
+ },
+}
+
+func (c *current) onS10(s interface{}) (interface{}, error) {
+ return s, nil
+}
+
+func (p *parser) callonS10() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onS10(stack["s"])
+}
+
+func (c *current) onS1(x, xs interface{}) (interface{}, error) {
+ return prepend(x, xs), nil
+}
+
+func (p *parser) callonS1() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onS1(stack["x"], stack["xs"])
+}
+
+func (c *current) onSelectStmt9(s interface{}) (interface{}, error) {
+ return s, nil
+}
+
+func (p *parser) callonSelectStmt9() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onSelectStmt9(stack["s"])
+}
+
+func (c *current) onSelectStmt18(i interface{}) (interface{}, error) {
+ return i, nil
+}
+
+func (p *parser) callonSelectStmt18() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onSelectStmt18(stack["i"])
+}
+
+func (c *current) onSelectStmt27(w interface{}) (interface{}, error) {
+ return w, nil
+}
+
+func (p *parser) callonSelectStmt27() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onSelectStmt27(stack["w"])
+}
+
+func (c *current) onSelectStmt34(g interface{}) (interface{}, error) {
+ return g, nil
+}
+
+func (p *parser) callonSelectStmt34() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onSelectStmt34(stack["g"])
+}
+
+func (c *current) onSelectStmt41(or interface{}) (interface{}, error) {
+ return or, nil
+}
+
+func (p *parser) callonSelectStmt41() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onSelectStmt41(stack["or"])
+}
+
+func (c *current) onSelectStmt48(l interface{}) (interface{}, error) {
+ return l, nil
+}
+
+func (p *parser) callonSelectStmt48() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onSelectStmt48(stack["l"])
+}
+
+func (c *current) onSelectStmt55(of interface{}) (interface{}, error) {
+ return of, nil
+}
+
+func (p *parser) callonSelectStmt55() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onSelectStmt55(stack["of"])
+}
+
+func (c *current) onSelectStmt1(f, fs, table, where, group, order, limit, offset interface{}) (interface{}, error) {
+ var (
+ tableNode *identifierNode
+ whereNode *whereOptionNode
+ limitNode *limitOptionNode
+ offsetNode *offsetOptionNode
+ )
+ if table != nil {
+ t := table.(identifierNode)
+ tableNode = &t
+ }
+ if where != nil {
+ w := where.(whereOptionNode)
+ whereNode = &w
+ }
+ if limit != nil {
+ l := limit.(limitOptionNode)
+ limitNode = &l
+ }
+ if offset != nil {
+ of := offset.(offsetOptionNode)
+ offsetNode = &of
+ }
+ return selectStmtNode{
+ column: prepend(f, fs),
+ table: tableNode,
+ where: whereNode,
+ group: toSlice(group),
+ order: toSlice(order),
+ limit: limitNode,
+ offset: offsetNode,
+ }, nil
+}
+
+func (p *parser) callonSelectStmt1() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onSelectStmt1(stack["f"], stack["fs"], stack["table"], stack["where"], stack["group"], stack["order"], stack["limit"], stack["offset"])
+}
+
+func (c *current) onUpdateStmt14(s interface{}) (interface{}, error) {
+ return s, nil
+}
+
+func (p *parser) callonUpdateStmt14() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onUpdateStmt14(stack["s"])
+}
+
+func (c *current) onUpdateStmt23(w interface{}) (interface{}, error) {
+ return w, nil
+}
+
+func (p *parser) callonUpdateStmt23() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onUpdateStmt23(stack["w"])
+}
+
+func (c *current) onUpdateStmt1(table, a, as, where interface{}) (interface{}, error) {
+ var (
+ whereNode *whereOptionNode
+ )
+ if where != nil {
+ w := where.(whereOptionNode)
+ whereNode = &w
+ }
+ return updateStmtNode{
+ table: table.(identifierNode),
+ assignment: prepend(a, as),
+ where: whereNode,
+ }, nil
+}
+
+func (p *parser) callonUpdateStmt1() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onUpdateStmt1(stack["table"], stack["a"], stack["as"], stack["where"])
+}
+
+func (c *current) onDeleteStmt11(w interface{}) (interface{}, error) {
+ return w, nil
+}
+
+func (p *parser) callonDeleteStmt11() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onDeleteStmt11(stack["w"])
+}
+
+func (c *current) onDeleteStmt1(table, where interface{}) (interface{}, error) {
+ var (
+ whereNode *whereOptionNode
+ )
+ if where != nil {
+ w := where.(whereOptionNode)
+ whereNode = &w
+ }
+ return deleteStmtNode{
+ table: table.(identifierNode),
+ where: whereNode,
+ }, nil
+}
+
+func (p *parser) callonDeleteStmt1() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onDeleteStmt1(stack["table"], stack["where"])
+}
+
+func (c *current) onInsertStmt1(table, insert interface{}) (interface{}, error) {
+ return insertStmtNode{
+ table: table.(identifierNode),
+ insert: insert,
+ }, nil
+}
+
+func (p *parser) callonInsertStmt1() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onInsertStmt1(stack["table"], stack["insert"])
+}
+
+func (c *current) onInsertValue1(e interface{}) (interface{}, error) {
+ return e, nil
+}
+
+func (p *parser) callonInsertValue1() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onInsertValue1(stack["e"])
+}
+
+func (c *current) onCreateTableStmt20(t interface{}) (interface{}, error) {
+ return t, nil
+}
+
+func (p *parser) callonCreateTableStmt20() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onCreateTableStmt20(stack["t"])
+}
+
+func (c *current) onCreateTableStmt14(s, ss interface{}) (interface{}, error) {
+ return prepend(s, ss), nil
+}
+
+func (p *parser) callonCreateTableStmt14() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onCreateTableStmt14(stack["s"], stack["ss"])
+}
+
+func (c *current) onCreateTableStmt1(table, column interface{}) (interface{}, error) {
+ return createTableStmtNode{
+ table: table.(identifierNode),
+ column: toSlice(column),
+ }, nil
+}
+
+func (p *parser) callonCreateTableStmt1() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onCreateTableStmt1(stack["table"], stack["column"])
+}
+
+func (c *current) onColumnSchema10(s interface{}) (interface{}, error) {
+ return s, nil
+}
+
+func (p *parser) callonColumnSchema10() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onColumnSchema10(stack["s"])
+}
+
+func (c *current) onColumnSchema1(i, t, cs interface{}) (interface{}, error) {
+ return columnSchemaNode{
+ column: i.(identifierNode),
+ dataType: t,
+ constraint: toSlice(cs),
+ }, nil
+}
+
+func (p *parser) callonColumnSchema1() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onColumnSchema1(stack["i"], stack["t"], stack["cs"])
+}
+
+func (c *current) onCreateIndexStmt6(u interface{}) (interface{}, error) {
+ return u, nil
+}
+
+func (p *parser) callonCreateIndexStmt6() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onCreateIndexStmt6(stack["u"])
+}
+
+func (c *current) onCreateIndexStmt28(x interface{}) (interface{}, error) {
+ return x, nil
+}
+
+func (p *parser) callonCreateIndexStmt28() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onCreateIndexStmt28(stack["x"])
+}
+
+func (c *current) onCreateIndexStmt1(unique, index, table, i, is interface{}) (interface{}, error) {
+ var (
+ uniqueNode *uniqueOptionNode
+ )
+ if unique != nil {
+ u := unique.(uniqueOptionNode)
+ uniqueNode = &u
+ }
+ return createIndexStmtNode{
+ index: index.(identifierNode),
+ table: table.(identifierNode),
+ column: prepend(i, is),
+ unique: uniqueNode,
+ }, nil
+}
+
+func (p *parser) callonCreateIndexStmt1() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onCreateIndexStmt1(stack["unique"], stack["index"], stack["table"], stack["i"], stack["is"])
+}
+
+func (c *current) onWhereClause1(e interface{}) (interface{}, error) {
+ return whereOptionNode{condition: e}, nil
+}
+
+func (p *parser) callonWhereClause1() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onWhereClause1(stack["e"])
+}
+
+func (c *current) onOrderByClause11(s interface{}) (interface{}, error) {
+ return s, nil
+}
+
+func (p *parser) callonOrderByClause11() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onOrderByClause11(stack["s"])
+}
+
+func (c *current) onOrderByClause1(f, fs interface{}) (interface{}, error) {
+ return prepend(f, fs), nil
+}
+
+func (p *parser) callonOrderByClause1() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onOrderByClause1(stack["f"], stack["fs"])
+}
+
+func (c *current) onOrderColumn7(t interface{}) (interface{}, error) {
+ return t, nil
+}
+
+func (p *parser) callonOrderColumn7() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onOrderColumn7(stack["t"])
+}
+
+func (c *current) onOrderColumn16(l interface{}) (interface{}, error) {
+ return l, nil
+}
+
+func (p *parser) callonOrderColumn16() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onOrderColumn16(stack["l"])
+}
+
+func (c *current) onOrderColumn1(i, s, n interface{}) (interface{}, error) {
+ return orderOptionNode{
+ expr: i,
+ desc: s != nil && string(s.([]byte)) == "desc",
+ nullfirst: n != nil && string(n.([]byte)) == "first",
+ }, nil
+}
+
+func (p *parser) callonOrderColumn1() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onOrderColumn1(stack["i"], stack["s"], stack["n"])
+}
+
+func (c *current) onGroupByClause11(s interface{}) (interface{}, error) {
+ return groupOptionNode{expr: s}, nil
+}
+
+func (p *parser) callonGroupByClause11() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onGroupByClause11(stack["s"])
+}
+
+func (c *current) onGroupByClause1(i, is interface{}) (interface{}, error) {
+ return prepend(groupOptionNode{expr: i}, is), nil
+}
+
+func (p *parser) callonGroupByClause1() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onGroupByClause1(stack["i"], stack["is"])
+}
+
+func (c *current) onOffsetClause1(i interface{}) (interface{}, error) {
+ return offsetOptionNode{value: i.(integerValueNode)}, nil
+}
+
+func (p *parser) callonOffsetClause1() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onOffsetClause1(stack["i"])
+}
+
+func (c *current) onLimitClause1(i interface{}) (interface{}, error) {
+ return limitOptionNode{value: i.(integerValueNode)}, nil
+}
+
+func (p *parser) callonLimitClause1() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onLimitClause1(stack["i"])
+}
+
+func (c *current) onInsertWithColumnClause13(x interface{}) (interface{}, error) {
+ return x, nil
+}
+
+func (p *parser) callonInsertWithColumnClause13() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onInsertWithColumnClause13(stack["x"])
+}
+
+func (c *current) onInsertWithColumnClause5(f, fs interface{}) (interface{}, error) {
+ return prepend(f, fs), nil
+}
+
+func (p *parser) callonInsertWithColumnClause5() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onInsertWithColumnClause5(stack["f"], stack["fs"])
+}
+
+func (c *current) onInsertWithColumnClause29(y interface{}) (interface{}, error) {
+ return y, nil
+}
+
+func (p *parser) callonInsertWithColumnClause29() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onInsertWithColumnClause29(stack["y"])
+}
+
+func (c *current) onInsertWithColumnClause1(cs, v, vs interface{}) (interface{}, error) {
+ return insertWithColumnOptionNode{
+ column: toSlice(cs),
+ value: prepend(v, vs),
+ }, nil
+}
+
+func (p *parser) callonInsertWithColumnClause1() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onInsertWithColumnClause1(stack["cs"], stack["v"], stack["vs"])
+}
+
+func (c *current) onInsertWithDefaultClause1() (interface{}, error) {
+ return insertWithDefaultOptionNode{}, nil
+}
+
+func (p *parser) callonInsertWithDefaultClause1() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onInsertWithDefaultClause1()
+}
+
+func (c *current) onPrimaryKeyClause1() (interface{}, error) {
+ return primaryOptionNode{}, nil
+}
+
+func (p *parser) callonPrimaryKeyClause1() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onPrimaryKeyClause1()
+}
+
+func (c *current) onNotNullClause1() (interface{}, error) {
+ return notNullOptionNode{}, nil
+}
+
+func (p *parser) callonNotNullClause1() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onNotNullClause1()
+}
+
+func (c *current) onUniqueClause1() (interface{}, error) {
+ return uniqueOptionNode{}, nil
+}
+
+func (p *parser) callonUniqueClause1() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onUniqueClause1()
+}
+
+func (c *current) onDefaultClause1(e interface{}) (interface{}, error) {
+ return defaultOptionNode{value: e}, nil
+}
+
+func (p *parser) callonDefaultClause1() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onDefaultClause1(stack["e"])
+}
+
+func (c *current) onForeignClause1(t, f interface{}) (interface{}, error) {
+ return foreignOptionNode{
+ table: t.(identifierNode),
+ column: f.(identifierNode),
+ }, nil
+}
+
+func (p *parser) callonForeignClause1() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onForeignClause1(stack["t"], stack["f"])
+}
+
+func (c *current) onAutoincrementClause1() (interface{}, error) {
+ return autoincrementOptionNode{}, nil
+}
+
+func (p *parser) callonAutoincrementClause1() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onAutoincrementClause1()
+}
+
+func (c *current) onExprWithDefault2(d interface{}) (interface{}, error) {
+ return d, nil
+}
+
+func (p *parser) callonExprWithDefault2() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onExprWithDefault2(stack["d"])
+}
+
+func (c *current) onLogicExpr47(op, s interface{}) (interface{}, error) {
+ return opSetSubject(op, s), nil
+}
+
+func (p *parser) callonLogicExpr47() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onLogicExpr47(stack["op"], stack["s"])
+}
+
+func (c *current) onLogicExpr41(o, os interface{}) (interface{}, error) {
+ return rightJoinOperators(o, os), nil
+}
+
+func (p *parser) callonLogicExpr41() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onLogicExpr41(stack["o"], stack["os"])
+}
+
+func (c *current) onLogicExpr37(op, s interface{}) (interface{}, error) {
+ return opSetSubject(op, s), nil
+}
+
+func (p *parser) callonLogicExpr37() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onLogicExpr37(stack["op"], stack["s"])
+}
+
+func (c *current) onLogicExpr31(o, os interface{}) (interface{}, error) {
+ return rightJoinOperators(o, os), nil
+}
+
+func (p *parser) callonLogicExpr31() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onLogicExpr31(stack["o"], stack["os"])
+}
+
+func (c *current) onLogicExpr22(op, s interface{}) (interface{}, error) {
+ return opSetTarget(op, s), nil
+}
+
+func (p *parser) callonLogicExpr22() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onLogicExpr22(stack["op"], stack["s"])
+}
+
+func (c *current) onLogicExpr17(l interface{}) (interface{}, error) {
+ return l, nil
+}
+
+func (p *parser) callonLogicExpr17() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onLogicExpr17(stack["l"])
+}
+
+func (c *current) onLogicExpr11(o, os interface{}) (interface{}, error) {
+ return rightJoinOperators(o, os), nil
+}
+
+func (p *parser) callonLogicExpr11() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onLogicExpr11(stack["o"], stack["os"])
+}
+
+func (c *current) onLogicExpr1In5(t interface{}) (interface{}, error) {
+ return t, nil
+}
+
+func (p *parser) callonLogicExpr1In5() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onLogicExpr1In5(stack["t"])
+}
+
+func (c *current) onLogicExpr1In1(n, s interface{}) (interface{}, error) {
+ op := opSetSubject(&inOperatorNode{}, s)
+ if n != nil {
+ return opSetTarget(n, op), nil
+ }
+ return op, nil
+}
+
+func (p *parser) callonLogicExpr1In1() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onLogicExpr1In1(stack["n"], stack["s"])
+}
+
+func (c *current) onLogicExpr1Null6(t interface{}) (interface{}, error) {
+ return t, nil
+}
+
+func (p *parser) callonLogicExpr1Null6() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onLogicExpr1Null6(stack["t"])
+}
+
+func (c *current) onLogicExpr1Null1(n interface{}) (interface{}, error) {
+ op := opSetSubject(&isOperatorNode{}, nullValueNode{})
+ if n != nil {
+ return opSetTarget(n, op), nil
+ }
+ return op, nil
+}
+
+func (p *parser) callonLogicExpr1Null1() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onLogicExpr1Null1(stack["n"])
+}
+
+func (c *current) onLogicExpr1Like5(t interface{}) (interface{}, error) {
+ return t, nil
+}
+
+func (p *parser) callonLogicExpr1Like5() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onLogicExpr1Like5(stack["t"])
+}
+
+func (c *current) onLogicExpr1Like1(n, s interface{}) (interface{}, error) {
+ op := opSetSubject(&likeOperatorNode{}, s)
+ if n != nil {
+ return opSetTarget(n, op), nil
+ }
+ return op, nil
+}
+
+func (p *parser) callonLogicExpr1Like1() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onLogicExpr1Like1(stack["n"], stack["s"])
+}
+
+func (c *current) onLogicExpr1Cmp1(op, s interface{}) (interface{}, error) {
+ return opSetSubject(op, s), nil
+}
+
+func (p *parser) callonLogicExpr1Cmp1() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onLogicExpr1Cmp1(stack["op"], stack["s"])
+}
+
+func (c *current) onArithmeticExpr37(op, s interface{}) (interface{}, error) {
+ return opSetSubject(op, s), nil
+}
+
+func (p *parser) callonArithmeticExpr37() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onArithmeticExpr37(stack["op"], stack["s"])
+}
+
+func (c *current) onArithmeticExpr31(o, os interface{}) (interface{}, error) {
+ return rightJoinOperators(o, os), nil
+}
+
+func (p *parser) callonArithmeticExpr31() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onArithmeticExpr31(stack["o"], stack["os"])
+}
+
+func (c *current) onArithmeticExpr27(op, s interface{}) (interface{}, error) {
+ return opSetSubject(op, s), nil
+}
+
+func (p *parser) callonArithmeticExpr27() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onArithmeticExpr27(stack["op"], stack["s"])
+}
+
+func (c *current) onArithmeticExpr21(o, os interface{}) (interface{}, error) {
+ return rightJoinOperators(o, os), nil
+}
+
+func (p *parser) callonArithmeticExpr21() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onArithmeticExpr21(stack["o"], stack["os"])
+}
+
+func (c *current) onArithmeticExpr17(op, s interface{}) (interface{}, error) {
+ return opSetSubject(op, s), nil
+}
+
+func (p *parser) callonArithmeticExpr17() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onArithmeticExpr17(stack["op"], stack["s"])
+}
+
+func (c *current) onArithmeticExpr11(o, os interface{}) (interface{}, error) {
+ return rightJoinOperators(o, os), nil
+}
+
+func (p *parser) callonArithmeticExpr11() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onArithmeticExpr11(stack["o"], stack["os"])
+}
+
+func (c *current) onMultiExpr7(e interface{}) (interface{}, error) {
+ return e, nil
+}
+
+func (p *parser) callonMultiExpr7() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onMultiExpr7(stack["e"])
+}
+
+func (c *current) onMultiExpr1(x, xs interface{}) (interface{}, error) {
+ return prepend(x, xs), nil
+}
+
+func (p *parser) callonMultiExpr1() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onMultiExpr1(stack["x"], stack["xs"])
+}
+
+func (c *current) onMultiExprWithDefault7(e interface{}) (interface{}, error) {
+ return e, nil
+}
+
+func (p *parser) callonMultiExprWithDefault7() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onMultiExprWithDefault7(stack["e"])
+}
+
+func (c *current) onMultiExprWithDefault1(x, xs interface{}) (interface{}, error) {
+ return prepend(x, xs), nil
+}
+
+func (p *parser) callonMultiExprWithDefault1() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onMultiExprWithDefault1(stack["x"], stack["xs"])
+}
+
+func (c *current) onOperand2(op, s interface{}) (interface{}, error) {
+ return opSetTarget(op, s), nil
+}
+
+func (p *parser) callonOperand2() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onOperand2(stack["op"], stack["s"])
+}
+
+func (c *current) onOperand9(e interface{}) (interface{}, error) {
+ return e, nil
+}
+
+func (p *parser) callonOperand9() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onOperand9(stack["e"])
+}
+
+func (c *current) onOperand17(t interface{}) (interface{}, error) {
+ return t, nil
+}
+
+func (p *parser) callonOperand17() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onOperand17(stack["t"])
+}
+
+func (c *current) onTypeCast1(o, s interface{}) (interface{}, error) {
+ return opSetSubject(opSetObject(&castOperatorNode{}, o), s), nil
+}
+
+func (p *parser) callonTypeCast1() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onTypeCast1(stack["o"], stack["s"])
+}
+
+func (c *current) onFunctionCall1(i, r interface{}) (interface{}, error) {
+ return opSetSubject(opSetObject(&functionOperatorNode{}, i), r), nil
+}
+
+func (p *parser) callonFunctionCall1() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onFunctionCall1(stack["i"], stack["r"])
+}
+
+func (c *current) onFunctionArgs2(a interface{}) (interface{}, error) {
+ return []interface{}{a}, nil
+}
+
+func (p *parser) callonFunctionArgs2() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onFunctionArgs2(stack["a"])
+}
+
+func (c *current) onAssignment1(i, e interface{}) (interface{}, error) {
+ return opSetSubject(opSetObject(&assignOperatorNode{}, i), e), nil
+}
+
+func (p *parser) callonAssignment1() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onAssignment1(stack["i"], stack["e"])
+}
+
+func (c *current) onSignOperator1() (interface{}, error) {
+ switch string(c.text) {
+ case "+":
+ return &posOperatorNode{}, nil
+ case "-":
+ return &negOperatorNode{}, nil
+ }
+ return nil, errors.New("unknown sign")
+}
+
+func (p *parser) callonSignOperator1() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onSignOperator1()
+}
+
+func (c *current) onNotOperator1() (interface{}, error) {
+ return &notOperatorNode{}, nil
+}
+
+func (p *parser) callonNotOperator1() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onNotOperator1()
+}
+
+func (c *current) onAndOperator1() (interface{}, error) {
+ return &andOperatorNode{}, nil
+}
+
+func (p *parser) callonAndOperator1() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onAndOperator1()
+}
+
+func (c *current) onOrOperator1() (interface{}, error) {
+ return &orOperatorNode{}, nil
+}
+
+func (p *parser) callonOrOperator1() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onOrOperator1()
+}
+
+func (c *current) onCmpOperator1() (interface{}, error) {
+ switch string(c.text) {
+ case "<=":
+ return &lessOrEqualOperatorNode{}, nil
+ case ">=":
+ return &greaterOrEqualOperatorNode{}, nil
+ case "<>":
+ return &notEqualOperatorNode{}, nil
+ case "!=":
+ return &notEqualOperatorNode{}, nil
+ case "<":
+ return &lessOperatorNode{}, nil
+ case ">":
+ return &greaterOperatorNode{}, nil
+ case "=":
+ return &equalOperatorNode{}, nil
+ }
+ return nil, errors.New("unknown cmp")
+}
+
+func (p *parser) callonCmpOperator1() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onCmpOperator1()
+}
+
+func (c *current) onConcatOperator1() (interface{}, error) {
+ return &concatOperatorNode{}, nil
+}
+
+func (p *parser) callonConcatOperator1() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onConcatOperator1()
+}
+
+func (c *current) onAddSubOperator1() (interface{}, error) {
+ switch string(c.text) {
+ case "+":
+ return &addOperatorNode{}, nil
+ case "-":
+ return &subOperatorNode{}, nil
+ }
+ return nil, errors.New("unknown add sub")
+}
+
+func (p *parser) callonAddSubOperator1() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onAddSubOperator1()
+}
+
+func (c *current) onMulDivModOperator1() (interface{}, error) {
+ switch string(c.text) {
+ case "*":
+ return &mulOperatorNode{}, nil
+ case "/":
+ return &divOperatorNode{}, nil
+ case "%":
+ return &modOperatorNode{}, nil
+ }
+ return nil, errors.New("unknown mul div mod")
+}
+
+func (p *parser) callonMulDivModOperator1() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onMulDivModOperator1()
+}
+
+func (c *current) onUIntType1(s interface{}) (interface{}, error) {
+ return intTypeNode{size: toInt(s.([]byte)), unsigned: true}, nil
+}
+
+func (p *parser) callonUIntType1() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onUIntType1(stack["s"])
+}
+
+func (c *current) onIntType1(s interface{}) (interface{}, error) {
+ return intTypeNode{size: toInt(s.([]byte))}, nil
+}
+
+func (p *parser) callonIntType1() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onIntType1(stack["s"])
+}
+
+func (c *current) onUFixedType1(s, t interface{}) (interface{}, error) {
+ return fixedTypeNode{
+ integerSize: toInt(s.([]byte)),
+ fractionalSize: toInt(t.([]byte)),
+ unsigned: true,
+ }, nil
+}
+
+func (p *parser) callonUFixedType1() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onUFixedType1(stack["s"], stack["t"])
+}
+
+func (c *current) onFixedType1(s, t interface{}) (interface{}, error) {
+ return fixedTypeNode{
+ integerSize: toInt(s.([]byte)),
+ fractionalSize: toInt(t.([]byte)),
+ }, nil
+}
+
+func (p *parser) callonFixedType1() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onFixedType1(stack["s"], stack["t"])
+}
+
+func (c *current) onFixedBytesType2(s interface{}) (interface{}, error) {
+ return fixedBytesTypeNode{size: toInt(s.([]byte))}, nil
+}
+
+func (p *parser) callonFixedBytesType2() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onFixedBytesType2(stack["s"])
+}
+
+func (c *current) onFixedBytesType9() (interface{}, error) {
+ return fixedBytesTypeNode{size: 1}, nil
+}
+
+func (p *parser) callonFixedBytesType9() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onFixedBytesType9()
+}
+
+func (c *current) onDynamicBytesType1() (interface{}, error) {
+ return dynamicBytesTypeNode{}, nil
+}
+
+func (p *parser) callonDynamicBytesType1() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onDynamicBytesType1()
+}
+
+func (c *current) onAddressType1() (interface{}, error) {
+ return addressTypeNode{}, nil
+}
+
+func (p *parser) callonAddressType1() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onAddressType1()
+}
+
+func (c *current) onBoolType1() (interface{}, error) {
+ return boolTypeNode{}, nil
+}
+
+func (p *parser) callonBoolType1() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onBoolType1()
+}
+
+func (c *current) onAnyLiteral1() (interface{}, error) {
+ return anyValueNode{}, nil
+}
+
+func (p *parser) callonAnyLiteral1() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onAnyLiteral1()
+}
+
+func (c *current) onDefaultLiteral1() (interface{}, error) {
+ return defaultValueNode{}, nil
+}
+
+func (p *parser) callonDefaultLiteral1() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onDefaultLiteral1()
+}
+
+func (c *current) onBoolLiteral1(b interface{}) (interface{}, error) {
+ return boolValueNode(string(b.([]byte)) == "true"), nil
+}
+
+func (p *parser) callonBoolLiteral1() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onBoolLiteral1(stack["b"])
+}
+
+func (c *current) onNullLiteral1() (interface{}, error) {
+ return nullValueNode{}, nil
+}
+
+func (p *parser) callonNullLiteral1() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onNullLiteral1()
+}
+
+func (c *current) onNumberLiteral2(h interface{}) (interface{}, error) {
+ return h, nil
+}
+
+func (p *parser) callonNumberLiteral2() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onNumberLiteral2(stack["h"])
+}
+
+func (c *current) onInteger1() (interface{}, error) {
+ return integerValueNode{v: toDecimal(c.text)}, nil
+}
+
+func (p *parser) callonInteger1() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onInteger1()
+}
+
+func (c *current) onNonZeroLeadingInteger1() (interface{}, error) {
+ return c.text, nil
+}
+
+func (p *parser) callonNonZeroLeadingInteger1() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onNonZeroLeadingInteger1()
+}
+
+func (c *current) onDecimal1() (interface{}, error) {
+ return decimalValueNode(toDecimal(c.text)), nil
+}
+
+func (p *parser) callonDecimal1() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onDecimal1()
+}
+
+func (c *current) onHex1(s interface{}) (interface{}, error) {
+ return hexToInteger(joinBytes(s)), nil
+}
+
+func (p *parser) callonHex1() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onHex1(stack["s"])
+}
+
+func (c *current) onHexString9() (interface{}, error) {
+ return c.text, nil
+}
+
+func (p *parser) callonHexString9() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onHexString9()
+}
+
+func (c *current) onHexString1(s interface{}) (interface{}, error) {
+ return bytesValueNode(hexToBytes(joinBytes(s))), nil
+}
+
+func (p *parser) callonHexString1() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onHexString1(stack["s"])
+}
+
+func (c *current) onNormalString6() (interface{}, error) {
+ return c.text, nil
+}
+
+func (p *parser) callonNormalString6() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onNormalString6()
+}
+
+func (c *current) onNormalString1(s interface{}) (interface{}, error) {
+ return bytesValueNode(resolveString(joinBytes(s))), nil
+}
+
+func (p *parser) callonNormalString1() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onNormalString1(stack["s"])
+}
+
+func (c *current) onTrueToken1() (interface{}, error) {
+ return toLower(c.text), nil
+}
+
+func (p *parser) callonTrueToken1() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onTrueToken1()
+}
+
+func (c *current) onFalseToken1() (interface{}, error) {
+ return toLower(c.text), nil
+}
+
+func (p *parser) callonFalseToken1() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onFalseToken1()
+}
+
+func (c *current) onLastToken1() (interface{}, error) {
+ return toLower(c.text), nil
+}
+
+func (p *parser) callonLastToken1() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onLastToken1()
+}
+
+func (c *current) onFirstToken1() (interface{}, error) {
+ return toLower(c.text), nil
+}
+
+func (p *parser) callonFirstToken1() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onFirstToken1()
+}
+
+func (c *current) onAscToken1() (interface{}, error) {
+ return toLower(c.text), nil
+}
+
+func (p *parser) callonAscToken1() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onAscToken1()
+}
+
+func (c *current) onDescToken1() (interface{}, error) {
+ return toLower(c.text), nil
+}
+
+func (p *parser) callonDescToken1() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onDescToken1()
+}
+
+func (c *current) onNormalIdentifier1() (interface{}, error) {
+ return identifierNode(c.text), nil
+}
+
+func (p *parser) callonNormalIdentifier1() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onNormalIdentifier1()
+}
+
+func (c *current) onStringIdentifier6() (interface{}, error) {
+ return c.text, nil
+}
+
+func (p *parser) callonStringIdentifier6() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onStringIdentifier6()
+}
+
+func (c *current) onStringIdentifier1(s interface{}) (interface{}, error) {
+ return identifierNode(resolveString(joinBytes(s))), nil
+}
+
+func (p *parser) callonStringIdentifier1() (interface{}, error) {
+ stack := p.vstack[len(p.vstack)-1]
+ _ = stack
+ return p.cur.onStringIdentifier1(stack["s"])
+}
+
+var (
+ // errNoRule is returned when the grammar to parse has no rule.
+ errNoRule = errors.New("grammar has no rule")
+
+ // errInvalidEntrypoint is returned when the specified entrypoint rule
+ // does not exit.
+ errInvalidEntrypoint = errors.New("invalid entrypoint")
+
+ // errInvalidEncoding is returned when the source is not properly
+ // utf8-encoded.
+ errInvalidEncoding = errors.New("invalid encoding")
+
+ // errMaxExprCnt is used to signal that the maximum number of
+ // expressions have been parsed.
+ errMaxExprCnt = errors.New("max number of expresssions parsed")
+)
+
+// Option is a function that can set an option on the parser. It returns
+// the previous setting as an Option.
+type Option func(*parser) Option
+
+// MaxExpressions creates an Option to stop parsing after the provided
+// number of expressions have been parsed, if the value is 0 then the parser will
+// parse for as many steps as needed (possibly an infinite number).
+//
+// The default for maxExprCnt is 0.
+func MaxExpressions(maxExprCnt uint64) Option {
+ return func(p *parser) Option {
+ oldMaxExprCnt := p.maxExprCnt
+ p.maxExprCnt = maxExprCnt
+ return MaxExpressions(oldMaxExprCnt)
+ }
+}
+
+// Entrypoint creates an Option to set the rule name to use as entrypoint.
+// The rule name must have been specified in the -alternate-entrypoints
+// if generating the parser with the -optimize-grammar flag, otherwise
+// it may have been optimized out. Passing an empty string sets the
+// entrypoint to the first rule in the grammar.
+//
+// The default is to start parsing at the first rule in the grammar.
+func Entrypoint(ruleName string) Option {
+ return func(p *parser) Option {
+ oldEntrypoint := p.entrypoint
+ p.entrypoint = ruleName
+ if ruleName == "" {
+ p.entrypoint = g.rules[0].name
+ }
+ return Entrypoint(oldEntrypoint)
+ }
+}
+
+// Statistics adds a user provided Stats struct to the parser to allow
+// the user to process the results after the parsing has finished.
+// Also the key for the "no match" counter is set.
+//
+// Example usage:
+//
+// input := "input"
+// stats := Stats{}
+// _, err := Parse("input-file", []byte(input), Statistics(&stats, "no match"))
+// if err != nil {
+// log.Panicln(err)
+// }
+// b, err := json.MarshalIndent(stats.ChoiceAltCnt, "", " ")
+// if err != nil {
+// log.Panicln(err)
+// }
+// fmt.Println(string(b))
+//
+func Statistics(stats *Stats, choiceNoMatch string) Option {
+ return func(p *parser) Option {
+ oldStats := p.Stats
+ p.Stats = stats
+ oldChoiceNoMatch := p.choiceNoMatch
+ p.choiceNoMatch = choiceNoMatch
+ if p.Stats.ChoiceAltCnt == nil {
+ p.Stats.ChoiceAltCnt = make(map[string]map[string]int)
+ }
+ return Statistics(oldStats, oldChoiceNoMatch)
+ }
+}
+
+// Debug creates an Option to set the debug flag to b. When set to true,
+// debugging information is printed to stdout while parsing.
+//
+// The default is false.
+func Debug(b bool) Option {
+ return func(p *parser) Option {
+ old := p.debug
+ p.debug = b
+ return Debug(old)
+ }
+}
+
+// Memoize creates an Option to set the memoize flag to b. When set to true,
+// the parser will cache all results so each expression is evaluated only
+// once. This guarantees linear parsing time even for pathological cases,
+// at the expense of more memory and slower times for typical cases.
+//
+// The default is false.
+func Memoize(b bool) Option {
+ return func(p *parser) Option {
+ old := p.memoize
+ p.memoize = b
+ return Memoize(old)
+ }
+}
+
+// AllowInvalidUTF8 creates an Option to allow invalid UTF-8 bytes.
+// Every invalid UTF-8 byte is treated as a utf8.RuneError (U+FFFD)
+// by character class matchers and is matched by the any matcher.
+// The returned matched value, c.text and c.offset are NOT affected.
+//
+// The default is false.
+func AllowInvalidUTF8(b bool) Option {
+ return func(p *parser) Option {
+ old := p.allowInvalidUTF8
+ p.allowInvalidUTF8 = b
+ return AllowInvalidUTF8(old)
+ }
+}
+
+// Recover creates an Option to set the recover flag to b. When set to
+// true, this causes the parser to recover from panics and convert it
+// to an error. Setting it to false can be useful while debugging to
+// access the full stack trace.
+//
+// The default is true.
+func Recover(b bool) Option {
+ return func(p *parser) Option {
+ old := p.recover
+ p.recover = b
+ return Recover(old)
+ }
+}
+
+// GlobalStore creates an Option to set a key to a certain value in
+// the globalStore.
+func GlobalStore(key string, value interface{}) Option {
+ return func(p *parser) Option {
+ old := p.cur.globalStore[key]
+ p.cur.globalStore[key] = value
+ return GlobalStore(key, old)
+ }
+}
+
+// InitState creates an Option to set a key to a certain value in
+// the global "state" store.
+func InitState(key string, value interface{}) Option {
+ return func(p *parser) Option {
+ old := p.cur.state[key]
+ p.cur.state[key] = value
+ return InitState(key, old)
+ }
+}
+
+// ParseFile parses the file identified by filename.
+func ParseFile(filename string, opts ...Option) (i interface{}, err error) {
+ f, err := os.Open(filename)
+ if err != nil {
+ return nil, err
+ }
+ defer func() {
+ if closeErr := f.Close(); closeErr != nil {
+ err = closeErr
+ }
+ }()
+ return ParseReader(filename, f, opts...)
+}
+
+// ParseReader parses the data from r using filename as information in the
+// error messages.
+func ParseReader(filename string, r io.Reader, opts ...Option) (interface{}, error) {
+ b, err := ioutil.ReadAll(r)
+ if err != nil {
+ return nil, err
+ }
+
+ return Parse(filename, b, opts...)
+}
+
+// Parse parses the data from b using filename as information in the
+// error messages.
+func Parse(filename string, b []byte, opts ...Option) (interface{}, error) {
+ return newParser(filename, b, opts...).parse(g)
+}
+
+// position records a position in the text.
+type position struct {
+ line, col, offset int
+}
+
+func (p position) String() string {
+ return fmt.Sprintf("%d:%d [%d]", p.line, p.col, p.offset)
+}
+
+// savepoint stores all state required to go back to this point in the
+// parser.
+type savepoint struct {
+ position
+ rn rune
+ w int
+}
+
+type current struct {
+ pos position // start position of the match
+ text []byte // raw text of the match
+
+ // state is a store for arbitrary key,value pairs that the user wants to be
+ // tied to the backtracking of the parser.
+ // This is always rolled back if a parsing rule fails.
+ state storeDict
+
+ // globalStore is a general store for the user to store arbitrary key-value
+ // pairs that they need to manage and that they do not want tied to the
+ // backtracking of the parser. This is only modified by the user and never
+ // rolled back by the parser. It is always up to the user to keep this in a
+ // consistent state.
+ globalStore storeDict
+}
+
+type storeDict map[string]interface{}
+
+// the AST types...
+
+type grammar struct {
+ pos position
+ rules []*rule
+}
+
+type rule struct {
+ pos position
+ name string
+ displayName string
+ expr interface{}
+}
+
+type choiceExpr struct {
+ pos position
+ alternatives []interface{}
+}
+
+type actionExpr struct {
+ pos position
+ expr interface{}
+ run func(*parser) (interface{}, error)
+}
+
+type recoveryExpr struct {
+ pos position
+ expr interface{}
+ recoverExpr interface{}
+ failureLabel []string
+}
+
+type seqExpr struct {
+ pos position
+ exprs []interface{}
+}
+
+type throwExpr struct {
+ pos position
+ label string
+}
+
+type labeledExpr struct {
+ pos position
+ label string
+ expr interface{}
+}
+
+type expr struct {
+ pos position
+ expr interface{}
+}
+
+type andExpr expr
+type notExpr expr
+type zeroOrOneExpr expr
+type zeroOrMoreExpr expr
+type oneOrMoreExpr expr
+
+type ruleRefExpr struct {
+ pos position
+ name string
+}
+
+type stateCodeExpr struct {
+ pos position
+ run func(*parser) error
+}
+
+type andCodeExpr struct {
+ pos position
+ run func(*parser) (bool, error)
+}
+
+type notCodeExpr struct {
+ pos position
+ run func(*parser) (bool, error)
+}
+
+type litMatcher struct {
+ pos position
+ val string
+ ignoreCase bool
+}
+
+type charClassMatcher struct {
+ pos position
+ val string
+ basicLatinChars [128]bool
+ chars []rune
+ ranges []rune
+ classes []*unicode.RangeTable
+ ignoreCase bool
+ inverted bool
+}
+
+type anyMatcher position
+
+// errList cumulates the errors found by the parser.
+type errList []error
+
+func (e *errList) add(err error) {
+ *e = append(*e, err)
+}
+
+func (e errList) err() error {
+ if len(e) == 0 {
+ return nil
+ }
+ e.dedupe()
+ return e
+}
+
+func (e *errList) dedupe() {
+ var cleaned []error
+ set := make(map[string]bool)
+ for _, err := range *e {
+ if msg := err.Error(); !set[msg] {
+ set[msg] = true
+ cleaned = append(cleaned, err)
+ }
+ }
+ *e = cleaned
+}
+
+func (e errList) Error() string {
+ switch len(e) {
+ case 0:
+ return ""
+ case 1:
+ return e[0].Error()
+ default:
+ var buf bytes.Buffer
+
+ for i, err := range e {
+ if i > 0 {
+ buf.WriteRune('\n')
+ }
+ buf.WriteString(err.Error())
+ }
+ return buf.String()
+ }
+}
+
+// parserError wraps an error with a prefix indicating the rule in which
+// the error occurred. The original error is stored in the Inner field.
+type parserError struct {
+ Inner error
+ pos position
+ prefix string
+ expected []string
+}
+
+// Error returns the error message.
+func (p *parserError) Error() string {
+ return p.prefix + ": " + p.Inner.Error()
+}
+
+// newParser creates a parser with the specified input source and options.
+func newParser(filename string, b []byte, opts ...Option) *parser {
+ stats := Stats{
+ ChoiceAltCnt: make(map[string]map[string]int),
+ }
+
+ p := &parser{
+ filename: filename,
+ errs: new(errList),
+ data: b,
+ pt: savepoint{position: position{line: 1}},
+ recover: true,
+ cur: current{
+ state: make(storeDict),
+ globalStore: make(storeDict),
+ },
+ maxFailPos: position{col: 1, line: 1},
+ maxFailExpected: make([]string, 0, 20),
+ Stats: &stats,
+ // start rule is rule [0] unless an alternate entrypoint is specified
+ entrypoint: g.rules[0].name,
+ }
+ p.setOptions(opts)
+
+ if p.maxExprCnt == 0 {
+ p.maxExprCnt = math.MaxUint64
+ }
+
+ return p
+}
+
+// setOptions applies the options to the parser.
+func (p *parser) setOptions(opts []Option) {
+ for _, opt := range opts {
+ opt(p)
+ }
+}
+
+type resultTuple struct {
+ v interface{}
+ b bool
+ end savepoint
+}
+
+const choiceNoMatch = -1
+
+// Stats stores some statistics, gathered during parsing
+type Stats struct {
+ // ExprCnt counts the number of expressions processed during parsing
+ // This value is compared to the maximum number of expressions allowed
+ // (set by the MaxExpressions option).
+ ExprCnt uint64
+
+ // ChoiceAltCnt is used to count for each ordered choice expression,
+ // which alternative is used how may times.
+ // These numbers allow to optimize the order of the ordered choice expression
+ // to increase the performance of the parser
+ //
+ // The outer key of ChoiceAltCnt is composed of the name of the rule as well
+ // as the line and the column of the ordered choice.
+ // The inner key of ChoiceAltCnt is the number (one-based) of the matching alternative.
+ // For each alternative the number of matches are counted. If an ordered choice does not
+ // match, a special counter is incremented. The name of this counter is set with
+ // the parser option Statistics.
+ // For an alternative to be included in ChoiceAltCnt, it has to match at least once.
+ ChoiceAltCnt map[string]map[string]int
+}
+
+type parser struct {
+ filename string
+ pt savepoint
+ cur current
+
+ data []byte
+ errs *errList
+
+ depth int
+ recover bool
+ debug bool
+
+ memoize bool
+ // memoization table for the packrat algorithm:
+ // map[offset in source] map[expression or rule] {value, match}
+ memo map[int]map[interface{}]resultTuple
+
+ // rules table, maps the rule identifier to the rule node
+ rules map[string]*rule
+ // variables stack, map of label to value
+ vstack []map[string]interface{}
+ // rule stack, allows identification of the current rule in errors
+ rstack []*rule
+
+ // parse fail
+ maxFailPos position
+ maxFailExpected []string
+ maxFailInvertExpected bool
+
+ // max number of expressions to be parsed
+ maxExprCnt uint64
+ // entrypoint for the parser
+ entrypoint string
+
+ allowInvalidUTF8 bool
+
+ *Stats
+
+ choiceNoMatch string
+ // recovery expression stack, keeps track of the currently available recovery expression, these are traversed in reverse
+ recoveryStack []map[string]interface{}
+}
+
+// push a variable set on the vstack.
+func (p *parser) pushV() {
+ if cap(p.vstack) == len(p.vstack) {
+ // create new empty slot in the stack
+ p.vstack = append(p.vstack, nil)
+ } else {
+ // slice to 1 more
+ p.vstack = p.vstack[:len(p.vstack)+1]
+ }
+
+ // get the last args set
+ m := p.vstack[len(p.vstack)-1]
+ if m != nil && len(m) == 0 {
+ // empty map, all good
+ return
+ }
+
+ m = make(map[string]interface{})
+ p.vstack[len(p.vstack)-1] = m
+}
+
+// pop a variable set from the vstack.
+func (p *parser) popV() {
+ // if the map is not empty, clear it
+ m := p.vstack[len(p.vstack)-1]
+ if len(m) > 0 {
+ // GC that map
+ p.vstack[len(p.vstack)-1] = nil
+ }
+ p.vstack = p.vstack[:len(p.vstack)-1]
+}
+
+// push a recovery expression with its labels to the recoveryStack
+func (p *parser) pushRecovery(labels []string, expr interface{}) {
+ if cap(p.recoveryStack) == len(p.recoveryStack) {
+ // create new empty slot in the stack
+ p.recoveryStack = append(p.recoveryStack, nil)
+ } else {
+ // slice to 1 more
+ p.recoveryStack = p.recoveryStack[:len(p.recoveryStack)+1]
+ }
+
+ m := make(map[string]interface{}, len(labels))
+ for _, fl := range labels {
+ m[fl] = expr
+ }
+ p.recoveryStack[len(p.recoveryStack)-1] = m
+}
+
+// pop a recovery expression from the recoveryStack
+func (p *parser) popRecovery() {
+ // GC that map
+ p.recoveryStack[len(p.recoveryStack)-1] = nil
+
+ p.recoveryStack = p.recoveryStack[:len(p.recoveryStack)-1]
+}
+
+func (p *parser) print(prefix, s string) string {
+ if !p.debug {
+ return s
+ }
+
+ fmt.Printf("%s %d:%d:%d: %s [%#U]\n",
+ prefix, p.pt.line, p.pt.col, p.pt.offset, s, p.pt.rn)
+ return s
+}
+
+func (p *parser) in(s string) string {
+ p.depth++
+ return p.print(strings.Repeat(" ", p.depth)+">", s)
+}
+
+func (p *parser) out(s string) string {
+ p.depth--
+ return p.print(strings.Repeat(" ", p.depth)+"<", s)
+}
+
+func (p *parser) addErr(err error) {
+ p.addErrAt(err, p.pt.position, []string{})
+}
+
+func (p *parser) addErrAt(err error, pos position, expected []string) {
+ var buf bytes.Buffer
+ if p.filename != "" {
+ buf.WriteString(p.filename)
+ }
+ if buf.Len() > 0 {
+ buf.WriteString(":")
+ }
+ buf.WriteString(fmt.Sprintf("%d:%d (%d)", pos.line, pos.col, pos.offset))
+ if len(p.rstack) > 0 {
+ if buf.Len() > 0 {
+ buf.WriteString(": ")
+ }
+ rule := p.rstack[len(p.rstack)-1]
+ if rule.displayName != "" {
+ buf.WriteString("rule " + rule.displayName)
+ } else {
+ buf.WriteString("rule " + rule.name)
+ }
+ }
+ pe := &parserError{Inner: err, pos: pos, prefix: buf.String(), expected: expected}
+ p.errs.add(pe)
+}
+
+func (p *parser) failAt(fail bool, pos position, want string) {
+ // process fail if parsing fails and not inverted or parsing succeeds and invert is set
+ if fail == p.maxFailInvertExpected {
+ if pos.offset < p.maxFailPos.offset {
+ return
+ }
+
+ if pos.offset > p.maxFailPos.offset {
+ p.maxFailPos = pos
+ p.maxFailExpected = p.maxFailExpected[:0]
+ }
+
+ if p.maxFailInvertExpected {
+ want = "!" + want
+ }
+ p.maxFailExpected = append(p.maxFailExpected, want)
+ }
+}
+
+// read advances the parser to the next rune.
+func (p *parser) read() {
+ p.pt.offset += p.pt.w
+ rn, n := utf8.DecodeRune(p.data[p.pt.offset:])
+ p.pt.rn = rn
+ p.pt.w = n
+ p.pt.col++
+ if rn == '\n' {
+ p.pt.line++
+ p.pt.col = 0
+ }
+
+ if rn == utf8.RuneError && n == 1 { // see utf8.DecodeRune
+ if !p.allowInvalidUTF8 {
+ p.addErr(errInvalidEncoding)
+ }
+ }
+}
+
+// restore parser position to the savepoint pt.
+func (p *parser) restore(pt savepoint) {
+ if p.debug {
+ defer p.out(p.in("restore"))
+ }
+ if pt.offset == p.pt.offset {
+ return
+ }
+ p.pt = pt
+}
+
+// Cloner is implemented by any value that has a Clone method, which returns a
+// copy of the value. This is mainly used for types which are not passed by
+// value (e.g map, slice, chan) or structs that contain such types.
+//
+// This is used in conjunction with the global state feature to create proper
+// copies of the state to allow the parser to properly restore the state in
+// the case of backtracking.
+type Cloner interface {
+ Clone() interface{}
+}
+
+// clone and return parser current state.
+func (p *parser) cloneState() storeDict {
+ if p.debug {
+ defer p.out(p.in("cloneState"))
+ }
+
+ state := make(storeDict, len(p.cur.state))
+ for k, v := range p.cur.state {
+ if c, ok := v.(Cloner); ok {
+ state[k] = c.Clone()
+ } else {
+ state[k] = v
+ }
+ }
+ return state
+}
+
+// restore parser current state to the state storeDict.
+// every restoreState should applied only one time for every cloned state
+func (p *parser) restoreState(state storeDict) {
+ if p.debug {
+ defer p.out(p.in("restoreState"))
+ }
+ p.cur.state = state
+}
+
+// get the slice of bytes from the savepoint start to the current position.
+func (p *parser) sliceFrom(start savepoint) []byte {
+ return p.data[start.position.offset:p.pt.position.offset]
+}
+
+func (p *parser) getMemoized(node interface{}) (resultTuple, bool) {
+ if len(p.memo) == 0 {
+ return resultTuple{}, false
+ }
+ m := p.memo[p.pt.offset]
+ if len(m) == 0 {
+ return resultTuple{}, false
+ }
+ res, ok := m[node]
+ return res, ok
+}
+
+func (p *parser) setMemoized(pt savepoint, node interface{}, tuple resultTuple) {
+ if p.memo == nil {
+ p.memo = make(map[int]map[interface{}]resultTuple)
+ }
+ m := p.memo[pt.offset]
+ if m == nil {
+ m = make(map[interface{}]resultTuple)
+ p.memo[pt.offset] = m
+ }
+ m[node] = tuple
+}
+
+func (p *parser) buildRulesTable(g *grammar) {
+ p.rules = make(map[string]*rule, len(g.rules))
+ for _, r := range g.rules {
+ p.rules[r.name] = r
+ }
+}
+
+func (p *parser) parse(g *grammar) (val interface{}, err error) {
+ if len(g.rules) == 0 {
+ p.addErr(errNoRule)
+ return nil, p.errs.err()
+ }
+
+ // TODO : not super critical but this could be generated
+ p.buildRulesTable(g)
+
+ if p.recover {
+ // panic can be used in action code to stop parsing immediately
+ // and return the panic as an error.
+ defer func() {
+ if e := recover(); e != nil {
+ if p.debug {
+ defer p.out(p.in("panic handler"))
+ }
+ val = nil
+ switch e := e.(type) {
+ case error:
+ p.addErr(e)
+ default:
+ p.addErr(fmt.Errorf("%v", e))
+ }
+ err = p.errs.err()
+ }
+ }()
+ }
+
+ startRule, ok := p.rules[p.entrypoint]
+ if !ok {
+ p.addErr(errInvalidEntrypoint)
+ return nil, p.errs.err()
+ }
+
+ p.read() // advance to first rune
+ val, ok = p.parseRule(startRule)
+ if !ok {
+ if len(*p.errs) == 0 {
+ // If parsing fails, but no errors have been recorded, the expected values
+ // for the farthest parser position are returned as error.
+ maxFailExpectedMap := make(map[string]struct{}, len(p.maxFailExpected))
+ for _, v := range p.maxFailExpected {
+ maxFailExpectedMap[v] = struct{}{}
+ }
+ expected := make([]string, 0, len(maxFailExpectedMap))
+ eof := false
+ if _, ok := maxFailExpectedMap["!."]; ok {
+ delete(maxFailExpectedMap, "!.")
+ eof = true
+ }
+ for k := range maxFailExpectedMap {
+ expected = append(expected, k)
+ }
+ sort.Strings(expected)
+ if eof {
+ expected = append(expected, "EOF")
+ }
+ p.addErrAt(errors.New("no match found, expected: "+listJoin(expected, ", ", "or")), p.maxFailPos, expected)
+ }
+
+ return nil, p.errs.err()
+ }
+ return val, p.errs.err()
+}
+
+func listJoin(list []string, sep string, lastSep string) string {
+ switch len(list) {
+ case 0:
+ return ""
+ case 1:
+ return list[0]
+ default:
+ return fmt.Sprintf("%s %s %s", strings.Join(list[:len(list)-1], sep), lastSep, list[len(list)-1])
+ }
+}
+
+func (p *parser) parseRule(rule *rule) (interface{}, bool) {
+ if p.debug {
+ defer p.out(p.in("parseRule " + rule.name))
+ }
+
+ if p.memoize {
+ res, ok := p.getMemoized(rule)
+ if ok {
+ p.restore(res.end)
+ return res.v, res.b
+ }
+ }
+
+ start := p.pt
+ p.rstack = append(p.rstack, rule)
+ p.pushV()
+ val, ok := p.parseExpr(rule.expr)
+ p.popV()
+ p.rstack = p.rstack[:len(p.rstack)-1]
+ if ok && p.debug {
+ p.print(strings.Repeat(" ", p.depth)+"MATCH", string(p.sliceFrom(start)))
+ }
+
+ if p.memoize {
+ p.setMemoized(start, rule, resultTuple{val, ok, p.pt})
+ }
+ return val, ok
+}
+
+func (p *parser) parseExpr(expr interface{}) (interface{}, bool) {
+ var pt savepoint
+
+ if p.memoize {
+ res, ok := p.getMemoized(expr)
+ if ok {
+ p.restore(res.end)
+ return res.v, res.b
+ }
+ pt = p.pt
+ }
+
+ p.ExprCnt++
+ if p.ExprCnt > p.maxExprCnt {
+ panic(errMaxExprCnt)
+ }
+
+ var val interface{}
+ var ok bool
+ switch expr := expr.(type) {
+ case *actionExpr:
+ val, ok = p.parseActionExpr(expr)
+ case *andCodeExpr:
+ val, ok = p.parseAndCodeExpr(expr)
+ case *andExpr:
+ val, ok = p.parseAndExpr(expr)
+ case *anyMatcher:
+ val, ok = p.parseAnyMatcher(expr)
+ case *charClassMatcher:
+ val, ok = p.parseCharClassMatcher(expr)
+ case *choiceExpr:
+ val, ok = p.parseChoiceExpr(expr)
+ case *labeledExpr:
+ val, ok = p.parseLabeledExpr(expr)
+ case *litMatcher:
+ val, ok = p.parseLitMatcher(expr)
+ case *notCodeExpr:
+ val, ok = p.parseNotCodeExpr(expr)
+ case *notExpr:
+ val, ok = p.parseNotExpr(expr)
+ case *oneOrMoreExpr:
+ val, ok = p.parseOneOrMoreExpr(expr)
+ case *recoveryExpr:
+ val, ok = p.parseRecoveryExpr(expr)
+ case *ruleRefExpr:
+ val, ok = p.parseRuleRefExpr(expr)
+ case *seqExpr:
+ val, ok = p.parseSeqExpr(expr)
+ case *stateCodeExpr:
+ val, ok = p.parseStateCodeExpr(expr)
+ case *throwExpr:
+ val, ok = p.parseThrowExpr(expr)
+ case *zeroOrMoreExpr:
+ val, ok = p.parseZeroOrMoreExpr(expr)
+ case *zeroOrOneExpr:
+ val, ok = p.parseZeroOrOneExpr(expr)
+ default:
+ panic(fmt.Sprintf("unknown expression type %T", expr))
+ }
+ if p.memoize {
+ p.setMemoized(pt, expr, resultTuple{val, ok, p.pt})
+ }
+ return val, ok
+}
+
+func (p *parser) parseActionExpr(act *actionExpr) (interface{}, bool) {
+ if p.debug {
+ defer p.out(p.in("parseActionExpr"))
+ }
+
+ start := p.pt
+ val, ok := p.parseExpr(act.expr)
+ if ok {
+ p.cur.pos = start.position
+ p.cur.text = p.sliceFrom(start)
+ state := p.cloneState()
+ actVal, err := act.run(p)
+ if err != nil {
+ p.addErrAt(err, start.position, []string{})
+ }
+ p.restoreState(state)
+
+ val = actVal
+ }
+ if ok && p.debug {
+ p.print(strings.Repeat(" ", p.depth)+"MATCH", string(p.sliceFrom(start)))
+ }
+ return val, ok
+}
+
+func (p *parser) parseAndCodeExpr(and *andCodeExpr) (interface{}, bool) {
+ if p.debug {
+ defer p.out(p.in("parseAndCodeExpr"))
+ }
+
+ state := p.cloneState()
+
+ ok, err := and.run(p)
+ if err != nil {
+ p.addErr(err)
+ }
+ p.restoreState(state)
+
+ return nil, ok
+}
+
+func (p *parser) parseAndExpr(and *andExpr) (interface{}, bool) {
+ if p.debug {
+ defer p.out(p.in("parseAndExpr"))
+ }
+
+ pt := p.pt
+ state := p.cloneState()
+ p.pushV()
+ _, ok := p.parseExpr(and.expr)
+ p.popV()
+ p.restoreState(state)
+ p.restore(pt)
+
+ return nil, ok
+}
+
+func (p *parser) parseAnyMatcher(any *anyMatcher) (interface{}, bool) {
+ if p.debug {
+ defer p.out(p.in("parseAnyMatcher"))
+ }
+
+ if p.pt.rn == utf8.RuneError && p.pt.w == 0 {
+ // EOF - see utf8.DecodeRune
+ p.failAt(false, p.pt.position, ".")
+ return nil, false
+ }
+ start := p.pt
+ p.read()
+ p.failAt(true, start.position, ".")
+ return p.sliceFrom(start), true
+}
+
+func (p *parser) parseCharClassMatcher(chr *charClassMatcher) (interface{}, bool) {
+ if p.debug {
+ defer p.out(p.in("parseCharClassMatcher"))
+ }
+
+ cur := p.pt.rn
+ start := p.pt
+
+ // can't match EOF
+ if cur == utf8.RuneError && p.pt.w == 0 { // see utf8.DecodeRune
+ p.failAt(false, start.position, chr.val)
+ return nil, false
+ }
+
+ if chr.ignoreCase {
+ cur = unicode.ToLower(cur)
+ }
+
+ // try to match in the list of available chars
+ for _, rn := range chr.chars {
+ if rn == cur {
+ if chr.inverted {
+ p.failAt(false, start.position, chr.val)
+ return nil, false
+ }
+ p.read()
+ p.failAt(true, start.position, chr.val)
+ return p.sliceFrom(start), true
+ }
+ }
+
+ // try to match in the list of ranges
+ for i := 0; i < len(chr.ranges); i += 2 {
+ if cur >= chr.ranges[i] && cur <= chr.ranges[i+1] {
+ if chr.inverted {
+ p.failAt(false, start.position, chr.val)
+ return nil, false
+ }
+ p.read()
+ p.failAt(true, start.position, chr.val)
+ return p.sliceFrom(start), true
+ }
+ }
+
+ // try to match in the list of Unicode classes
+ for _, cl := range chr.classes {
+ if unicode.Is(cl, cur) {
+ if chr.inverted {
+ p.failAt(false, start.position, chr.val)
+ return nil, false
+ }
+ p.read()
+ p.failAt(true, start.position, chr.val)
+ return p.sliceFrom(start), true
+ }
+ }
+
+ if chr.inverted {
+ p.read()
+ p.failAt(true, start.position, chr.val)
+ return p.sliceFrom(start), true
+ }
+ p.failAt(false, start.position, chr.val)
+ return nil, false
+}
+
+func (p *parser) incChoiceAltCnt(ch *choiceExpr, altI int) {
+ choiceIdent := fmt.Sprintf("%s %d:%d", p.rstack[len(p.rstack)-1].name, ch.pos.line, ch.pos.col)
+ m := p.ChoiceAltCnt[choiceIdent]
+ if m == nil {
+ m = make(map[string]int)
+ p.ChoiceAltCnt[choiceIdent] = m
+ }
+ // We increment altI by 1, so the keys do not start at 0
+ alt := strconv.Itoa(altI + 1)
+ if altI == choiceNoMatch {
+ alt = p.choiceNoMatch
+ }
+ m[alt]++
+}
+
+func (p *parser) parseChoiceExpr(ch *choiceExpr) (interface{}, bool) {
+ if p.debug {
+ defer p.out(p.in("parseChoiceExpr"))
+ }
+
+ for altI, alt := range ch.alternatives {
+ // dummy assignment to prevent compile error if optimized
+ _ = altI
+
+ state := p.cloneState()
+
+ p.pushV()
+ val, ok := p.parseExpr(alt)
+ p.popV()
+ if ok {
+ p.incChoiceAltCnt(ch, altI)
+ return val, ok
+ }
+ p.restoreState(state)
+ }
+ p.incChoiceAltCnt(ch, choiceNoMatch)
+ return nil, false
+}
+
+func (p *parser) parseLabeledExpr(lab *labeledExpr) (interface{}, bool) {
+ if p.debug {
+ defer p.out(p.in("parseLabeledExpr"))
+ }
+
+ p.pushV()
+ val, ok := p.parseExpr(lab.expr)
+ p.popV()
+ if ok && lab.label != "" {
+ m := p.vstack[len(p.vstack)-1]
+ m[lab.label] = val
+ }
+ return val, ok
+}
+
+func (p *parser) parseLitMatcher(lit *litMatcher) (interface{}, bool) {
+ if p.debug {
+ defer p.out(p.in("parseLitMatcher"))
+ }
+
+ ignoreCase := ""
+ if lit.ignoreCase {
+ ignoreCase = "i"
+ }
+ val := fmt.Sprintf("%q%s", lit.val, ignoreCase)
+ start := p.pt
+ for _, want := range lit.val {
+ cur := p.pt.rn
+ if lit.ignoreCase {
+ cur = unicode.ToLower(cur)
+ }
+ if cur != want {
+ p.failAt(false, start.position, val)
+ p.restore(start)
+ return nil, false
+ }
+ p.read()
+ }
+ p.failAt(true, start.position, val)
+ return p.sliceFrom(start), true
+}
+
+func (p *parser) parseNotCodeExpr(not *notCodeExpr) (interface{}, bool) {
+ if p.debug {
+ defer p.out(p.in("parseNotCodeExpr"))
+ }
+
+ state := p.cloneState()
+
+ ok, err := not.run(p)
+ if err != nil {
+ p.addErr(err)
+ }
+ p.restoreState(state)
+
+ return nil, !ok
+}
+
+func (p *parser) parseNotExpr(not *notExpr) (interface{}, bool) {
+ if p.debug {
+ defer p.out(p.in("parseNotExpr"))
+ }
+
+ pt := p.pt
+ state := p.cloneState()
+ p.pushV()
+ p.maxFailInvertExpected = !p.maxFailInvertExpected
+ _, ok := p.parseExpr(not.expr)
+ p.maxFailInvertExpected = !p.maxFailInvertExpected
+ p.popV()
+ p.restoreState(state)
+ p.restore(pt)
+
+ return nil, !ok
+}
+
+func (p *parser) parseOneOrMoreExpr(expr *oneOrMoreExpr) (interface{}, bool) {
+ if p.debug {
+ defer p.out(p.in("parseOneOrMoreExpr"))
+ }
+
+ var vals []interface{}
+
+ for {
+ p.pushV()
+ val, ok := p.parseExpr(expr.expr)
+ p.popV()
+ if !ok {
+ if len(vals) == 0 {
+ // did not match once, no match
+ return nil, false
+ }
+ return vals, true
+ }
+ vals = append(vals, val)
+ }
+}
+
+func (p *parser) parseRecoveryExpr(recover *recoveryExpr) (interface{}, bool) {
+ if p.debug {
+ defer p.out(p.in("parseRecoveryExpr (" + strings.Join(recover.failureLabel, ",") + ")"))
+ }
+
+ p.pushRecovery(recover.failureLabel, recover.recoverExpr)
+ val, ok := p.parseExpr(recover.expr)
+ p.popRecovery()
+
+ return val, ok
+}
+
+func (p *parser) parseRuleRefExpr(ref *ruleRefExpr) (interface{}, bool) {
+ if p.debug {
+ defer p.out(p.in("parseRuleRefExpr " + ref.name))
+ }
+
+ if ref.name == "" {
+ panic(fmt.Sprintf("%s: invalid rule: missing name", ref.pos))
+ }
+
+ rule := p.rules[ref.name]
+ if rule == nil {
+ p.addErr(fmt.Errorf("undefined rule: %s", ref.name))
+ return nil, false
+ }
+ return p.parseRule(rule)
+}
+
+func (p *parser) parseSeqExpr(seq *seqExpr) (interface{}, bool) {
+ if p.debug {
+ defer p.out(p.in("parseSeqExpr"))
+ }
+
+ vals := make([]interface{}, 0, len(seq.exprs))
+
+ pt := p.pt
+ state := p.cloneState()
+ for _, expr := range seq.exprs {
+ val, ok := p.parseExpr(expr)
+ if !ok {
+ p.restoreState(state)
+ p.restore(pt)
+ return nil, false
+ }
+ vals = append(vals, val)
+ }
+ return vals, true
+}
+
+func (p *parser) parseStateCodeExpr(state *stateCodeExpr) (interface{}, bool) {
+ if p.debug {
+ defer p.out(p.in("parseStateCodeExpr"))
+ }
+
+ err := state.run(p)
+ if err != nil {
+ p.addErr(err)
+ }
+ return nil, true
+}
+
+func (p *parser) parseThrowExpr(expr *throwExpr) (interface{}, bool) {
+ if p.debug {
+ defer p.out(p.in("parseThrowExpr"))
+ }
+
+ for i := len(p.recoveryStack) - 1; i >= 0; i-- {
+ if recoverExpr, ok := p.recoveryStack[i][expr.label]; ok {
+ if val, ok := p.parseExpr(recoverExpr); ok {
+ return val, ok
+ }
+ }
+ }
+
+ return nil, false
+}
+
+func (p *parser) parseZeroOrMoreExpr(expr *zeroOrMoreExpr) (interface{}, bool) {
+ if p.debug {
+ defer p.out(p.in("parseZeroOrMoreExpr"))
+ }
+
+ var vals []interface{}
+
+ for {
+ p.pushV()
+ val, ok := p.parseExpr(expr.expr)
+ p.popV()
+ if !ok {
+ return vals, true
+ }
+ vals = append(vals, val)
+ }
+}
+
+func (p *parser) parseZeroOrOneExpr(expr *zeroOrOneExpr) (interface{}, bool) {
+ if p.debug {
+ defer p.out(p.in("parseZeroOrOneExpr"))
+ }
+
+ p.pushV()
+ val, _ := p.parseExpr(expr.expr)
+ p.popV()
+ // whether it matched or not, consider it a match
+ return val, true
+}
diff --git a/core/vm/sqlvm/grammar.peg b/core/vm/sqlvm/grammar.peg
new file mode 100644
index 000000000..ac2f8928c
--- /dev/null
+++ b/core/vm/sqlvm/grammar.peg
@@ -0,0 +1,763 @@
+{
+package sqlvm
+}
+
+S
+ <- _ x:Stmt? _ xs:( ';' _ s:Stmt? _ { return s, nil } )* EOF
+{ return prepend(x, xs), nil }
+
+/* statement */
+Stmt
+ = SelectStmt
+ / UpdateStmt
+ / DeleteStmt
+ / InsertStmt
+ / CreateTableStmt
+ / CreateIndexStmt
+
+SelectStmt
+ = SelectToken
+ _ f:SelectColumn fs:( _ SeparatorToken _ s:SelectColumn { return s, nil } )*
+ table:( _ FromToken _ i:Identifier { return i, nil } )?
+ where:( _ w:WhereClause { return w, nil } )?
+ group:( _ g:GroupByClause { return g, nil } )?
+ order:( _ or:OrderByClause { return or, nil } )?
+ limit:( _ l:LimitClause { return l, nil } )?
+ offset:( _ of:OffsetClause { return of, nil } )?
+{
+ var (
+ tableNode *identifierNode
+ whereNode *whereOptionNode
+ limitNode *limitOptionNode
+ offsetNode *offsetOptionNode
+ )
+ if table != nil {
+ t := table.(identifierNode)
+ tableNode = &t
+ }
+ if where != nil {
+ w := where.(whereOptionNode)
+ whereNode = &w
+ }
+ if limit != nil {
+ l := limit.(limitOptionNode)
+ limitNode = &l
+ }
+ if offset != nil {
+ of := offset.(offsetOptionNode)
+ offsetNode = &of
+ }
+ return selectStmtNode{
+ column: prepend(f, fs),
+ table: tableNode,
+ where: whereNode,
+ group: toSlice(group),
+ order: toSlice(order),
+ limit: limitNode,
+ offset: offsetNode,
+ }, nil
+}
+
+SelectColumn
+ = AnyLiteral
+ / Expr
+
+UpdateStmt
+ = UpdateToken
+ _ table:Identifier
+ _ SetToken
+ _ a:Assignment as:( _ SeparatorToken _ s:Assignment { return s, nil } )*
+ where:( _ w:WhereClause { return w, nil } )?
+{
+ var (
+ whereNode *whereOptionNode
+ )
+ if where != nil {
+ w := where.(whereOptionNode)
+ whereNode = &w
+ }
+ return updateStmtNode{
+ table: table.(identifierNode),
+ assignment: prepend(a, as),
+ where: whereNode,
+ }, nil
+}
+
+DeleteStmt
+ = DeleteToken
+ _ FromToken
+ _ table:Identifier
+ where:( _ w:WhereClause { return w, nil } )?
+{
+ var (
+ whereNode *whereOptionNode
+ )
+ if where != nil {
+ w := where.(whereOptionNode)
+ whereNode = &w
+ }
+ return deleteStmtNode{
+ table: table.(identifierNode),
+ where: whereNode,
+ }, nil
+}
+
+InsertStmt
+ = InsertToken
+ _ IntoToken
+ _ table:Identifier
+ _ insert:( InsertWithColumnClause / InsertWithDefaultClause )
+{
+ return insertStmtNode{
+ table: table.(identifierNode),
+ insert: insert,
+ }, nil
+}
+
+InsertValue
+ = '(' _ e:MultiExprWithDefault _ ')'
+{ return e, nil }
+
+CreateTableStmt
+ = CreateToken
+ _ TableToken
+ _ table:Identifier
+ _ '('
+ _ column:(
+ s:ColumnSchema
+ ss:( _ SeparatorToken _ t:ColumnSchema { return t, nil } )*
+ { return prepend(s, ss), nil }
+ )?
+ _ ')'
+{
+ return createTableStmtNode{
+ table: table.(identifierNode),
+ column: toSlice(column),
+ }, nil
+}
+
+ColumnSchema
+ = i:Identifier
+ _ t:DataType
+ cs:( _ s:ColumnConstraint { return s, nil } )*
+{
+ return columnSchemaNode{
+ column: i.(identifierNode),
+ dataType: t,
+ constraint: toSlice(cs),
+ }, nil
+}
+
+ColumnConstraint
+ = PrimaryKeyClause
+ / NotNullClause
+ / UniqueClause
+ / DefaultClause
+ / ForeignClause
+ / AutoincrementClause
+
+CreateIndexStmt
+ = CreateToken
+ unique:( _ u:UniqueClause { return u, nil } )?
+ _ IndexToken
+ _ index:Identifier
+ _ OnToken
+ _ table:Identifier
+ _ '(' _ i:Identifier is:( _ SeparatorToken _ x:Identifier { return x, nil } )* _ ')'
+{
+ var (
+ uniqueNode *uniqueOptionNode
+ )
+ if unique != nil {
+ u := unique.(uniqueOptionNode)
+ uniqueNode = &u
+ }
+ return createIndexStmtNode{
+ index: index.(identifierNode),
+ table: table.(identifierNode),
+ column: prepend(i, is),
+ unique: uniqueNode,
+ }, nil
+}
+
+/* clause */
+WhereClause
+ = WhereToken _ e:Expr
+{ return whereOptionNode{condition: e}, nil }
+
+OrderByClause
+ = OrderToken
+ _ ByToken
+ _ f:OrderColumn
+ fs:( _ SeparatorToken _ s:OrderColumn { return s, nil } )*
+{ return prepend(f, fs), nil }
+
+OrderColumn
+ = i:Expr
+ s:( _ t:( AscToken / DescToken ) { return t, nil } )?
+ n:( _ NullsToken _ l:( LastToken / FirstToken ) { return l, nil } )?
+{
+ return orderOptionNode{
+ expr: i,
+ desc: s != nil && string(s.([]byte)) == "desc",
+ nullfirst: n != nil && string(n.([]byte)) == "first",
+ }, nil
+}
+
+GroupByClause
+ = GroupToken
+ _ ByToken
+ _ i:Expr
+ is:( _ SeparatorToken _ s:Expr { return groupOptionNode{expr: s}, nil } )*
+{ return prepend(groupOptionNode{expr: i}, is), nil }
+
+OffsetClause
+ = OffsetToken _ i:Integer
+{ return offsetOptionNode{value: i.(integerValueNode)}, nil }
+
+LimitClause
+ = LimitToken _ i:Integer
+{ return limitOptionNode{value: i.(integerValueNode)}, nil }
+
+InsertWithColumnClause
+ = cs:( '('
+ _ f:Identifier
+ fs:( _ SeparatorToken _ x:Identifier { return x, nil } )*
+ _ ')'
+ _ { return prepend(f, fs), nil }
+ )?
+ ValuesToken
+ _ v:InsertValue
+ vs:( _ SeparatorToken _ y:InsertValue { return y, nil } )*
+{
+ return insertWithColumnOptionNode{
+ column: toSlice(cs),
+ value: prepend(v, vs),
+ }, nil
+}
+
+InsertWithDefaultClause
+ = DefaultToken _ ValuesToken
+{ return insertWithDefaultOptionNode{}, nil }
+
+PrimaryKeyClause
+ = PrimaryToken _ KeyToken
+{ return primaryOptionNode{}, nil }
+
+NotNullClause
+ = NotToken _ NullToken
+{ return notNullOptionNode{}, nil }
+
+UniqueClause
+ = UniqueToken
+{ return uniqueOptionNode{}, nil }
+
+DefaultClause
+ = DefaultToken _ e:Expr
+{ return defaultOptionNode{value: e}, nil }
+
+ForeignClause
+ = ReferencesToken _ t:Identifier _ '(' _ f:Identifier _ ')'
+{
+ return foreignOptionNode{
+ table: t.(identifierNode),
+ column: f.(identifierNode),
+ }, nil
+}
+
+AutoincrementClause
+ = AutoincrementToken
+{ return autoincrementOptionNode{}, nil }
+
+/* expression */
+Expr
+ = LogicExpr
+
+ExprWithDefault
+ = &(DefaultLiteral) d:DefaultLiteral { return d, nil }
+ / Expr
+
+LogicExpr
+ = LogicExpr4
+
+LogicExpr4
+ = o:LogicExpr3
+ os:( _ op:OrOperator _ s:LogicExpr3 { return opSetSubject(op, s), nil } )*
+{ return rightJoinOperators(o, os), nil }
+
+LogicExpr3
+ = o:LogicExpr2
+ os:( _ op:AndOperator _ s:LogicExpr2 { return opSetSubject(op, s), nil } )*
+{ return rightJoinOperators(o, os), nil }
+
+LogicExpr2
+ = op:NotOperator _ s:LogicExpr2
+ { return opSetTarget(op, s), nil }
+ / LogicExpr1
+
+LogicExpr1
+ = o:ArithmeticExpr os:( _ l:LogicExpr1Op { return l, nil } )*
+{ return rightJoinOperators(o, os), nil }
+
+LogicExpr1Op
+ = LogicExpr1In
+ / LogicExpr1Null
+ / LogicExpr1Like
+ / LogicExpr1Cmp
+
+LogicExpr1In
+ = n:( t:NotOperator _ { return t, nil } )? InToken _ '(' _ s:MultiExpr _ ')'
+{
+ op := opSetSubject(&inOperatorNode{}, s)
+ if n != nil {
+ return opSetTarget(n, op), nil
+ }
+ return op, nil
+}
+
+LogicExpr1Null
+ = IsToken n:( _ t:NotOperator { return t, nil } )? _ NullToken
+{
+ op := opSetSubject(&isOperatorNode{}, nullValueNode{})
+ if n != nil {
+ return opSetTarget(n, op), nil
+ }
+ return op, nil
+}
+
+LogicExpr1Like
+ = n:( t:NotOperator _ { return t, nil } )? LikeToken _ s:Expr
+{
+ op := opSetSubject(&likeOperatorNode{}, s)
+ if n != nil {
+ return opSetTarget(n, op), nil
+ }
+ return op, nil
+}
+
+LogicExpr1Cmp
+ = op:CmpOperator _ s:ArithmeticExpr
+{ return opSetSubject(op, s), nil }
+
+ArithmeticExpr
+ = ArithmeticExpr3
+
+ArithmeticExpr3
+ = o:ArithmeticExpr2 os:( _ op:ConcatOperator _ s:ArithmeticExpr2 { return opSetSubject(op, s), nil } )*
+{ return rightJoinOperators(o, os), nil }
+
+ArithmeticExpr2
+ = o:ArithmeticExpr1 os:( _ op:AddSubOperator _ s:ArithmeticExpr1 { return opSetSubject(op, s), nil } )*
+{ return rightJoinOperators(o, os), nil }
+
+ArithmeticExpr1
+ = o:Operand os:( _ op:MulDivModOperator _ s:Operand { return opSetSubject(op, s), nil } )*
+{ return rightJoinOperators(o, os), nil }
+
+MultiExpr
+ = x:Expr xs:( _ SeparatorToken _ e:Expr { return e, nil } )*
+{ return prepend(x, xs), nil }
+
+MultiExprWithDefault
+ = x:ExprWithDefault xs:( _ SeparatorToken _ e:ExprWithDefault { return e, nil } )*
+{ return prepend(x, xs), nil }
+
+Operand
+ = op:UnaryOperator _ s:Operand { return opSetTarget(op, s), nil }
+ / '(' _ e:Expr _ ')' { return e, nil }
+ / &(CastToken) t:TypeCast { return t, nil }
+ / FunctionCall
+ / Value
+ / Identifier
+
+TypeCast
+ = CastToken _ '(' _ o:Expr _ AsToken _ s:DataType _ ')'
+{ return opSetSubject(opSetObject(&castOperatorNode{}, o), s), nil }
+
+FunctionCall
+ = i:Identifier _ '(' _ r:FunctionArgs? _ ')'
+{ return opSetSubject(opSetObject(&functionOperatorNode{}, i), r), nil }
+
+FunctionArgs
+ = a:AnyLiteral { return []interface{}{a}, nil }
+ / MultiExpr
+
+Assignment
+ = i:Identifier _ '=' _ e:ExprWithDefault
+{ return opSetSubject(opSetObject(&assignOperatorNode{}, i), e), nil }
+
+/* operator */
+UnaryOperator
+ = SignOperator
+
+SignOperator
+ = Sign
+{
+ switch string(c.text) {
+ case "+":
+ return &posOperatorNode{}, nil
+ case "-":
+ return &negOperatorNode{}, nil
+ }
+ return nil, errors.New("unknown sign")
+}
+
+NotOperator
+ = NotToken
+{ return &notOperatorNode{}, nil }
+
+AndOperator
+ = AndToken
+{ return &andOperatorNode{}, nil }
+
+OrOperator
+ = OrToken
+{ return &orOperatorNode{}, nil }
+
+CmpOperator
+ = ( "<=" / ">=" / "<>" / "!=" / [<>=] )
+{
+ switch string(c.text) {
+ case "<=":
+ return &lessOrEqualOperatorNode{}, nil
+ case ">=":
+ return &greaterOrEqualOperatorNode{}, nil
+ case "<>":
+ return &notEqualOperatorNode{}, nil
+ case "!=":
+ return &notEqualOperatorNode{}, nil
+ case "<":
+ return &lessOperatorNode{}, nil
+ case ">":
+ return &greaterOperatorNode{}, nil
+ case "=":
+ return &equalOperatorNode{}, nil
+ }
+ return nil, errors.New("unknown cmp")
+}
+
+ConcatOperator
+ = "||"
+{ return &concatOperatorNode{}, nil }
+
+AddSubOperator
+ = [+-]
+{
+ switch string(c.text) {
+ case "+":
+ return &addOperatorNode{}, nil
+ case "-":
+ return &subOperatorNode{}, nil
+ }
+ return nil, errors.New("unknown add sub")
+}
+
+MulDivModOperator
+ = [*/%]
+{
+ switch string(c.text) {
+ case "*":
+ return &mulOperatorNode{}, nil
+ case "/":
+ return &divOperatorNode{}, nil
+ case "%":
+ return &modOperatorNode{}, nil
+ }
+ return nil, errors.New("unknown mul div mod")
+}
+
+/* type */
+DataType
+ = UIntType
+ / IntType
+ / UFixedType
+ / FixedType
+ / FixedBytesType
+ / DynamicBytesType
+ / BoolType
+ / AddressType
+
+UIntType
+ = "UINT"i s:NonZeroLeadingInteger !NormalIdentifierRest
+{ return intTypeNode{size: toInt(s.([]byte)), unsigned: true}, nil }
+
+IntType
+ = "INT"i s:NonZeroLeadingInteger !NormalIdentifierRest
+{ return intTypeNode{size: toInt(s.([]byte))}, nil }
+
+UFixedType
+ = "UFIXED"i s:NonZeroLeadingInteger "X"i t:NonZeroLeadingInteger !NormalIdentifierRest
+{
+ return fixedTypeNode{
+ integerSize: toInt(s.([]byte)),
+ fractionalSize: toInt(t.([]byte)),
+ unsigned: true,
+ }, nil
+}
+
+FixedType
+ = "FIXED"i s:NonZeroLeadingInteger "X"i t:NonZeroLeadingInteger !NormalIdentifierRest
+{
+ return fixedTypeNode{
+ integerSize: toInt(s.([]byte)),
+ fractionalSize: toInt(t.([]byte)),
+ }, nil
+}
+
+FixedBytesType
+ = "BYTES"i s:NonZeroLeadingInteger !NormalIdentifierRest
+{ return fixedBytesTypeNode{size: toInt(s.([]byte))}, nil }
+ / "BYTE"i !NormalIdentifierRest
+{ return fixedBytesTypeNode{size: 1}, nil }
+
+DynamicBytesType
+ = ( "BYTES"i !NormalIdentifierRest
+ / "STRING"i !NormalIdentifierRest
+ / "TEXT"i !NormalIdentifierRest
+ )
+{ return dynamicBytesTypeNode{}, nil }
+
+AddressType
+ = "ADDRESS"i !NormalIdentifierRest
+{ return addressTypeNode{}, nil }
+
+BoolType
+ = ( "BOOL"i !NormalIdentifierRest
+ / "BOOLEAN"i !NormalIdentifierRest
+ )
+{ return boolTypeNode{}, nil }
+
+/* value */
+Value
+ = NumberLiteral
+ / StringLiteral
+ / BoolLiteral
+ / NullLiteral
+
+AnyLiteral
+ = AnyToken
+{ return anyValueNode{}, nil }
+
+DefaultLiteral
+ = DefaultToken
+{ return defaultValueNode{}, nil }
+
+BoolLiteral
+ = b:( TrueToken / FalseToken )
+{ return boolValueNode(string(b.([]byte)) == "true"), nil }
+
+NullLiteral
+ = NullToken
+{ return nullValueNode{}, nil }
+
+NumberLiteral
+ = &("0" "X"i) h:Hex { return h, nil }
+ / Decimal
+
+Sign
+ = [-+]
+
+Integer
+ = [0-9]+
+{ return integerValueNode{v: toDecimal(c.text)}, nil }
+
+NonZeroLeadingInteger
+ = ( "0" / [1-9][0-9]* )
+{ return c.text, nil }
+
+Fixnum
+ = Integer "." Integer
+ / Integer "."?
+ / "." Integer
+
+Decimal
+ = Fixnum ( "E"i Sign? Integer )?
+{ return decimalValueNode(toDecimal(c.text)), nil }
+
+Hex
+ = "0" "X"i s:( [0-9A-Fa-f] )+ !NormalIdentifierRest
+{ return hexToInteger(joinBytes(s)), nil }
+
+StringLiteral
+ = HexString
+ / NormalString
+
+HexString
+ = ( "HEX"i / "X"i ) "'" s:([0-9a-fA-F][0-9a-fA-F] { return c.text, nil } )* "'"
+{ return bytesValueNode(hexToBytes(joinBytes(s))), nil }
+
+NormalString
+ = "'" s:( ( [^'\r\n\\] / "\\" . ) { return c.text, nil } )* "'"
+{ return bytesValueNode(resolveString(joinBytes(s))), nil }
+
+/* token */
+SelectToken
+ = "SELECT"i !NormalIdentifierRest
+
+FromToken
+ = "FROM"i !NormalIdentifierRest
+
+WhereToken
+ = "WHERE"i !NormalIdentifierRest
+
+OrderToken
+ = "ORDER"i !NormalIdentifierRest
+
+ByToken
+ = "BY"i !NormalIdentifierRest
+
+GroupToken
+ = "GROUP"i !NormalIdentifierRest
+
+LimitToken
+ = "LIMIT"i !NormalIdentifierRest
+
+OffsetToken
+ = "OFFSET"i !NormalIdentifierRest
+
+UpdateToken
+ = "UPDATE"i !NormalIdentifierRest
+
+SetToken
+ = "SET"i !NormalIdentifierRest
+
+DeleteToken
+ = "DELETE"i !NormalIdentifierRest
+
+InsertToken
+ = "INSERT"i !NormalIdentifierRest
+
+IntoToken
+ = "INTO"i !NormalIdentifierRest
+
+ValuesToken
+ = "VALUES"i !NormalIdentifierRest
+
+CreateToken
+ = "CREATE"i !NormalIdentifierRest
+
+TableToken
+ = "TABLE"i !NormalIdentifierRest
+
+IndexToken
+ = "INDEX"i !NormalIdentifierRest
+
+UniqueToken
+ = "UNIQUE"i !NormalIdentifierRest
+
+DefaultToken
+ = "DEFAULT"i !NormalIdentifierRest
+
+PrimaryToken
+ = "PRIMARY"i !NormalIdentifierRest
+
+KeyToken
+ = "KEY"i !NormalIdentifierRest
+
+ReferencesToken
+ = "REFERENCES"i !NormalIdentifierRest
+
+AutoincrementToken
+ = "AUTOINCREMENT"i !NormalIdentifierRest
+
+OnToken
+ = "ON"i !NormalIdentifierRest
+
+TrueToken
+ = "TRUE"i !NormalIdentifierRest
+{ return toLower(c.text), nil }
+
+FalseToken
+ = "FALSE"i !NormalIdentifierRest
+{ return toLower(c.text), nil }
+
+NullToken
+ = "NULL"i !NormalIdentifierRest
+
+IsToken
+ = "IS"i !NormalIdentifierRest
+
+NullsToken
+ = "NULLS"i !NormalIdentifierRest
+
+LastToken
+ = "LAST"i !NormalIdentifierRest
+{ return toLower(c.text), nil }
+
+FirstToken
+ = "FIRST"i !NormalIdentifierRest
+{ return toLower(c.text), nil }
+
+AndToken
+ = "AND"i !NormalIdentifierRest
+
+OrToken
+ = "OR"i !NormalIdentifierRest
+
+NotToken
+ = "NOT"i !NormalIdentifierRest
+
+InToken
+ = "IN"i !NormalIdentifierRest
+
+LikeToken
+ = "LIKE"i !NormalIdentifierRest
+
+AscToken
+ = "ASC"i !NormalIdentifierRest
+{ return toLower(c.text), nil }
+
+DescToken
+ = "DESC"i !NormalIdentifierRest
+{ return toLower(c.text), nil }
+
+CastToken
+ = "CAST"i !NormalIdentifierRest
+
+AsToken
+ = "AS"i !NormalIdentifierRest
+
+SeparatorToken
+ = ","
+
+AnyToken
+ = "*"
+
+/* identifier */
+Identifier
+ = NormalIdentifier
+ / StringIdentifier
+
+NormalIdentifier
+ = NormalIdentifierStart NormalIdentifierRest*
+{ return identifierNode(c.text), nil }
+
+NormalIdentifierStart
+ = [a-zA-Z@#_\u0080-\uffff]
+
+NormalIdentifierRest
+ = [a-zA-Z0-9@#$_\u0080-\uffff]
+
+StringIdentifier
+ = "\"" s:( ( [^"\r\n\\] / "\\" . ) { return c.text, nil } )* "\""
+{
+ return identifierNode(resolveString(joinBytes(s))), nil
+}
+
+/* skip */
+_
+ = ( Whitespace / Newline )*
+
+Newline
+ = "\r\n"
+ / "\r"
+ / "\n"
+
+Whitespace
+ = " "
+ / "\t"
+ / "\v"
+ / "\f"
+
+EOF
+ = !.
diff --git a/core/vm/sqlvm/parser.go b/core/vm/sqlvm/parser.go
new file mode 100644
index 000000000..0b284c0e3
--- /dev/null
+++ b/core/vm/sqlvm/parser.go
@@ -0,0 +1,125 @@
+package sqlvm
+
+import (
+ "encoding/hex"
+ "strconv"
+ "strings"
+
+ "github.com/shopspring/decimal"
+)
+
+// Parser was generated with pigeon v1.0.0-99-gbb0192c.
+//go:generate pigeon -no-recover -o grammar.go grammar.peg
+//go:generate goimports -w grammar.go
+
+func prepend(x interface{}, xs interface{}) []interface{} {
+ return append([]interface{}{x}, toSlice(xs)...)
+}
+
+func toSlice(x interface{}) []interface{} {
+ if x == nil {
+ return nil
+ }
+ return x.([]interface{})
+}
+
+// TODO(wmin0): finish it.
+func isAddress(h []byte) bool {
+ return false
+}
+
+func hexToInteger(h []byte) interface{} {
+ d := decimal.Zero
+ l := len(h)
+ base := decimal.New(16, 0)
+ for idx, b := range h {
+ i, _ := strconv.ParseInt(string([]byte{b}), 16, 32)
+ d = d.Add(
+ decimal.New(i, 0).
+ Mul(base.Pow(decimal.New(int64(l-idx-1), 0))),
+ )
+ }
+ return integerValueNode{v: d, address: isAddress(h)}
+}
+
+func hexToBytes(h []byte) []byte {
+ bs, _ := hex.DecodeString(string(h))
+ return bs
+}
+
+func toInt(b []byte) int32 {
+ i, _ := strconv.ParseInt(string(b), 10, 32)
+ return int32(i)
+}
+
+func toDecimal(b []byte) decimal.Decimal {
+ return decimal.RequireFromString(string(b))
+}
+
+func toLower(b []byte) []byte {
+ return []byte(strings.ToLower(string(b)))
+}
+
+func joinBytes(x interface{}) []byte {
+ xs := toSlice(x)
+ bs := []byte{}
+ for _, b := range xs {
+ bs = append(bs, b.([]byte)...)
+ }
+ return bs
+}
+
+func opSetSubject(op interface{}, s interface{}) interface{} {
+ x := op.(binaryOperator)
+ x.setSubject(s)
+ return x
+}
+
+func opSetObject(op interface{}, o interface{}) interface{} {
+ x := op.(binaryOperator)
+ x.setObject(o)
+ return x
+}
+
+func opSetTarget(op interface{}, t interface{}) interface{} {
+ x := op.(unaryOperator)
+ x.setTarget(t)
+ return x
+}
+
+func joinOperator(x interface{}, o interface{}) {
+ if op, ok := x.(unaryOperator); ok {
+ joinOperator(op.getTarget(), o)
+ return
+ }
+ if op, ok := x.(binaryOperator); ok {
+ op.setObject(o)
+ return
+ }
+}
+
+func rightJoinOperators(o interface{}, x interface{}) interface{} {
+ xs := toSlice(x)
+ if len(xs) == 0 {
+ return o
+ }
+ l := len(xs)
+ for idx := range xs {
+ if idx == l-1 {
+ break
+ }
+ joinOperator(xs[idx+1], xs[idx])
+ }
+ joinOperator(xs[0], o)
+ return xs[l-1]
+}
+
+// TODO(wmin0): finish it.
+func resolveString(s []byte) []byte {
+ return s
+}
+
+// ParseString parses input string to AST.
+func ParseString(s string) (interface{}, error) {
+ return ParseReader("parser", strings.NewReader(s))
+}
diff --git a/core/vm/sqlvm/parser_test.go b/core/vm/sqlvm/parser_test.go
new file mode 100644
index 000000000..e7dc18e95
--- /dev/null
+++ b/core/vm/sqlvm/parser_test.go
@@ -0,0 +1,82 @@
+package sqlvm
+
+import (
+ "testing"
+
+ "github.com/stretchr/testify/suite"
+)
+
+type ParserTestSuite struct{ suite.Suite }
+
+func (s *ParserTestSuite) requireParseNoError(sql string) {
+ _, err := ParseString(sql)
+ s.Require().NoError(err)
+}
+
+func (s *ParserTestSuite) TestParse() {
+ // Test stmt.
+ s.requireParseNoError(``)
+ s.requireParseNoError(`;`)
+ s.requireParseNoError(`;;;select 1;;;;`)
+
+ // Test expr.
+ s.requireParseNoError(`select 1 + 2 * 3`)
+ s.requireParseNoError(`select a(1 + 1)`)
+ s.requireParseNoError(`select hEx'12'`)
+ s.requireParseNoError(`select x'12'`)
+ s.requireParseNoError(`select 0xABC`)
+ s.requireParseNoError(`select true and false or true and false or true`)
+ s.requireParseNoError(`SeLeCT '1' NoT LiKe '1';`)
+ s.requireParseNoError(`select a in (1,2) is not null not in (true)`)
+ s.requireParseNoError(`select count(*)`)
+ s.requireParseNoError(`select cast(a as fixed65535X1)`)
+ s.requireParseNoError(`select "now!" ( not a + b, aa( + 3 + .1 + 1. ) + - .3e-9 + 1.e-10, 'a' || 'b' and true )`)
+
+ // Test where.
+ s.requireParseNoError(`select * from abc where abc is null`)
+ s.requireParseNoError(`select * from abc where abc is not null`)
+ s.requireParseNoError(`select * from abc where abc in (1, 1)`)
+ s.requireParseNoError(`select * from abc where abc not in (1, 1)`)
+ s.requireParseNoError(`select * from abc where not true`)
+ s.requireParseNoError(`select * from abc where a like a + 1`)
+
+ // Test some logic expr and no from.
+ s.requireParseNoError(`select 1 where a is not null = b`)
+ s.requireParseNoError(`select 1 where null = null is null and true`)
+ s.requireParseNoError(`select 1 where null is null = null`)
+ s.requireParseNoError(`SELECT 1 + 2 WHERE 3 <> 4`)
+
+ // Test order by.
+ s.requireParseNoError(`select a=b+1 from a order by a desc`)
+ s.requireParseNoError(`select 1 from a order by b + 1 desc`)
+ s.requireParseNoError(`select 1 from a order by b + 1 nulls first`)
+ s.requireParseNoError(`select 1 from a order by b + 1 desc nulls last`)
+
+ // Test group by.
+ s.requireParseNoError(`select 1 from a group by b + 1`)
+
+ // Test insert.
+ s.requireParseNoError(`insert into "abc"(a) values (f(a, b),g(a),h())`)
+ s.requireParseNoError(`insert into "abc"(a) values (1,2,3), (f(a, b),g(a),h())`)
+ s.requireParseNoError(`insert into a default values`)
+ s.requireParseNoError(`insert into a values (default)`)
+
+ // Test update.
+ s.requireParseNoError(`update "~!@#$%^&*()" set b = default where a is null;`)
+ s.requireParseNoError(`update "~!@#$%^&*()" set b = default, a = 123 where a is null;`)
+
+ // Test delete.
+ s.requireParseNoError(`delete from a where b is null`)
+
+ // Test create table.
+ s.requireParseNoError(`create table a (a int32 not null unique primary key default 0)`)
+ s.requireParseNoError(`create table "~!@#$%^&*()" ( a int32 references b ( a ) , b string primary key, c address not null default 1 + 1 )`)
+
+ // Test create index.
+ s.requireParseNoError(`create unique index a on a (a)`)
+ s.requireParseNoError(`create index "~!@#$%^&*()" on ㄅ ( a , b )`)
+}
+
+func TestParser(t *testing.T) {
+ suite.Run(t, new(ParserTestSuite))
+}
diff --git a/core/vm/sqlvm/type.go b/core/vm/sqlvm/type.go
new file mode 100644
index 000000000..890b5e6ee
--- /dev/null
+++ b/core/vm/sqlvm/type.go
@@ -0,0 +1,408 @@
+package sqlvm
+
+import (
+ "fmt"
+ "reflect"
+
+ "github.com/shopspring/decimal"
+)
+
+type identifierNode string
+
+type valuer interface {
+ value() interface{}
+}
+
+type boolValueNode bool
+
+func (n boolValueNode) value() interface{} { return bool(n) }
+
+type integerValueNode struct {
+ v decimal.Decimal
+ address bool
+}
+
+func (n integerValueNode) value() interface{} { return n.v }
+func (n integerValueNode) String() string { return n.v.String() }
+
+type decimalValueNode decimal.Decimal
+
+func (n decimalValueNode) value() interface{} { return decimal.Decimal(n) }
+func (n decimalValueNode) String() string { return decimal.Decimal(n).String() }
+
+type bytesValueNode []byte
+
+func (n bytesValueNode) value() interface{} { return []byte(n) }
+func (n bytesValueNode) String() string { return string(n) }
+
+type anyValueNode struct{}
+
+func (n anyValueNode) value() interface{} { return n }
+
+type defaultValueNode struct{}
+
+func (n defaultValueNode) value() interface{} { return n }
+
+type nullValueNode struct{}
+
+func (n nullValueNode) value() interface{} { return n }
+
+type intTypeNode struct {
+ size int32
+ unsigned bool
+}
+
+type fixedTypeNode struct {
+ integerSize int32
+ fractionalSize int32
+ unsigned bool
+}
+
+type dynamicBytesTypeNode struct{}
+
+type fixedBytesTypeNode struct {
+ size int32
+}
+
+type addressTypeNode struct{}
+type boolTypeNode struct{}
+
+type unaryOperator interface {
+ getTarget() interface{}
+ setTarget(interface{})
+}
+
+type binaryOperator interface {
+ getObject() interface{}
+ getSubject() interface{}
+ setObject(interface{})
+ setSubject(interface{})
+}
+
+type unaryOperatorNode struct {
+ target interface{}
+}
+
+func (n unaryOperatorNode) getTarget() interface{} {
+ return n.target
+}
+
+func (n *unaryOperatorNode) setTarget(t interface{}) {
+ n.target = t
+}
+
+type binaryOperatorNode struct {
+ object interface{}
+ subject interface{}
+}
+
+func (n binaryOperatorNode) getObject() interface{} {
+ return n.object
+}
+
+func (n binaryOperatorNode) getSubject() interface{} {
+ return n.subject
+}
+
+func (n *binaryOperatorNode) setObject(o interface{}) {
+ n.object = o
+}
+
+func (n *binaryOperatorNode) setSubject(s interface{}) {
+ n.subject = s
+}
+
+type posOperatorNode struct{ unaryOperatorNode }
+type negOperatorNode struct{ unaryOperatorNode }
+type notOperatorNode struct{ unaryOperatorNode }
+type andOperatorNode struct{ binaryOperatorNode }
+type orOperatorNode struct{ binaryOperatorNode }
+
+type greaterOrEqualOperatorNode struct{ binaryOperatorNode }
+type lessOrEqualOperatorNode struct{ binaryOperatorNode }
+type notEqualOperatorNode struct{ binaryOperatorNode }
+type equalOperatorNode struct{ binaryOperatorNode }
+type greaterOperatorNode struct{ binaryOperatorNode }
+type lessOperatorNode struct{ binaryOperatorNode }
+
+type concatOperatorNode struct{ binaryOperatorNode }
+type addOperatorNode struct{ binaryOperatorNode }
+type subOperatorNode struct{ binaryOperatorNode }
+type mulOperatorNode struct{ binaryOperatorNode }
+type divOperatorNode struct{ binaryOperatorNode }
+type modOperatorNode struct{ binaryOperatorNode }
+
+type inOperatorNode struct{ binaryOperatorNode }
+type isOperatorNode struct{ binaryOperatorNode }
+type likeOperatorNode struct{ binaryOperatorNode }
+
+type castOperatorNode struct{ binaryOperatorNode }
+type assignOperatorNode struct{ binaryOperatorNode }
+type functionOperatorNode struct{ binaryOperatorNode }
+
+type optional interface {
+ getOption() map[string]interface{}
+}
+
+type nilOptionNode struct{}
+
+func (n nilOptionNode) getOption() map[string]interface{} { return nil }
+
+type whereOptionNode struct {
+ condition interface{}
+}
+
+func (n whereOptionNode) getOption() map[string]interface{} {
+ return map[string]interface{}{
+ "condition": n.condition,
+ }
+}
+
+type orderOptionNode struct {
+ expr interface{}
+ desc bool
+ nullfirst bool
+}
+
+func (n orderOptionNode) getOption() map[string]interface{} {
+ return map[string]interface{}{
+ "expr": n.expr,
+ "desc": n.desc,
+ "nullfirst": n.nullfirst,
+ }
+}
+
+type groupOptionNode struct {
+ expr interface{}
+}
+
+func (n groupOptionNode) getOption() map[string]interface{} {
+ return map[string]interface{}{
+ "expr": n.expr,
+ }
+}
+
+type offsetOptionNode struct {
+ value integerValueNode
+}
+
+func (n offsetOptionNode) getOption() map[string]interface{} {
+ return map[string]interface{}{
+ "value": n.value,
+ }
+}
+
+type limitOptionNode struct {
+ value integerValueNode
+}
+
+func (n limitOptionNode) getOption() map[string]interface{} {
+ return map[string]interface{}{
+ "value": n.value,
+ }
+}
+
+type insertWithColumnOptionNode struct {
+ column []interface{}
+ value []interface{}
+}
+
+func (n insertWithColumnOptionNode) getOption() map[string]interface{} {
+ return map[string]interface{}{
+ "column": n.column,
+ "value": n.value,
+ }
+}
+
+type insertWithDefaultOptionNode struct{ nilOptionNode }
+type primaryOptionNode struct{ nilOptionNode }
+type notNullOptionNode struct{ nilOptionNode }
+type uniqueOptionNode struct{ nilOptionNode }
+type autoincrementOptionNode struct{ nilOptionNode }
+
+type defaultOptionNode struct {
+ value interface{}
+}
+
+func (n defaultOptionNode) getOption() map[string]interface{} {
+ return map[string]interface{}{
+ "value": n.value,
+ }
+}
+
+type foreignOptionNode struct {
+ table identifierNode
+ column identifierNode
+}
+
+func (n foreignOptionNode) getOption() map[string]interface{} {
+ return map[string]interface{}{
+ "table": n.table,
+ "column": n.column,
+ }
+}
+
+type selectStmtNode struct {
+ column []interface{}
+ table *identifierNode
+ where *whereOptionNode
+ group []interface{}
+ order []interface{}
+ limit *limitOptionNode
+ offset *offsetOptionNode
+}
+
+func (n selectStmtNode) getOption() map[string]interface{} {
+ return map[string]interface{}{
+ "column": n.column,
+ "table": n.table,
+ "where": n.where,
+ "group": n.group,
+ "order": n.order,
+ "limit": n.limit,
+ "offset": n.offset,
+ }
+}
+
+type updateStmtNode struct {
+ table identifierNode
+ assignment []interface{}
+ where *whereOptionNode
+}
+
+func (n updateStmtNode) getOption() map[string]interface{} {
+ return map[string]interface{}{
+ "table": n.table,
+ "assignment": n.assignment,
+ "where": n.where,
+ }
+}
+
+type deleteStmtNode struct {
+ table identifierNode
+ where *whereOptionNode
+}
+
+func (n deleteStmtNode) getOption() map[string]interface{} {
+ return map[string]interface{}{
+ "table": n.table,
+ "where": n.where,
+ }
+}
+
+type insertStmtNode struct {
+ table identifierNode
+ insert interface{}
+}
+
+func (n insertStmtNode) getOption() map[string]interface{} {
+ return map[string]interface{}{
+ "table": n.table,
+ "insert": n.insert,
+ }
+}
+
+type createTableStmtNode struct {
+ table identifierNode
+ column []interface{}
+}
+
+func (n createTableStmtNode) getOption() map[string]interface{} {
+ return map[string]interface{}{
+ "table": n.table,
+ "column": n.column,
+ }
+}
+
+type columnSchemaNode struct {
+ column identifierNode
+ dataType interface{}
+ constraint []interface{}
+}
+
+func (n columnSchemaNode) getOption() map[string]interface{} {
+ return map[string]interface{}{
+ "column": n.column,
+ "data_type": n.dataType,
+ "constraint": n.constraint,
+ }
+}
+
+type createIndexStmtNode struct {
+ index identifierNode
+ table identifierNode
+ column []interface{}
+ unique *uniqueOptionNode
+}
+
+func (n createIndexStmtNode) getOption() map[string]interface{} {
+ return map[string]interface{}{
+ "index": n.index,
+ "table": n.table,
+ "column": n.column,
+ "unique": n.unique,
+ }
+}
+
+// PrintAST prints ast to stdout.
+func PrintAST(n interface{}, indent string) {
+ if n == nil {
+ fmt.Printf("%snil\n", indent)
+ return
+ }
+ typeOf := reflect.TypeOf(n)
+ valueOf := reflect.ValueOf(n)
+ name := ""
+ if typeOf.Kind() == reflect.Ptr {
+ if valueOf.IsNil() {
+ fmt.Printf("%snil\n", indent)
+ return
+ }
+ name = "*"
+ valueOf = valueOf.Elem()
+ typeOf = typeOf.Elem()
+ }
+ name = name + typeOf.Name()
+
+ if op, ok := n.(optional); ok {
+ fmt.Printf("%s%s", indent, name)
+ m := op.getOption()
+ if m == nil {
+ fmt.Printf("\n")
+ return
+ }
+ fmt.Printf(":\n")
+ for k := range m {
+ fmt.Printf("%s %s:\n", indent, k)
+ PrintAST(m[k], indent+" ")
+ }
+ return
+ }
+ if op, ok := n.(unaryOperator); ok {
+ fmt.Printf("%s%s:\n", indent, name)
+ fmt.Printf("%s target:\n", indent)
+ PrintAST(op.getTarget(), indent+" ")
+ return
+ }
+ if op, ok := n.(binaryOperator); ok {
+ fmt.Printf("%s%s:\n", indent, name)
+ fmt.Printf("%s object:\n", indent)
+ PrintAST(op.getObject(), indent+" ")
+ fmt.Printf("%s subject:\n", indent)
+ PrintAST(op.getSubject(), indent+" ")
+ return
+ }
+ if arr, ok := n.([]interface{}); ok {
+ fmt.Printf("%s[\n", indent)
+ for idx := range arr {
+ PrintAST(arr[idx], indent+" ")
+ }
+ fmt.Printf("%s]\n", indent)
+ return
+ }
+ if stringer, ok := n.(fmt.Stringer); ok {
+ fmt.Printf("%s%s: %s\n", indent, name, stringer.String())
+ return
+ }
+ fmt.Printf("%s%s: %+v\n", indent, name, valueOf.Interface())
+}