From 65e85271b6640f52bff0fbd114131d83656c86ad Mon Sep 17 00:00:00 2001 From: Ting-Wei Lan Date: Mon, 4 Mar 2019 14:30:51 +0800 Subject: core: vm: sqlvm: parser: move generated code to internal package Code generated by pigeon includes many exported symbols which should not be used by any other code other than the parser itself. To prevent them from being misused, we used to hide them by editing the generated code with sed. This commit removes the unreliable sed trick by putting generated code to internal package. --- core/vm/sqlvm/parser/grammar.go | 7860 ----------------------------- core/vm/sqlvm/parser/grammar.peg | 1207 ----- core/vm/sqlvm/parser/grammar.sed | 4 - core/vm/sqlvm/parser/internal/grammar.go | 7860 +++++++++++++++++++++++++++++ core/vm/sqlvm/parser/internal/grammar.peg | 1207 +++++ core/vm/sqlvm/parser/internal/helpers.go | 317 ++ core/vm/sqlvm/parser/parser.go | 317 +- 7 files changed, 9396 insertions(+), 9376 deletions(-) delete mode 100644 core/vm/sqlvm/parser/grammar.go delete mode 100644 core/vm/sqlvm/parser/grammar.peg delete mode 100644 core/vm/sqlvm/parser/grammar.sed create mode 100644 core/vm/sqlvm/parser/internal/grammar.go create mode 100644 core/vm/sqlvm/parser/internal/grammar.peg create mode 100644 core/vm/sqlvm/parser/internal/helpers.go (limited to 'core/vm') diff --git a/core/vm/sqlvm/parser/grammar.go b/core/vm/sqlvm/parser/grammar.go deleted file mode 100644 index 36b3c06fe..000000000 --- a/core/vm/sqlvm/parser/grammar.go +++ /dev/null @@ -1,7860 +0,0 @@ -// Code generated by pigeon; DO NOT EDIT. - -package parser - -import ( - "bytes" - goerrors "errors" - "fmt" - "io" - "io/ioutil" - "math" - "os" - "sort" - "strconv" - "strings" - "unicode" - "unicode/utf8" - - "github.com/dexon-foundation/dexon/core/vm/sqlvm/ast" - "github.com/dexon-foundation/dexon/core/vm/sqlvm/errors" -) - -var g = &grammar{ - rules: []*rule{ - { - name: "S", - pos: position{line: 10, col: 1, offset: 145}, - expr: &actionExpr{ - pos: position{line: 11, col: 5, offset: 151}, - run: (*parser).callonS1, - expr: &seqExpr{ - pos: position{line: 11, col: 5, offset: 151}, - exprs: []interface{}{ - &ruleRefExpr{ - pos: position{line: 11, col: 5, offset: 151}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 11, col: 7, offset: 153}, - label: "x", - expr: &zeroOrOneExpr{ - pos: position{line: 11, col: 9, offset: 155}, - expr: &ruleRefExpr{ - pos: position{line: 11, col: 9, offset: 155}, - name: "Stmt", - }, - }, - }, - &ruleRefExpr{ - pos: position{line: 11, col: 15, offset: 161}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 11, col: 17, offset: 163}, - label: "xs", - expr: &zeroOrMoreExpr{ - pos: position{line: 11, col: 20, offset: 166}, - expr: &actionExpr{ - pos: position{line: 11, col: 22, offset: 168}, - run: (*parser).callonS10, - expr: &seqExpr{ - pos: position{line: 11, col: 22, offset: 168}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 11, col: 22, offset: 168}, - val: ";", - ignoreCase: false, - }, - &ruleRefExpr{ - pos: position{line: 11, col: 26, offset: 172}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 11, col: 28, offset: 174}, - label: "s", - expr: &zeroOrOneExpr{ - pos: position{line: 11, col: 30, offset: 176}, - expr: &ruleRefExpr{ - pos: position{line: 11, col: 30, offset: 176}, - name: "Stmt", - }, - }, - }, - &ruleRefExpr{ - pos: position{line: 11, col: 36, offset: 182}, - name: "_", - }, - }, - }, - }, - }, - }, - &ruleRefExpr{ - pos: position{line: 11, col: 59, offset: 205}, - name: "EOF", - }, - }, - }, - }, - }, - { - name: "Stmt", - pos: position{line: 15, col: 1, offset: 271}, - expr: &choiceExpr{ - pos: position{line: 16, col: 4, offset: 279}, - alternatives: []interface{}{ - &ruleRefExpr{ - pos: position{line: 16, col: 4, offset: 279}, - name: "SelectStmt", - }, - &ruleRefExpr{ - pos: position{line: 17, col: 4, offset: 293}, - name: "UpdateStmt", - }, - &ruleRefExpr{ - pos: position{line: 18, col: 4, offset: 307}, - name: "DeleteStmt", - }, - &ruleRefExpr{ - pos: position{line: 19, col: 4, offset: 321}, - name: "InsertStmt", - }, - &ruleRefExpr{ - pos: position{line: 20, col: 4, offset: 335}, - name: "CreateTableStmt", - }, - &ruleRefExpr{ - pos: position{line: 21, col: 4, offset: 354}, - name: "CreateIndexStmt", - }, - }, - }, - }, - { - name: "SelectStmt", - pos: position{line: 23, col: 1, offset: 371}, - expr: &actionExpr{ - pos: position{line: 24, col: 4, offset: 385}, - run: (*parser).callonSelectStmt1, - expr: &seqExpr{ - pos: position{line: 24, col: 4, offset: 385}, - exprs: []interface{}{ - &ruleRefExpr{ - pos: position{line: 24, col: 4, offset: 385}, - name: "SelectToken", - }, - &ruleRefExpr{ - pos: position{line: 25, col: 2, offset: 398}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 25, col: 4, offset: 400}, - label: "f", - expr: &ruleRefExpr{ - pos: position{line: 25, col: 6, offset: 402}, - name: "SelectColumn", - }, - }, - &labeledExpr{ - pos: position{line: 25, col: 19, offset: 415}, - label: "fs", - expr: &zeroOrMoreExpr{ - pos: position{line: 25, col: 22, offset: 418}, - expr: &actionExpr{ - pos: position{line: 25, col: 24, offset: 420}, - run: (*parser).callonSelectStmt9, - expr: &seqExpr{ - pos: position{line: 25, col: 24, offset: 420}, - exprs: []interface{}{ - &ruleRefExpr{ - pos: position{line: 25, col: 24, offset: 420}, - name: "_", - }, - &ruleRefExpr{ - pos: position{line: 25, col: 26, offset: 422}, - name: "SeparatorToken", - }, - &ruleRefExpr{ - pos: position{line: 25, col: 41, offset: 437}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 25, col: 43, offset: 439}, - label: "s", - expr: &ruleRefExpr{ - pos: position{line: 25, col: 45, offset: 441}, - name: "SelectColumn", - }, - }, - }, - }, - }, - }, - }, - &labeledExpr{ - pos: position{line: 26, col: 2, offset: 476}, - label: "table", - expr: &zeroOrOneExpr{ - pos: position{line: 26, col: 8, offset: 482}, - expr: &actionExpr{ - pos: position{line: 26, col: 10, offset: 484}, - run: (*parser).callonSelectStmt18, - expr: &seqExpr{ - pos: position{line: 26, col: 10, offset: 484}, - exprs: []interface{}{ - &ruleRefExpr{ - pos: position{line: 26, col: 10, offset: 484}, - name: "_", - }, - &ruleRefExpr{ - pos: position{line: 26, col: 12, offset: 486}, - name: "FromToken", - }, - &ruleRefExpr{ - pos: position{line: 26, col: 22, offset: 496}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 26, col: 24, offset: 498}, - label: "i", - expr: &ruleRefExpr{ - pos: position{line: 26, col: 26, offset: 500}, - name: "Identifier", - }, - }, - }, - }, - }, - }, - }, - &labeledExpr{ - pos: position{line: 27, col: 2, offset: 533}, - label: "where", - expr: &zeroOrOneExpr{ - pos: position{line: 27, col: 8, offset: 539}, - expr: &actionExpr{ - pos: position{line: 27, col: 10, offset: 541}, - run: (*parser).callonSelectStmt27, - expr: &seqExpr{ - pos: position{line: 27, col: 10, offset: 541}, - exprs: []interface{}{ - &ruleRefExpr{ - pos: position{line: 27, col: 10, offset: 541}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 27, col: 12, offset: 543}, - label: "w", - expr: &ruleRefExpr{ - pos: position{line: 27, col: 14, offset: 545}, - name: "WhereClause", - }, - }, - }, - }, - }, - }, - }, - &labeledExpr{ - pos: position{line: 28, col: 2, offset: 579}, - label: "group", - expr: &zeroOrOneExpr{ - pos: position{line: 28, col: 8, offset: 585}, - expr: &actionExpr{ - pos: position{line: 28, col: 10, offset: 587}, - run: (*parser).callonSelectStmt34, - expr: &seqExpr{ - pos: position{line: 28, col: 10, offset: 587}, - exprs: []interface{}{ - &ruleRefExpr{ - pos: position{line: 28, col: 10, offset: 587}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 28, col: 12, offset: 589}, - label: "g", - expr: &ruleRefExpr{ - pos: position{line: 28, col: 14, offset: 591}, - name: "GroupByClause", - }, - }, - }, - }, - }, - }, - }, - &labeledExpr{ - pos: position{line: 29, col: 2, offset: 627}, - label: "order", - expr: &zeroOrOneExpr{ - pos: position{line: 29, col: 8, offset: 633}, - expr: &actionExpr{ - pos: position{line: 29, col: 10, offset: 635}, - run: (*parser).callonSelectStmt41, - expr: &seqExpr{ - pos: position{line: 29, col: 10, offset: 635}, - exprs: []interface{}{ - &ruleRefExpr{ - pos: position{line: 29, col: 10, offset: 635}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 29, col: 12, offset: 637}, - label: "or", - expr: &ruleRefExpr{ - pos: position{line: 29, col: 15, offset: 640}, - name: "OrderByClause", - }, - }, - }, - }, - }, - }, - }, - &labeledExpr{ - pos: position{line: 30, col: 2, offset: 677}, - label: "limit", - expr: &zeroOrOneExpr{ - pos: position{line: 30, col: 8, offset: 683}, - expr: &actionExpr{ - pos: position{line: 30, col: 10, offset: 685}, - run: (*parser).callonSelectStmt48, - expr: &seqExpr{ - pos: position{line: 30, col: 10, offset: 685}, - exprs: []interface{}{ - &ruleRefExpr{ - pos: position{line: 30, col: 10, offset: 685}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 30, col: 12, offset: 687}, - label: "l", - expr: &ruleRefExpr{ - pos: position{line: 30, col: 14, offset: 689}, - name: "LimitClause", - }, - }, - }, - }, - }, - }, - }, - &labeledExpr{ - pos: position{line: 31, col: 2, offset: 723}, - label: "offset", - expr: &zeroOrOneExpr{ - pos: position{line: 31, col: 9, offset: 730}, - expr: &actionExpr{ - pos: position{line: 31, col: 11, offset: 732}, - run: (*parser).callonSelectStmt55, - expr: &seqExpr{ - pos: position{line: 31, col: 11, offset: 732}, - exprs: []interface{}{ - &ruleRefExpr{ - pos: position{line: 31, col: 11, offset: 732}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 31, col: 13, offset: 734}, - label: "of", - expr: &ruleRefExpr{ - pos: position{line: 31, col: 16, offset: 737}, - name: "OffsetClause", - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - { - name: "SelectColumn", - pos: position{line: 62, col: 1, offset: 1604}, - expr: &choiceExpr{ - pos: position{line: 63, col: 4, offset: 1620}, - alternatives: []interface{}{ - &ruleRefExpr{ - pos: position{line: 63, col: 4, offset: 1620}, - name: "AnyLiteral", - }, - &ruleRefExpr{ - pos: position{line: 64, col: 4, offset: 1634}, - name: "Expr", - }, - }, - }, - }, - { - name: "UpdateStmt", - pos: position{line: 66, col: 1, offset: 1640}, - expr: &actionExpr{ - pos: position{line: 67, col: 4, offset: 1654}, - run: (*parser).callonUpdateStmt1, - expr: &seqExpr{ - pos: position{line: 67, col: 4, offset: 1654}, - exprs: []interface{}{ - &ruleRefExpr{ - pos: position{line: 67, col: 4, offset: 1654}, - name: "UpdateToken", - }, - &ruleRefExpr{ - pos: position{line: 68, col: 2, offset: 1667}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 68, col: 4, offset: 1669}, - label: "table", - expr: &ruleRefExpr{ - pos: position{line: 68, col: 10, offset: 1675}, - name: "Identifier", - }, - }, - &ruleRefExpr{ - pos: position{line: 69, col: 2, offset: 1687}, - name: "_", - }, - &ruleRefExpr{ - pos: position{line: 69, col: 4, offset: 1689}, - name: "SetToken", - }, - &ruleRefExpr{ - pos: position{line: 70, col: 2, offset: 1699}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 70, col: 4, offset: 1701}, - label: "a", - expr: &ruleRefExpr{ - pos: position{line: 70, col: 6, offset: 1703}, - name: "Assignment", - }, - }, - &labeledExpr{ - pos: position{line: 70, col: 17, offset: 1714}, - label: "as", - expr: &zeroOrMoreExpr{ - pos: position{line: 70, col: 20, offset: 1717}, - expr: &actionExpr{ - pos: position{line: 70, col: 22, offset: 1719}, - run: (*parser).callonUpdateStmt14, - expr: &seqExpr{ - pos: position{line: 70, col: 22, offset: 1719}, - exprs: []interface{}{ - &ruleRefExpr{ - pos: position{line: 70, col: 22, offset: 1719}, - name: "_", - }, - &ruleRefExpr{ - pos: position{line: 70, col: 24, offset: 1721}, - name: "SeparatorToken", - }, - &ruleRefExpr{ - pos: position{line: 70, col: 39, offset: 1736}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 70, col: 41, offset: 1738}, - label: "s", - expr: &ruleRefExpr{ - pos: position{line: 70, col: 43, offset: 1740}, - name: "Assignment", - }, - }, - }, - }, - }, - }, - }, - &labeledExpr{ - pos: position{line: 71, col: 2, offset: 1773}, - label: "where", - expr: &zeroOrOneExpr{ - pos: position{line: 71, col: 8, offset: 1779}, - expr: &actionExpr{ - pos: position{line: 71, col: 10, offset: 1781}, - run: (*parser).callonUpdateStmt23, - expr: &seqExpr{ - pos: position{line: 71, col: 10, offset: 1781}, - exprs: []interface{}{ - &ruleRefExpr{ - pos: position{line: 71, col: 10, offset: 1781}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 71, col: 12, offset: 1783}, - label: "w", - expr: &ruleRefExpr{ - pos: position{line: 71, col: 14, offset: 1785}, - name: "WhereClause", - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - { - name: "DeleteStmt", - pos: position{line: 88, col: 1, offset: 2273}, - expr: &actionExpr{ - pos: position{line: 89, col: 4, offset: 2287}, - run: (*parser).callonDeleteStmt1, - expr: &seqExpr{ - pos: position{line: 89, col: 4, offset: 2287}, - exprs: []interface{}{ - &ruleRefExpr{ - pos: position{line: 89, col: 4, offset: 2287}, - name: "DeleteToken", - }, - &ruleRefExpr{ - pos: position{line: 90, col: 2, offset: 2300}, - name: "_", - }, - &ruleRefExpr{ - pos: position{line: 90, col: 4, offset: 2302}, - name: "FromToken", - }, - &ruleRefExpr{ - pos: position{line: 91, col: 2, offset: 2313}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 91, col: 4, offset: 2315}, - label: "table", - expr: &ruleRefExpr{ - pos: position{line: 91, col: 10, offset: 2321}, - name: "Identifier", - }, - }, - &labeledExpr{ - pos: position{line: 92, col: 2, offset: 2333}, - label: "where", - expr: &zeroOrOneExpr{ - pos: position{line: 92, col: 8, offset: 2339}, - expr: &actionExpr{ - pos: position{line: 92, col: 10, offset: 2341}, - run: (*parser).callonDeleteStmt11, - expr: &seqExpr{ - pos: position{line: 92, col: 10, offset: 2341}, - exprs: []interface{}{ - &ruleRefExpr{ - pos: position{line: 92, col: 10, offset: 2341}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 92, col: 12, offset: 2343}, - label: "w", - expr: &ruleRefExpr{ - pos: position{line: 92, col: 14, offset: 2345}, - name: "WhereClause", - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - { - name: "InsertStmt", - pos: position{line: 104, col: 1, offset: 2617}, - expr: &actionExpr{ - pos: position{line: 105, col: 4, offset: 2631}, - run: (*parser).callonInsertStmt1, - expr: &seqExpr{ - pos: position{line: 105, col: 4, offset: 2631}, - exprs: []interface{}{ - &ruleRefExpr{ - pos: position{line: 105, col: 4, offset: 2631}, - name: "InsertToken", - }, - &ruleRefExpr{ - pos: position{line: 106, col: 2, offset: 2644}, - name: "_", - }, - &ruleRefExpr{ - pos: position{line: 106, col: 4, offset: 2646}, - name: "IntoToken", - }, - &ruleRefExpr{ - pos: position{line: 107, col: 2, offset: 2657}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 107, col: 4, offset: 2659}, - label: "table", - expr: &ruleRefExpr{ - pos: position{line: 107, col: 10, offset: 2665}, - name: "Identifier", - }, - }, - &ruleRefExpr{ - pos: position{line: 108, col: 2, offset: 2677}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 108, col: 4, offset: 2679}, - label: "insert", - expr: &choiceExpr{ - pos: position{line: 108, col: 13, offset: 2688}, - alternatives: []interface{}{ - &ruleRefExpr{ - pos: position{line: 108, col: 13, offset: 2688}, - name: "InsertWithColumnClause", - }, - &ruleRefExpr{ - pos: position{line: 108, col: 38, offset: 2713}, - name: "InsertWithDefaultClause", - }, - }, - }, - }, - }, - }, - }, - }, - { - name: "InsertValue", - pos: position{line: 125, col: 1, offset: 3124}, - expr: &actionExpr{ - pos: position{line: 126, col: 4, offset: 3139}, - run: (*parser).callonInsertValue1, - expr: &seqExpr{ - pos: position{line: 126, col: 4, offset: 3139}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 126, col: 4, offset: 3139}, - val: "(", - ignoreCase: false, - }, - &ruleRefExpr{ - pos: position{line: 126, col: 8, offset: 3143}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 126, col: 10, offset: 3145}, - label: "e", - expr: &ruleRefExpr{ - pos: position{line: 126, col: 12, offset: 3147}, - name: "MultiExprWithDefault", - }, - }, - &ruleRefExpr{ - pos: position{line: 126, col: 33, offset: 3168}, - name: "_", - }, - &litMatcher{ - pos: position{line: 126, col: 35, offset: 3170}, - val: ")", - ignoreCase: false, - }, - }, - }, - }, - }, - { - name: "CreateTableStmt", - pos: position{line: 129, col: 1, offset: 3193}, - expr: &actionExpr{ - pos: position{line: 130, col: 4, offset: 3212}, - run: (*parser).callonCreateTableStmt1, - expr: &seqExpr{ - pos: position{line: 130, col: 4, offset: 3212}, - exprs: []interface{}{ - &ruleRefExpr{ - pos: position{line: 130, col: 4, offset: 3212}, - name: "CreateToken", - }, - &ruleRefExpr{ - pos: position{line: 131, col: 2, offset: 3225}, - name: "_", - }, - &ruleRefExpr{ - pos: position{line: 131, col: 4, offset: 3227}, - name: "TableToken", - }, - &ruleRefExpr{ - pos: position{line: 132, col: 2, offset: 3239}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 132, col: 4, offset: 3241}, - label: "table", - expr: &ruleRefExpr{ - pos: position{line: 132, col: 10, offset: 3247}, - name: "Identifier", - }, - }, - &ruleRefExpr{ - pos: position{line: 133, col: 2, offset: 3259}, - name: "_", - }, - &litMatcher{ - pos: position{line: 133, col: 4, offset: 3261}, - val: "(", - ignoreCase: false, - }, - &ruleRefExpr{ - pos: position{line: 134, col: 2, offset: 3266}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 134, col: 4, offset: 3268}, - label: "column", - expr: &zeroOrOneExpr{ - pos: position{line: 134, col: 11, offset: 3275}, - expr: &actionExpr{ - pos: position{line: 135, col: 3, offset: 3279}, - run: (*parser).callonCreateTableStmt14, - expr: &seqExpr{ - pos: position{line: 135, col: 3, offset: 3279}, - exprs: []interface{}{ - &labeledExpr{ - pos: position{line: 135, col: 3, offset: 3279}, - label: "s", - expr: &ruleRefExpr{ - pos: position{line: 135, col: 5, offset: 3281}, - name: "ColumnSchema", - }, - }, - &labeledExpr{ - pos: position{line: 136, col: 3, offset: 3296}, - label: "ss", - expr: &zeroOrMoreExpr{ - pos: position{line: 136, col: 6, offset: 3299}, - expr: &actionExpr{ - pos: position{line: 136, col: 8, offset: 3301}, - run: (*parser).callonCreateTableStmt20, - expr: &seqExpr{ - pos: position{line: 136, col: 8, offset: 3301}, - exprs: []interface{}{ - &ruleRefExpr{ - pos: position{line: 136, col: 8, offset: 3301}, - name: "_", - }, - &ruleRefExpr{ - pos: position{line: 136, col: 10, offset: 3303}, - name: "SeparatorToken", - }, - &ruleRefExpr{ - pos: position{line: 136, col: 25, offset: 3318}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 136, col: 27, offset: 3320}, - label: "t", - expr: &ruleRefExpr{ - pos: position{line: 136, col: 29, offset: 3322}, - name: "ColumnSchema", - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - &ruleRefExpr{ - pos: position{line: 139, col: 2, offset: 3407}, - name: "_", - }, - &litMatcher{ - pos: position{line: 139, col: 4, offset: 3409}, - val: ")", - ignoreCase: false, - }, - }, - }, - }, - }, - { - name: "ColumnSchema", - pos: position{line: 153, col: 1, offset: 3787}, - expr: &actionExpr{ - pos: position{line: 154, col: 4, offset: 3803}, - run: (*parser).callonColumnSchema1, - expr: &seqExpr{ - pos: position{line: 154, col: 4, offset: 3803}, - exprs: []interface{}{ - &labeledExpr{ - pos: position{line: 154, col: 4, offset: 3803}, - label: "i", - expr: &ruleRefExpr{ - pos: position{line: 154, col: 6, offset: 3805}, - name: "Identifier", - }, - }, - &ruleRefExpr{ - pos: position{line: 155, col: 2, offset: 3817}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 155, col: 4, offset: 3819}, - label: "t", - expr: &ruleRefExpr{ - pos: position{line: 155, col: 6, offset: 3821}, - name: "DataType", - }, - }, - &labeledExpr{ - pos: position{line: 156, col: 2, offset: 3831}, - label: "cs", - expr: &zeroOrMoreExpr{ - pos: position{line: 156, col: 5, offset: 3834}, - expr: &actionExpr{ - pos: position{line: 156, col: 7, offset: 3836}, - run: (*parser).callonColumnSchema10, - expr: &seqExpr{ - pos: position{line: 156, col: 7, offset: 3836}, - exprs: []interface{}{ - &ruleRefExpr{ - pos: position{line: 156, col: 7, offset: 3836}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 156, col: 9, offset: 3838}, - label: "s", - expr: &ruleRefExpr{ - pos: position{line: 156, col: 11, offset: 3840}, - name: "ColumnConstraint", - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - { - name: "ColumnConstraint", - pos: position{line: 186, col: 1, offset: 4692}, - expr: &choiceExpr{ - pos: position{line: 187, col: 4, offset: 4712}, - alternatives: []interface{}{ - &ruleRefExpr{ - pos: position{line: 187, col: 4, offset: 4712}, - name: "PrimaryKeyClause", - }, - &ruleRefExpr{ - pos: position{line: 188, col: 4, offset: 4732}, - name: "NotNullClause", - }, - &ruleRefExpr{ - pos: position{line: 189, col: 4, offset: 4749}, - name: "UniqueClause", - }, - &ruleRefExpr{ - pos: position{line: 190, col: 4, offset: 4765}, - name: "DefaultClause", - }, - &ruleRefExpr{ - pos: position{line: 191, col: 4, offset: 4782}, - name: "ForeignClause", - }, - &ruleRefExpr{ - pos: position{line: 192, col: 4, offset: 4799}, - name: "AutoincrementClause", - }, - }, - }, - }, - { - name: "CreateIndexStmt", - pos: position{line: 194, col: 1, offset: 4820}, - expr: &actionExpr{ - pos: position{line: 195, col: 4, offset: 4839}, - run: (*parser).callonCreateIndexStmt1, - expr: &seqExpr{ - pos: position{line: 195, col: 4, offset: 4839}, - exprs: []interface{}{ - &ruleRefExpr{ - pos: position{line: 195, col: 4, offset: 4839}, - name: "CreateToken", - }, - &labeledExpr{ - pos: position{line: 196, col: 2, offset: 4852}, - label: "unique", - expr: &zeroOrOneExpr{ - pos: position{line: 196, col: 9, offset: 4859}, - expr: &actionExpr{ - pos: position{line: 196, col: 11, offset: 4861}, - run: (*parser).callonCreateIndexStmt6, - expr: &seqExpr{ - pos: position{line: 196, col: 11, offset: 4861}, - exprs: []interface{}{ - &ruleRefExpr{ - pos: position{line: 196, col: 11, offset: 4861}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 196, col: 13, offset: 4863}, - label: "u", - expr: &ruleRefExpr{ - pos: position{line: 196, col: 15, offset: 4865}, - name: "UniqueClause", - }, - }, - }, - }, - }, - }, - }, - &ruleRefExpr{ - pos: position{line: 197, col: 2, offset: 4900}, - name: "_", - }, - &ruleRefExpr{ - pos: position{line: 197, col: 4, offset: 4902}, - name: "IndexToken", - }, - &ruleRefExpr{ - pos: position{line: 198, col: 2, offset: 4914}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 198, col: 4, offset: 4916}, - label: "index", - expr: &ruleRefExpr{ - pos: position{line: 198, col: 10, offset: 4922}, - name: "Identifier", - }, - }, - &ruleRefExpr{ - pos: position{line: 199, col: 2, offset: 4934}, - name: "_", - }, - &ruleRefExpr{ - pos: position{line: 199, col: 4, offset: 4936}, - name: "OnToken", - }, - &ruleRefExpr{ - pos: position{line: 200, col: 2, offset: 4945}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 200, col: 4, offset: 4947}, - label: "table", - expr: &ruleRefExpr{ - pos: position{line: 200, col: 10, offset: 4953}, - name: "Identifier", - }, - }, - &ruleRefExpr{ - pos: position{line: 201, col: 2, offset: 4965}, - name: "_", - }, - &litMatcher{ - pos: position{line: 201, col: 4, offset: 4967}, - val: "(", - ignoreCase: false, - }, - &ruleRefExpr{ - pos: position{line: 201, col: 8, offset: 4971}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 201, col: 10, offset: 4973}, - label: "i", - expr: &ruleRefExpr{ - pos: position{line: 201, col: 12, offset: 4975}, - name: "Identifier", - }, - }, - &labeledExpr{ - pos: position{line: 201, col: 23, offset: 4986}, - label: "is", - expr: &zeroOrMoreExpr{ - pos: position{line: 201, col: 26, offset: 4989}, - expr: &actionExpr{ - pos: position{line: 201, col: 28, offset: 4991}, - run: (*parser).callonCreateIndexStmt28, - expr: &seqExpr{ - pos: position{line: 201, col: 28, offset: 4991}, - exprs: []interface{}{ - &ruleRefExpr{ - pos: position{line: 201, col: 28, offset: 4991}, - name: "_", - }, - &ruleRefExpr{ - pos: position{line: 201, col: 30, offset: 4993}, - name: "SeparatorToken", - }, - &ruleRefExpr{ - pos: position{line: 201, col: 45, offset: 5008}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 201, col: 47, offset: 5010}, - label: "x", - expr: &ruleRefExpr{ - pos: position{line: 201, col: 49, offset: 5012}, - name: "Identifier", - }, - }, - }, - }, - }, - }, - }, - &ruleRefExpr{ - pos: position{line: 201, col: 81, offset: 5044}, - name: "_", - }, - &litMatcher{ - pos: position{line: 201, col: 83, offset: 5046}, - val: ")", - ignoreCase: false, - }, - }, - }, - }, - }, - { - name: "WhereClause", - pos: position{line: 220, col: 1, offset: 5567}, - expr: &actionExpr{ - pos: position{line: 221, col: 4, offset: 5582}, - run: (*parser).callonWhereClause1, - expr: &seqExpr{ - pos: position{line: 221, col: 4, offset: 5582}, - exprs: []interface{}{ - &ruleRefExpr{ - pos: position{line: 221, col: 4, offset: 5582}, - name: "WhereToken", - }, - &ruleRefExpr{ - pos: position{line: 221, col: 15, offset: 5593}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 221, col: 17, offset: 5595}, - label: "e", - expr: &ruleRefExpr{ - pos: position{line: 221, col: 19, offset: 5597}, - name: "Expr", - }, - }, - }, - }, - }, - }, - { - name: "OrderByClause", - pos: position{line: 230, col: 1, offset: 5769}, - expr: &actionExpr{ - pos: position{line: 231, col: 4, offset: 5786}, - run: (*parser).callonOrderByClause1, - expr: &seqExpr{ - pos: position{line: 231, col: 4, offset: 5786}, - exprs: []interface{}{ - &ruleRefExpr{ - pos: position{line: 231, col: 4, offset: 5786}, - name: "OrderToken", - }, - &ruleRefExpr{ - pos: position{line: 232, col: 2, offset: 5798}, - name: "_", - }, - &ruleRefExpr{ - pos: position{line: 232, col: 4, offset: 5800}, - name: "ByToken", - }, - &ruleRefExpr{ - pos: position{line: 233, col: 2, offset: 5809}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 233, col: 4, offset: 5811}, - label: "f", - expr: &ruleRefExpr{ - pos: position{line: 233, col: 6, offset: 5813}, - name: "OrderColumn", - }, - }, - &labeledExpr{ - pos: position{line: 234, col: 2, offset: 5826}, - label: "fs", - expr: &zeroOrMoreExpr{ - pos: position{line: 234, col: 5, offset: 5829}, - expr: &actionExpr{ - pos: position{line: 234, col: 7, offset: 5831}, - run: (*parser).callonOrderByClause11, - expr: &seqExpr{ - pos: position{line: 234, col: 7, offset: 5831}, - exprs: []interface{}{ - &ruleRefExpr{ - pos: position{line: 234, col: 7, offset: 5831}, - name: "_", - }, - &ruleRefExpr{ - pos: position{line: 234, col: 9, offset: 5833}, - name: "SeparatorToken", - }, - &ruleRefExpr{ - pos: position{line: 234, col: 24, offset: 5848}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 234, col: 26, offset: 5850}, - label: "s", - expr: &ruleRefExpr{ - pos: position{line: 234, col: 28, offset: 5852}, - name: "OrderColumn", - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - { - name: "OrderColumn", - pos: position{line: 239, col: 1, offset: 5931}, - expr: &actionExpr{ - pos: position{line: 240, col: 4, offset: 5946}, - run: (*parser).callonOrderColumn1, - expr: &seqExpr{ - pos: position{line: 240, col: 4, offset: 5946}, - exprs: []interface{}{ - &labeledExpr{ - pos: position{line: 240, col: 4, offset: 5946}, - label: "i", - expr: &ruleRefExpr{ - pos: position{line: 240, col: 6, offset: 5948}, - name: "Expr", - }, - }, - &labeledExpr{ - pos: position{line: 241, col: 2, offset: 5954}, - label: "s", - expr: &zeroOrOneExpr{ - pos: position{line: 241, col: 4, offset: 5956}, - expr: &actionExpr{ - pos: position{line: 241, col: 6, offset: 5958}, - run: (*parser).callonOrderColumn7, - expr: &seqExpr{ - pos: position{line: 241, col: 6, offset: 5958}, - exprs: []interface{}{ - &ruleRefExpr{ - pos: position{line: 241, col: 6, offset: 5958}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 241, col: 8, offset: 5960}, - label: "t", - expr: &choiceExpr{ - pos: position{line: 241, col: 12, offset: 5964}, - alternatives: []interface{}{ - &ruleRefExpr{ - pos: position{line: 241, col: 12, offset: 5964}, - name: "AscToken", - }, - &ruleRefExpr{ - pos: position{line: 241, col: 23, offset: 5975}, - name: "DescToken", - }, - }, - }, - }, - }, - }, - }, - }, - }, - &labeledExpr{ - pos: position{line: 242, col: 2, offset: 6009}, - label: "n", - expr: &zeroOrOneExpr{ - pos: position{line: 242, col: 4, offset: 6011}, - expr: &actionExpr{ - pos: position{line: 242, col: 6, offset: 6013}, - run: (*parser).callonOrderColumn16, - expr: &seqExpr{ - pos: position{line: 242, col: 6, offset: 6013}, - exprs: []interface{}{ - &ruleRefExpr{ - pos: position{line: 242, col: 6, offset: 6013}, - name: "_", - }, - &ruleRefExpr{ - pos: position{line: 242, col: 8, offset: 6015}, - name: "NullsToken", - }, - &ruleRefExpr{ - pos: position{line: 242, col: 19, offset: 6026}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 242, col: 21, offset: 6028}, - label: "l", - expr: &choiceExpr{ - pos: position{line: 242, col: 25, offset: 6032}, - alternatives: []interface{}{ - &ruleRefExpr{ - pos: position{line: 242, col: 25, offset: 6032}, - name: "LastToken", - }, - &ruleRefExpr{ - pos: position{line: 242, col: 37, offset: 6044}, - name: "FirstToken", - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - { - name: "GroupByClause", - pos: position{line: 253, col: 1, offset: 6355}, - expr: &actionExpr{ - pos: position{line: 254, col: 4, offset: 6372}, - run: (*parser).callonGroupByClause1, - expr: &seqExpr{ - pos: position{line: 254, col: 4, offset: 6372}, - exprs: []interface{}{ - &ruleRefExpr{ - pos: position{line: 254, col: 4, offset: 6372}, - name: "GroupToken", - }, - &ruleRefExpr{ - pos: position{line: 255, col: 2, offset: 6384}, - name: "_", - }, - &ruleRefExpr{ - pos: position{line: 255, col: 4, offset: 6386}, - name: "ByToken", - }, - &ruleRefExpr{ - pos: position{line: 256, col: 2, offset: 6395}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 256, col: 4, offset: 6397}, - label: "f", - expr: &ruleRefExpr{ - pos: position{line: 256, col: 6, offset: 6399}, - name: "GroupColumn", - }, - }, - &labeledExpr{ - pos: position{line: 257, col: 2, offset: 6412}, - label: "fs", - expr: &zeroOrMoreExpr{ - pos: position{line: 257, col: 5, offset: 6415}, - expr: &actionExpr{ - pos: position{line: 257, col: 7, offset: 6417}, - run: (*parser).callonGroupByClause11, - expr: &seqExpr{ - pos: position{line: 257, col: 7, offset: 6417}, - exprs: []interface{}{ - &ruleRefExpr{ - pos: position{line: 257, col: 7, offset: 6417}, - name: "_", - }, - &ruleRefExpr{ - pos: position{line: 257, col: 9, offset: 6419}, - name: "SeparatorToken", - }, - &ruleRefExpr{ - pos: position{line: 257, col: 24, offset: 6434}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 257, col: 26, offset: 6436}, - label: "s", - expr: &ruleRefExpr{ - pos: position{line: 257, col: 28, offset: 6438}, - name: "GroupColumn", - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - { - name: "GroupColumn", - pos: position{line: 262, col: 1, offset: 6517}, - expr: &actionExpr{ - pos: position{line: 263, col: 4, offset: 6532}, - run: (*parser).callonGroupColumn1, - expr: &labeledExpr{ - pos: position{line: 263, col: 4, offset: 6532}, - label: "i", - expr: &ruleRefExpr{ - pos: position{line: 263, col: 6, offset: 6534}, - name: "Expr", - }, - }, - }, - }, - { - name: "OffsetClause", - pos: position{line: 272, col: 1, offset: 6701}, - expr: &actionExpr{ - pos: position{line: 273, col: 4, offset: 6717}, - run: (*parser).callonOffsetClause1, - expr: &seqExpr{ - pos: position{line: 273, col: 4, offset: 6717}, - exprs: []interface{}{ - &ruleRefExpr{ - pos: position{line: 273, col: 4, offset: 6717}, - name: "OffsetToken", - }, - &ruleRefExpr{ - pos: position{line: 273, col: 16, offset: 6729}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 273, col: 18, offset: 6731}, - label: "i", - expr: &ruleRefExpr{ - pos: position{line: 273, col: 20, offset: 6733}, - name: "Integer", - }, - }, - }, - }, - }, - }, - { - name: "LimitClause", - pos: position{line: 282, col: 1, offset: 6914}, - expr: &actionExpr{ - pos: position{line: 283, col: 4, offset: 6929}, - run: (*parser).callonLimitClause1, - expr: &seqExpr{ - pos: position{line: 283, col: 4, offset: 6929}, - exprs: []interface{}{ - &ruleRefExpr{ - pos: position{line: 283, col: 4, offset: 6929}, - name: "LimitToken", - }, - &ruleRefExpr{ - pos: position{line: 283, col: 15, offset: 6940}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 283, col: 17, offset: 6942}, - label: "i", - expr: &ruleRefExpr{ - pos: position{line: 283, col: 19, offset: 6944}, - name: "Integer", - }, - }, - }, - }, - }, - }, - { - name: "InsertWithColumnClause", - pos: position{line: 292, col: 1, offset: 7124}, - expr: &actionExpr{ - pos: position{line: 293, col: 4, offset: 7150}, - run: (*parser).callonInsertWithColumnClause1, - expr: &seqExpr{ - pos: position{line: 293, col: 4, offset: 7150}, - exprs: []interface{}{ - &labeledExpr{ - pos: position{line: 293, col: 4, offset: 7150}, - label: "cs", - expr: &zeroOrOneExpr{ - pos: position{line: 293, col: 7, offset: 7153}, - expr: &actionExpr{ - pos: position{line: 293, col: 9, offset: 7155}, - run: (*parser).callonInsertWithColumnClause5, - expr: &seqExpr{ - pos: position{line: 293, col: 9, offset: 7155}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 293, col: 9, offset: 7155}, - val: "(", - ignoreCase: false, - }, - &ruleRefExpr{ - pos: position{line: 294, col: 4, offset: 7162}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 294, col: 6, offset: 7164}, - label: "f", - expr: &ruleRefExpr{ - pos: position{line: 294, col: 8, offset: 7166}, - name: "Identifier", - }, - }, - &labeledExpr{ - pos: position{line: 295, col: 4, offset: 7180}, - label: "fs", - expr: &zeroOrMoreExpr{ - pos: position{line: 295, col: 7, offset: 7183}, - expr: &actionExpr{ - pos: position{line: 295, col: 9, offset: 7185}, - run: (*parser).callonInsertWithColumnClause13, - expr: &seqExpr{ - pos: position{line: 295, col: 9, offset: 7185}, - exprs: []interface{}{ - &ruleRefExpr{ - pos: position{line: 295, col: 9, offset: 7185}, - name: "_", - }, - &ruleRefExpr{ - pos: position{line: 295, col: 11, offset: 7187}, - name: "SeparatorToken", - }, - &ruleRefExpr{ - pos: position{line: 295, col: 26, offset: 7202}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 295, col: 28, offset: 7204}, - label: "x", - expr: &ruleRefExpr{ - pos: position{line: 295, col: 30, offset: 7206}, - name: "Identifier", - }, - }, - }, - }, - }, - }, - }, - &ruleRefExpr{ - pos: position{line: 296, col: 4, offset: 7241}, - name: "_", - }, - &litMatcher{ - pos: position{line: 296, col: 6, offset: 7243}, - val: ")", - ignoreCase: false, - }, - &ruleRefExpr{ - pos: position{line: 297, col: 4, offset: 7250}, - name: "_", - }, - }, - }, - }, - }, - }, - &ruleRefExpr{ - pos: position{line: 299, col: 3, offset: 7303}, - name: "ValuesToken", - }, - &ruleRefExpr{ - pos: position{line: 300, col: 2, offset: 7316}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 300, col: 4, offset: 7318}, - label: "v", - expr: &ruleRefExpr{ - pos: position{line: 300, col: 6, offset: 7320}, - name: "InsertValue", - }, - }, - &labeledExpr{ - pos: position{line: 301, col: 2, offset: 7333}, - label: "vs", - expr: &zeroOrMoreExpr{ - pos: position{line: 301, col: 5, offset: 7336}, - expr: &actionExpr{ - pos: position{line: 301, col: 7, offset: 7338}, - run: (*parser).callonInsertWithColumnClause29, - expr: &seqExpr{ - pos: position{line: 301, col: 7, offset: 7338}, - exprs: []interface{}{ - &ruleRefExpr{ - pos: position{line: 301, col: 7, offset: 7338}, - name: "_", - }, - &ruleRefExpr{ - pos: position{line: 301, col: 9, offset: 7340}, - name: "SeparatorToken", - }, - &ruleRefExpr{ - pos: position{line: 301, col: 24, offset: 7355}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 301, col: 26, offset: 7357}, - label: "y", - expr: &ruleRefExpr{ - pos: position{line: 301, col: 28, offset: 7359}, - name: "InsertValue", - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - { - name: "InsertWithDefaultClause", - pos: position{line: 320, col: 1, offset: 7935}, - expr: &actionExpr{ - pos: position{line: 321, col: 4, offset: 7962}, - run: (*parser).callonInsertWithDefaultClause1, - expr: &seqExpr{ - pos: position{line: 321, col: 4, offset: 7962}, - exprs: []interface{}{ - &ruleRefExpr{ - pos: position{line: 321, col: 4, offset: 7962}, - name: "DefaultToken", - }, - &ruleRefExpr{ - pos: position{line: 321, col: 17, offset: 7975}, - name: "_", - }, - &ruleRefExpr{ - pos: position{line: 321, col: 19, offset: 7977}, - name: "ValuesToken", - }, - }, - }, - }, - }, - { - name: "PrimaryKeyClause", - pos: position{line: 329, col: 1, offset: 8133}, - expr: &actionExpr{ - pos: position{line: 330, col: 4, offset: 8153}, - run: (*parser).callonPrimaryKeyClause1, - expr: &seqExpr{ - pos: position{line: 330, col: 4, offset: 8153}, - exprs: []interface{}{ - &ruleRefExpr{ - pos: position{line: 330, col: 4, offset: 8153}, - name: "PrimaryToken", - }, - &ruleRefExpr{ - pos: position{line: 330, col: 17, offset: 8166}, - name: "_", - }, - &ruleRefExpr{ - pos: position{line: 330, col: 19, offset: 8168}, - name: "KeyToken", - }, - }, - }, - }, - }, - { - name: "NotNullClause", - pos: position{line: 338, col: 1, offset: 8311}, - expr: &actionExpr{ - pos: position{line: 339, col: 4, offset: 8328}, - run: (*parser).callonNotNullClause1, - expr: &seqExpr{ - pos: position{line: 339, col: 4, offset: 8328}, - exprs: []interface{}{ - &ruleRefExpr{ - pos: position{line: 339, col: 4, offset: 8328}, - name: "NotToken", - }, - &ruleRefExpr{ - pos: position{line: 339, col: 13, offset: 8337}, - name: "_", - }, - &ruleRefExpr{ - pos: position{line: 339, col: 15, offset: 8339}, - name: "NullToken", - }, - }, - }, - }, - }, - { - name: "UniqueClause", - pos: position{line: 347, col: 1, offset: 8483}, - expr: &actionExpr{ - pos: position{line: 348, col: 4, offset: 8499}, - run: (*parser).callonUniqueClause1, - expr: &ruleRefExpr{ - pos: position{line: 348, col: 4, offset: 8499}, - name: "UniqueToken", - }, - }, - }, - { - name: "DefaultClause", - pos: position{line: 356, col: 1, offset: 8644}, - expr: &actionExpr{ - pos: position{line: 357, col: 4, offset: 8661}, - run: (*parser).callonDefaultClause1, - expr: &seqExpr{ - pos: position{line: 357, col: 4, offset: 8661}, - exprs: []interface{}{ - &ruleRefExpr{ - pos: position{line: 357, col: 4, offset: 8661}, - name: "DefaultToken", - }, - &ruleRefExpr{ - pos: position{line: 357, col: 17, offset: 8674}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 357, col: 19, offset: 8676}, - label: "e", - expr: &ruleRefExpr{ - pos: position{line: 357, col: 21, offset: 8678}, - name: "Expr", - }, - }, - }, - }, - }, - }, - { - name: "ForeignClause", - pos: position{line: 366, col: 1, offset: 8848}, - expr: &actionExpr{ - pos: position{line: 367, col: 4, offset: 8865}, - run: (*parser).callonForeignClause1, - expr: &seqExpr{ - pos: position{line: 367, col: 4, offset: 8865}, - exprs: []interface{}{ - &ruleRefExpr{ - pos: position{line: 367, col: 4, offset: 8865}, - name: "ReferencesToken", - }, - &ruleRefExpr{ - pos: position{line: 367, col: 20, offset: 8881}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 367, col: 22, offset: 8883}, - label: "t", - expr: &ruleRefExpr{ - pos: position{line: 367, col: 24, offset: 8885}, - name: "Identifier", - }, - }, - &ruleRefExpr{ - pos: position{line: 367, col: 35, offset: 8896}, - name: "_", - }, - &litMatcher{ - pos: position{line: 367, col: 37, offset: 8898}, - val: "(", - ignoreCase: false, - }, - &ruleRefExpr{ - pos: position{line: 367, col: 41, offset: 8902}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 367, col: 43, offset: 8904}, - label: "f", - expr: &ruleRefExpr{ - pos: position{line: 367, col: 45, offset: 8906}, - name: "Identifier", - }, - }, - &ruleRefExpr{ - pos: position{line: 367, col: 56, offset: 8917}, - name: "_", - }, - &litMatcher{ - pos: position{line: 367, col: 58, offset: 8919}, - val: ")", - ignoreCase: false, - }, - }, - }, - }, - }, - { - name: "AutoincrementClause", - pos: position{line: 377, col: 1, offset: 9134}, - expr: &actionExpr{ - pos: position{line: 378, col: 4, offset: 9157}, - run: (*parser).callonAutoincrementClause1, - expr: &ruleRefExpr{ - pos: position{line: 378, col: 4, offset: 9157}, - name: "AutoincrementToken", - }, - }, - }, - { - name: "Expr", - pos: position{line: 387, col: 1, offset: 9334}, - expr: &ruleRefExpr{ - pos: position{line: 388, col: 4, offset: 9342}, - name: "LogicExpr", - }, - }, - { - name: "ExprWithDefault", - pos: position{line: 390, col: 1, offset: 9353}, - expr: &choiceExpr{ - pos: position{line: 391, col: 4, offset: 9372}, - alternatives: []interface{}{ - &actionExpr{ - pos: position{line: 391, col: 4, offset: 9372}, - run: (*parser).callonExprWithDefault2, - expr: &seqExpr{ - pos: position{line: 391, col: 4, offset: 9372}, - exprs: []interface{}{ - &andExpr{ - pos: position{line: 391, col: 4, offset: 9372}, - expr: &ruleRefExpr{ - pos: position{line: 391, col: 6, offset: 9374}, - name: "DefaultLiteral", - }, - }, - &labeledExpr{ - pos: position{line: 391, col: 22, offset: 9390}, - label: "d", - expr: &ruleRefExpr{ - pos: position{line: 391, col: 24, offset: 9392}, - name: "DefaultLiteral", - }, - }, - }, - }, - }, - &ruleRefExpr{ - pos: position{line: 392, col: 4, offset: 9428}, - name: "Expr", - }, - }, - }, - }, - { - name: "LogicExpr", - pos: position{line: 394, col: 1, offset: 9434}, - expr: &ruleRefExpr{ - pos: position{line: 395, col: 4, offset: 9447}, - name: "LogicExpr4", - }, - }, - { - name: "LogicExpr4", - pos: position{line: 397, col: 1, offset: 9459}, - expr: &actionExpr{ - pos: position{line: 398, col: 4, offset: 9473}, - run: (*parser).callonLogicExpr41, - expr: &seqExpr{ - pos: position{line: 398, col: 4, offset: 9473}, - exprs: []interface{}{ - &labeledExpr{ - pos: position{line: 398, col: 4, offset: 9473}, - label: "o", - expr: &ruleRefExpr{ - pos: position{line: 398, col: 6, offset: 9475}, - name: "LogicExpr3", - }, - }, - &labeledExpr{ - pos: position{line: 399, col: 3, offset: 9488}, - label: "os", - expr: &zeroOrMoreExpr{ - pos: position{line: 399, col: 6, offset: 9491}, - expr: &actionExpr{ - pos: position{line: 399, col: 8, offset: 9493}, - run: (*parser).callonLogicExpr47, - expr: &seqExpr{ - pos: position{line: 399, col: 8, offset: 9493}, - exprs: []interface{}{ - &ruleRefExpr{ - pos: position{line: 399, col: 8, offset: 9493}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 399, col: 10, offset: 9495}, - label: "op", - expr: &ruleRefExpr{ - pos: position{line: 399, col: 13, offset: 9498}, - name: "OrOperator", - }, - }, - &ruleRefExpr{ - pos: position{line: 399, col: 24, offset: 9509}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 399, col: 26, offset: 9511}, - label: "s", - expr: &ruleRefExpr{ - pos: position{line: 399, col: 28, offset: 9513}, - name: "LogicExpr3", - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - { - name: "LogicExpr3", - pos: position{line: 403, col: 1, offset: 9676}, - expr: &actionExpr{ - pos: position{line: 404, col: 4, offset: 9690}, - run: (*parser).callonLogicExpr31, - expr: &seqExpr{ - pos: position{line: 404, col: 4, offset: 9690}, - exprs: []interface{}{ - &labeledExpr{ - pos: position{line: 404, col: 4, offset: 9690}, - label: "o", - expr: &ruleRefExpr{ - pos: position{line: 404, col: 6, offset: 9692}, - name: "LogicExpr2", - }, - }, - &labeledExpr{ - pos: position{line: 405, col: 3, offset: 9705}, - label: "os", - expr: &zeroOrMoreExpr{ - pos: position{line: 405, col: 6, offset: 9708}, - expr: &actionExpr{ - pos: position{line: 405, col: 8, offset: 9710}, - run: (*parser).callonLogicExpr37, - expr: &seqExpr{ - pos: position{line: 405, col: 8, offset: 9710}, - exprs: []interface{}{ - &ruleRefExpr{ - pos: position{line: 405, col: 8, offset: 9710}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 405, col: 10, offset: 9712}, - label: "op", - expr: &ruleRefExpr{ - pos: position{line: 405, col: 13, offset: 9715}, - name: "AndOperator", - }, - }, - &ruleRefExpr{ - pos: position{line: 405, col: 25, offset: 9727}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 405, col: 27, offset: 9729}, - label: "s", - expr: &ruleRefExpr{ - pos: position{line: 405, col: 29, offset: 9731}, - name: "LogicExpr2", - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - { - name: "LogicExpr2", - pos: position{line: 409, col: 1, offset: 9894}, - expr: &choiceExpr{ - pos: position{line: 410, col: 4, offset: 9908}, - alternatives: []interface{}{ - &actionExpr{ - pos: position{line: 410, col: 4, offset: 9908}, - run: (*parser).callonLogicExpr22, - expr: &seqExpr{ - pos: position{line: 410, col: 4, offset: 9908}, - exprs: []interface{}{ - &labeledExpr{ - pos: position{line: 410, col: 4, offset: 9908}, - label: "op", - expr: &ruleRefExpr{ - pos: position{line: 410, col: 7, offset: 9911}, - name: "NotOperator", - }, - }, - &ruleRefExpr{ - pos: position{line: 410, col: 19, offset: 9923}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 410, col: 21, offset: 9925}, - label: "s", - expr: &ruleRefExpr{ - pos: position{line: 410, col: 23, offset: 9927}, - name: "LogicExpr2", - }, - }, - }, - }, - }, - &ruleRefExpr{ - pos: position{line: 412, col: 4, offset: 10012}, - name: "LogicExpr1", - }, - }, - }, - }, - { - name: "LogicExpr1", - pos: position{line: 414, col: 1, offset: 10024}, - expr: &actionExpr{ - pos: position{line: 415, col: 4, offset: 10038}, - run: (*parser).callonLogicExpr11, - expr: &seqExpr{ - pos: position{line: 415, col: 4, offset: 10038}, - exprs: []interface{}{ - &labeledExpr{ - pos: position{line: 415, col: 4, offset: 10038}, - label: "o", - expr: &ruleRefExpr{ - pos: position{line: 415, col: 6, offset: 10040}, - name: "ArithmeticExpr", - }, - }, - &labeledExpr{ - pos: position{line: 415, col: 21, offset: 10055}, - label: "os", - expr: &zeroOrMoreExpr{ - pos: position{line: 415, col: 24, offset: 10058}, - expr: &actionExpr{ - pos: position{line: 415, col: 26, offset: 10060}, - run: (*parser).callonLogicExpr17, - expr: &seqExpr{ - pos: position{line: 415, col: 26, offset: 10060}, - exprs: []interface{}{ - &ruleRefExpr{ - pos: position{line: 415, col: 26, offset: 10060}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 415, col: 28, offset: 10062}, - label: "l", - expr: &ruleRefExpr{ - pos: position{line: 415, col: 30, offset: 10064}, - name: "LogicExpr1Op", - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - { - name: "LogicExpr1Op", - pos: position{line: 418, col: 1, offset: 10173}, - expr: &choiceExpr{ - pos: position{line: 419, col: 4, offset: 10189}, - alternatives: []interface{}{ - &ruleRefExpr{ - pos: position{line: 419, col: 4, offset: 10189}, - name: "LogicExpr1In", - }, - &ruleRefExpr{ - pos: position{line: 420, col: 4, offset: 10205}, - name: "LogicExpr1Is", - }, - &ruleRefExpr{ - pos: position{line: 421, col: 4, offset: 10221}, - name: "LogicExpr1Like", - }, - &ruleRefExpr{ - pos: position{line: 422, col: 4, offset: 10239}, - name: "LogicExpr1Cmp", - }, - }, - }, - }, - { - name: "LogicExpr1In", - pos: position{line: 424, col: 1, offset: 10254}, - expr: &actionExpr{ - pos: position{line: 425, col: 4, offset: 10270}, - run: (*parser).callonLogicExpr1In1, - expr: &seqExpr{ - pos: position{line: 425, col: 4, offset: 10270}, - exprs: []interface{}{ - &labeledExpr{ - pos: position{line: 425, col: 4, offset: 10270}, - label: "n", - expr: &zeroOrOneExpr{ - pos: position{line: 425, col: 6, offset: 10272}, - expr: &actionExpr{ - pos: position{line: 425, col: 8, offset: 10274}, - run: (*parser).callonLogicExpr1In5, - expr: &seqExpr{ - pos: position{line: 425, col: 8, offset: 10274}, - exprs: []interface{}{ - &labeledExpr{ - pos: position{line: 425, col: 8, offset: 10274}, - label: "t", - expr: &ruleRefExpr{ - pos: position{line: 425, col: 10, offset: 10276}, - name: "NotOperator", - }, - }, - &ruleRefExpr{ - pos: position{line: 425, col: 22, offset: 10288}, - name: "_", - }, - }, - }, - }, - }, - }, - &ruleRefExpr{ - pos: position{line: 425, col: 45, offset: 10311}, - name: "InToken", - }, - &ruleRefExpr{ - pos: position{line: 425, col: 53, offset: 10319}, - name: "_", - }, - &litMatcher{ - pos: position{line: 425, col: 55, offset: 10321}, - val: "(", - ignoreCase: false, - }, - &ruleRefExpr{ - pos: position{line: 425, col: 59, offset: 10325}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 425, col: 61, offset: 10327}, - label: "s", - expr: &ruleRefExpr{ - pos: position{line: 425, col: 63, offset: 10329}, - name: "MultiExpr", - }, - }, - &ruleRefExpr{ - pos: position{line: 425, col: 73, offset: 10339}, - name: "_", - }, - &litMatcher{ - pos: position{line: 425, col: 75, offset: 10341}, - val: ")", - ignoreCase: false, - }, - }, - }, - }, - }, - { - name: "LogicExpr1Is", - pos: position{line: 437, col: 1, offset: 10582}, - expr: &actionExpr{ - pos: position{line: 438, col: 4, offset: 10598}, - run: (*parser).callonLogicExpr1Is1, - expr: &seqExpr{ - pos: position{line: 438, col: 4, offset: 10598}, - exprs: []interface{}{ - &ruleRefExpr{ - pos: position{line: 438, col: 4, offset: 10598}, - name: "IsToken", - }, - &labeledExpr{ - pos: position{line: 438, col: 12, offset: 10606}, - label: "n", - expr: &zeroOrOneExpr{ - pos: position{line: 438, col: 14, offset: 10608}, - expr: &actionExpr{ - pos: position{line: 438, col: 16, offset: 10610}, - run: (*parser).callonLogicExpr1Is6, - expr: &seqExpr{ - pos: position{line: 438, col: 16, offset: 10610}, - exprs: []interface{}{ - &ruleRefExpr{ - pos: position{line: 438, col: 16, offset: 10610}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 438, col: 18, offset: 10612}, - label: "t", - expr: &ruleRefExpr{ - pos: position{line: 438, col: 20, offset: 10614}, - name: "NotOperator", - }, - }, - }, - }, - }, - }, - }, - &ruleRefExpr{ - pos: position{line: 438, col: 53, offset: 10647}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 438, col: 55, offset: 10649}, - label: "u", - expr: &ruleRefExpr{ - pos: position{line: 438, col: 57, offset: 10651}, - name: "NullLiteral", - }, - }, - }, - }, - }, - }, - { - name: "LogicExpr1Like", - pos: position{line: 450, col: 1, offset: 10911}, - expr: &actionExpr{ - pos: position{line: 451, col: 4, offset: 10929}, - run: (*parser).callonLogicExpr1Like1, - expr: &seqExpr{ - pos: position{line: 451, col: 4, offset: 10929}, - exprs: []interface{}{ - &labeledExpr{ - pos: position{line: 451, col: 4, offset: 10929}, - label: "n", - expr: &zeroOrOneExpr{ - pos: position{line: 451, col: 6, offset: 10931}, - expr: &actionExpr{ - pos: position{line: 451, col: 8, offset: 10933}, - run: (*parser).callonLogicExpr1Like5, - expr: &seqExpr{ - pos: position{line: 451, col: 8, offset: 10933}, - exprs: []interface{}{ - &labeledExpr{ - pos: position{line: 451, col: 8, offset: 10933}, - label: "t", - expr: &ruleRefExpr{ - pos: position{line: 451, col: 10, offset: 10935}, - name: "NotOperator", - }, - }, - &ruleRefExpr{ - pos: position{line: 451, col: 22, offset: 10947}, - name: "_", - }, - }, - }, - }, - }, - }, - &ruleRefExpr{ - pos: position{line: 451, col: 45, offset: 10970}, - name: "LikeToken", - }, - &ruleRefExpr{ - pos: position{line: 451, col: 55, offset: 10980}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 451, col: 57, offset: 10982}, - label: "s", - expr: &ruleRefExpr{ - pos: position{line: 451, col: 59, offset: 10984}, - name: "Expr", - }, - }, - }, - }, - }, - }, - { - name: "LogicExpr1Cmp", - pos: position{line: 463, col: 1, offset: 11233}, - expr: &actionExpr{ - pos: position{line: 464, col: 4, offset: 11250}, - run: (*parser).callonLogicExpr1Cmp1, - expr: &seqExpr{ - pos: position{line: 464, col: 4, offset: 11250}, - exprs: []interface{}{ - &labeledExpr{ - pos: position{line: 464, col: 4, offset: 11250}, - label: "op", - expr: &ruleRefExpr{ - pos: position{line: 464, col: 7, offset: 11253}, - name: "CmpOperator", - }, - }, - &ruleRefExpr{ - pos: position{line: 464, col: 19, offset: 11265}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 464, col: 21, offset: 11267}, - label: "s", - expr: &ruleRefExpr{ - pos: position{line: 464, col: 23, offset: 11269}, - name: "ArithmeticExpr", - }, - }, - }, - }, - }, - }, - { - name: "ArithmeticExpr", - pos: position{line: 467, col: 1, offset: 11357}, - expr: &ruleRefExpr{ - pos: position{line: 468, col: 4, offset: 11375}, - name: "ArithmeticExpr3", - }, - }, - { - name: "ArithmeticExpr3", - pos: position{line: 470, col: 1, offset: 11392}, - expr: &actionExpr{ - pos: position{line: 471, col: 4, offset: 11411}, - run: (*parser).callonArithmeticExpr31, - expr: &seqExpr{ - pos: position{line: 471, col: 4, offset: 11411}, - exprs: []interface{}{ - &labeledExpr{ - pos: position{line: 471, col: 4, offset: 11411}, - label: "o", - expr: &ruleRefExpr{ - pos: position{line: 471, col: 6, offset: 11413}, - name: "ArithmeticExpr2", - }, - }, - &labeledExpr{ - pos: position{line: 472, col: 3, offset: 11431}, - label: "os", - expr: &zeroOrMoreExpr{ - pos: position{line: 472, col: 6, offset: 11434}, - expr: &actionExpr{ - pos: position{line: 472, col: 8, offset: 11436}, - run: (*parser).callonArithmeticExpr37, - expr: &seqExpr{ - pos: position{line: 472, col: 8, offset: 11436}, - exprs: []interface{}{ - &ruleRefExpr{ - pos: position{line: 472, col: 8, offset: 11436}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 472, col: 10, offset: 11438}, - label: "op", - expr: &ruleRefExpr{ - pos: position{line: 472, col: 13, offset: 11441}, - name: "ConcatOperator", - }, - }, - &ruleRefExpr{ - pos: position{line: 472, col: 28, offset: 11456}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 472, col: 30, offset: 11458}, - label: "s", - expr: &ruleRefExpr{ - pos: position{line: 472, col: 32, offset: 11460}, - name: "ArithmeticExpr2", - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - { - name: "ArithmeticExpr2", - pos: position{line: 476, col: 1, offset: 11628}, - expr: &actionExpr{ - pos: position{line: 477, col: 4, offset: 11647}, - run: (*parser).callonArithmeticExpr21, - expr: &seqExpr{ - pos: position{line: 477, col: 4, offset: 11647}, - exprs: []interface{}{ - &labeledExpr{ - pos: position{line: 477, col: 4, offset: 11647}, - label: "o", - expr: &ruleRefExpr{ - pos: position{line: 477, col: 6, offset: 11649}, - name: "ArithmeticExpr1", - }, - }, - &labeledExpr{ - pos: position{line: 478, col: 3, offset: 11667}, - label: "os", - expr: &zeroOrMoreExpr{ - pos: position{line: 478, col: 6, offset: 11670}, - expr: &actionExpr{ - pos: position{line: 478, col: 8, offset: 11672}, - run: (*parser).callonArithmeticExpr27, - expr: &seqExpr{ - pos: position{line: 478, col: 8, offset: 11672}, - exprs: []interface{}{ - &ruleRefExpr{ - pos: position{line: 478, col: 8, offset: 11672}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 478, col: 10, offset: 11674}, - label: "op", - expr: &ruleRefExpr{ - pos: position{line: 478, col: 13, offset: 11677}, - name: "AddSubOperator", - }, - }, - &ruleRefExpr{ - pos: position{line: 478, col: 28, offset: 11692}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 478, col: 30, offset: 11694}, - label: "s", - expr: &ruleRefExpr{ - pos: position{line: 478, col: 32, offset: 11696}, - name: "ArithmeticExpr1", - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - { - name: "ArithmeticExpr1", - pos: position{line: 482, col: 1, offset: 11864}, - expr: &actionExpr{ - pos: position{line: 483, col: 4, offset: 11883}, - run: (*parser).callonArithmeticExpr11, - expr: &seqExpr{ - pos: position{line: 483, col: 4, offset: 11883}, - exprs: []interface{}{ - &labeledExpr{ - pos: position{line: 483, col: 4, offset: 11883}, - label: "o", - expr: &ruleRefExpr{ - pos: position{line: 483, col: 6, offset: 11885}, - name: "Operand", - }, - }, - &labeledExpr{ - pos: position{line: 484, col: 3, offset: 11895}, - label: "os", - expr: &zeroOrMoreExpr{ - pos: position{line: 484, col: 6, offset: 11898}, - expr: &actionExpr{ - pos: position{line: 484, col: 8, offset: 11900}, - run: (*parser).callonArithmeticExpr17, - expr: &seqExpr{ - pos: position{line: 484, col: 8, offset: 11900}, - exprs: []interface{}{ - &ruleRefExpr{ - pos: position{line: 484, col: 8, offset: 11900}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 484, col: 10, offset: 11902}, - label: "op", - expr: &ruleRefExpr{ - pos: position{line: 484, col: 13, offset: 11905}, - name: "MulDivModOperator", - }, - }, - &ruleRefExpr{ - pos: position{line: 484, col: 31, offset: 11923}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 484, col: 33, offset: 11925}, - label: "s", - expr: &ruleRefExpr{ - pos: position{line: 484, col: 35, offset: 11927}, - name: "Operand", - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - { - name: "MultiExpr", - pos: position{line: 488, col: 1, offset: 12087}, - expr: &actionExpr{ - pos: position{line: 489, col: 4, offset: 12100}, - run: (*parser).callonMultiExpr1, - expr: &seqExpr{ - pos: position{line: 489, col: 4, offset: 12100}, - exprs: []interface{}{ - &labeledExpr{ - pos: position{line: 489, col: 4, offset: 12100}, - label: "x", - expr: &ruleRefExpr{ - pos: position{line: 489, col: 6, offset: 12102}, - name: "Expr", - }, - }, - &labeledExpr{ - pos: position{line: 489, col: 11, offset: 12107}, - label: "xs", - expr: &zeroOrMoreExpr{ - pos: position{line: 489, col: 14, offset: 12110}, - expr: &actionExpr{ - pos: position{line: 489, col: 16, offset: 12112}, - run: (*parser).callonMultiExpr7, - expr: &seqExpr{ - pos: position{line: 489, col: 16, offset: 12112}, - exprs: []interface{}{ - &ruleRefExpr{ - pos: position{line: 489, col: 16, offset: 12112}, - name: "_", - }, - &ruleRefExpr{ - pos: position{line: 489, col: 18, offset: 12114}, - name: "SeparatorToken", - }, - &ruleRefExpr{ - pos: position{line: 489, col: 33, offset: 12129}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 489, col: 35, offset: 12131}, - label: "e", - expr: &ruleRefExpr{ - pos: position{line: 489, col: 37, offset: 12133}, - name: "Expr", - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - { - name: "MultiExprWithDefault", - pos: position{line: 492, col: 1, offset: 12221}, - expr: &actionExpr{ - pos: position{line: 493, col: 4, offset: 12245}, - run: (*parser).callonMultiExprWithDefault1, - expr: &seqExpr{ - pos: position{line: 493, col: 4, offset: 12245}, - exprs: []interface{}{ - &labeledExpr{ - pos: position{line: 493, col: 4, offset: 12245}, - label: "x", - expr: &ruleRefExpr{ - pos: position{line: 493, col: 6, offset: 12247}, - name: "ExprWithDefault", - }, - }, - &labeledExpr{ - pos: position{line: 493, col: 22, offset: 12263}, - label: "xs", - expr: &zeroOrMoreExpr{ - pos: position{line: 493, col: 25, offset: 12266}, - expr: &actionExpr{ - pos: position{line: 493, col: 27, offset: 12268}, - run: (*parser).callonMultiExprWithDefault7, - expr: &seqExpr{ - pos: position{line: 493, col: 27, offset: 12268}, - exprs: []interface{}{ - &ruleRefExpr{ - pos: position{line: 493, col: 27, offset: 12268}, - name: "_", - }, - &ruleRefExpr{ - pos: position{line: 493, col: 29, offset: 12270}, - name: "SeparatorToken", - }, - &ruleRefExpr{ - pos: position{line: 493, col: 44, offset: 12285}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 493, col: 46, offset: 12287}, - label: "e", - expr: &ruleRefExpr{ - pos: position{line: 493, col: 48, offset: 12289}, - name: "ExprWithDefault", - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - { - name: "Operand", - pos: position{line: 496, col: 1, offset: 12388}, - expr: &choiceExpr{ - pos: position{line: 497, col: 4, offset: 12399}, - alternatives: []interface{}{ - &actionExpr{ - pos: position{line: 497, col: 4, offset: 12399}, - run: (*parser).callonOperand2, - expr: &seqExpr{ - pos: position{line: 497, col: 4, offset: 12399}, - exprs: []interface{}{ - &labeledExpr{ - pos: position{line: 497, col: 4, offset: 12399}, - label: "op", - expr: &ruleRefExpr{ - pos: position{line: 497, col: 7, offset: 12402}, - name: "UnaryOperator", - }, - }, - &ruleRefExpr{ - pos: position{line: 497, col: 21, offset: 12416}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 497, col: 23, offset: 12418}, - label: "s", - expr: &ruleRefExpr{ - pos: position{line: 497, col: 25, offset: 12420}, - name: "Operand", - }, - }, - }, - }, - }, - &actionExpr{ - pos: position{line: 499, col: 4, offset: 12503}, - run: (*parser).callonOperand9, - expr: &seqExpr{ - pos: position{line: 499, col: 4, offset: 12503}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 499, col: 4, offset: 12503}, - val: "(", - ignoreCase: false, - }, - &ruleRefExpr{ - pos: position{line: 499, col: 8, offset: 12507}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 499, col: 10, offset: 12509}, - label: "e", - expr: &ruleRefExpr{ - pos: position{line: 499, col: 12, offset: 12511}, - name: "Expr", - }, - }, - &ruleRefExpr{ - pos: position{line: 499, col: 17, offset: 12516}, - name: "_", - }, - &litMatcher{ - pos: position{line: 499, col: 19, offset: 12518}, - val: ")", - ignoreCase: false, - }, - }, - }, - }, - &actionExpr{ - pos: position{line: 507, col: 4, offset: 12709}, - run: (*parser).callonOperand17, - expr: &seqExpr{ - pos: position{line: 507, col: 4, offset: 12709}, - exprs: []interface{}{ - &andExpr{ - pos: position{line: 507, col: 4, offset: 12709}, - expr: &ruleRefExpr{ - pos: position{line: 507, col: 6, offset: 12711}, - name: "CastToken", - }, - }, - &labeledExpr{ - pos: position{line: 507, col: 17, offset: 12722}, - label: "t", - expr: &ruleRefExpr{ - pos: position{line: 507, col: 19, offset: 12724}, - name: "TypeCast", - }, - }, - }, - }, - }, - &ruleRefExpr{ - pos: position{line: 508, col: 4, offset: 12754}, - name: "FunctionCall", - }, - &ruleRefExpr{ - pos: position{line: 509, col: 4, offset: 12770}, - name: "Value", - }, - &ruleRefExpr{ - pos: position{line: 510, col: 4, offset: 12779}, - name: "Identifier", - }, - }, - }, - }, - { - name: "TypeCast", - pos: position{line: 512, col: 1, offset: 12791}, - expr: &actionExpr{ - pos: position{line: 513, col: 4, offset: 12803}, - run: (*parser).callonTypeCast1, - expr: &seqExpr{ - pos: position{line: 513, col: 4, offset: 12803}, - exprs: []interface{}{ - &ruleRefExpr{ - pos: position{line: 513, col: 4, offset: 12803}, - name: "CastToken", - }, - &ruleRefExpr{ - pos: position{line: 513, col: 14, offset: 12813}, - name: "_", - }, - &litMatcher{ - pos: position{line: 513, col: 16, offset: 12815}, - val: "(", - ignoreCase: false, - }, - &ruleRefExpr{ - pos: position{line: 513, col: 20, offset: 12819}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 513, col: 22, offset: 12821}, - label: "o", - expr: &ruleRefExpr{ - pos: position{line: 513, col: 24, offset: 12823}, - name: "Expr", - }, - }, - &ruleRefExpr{ - pos: position{line: 513, col: 29, offset: 12828}, - name: "_", - }, - &ruleRefExpr{ - pos: position{line: 513, col: 31, offset: 12830}, - name: "AsToken", - }, - &ruleRefExpr{ - pos: position{line: 513, col: 39, offset: 12838}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 513, col: 41, offset: 12840}, - label: "s", - expr: &ruleRefExpr{ - pos: position{line: 513, col: 43, offset: 12842}, - name: "DataType", - }, - }, - &ruleRefExpr{ - pos: position{line: 513, col: 52, offset: 12851}, - name: "_", - }, - &litMatcher{ - pos: position{line: 513, col: 54, offset: 12853}, - val: ")", - ignoreCase: false, - }, - }, - }, - }, - }, - { - name: "FunctionCall", - pos: position{line: 523, col: 1, offset: 13062}, - expr: &actionExpr{ - pos: position{line: 524, col: 4, offset: 13078}, - run: (*parser).callonFunctionCall1, - expr: &seqExpr{ - pos: position{line: 524, col: 4, offset: 13078}, - exprs: []interface{}{ - &labeledExpr{ - pos: position{line: 524, col: 4, offset: 13078}, - label: "i", - expr: &ruleRefExpr{ - pos: position{line: 524, col: 6, offset: 13080}, - name: "Identifier", - }, - }, - &ruleRefExpr{ - pos: position{line: 524, col: 17, offset: 13091}, - name: "_", - }, - &litMatcher{ - pos: position{line: 524, col: 19, offset: 13093}, - val: "(", - ignoreCase: false, - }, - &ruleRefExpr{ - pos: position{line: 524, col: 23, offset: 13097}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 524, col: 25, offset: 13099}, - label: "r", - expr: &zeroOrOneExpr{ - pos: position{line: 524, col: 27, offset: 13101}, - expr: &ruleRefExpr{ - pos: position{line: 524, col: 27, offset: 13101}, - name: "FunctionArgs", - }, - }, - }, - &ruleRefExpr{ - pos: position{line: 524, col: 41, offset: 13115}, - name: "_", - }, - &litMatcher{ - pos: position{line: 524, col: 43, offset: 13117}, - val: ")", - ignoreCase: false, - }, - }, - }, - }, - }, - { - name: "FunctionArgs", - pos: position{line: 536, col: 1, offset: 13346}, - expr: &choiceExpr{ - pos: position{line: 537, col: 4, offset: 13362}, - alternatives: []interface{}{ - &actionExpr{ - pos: position{line: 537, col: 4, offset: 13362}, - run: (*parser).callonFunctionArgs2, - expr: &labeledExpr{ - pos: position{line: 537, col: 4, offset: 13362}, - label: "a", - expr: &ruleRefExpr{ - pos: position{line: 537, col: 6, offset: 13364}, - name: "AnyLiteral", - }, - }, - }, - &ruleRefExpr{ - pos: position{line: 538, col: 4, offset: 13432}, - name: "MultiExpr", - }, - }, - }, - }, - { - name: "Assignment", - pos: position{line: 540, col: 1, offset: 13443}, - expr: &actionExpr{ - pos: position{line: 541, col: 4, offset: 13457}, - run: (*parser).callonAssignment1, - expr: &seqExpr{ - pos: position{line: 541, col: 4, offset: 13457}, - exprs: []interface{}{ - &labeledExpr{ - pos: position{line: 541, col: 4, offset: 13457}, - label: "i", - expr: &ruleRefExpr{ - pos: position{line: 541, col: 6, offset: 13459}, - name: "Identifier", - }, - }, - &ruleRefExpr{ - pos: position{line: 541, col: 17, offset: 13470}, - name: "_", - }, - &litMatcher{ - pos: position{line: 541, col: 19, offset: 13472}, - val: "=", - ignoreCase: false, - }, - &ruleRefExpr{ - pos: position{line: 541, col: 23, offset: 13476}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 541, col: 25, offset: 13478}, - label: "e", - expr: &ruleRefExpr{ - pos: position{line: 541, col: 27, offset: 13480}, - name: "ExprWithDefault", - }, - }, - }, - }, - }, - }, - { - name: "UnaryOperator", - pos: position{line: 552, col: 1, offset: 13716}, - expr: &ruleRefExpr{ - pos: position{line: 553, col: 4, offset: 13733}, - name: "SignOperator", - }, - }, - { - name: "SignOperator", - pos: position{line: 555, col: 1, offset: 13747}, - expr: &actionExpr{ - pos: position{line: 556, col: 4, offset: 13763}, - run: (*parser).callonSignOperator1, - expr: &ruleRefExpr{ - pos: position{line: 556, col: 4, offset: 13763}, - name: "Sign", - }, - }, - }, - { - name: "NotOperator", - pos: position{line: 572, col: 1, offset: 14068}, - expr: &actionExpr{ - pos: position{line: 573, col: 4, offset: 14083}, - run: (*parser).callonNotOperator1, - expr: &ruleRefExpr{ - pos: position{line: 573, col: 4, offset: 14083}, - name: "NotToken", - }, - }, - }, - { - name: "AndOperator", - pos: position{line: 581, col: 1, offset: 14224}, - expr: &actionExpr{ - pos: position{line: 582, col: 4, offset: 14239}, - run: (*parser).callonAndOperator1, - expr: &ruleRefExpr{ - pos: position{line: 582, col: 4, offset: 14239}, - name: "AndToken", - }, - }, - }, - { - name: "OrOperator", - pos: position{line: 590, col: 1, offset: 14380}, - expr: &actionExpr{ - pos: position{line: 591, col: 4, offset: 14394}, - run: (*parser).callonOrOperator1, - expr: &ruleRefExpr{ - pos: position{line: 591, col: 4, offset: 14394}, - name: "OrToken", - }, - }, - }, - { - name: "CmpOperator", - pos: position{line: 599, col: 1, offset: 14533}, - expr: &actionExpr{ - pos: position{line: 600, col: 4, offset: 14548}, - run: (*parser).callonCmpOperator1, - expr: &choiceExpr{ - pos: position{line: 600, col: 6, offset: 14550}, - alternatives: []interface{}{ - &litMatcher{ - pos: position{line: 600, col: 6, offset: 14550}, - val: "<=", - ignoreCase: false, - }, - &litMatcher{ - pos: position{line: 600, col: 13, offset: 14557}, - val: ">=", - ignoreCase: false, - }, - &litMatcher{ - pos: position{line: 600, col: 20, offset: 14564}, - val: "<>", - ignoreCase: false, - }, - &litMatcher{ - pos: position{line: 600, col: 27, offset: 14571}, - val: "!=", - ignoreCase: false, - }, - &charClassMatcher{ - pos: position{line: 600, col: 34, offset: 14578}, - val: "[<>=]", - chars: []rune{'<', '>', '='}, - ignoreCase: false, - inverted: false, - }, - }, - }, - }, - }, - { - name: "ConcatOperator", - pos: position{line: 626, col: 1, offset: 15157}, - expr: &actionExpr{ - pos: position{line: 627, col: 4, offset: 15175}, - run: (*parser).callonConcatOperator1, - expr: &litMatcher{ - pos: position{line: 627, col: 4, offset: 15175}, - val: "||", - ignoreCase: false, - }, - }, - }, - { - name: "AddSubOperator", - pos: position{line: 635, col: 1, offset: 15315}, - expr: &actionExpr{ - pos: position{line: 636, col: 4, offset: 15333}, - run: (*parser).callonAddSubOperator1, - expr: &charClassMatcher{ - pos: position{line: 636, col: 4, offset: 15333}, - val: "[+-]", - chars: []rune{'+', '-'}, - ignoreCase: false, - inverted: false, - }, - }, - }, - { - name: "MulDivModOperator", - pos: position{line: 652, col: 1, offset: 15667}, - expr: &actionExpr{ - pos: position{line: 653, col: 4, offset: 15688}, - run: (*parser).callonMulDivModOperator1, - expr: &charClassMatcher{ - pos: position{line: 653, col: 4, offset: 15688}, - val: "[*/%]", - chars: []rune{'*', '/', '%'}, - ignoreCase: false, - inverted: false, - }, - }, - }, - { - name: "DataType", - pos: position{line: 672, col: 1, offset: 16088}, - expr: &choiceExpr{ - pos: position{line: 673, col: 4, offset: 16100}, - alternatives: []interface{}{ - &ruleRefExpr{ - pos: position{line: 673, col: 4, offset: 16100}, - name: "UIntType", - }, - &ruleRefExpr{ - pos: position{line: 674, col: 4, offset: 16112}, - name: "IntType", - }, - &ruleRefExpr{ - pos: position{line: 675, col: 4, offset: 16123}, - name: "UFixedType", - }, - &ruleRefExpr{ - pos: position{line: 676, col: 4, offset: 16137}, - name: "FixedType", - }, - &ruleRefExpr{ - pos: position{line: 677, col: 4, offset: 16150}, - name: "FixedBytesType", - }, - &ruleRefExpr{ - pos: position{line: 678, col: 4, offset: 16168}, - name: "DynamicBytesType", - }, - &ruleRefExpr{ - pos: position{line: 679, col: 4, offset: 16188}, - name: "BoolType", - }, - &ruleRefExpr{ - pos: position{line: 680, col: 4, offset: 16200}, - name: "AddressType", - }, - }, - }, - }, - { - name: "UIntType", - pos: position{line: 682, col: 1, offset: 16213}, - expr: &actionExpr{ - pos: position{line: 683, col: 4, offset: 16225}, - run: (*parser).callonUIntType1, - expr: &seqExpr{ - pos: position{line: 683, col: 4, offset: 16225}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 683, col: 4, offset: 16225}, - val: "uint", - ignoreCase: true, - }, - &labeledExpr{ - pos: position{line: 683, col: 12, offset: 16233}, - label: "s", - expr: &ruleRefExpr{ - pos: position{line: 683, col: 14, offset: 16235}, - name: "NonZeroLeadingInteger", - }, - }, - ¬Expr{ - pos: position{line: 683, col: 36, offset: 16257}, - expr: &ruleRefExpr{ - pos: position{line: 683, col: 37, offset: 16258}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - }, - }, - { - name: "IntType", - pos: position{line: 705, col: 1, offset: 16782}, - expr: &actionExpr{ - pos: position{line: 706, col: 4, offset: 16793}, - run: (*parser).callonIntType1, - expr: &seqExpr{ - pos: position{line: 706, col: 4, offset: 16793}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 706, col: 4, offset: 16793}, - val: "int", - ignoreCase: true, - }, - &labeledExpr{ - pos: position{line: 706, col: 11, offset: 16800}, - label: "s", - expr: &ruleRefExpr{ - pos: position{line: 706, col: 13, offset: 16802}, - name: "NonZeroLeadingInteger", - }, - }, - ¬Expr{ - pos: position{line: 706, col: 35, offset: 16824}, - expr: &ruleRefExpr{ - pos: position{line: 706, col: 36, offset: 16825}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - }, - }, - { - name: "UFixedType", - pos: position{line: 728, col: 1, offset: 17349}, - expr: &actionExpr{ - pos: position{line: 729, col: 4, offset: 17363}, - run: (*parser).callonUFixedType1, - expr: &seqExpr{ - pos: position{line: 729, col: 4, offset: 17363}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 729, col: 4, offset: 17363}, - val: "ufixed", - ignoreCase: true, - }, - &labeledExpr{ - pos: position{line: 729, col: 14, offset: 17373}, - label: "s", - expr: &ruleRefExpr{ - pos: position{line: 729, col: 16, offset: 17375}, - name: "NonZeroLeadingInteger", - }, - }, - &litMatcher{ - pos: position{line: 729, col: 38, offset: 17397}, - val: "x", - ignoreCase: true, - }, - &labeledExpr{ - pos: position{line: 729, col: 43, offset: 17402}, - label: "t", - expr: &ruleRefExpr{ - pos: position{line: 729, col: 45, offset: 17404}, - name: "NonZeroLeadingInteger", - }, - }, - ¬Expr{ - pos: position{line: 729, col: 67, offset: 17426}, - expr: &ruleRefExpr{ - pos: position{line: 729, col: 68, offset: 17427}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - }, - }, - { - name: "FixedType", - pos: position{line: 764, col: 1, offset: 18346}, - expr: &actionExpr{ - pos: position{line: 765, col: 4, offset: 18359}, - run: (*parser).callonFixedType1, - expr: &seqExpr{ - pos: position{line: 765, col: 4, offset: 18359}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 765, col: 4, offset: 18359}, - val: "fixed", - ignoreCase: true, - }, - &labeledExpr{ - pos: position{line: 765, col: 13, offset: 18368}, - label: "s", - expr: &ruleRefExpr{ - pos: position{line: 765, col: 15, offset: 18370}, - name: "NonZeroLeadingInteger", - }, - }, - &litMatcher{ - pos: position{line: 765, col: 37, offset: 18392}, - val: "x", - ignoreCase: true, - }, - &labeledExpr{ - pos: position{line: 765, col: 42, offset: 18397}, - label: "t", - expr: &ruleRefExpr{ - pos: position{line: 765, col: 44, offset: 18399}, - name: "NonZeroLeadingInteger", - }, - }, - ¬Expr{ - pos: position{line: 765, col: 66, offset: 18421}, - expr: &ruleRefExpr{ - pos: position{line: 765, col: 67, offset: 18422}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - }, - }, - { - name: "FixedBytesType", - pos: position{line: 800, col: 1, offset: 19340}, - expr: &choiceExpr{ - pos: position{line: 801, col: 4, offset: 19358}, - alternatives: []interface{}{ - &actionExpr{ - pos: position{line: 801, col: 4, offset: 19358}, - run: (*parser).callonFixedBytesType2, - expr: &seqExpr{ - pos: position{line: 801, col: 4, offset: 19358}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 801, col: 4, offset: 19358}, - val: "bytes", - ignoreCase: true, - }, - &labeledExpr{ - pos: position{line: 801, col: 13, offset: 19367}, - label: "s", - expr: &ruleRefExpr{ - pos: position{line: 801, col: 15, offset: 19369}, - name: "NonZeroLeadingInteger", - }, - }, - ¬Expr{ - pos: position{line: 801, col: 37, offset: 19391}, - expr: &ruleRefExpr{ - pos: position{line: 801, col: 38, offset: 19392}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - }, - &actionExpr{ - pos: position{line: 821, col: 4, offset: 19909}, - run: (*parser).callonFixedBytesType9, - expr: &seqExpr{ - pos: position{line: 821, col: 4, offset: 19909}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 821, col: 4, offset: 19909}, - val: "byte", - ignoreCase: true, - }, - ¬Expr{ - pos: position{line: 821, col: 12, offset: 19917}, - expr: &ruleRefExpr{ - pos: position{line: 821, col: 13, offset: 19918}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - }, - }, - }, - }, - { - name: "DynamicBytesType", - pos: position{line: 830, col: 1, offset: 20089}, - expr: &actionExpr{ - pos: position{line: 831, col: 4, offset: 20109}, - run: (*parser).callonDynamicBytesType1, - expr: &choiceExpr{ - pos: position{line: 831, col: 6, offset: 20111}, - alternatives: []interface{}{ - &seqExpr{ - pos: position{line: 831, col: 6, offset: 20111}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 831, col: 6, offset: 20111}, - val: "bytes", - ignoreCase: true, - }, - ¬Expr{ - pos: position{line: 831, col: 15, offset: 20120}, - expr: &ruleRefExpr{ - pos: position{line: 831, col: 16, offset: 20121}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - &seqExpr{ - pos: position{line: 832, col: 5, offset: 20146}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 832, col: 5, offset: 20146}, - val: "string", - ignoreCase: true, - }, - ¬Expr{ - pos: position{line: 832, col: 15, offset: 20156}, - expr: &ruleRefExpr{ - pos: position{line: 832, col: 16, offset: 20157}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - &seqExpr{ - pos: position{line: 833, col: 5, offset: 20182}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 833, col: 5, offset: 20182}, - val: "text", - ignoreCase: true, - }, - ¬Expr{ - pos: position{line: 833, col: 13, offset: 20190}, - expr: &ruleRefExpr{ - pos: position{line: 833, col: 14, offset: 20191}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - }, - }, - }, - }, - { - name: "AddressType", - pos: position{line: 842, col: 1, offset: 20352}, - expr: &actionExpr{ - pos: position{line: 843, col: 4, offset: 20367}, - run: (*parser).callonAddressType1, - expr: &seqExpr{ - pos: position{line: 843, col: 4, offset: 20367}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 843, col: 4, offset: 20367}, - val: "address", - ignoreCase: true, - }, - ¬Expr{ - pos: position{line: 843, col: 15, offset: 20378}, - expr: &ruleRefExpr{ - pos: position{line: 843, col: 16, offset: 20379}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - }, - }, - { - name: "BoolType", - pos: position{line: 851, col: 1, offset: 20532}, - expr: &actionExpr{ - pos: position{line: 852, col: 4, offset: 20544}, - run: (*parser).callonBoolType1, - expr: &choiceExpr{ - pos: position{line: 852, col: 6, offset: 20546}, - alternatives: []interface{}{ - &seqExpr{ - pos: position{line: 852, col: 6, offset: 20546}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 852, col: 6, offset: 20546}, - val: "bool", - ignoreCase: true, - }, - ¬Expr{ - pos: position{line: 852, col: 14, offset: 20554}, - expr: &ruleRefExpr{ - pos: position{line: 852, col: 15, offset: 20555}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - &seqExpr{ - pos: position{line: 853, col: 5, offset: 20580}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 853, col: 5, offset: 20580}, - val: "boolean", - ignoreCase: true, - }, - ¬Expr{ - pos: position{line: 853, col: 16, offset: 20591}, - expr: &ruleRefExpr{ - pos: position{line: 853, col: 17, offset: 20592}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - }, - }, - }, - }, - { - name: "Value", - pos: position{line: 863, col: 1, offset: 20758}, - expr: &choiceExpr{ - pos: position{line: 864, col: 4, offset: 20767}, - alternatives: []interface{}{ - &ruleRefExpr{ - pos: position{line: 864, col: 4, offset: 20767}, - name: "NumberLiteral", - }, - &ruleRefExpr{ - pos: position{line: 865, col: 4, offset: 20784}, - name: "StringLiteral", - }, - &ruleRefExpr{ - pos: position{line: 866, col: 4, offset: 20801}, - name: "BoolLiteral", - }, - &ruleRefExpr{ - pos: position{line: 867, col: 4, offset: 20816}, - name: "NullLiteral", - }, - }, - }, - }, - { - name: "AnyLiteral", - pos: position{line: 869, col: 1, offset: 20829}, - expr: &actionExpr{ - pos: position{line: 870, col: 4, offset: 20843}, - run: (*parser).callonAnyLiteral1, - expr: &ruleRefExpr{ - pos: position{line: 870, col: 4, offset: 20843}, - name: "AnyToken", - }, - }, - }, - { - name: "DefaultLiteral", - pos: position{line: 878, col: 1, offset: 20981}, - expr: &actionExpr{ - pos: position{line: 879, col: 4, offset: 20999}, - run: (*parser).callonDefaultLiteral1, - expr: &ruleRefExpr{ - pos: position{line: 879, col: 4, offset: 20999}, - name: "DefaultToken", - }, - }, - }, - { - name: "BoolLiteral", - pos: position{line: 887, col: 1, offset: 21145}, - expr: &actionExpr{ - pos: position{line: 888, col: 4, offset: 21160}, - run: (*parser).callonBoolLiteral1, - expr: &labeledExpr{ - pos: position{line: 888, col: 4, offset: 21160}, - label: "b", - expr: &choiceExpr{ - pos: position{line: 888, col: 8, offset: 21164}, - alternatives: []interface{}{ - &ruleRefExpr{ - pos: position{line: 888, col: 8, offset: 21164}, - name: "TrueToken", - }, - &ruleRefExpr{ - pos: position{line: 888, col: 20, offset: 21176}, - name: "FalseToken", - }, - }, - }, - }, - }, - }, - { - name: "NullLiteral", - pos: position{line: 897, col: 1, offset: 21358}, - expr: &actionExpr{ - pos: position{line: 898, col: 4, offset: 21373}, - run: (*parser).callonNullLiteral1, - expr: &ruleRefExpr{ - pos: position{line: 898, col: 4, offset: 21373}, - name: "NullToken", - }, - }, - }, - { - name: "NumberLiteral", - pos: position{line: 906, col: 1, offset: 21513}, - expr: &choiceExpr{ - pos: position{line: 907, col: 4, offset: 21530}, - alternatives: []interface{}{ - &actionExpr{ - pos: position{line: 907, col: 4, offset: 21530}, - run: (*parser).callonNumberLiteral2, - expr: &seqExpr{ - pos: position{line: 907, col: 4, offset: 21530}, - exprs: []interface{}{ - &andExpr{ - pos: position{line: 907, col: 4, offset: 21530}, - expr: &seqExpr{ - pos: position{line: 907, col: 6, offset: 21532}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 907, col: 6, offset: 21532}, - val: "0", - ignoreCase: false, - }, - &litMatcher{ - pos: position{line: 907, col: 10, offset: 21536}, - val: "x", - ignoreCase: true, - }, - }, - }, - }, - &labeledExpr{ - pos: position{line: 907, col: 16, offset: 21542}, - label: "h", - expr: &ruleRefExpr{ - pos: position{line: 907, col: 18, offset: 21544}, - name: "Hex", - }, - }, - }, - }, - }, - &ruleRefExpr{ - pos: position{line: 908, col: 4, offset: 21569}, - name: "Decimal", - }, - }, - }, - }, - { - name: "Sign", - pos: position{line: 910, col: 1, offset: 21578}, - expr: &charClassMatcher{ - pos: position{line: 911, col: 4, offset: 21586}, - val: "[-+]", - chars: []rune{'-', '+'}, - ignoreCase: false, - inverted: false, - }, - }, - { - name: "Integer", - pos: position{line: 913, col: 1, offset: 21592}, - expr: &actionExpr{ - pos: position{line: 914, col: 4, offset: 21603}, - run: (*parser).callonInteger1, - expr: &oneOrMoreExpr{ - pos: position{line: 914, col: 4, offset: 21603}, - expr: &charClassMatcher{ - pos: position{line: 914, col: 4, offset: 21603}, - val: "[0-9]", - ranges: []rune{'0', '9'}, - ignoreCase: false, - inverted: false, - }, - }, - }, - }, - { - name: "NonZeroLeadingInteger", - pos: position{line: 936, col: 1, offset: 22115}, - expr: &actionExpr{ - pos: position{line: 937, col: 4, offset: 22140}, - run: (*parser).callonNonZeroLeadingInteger1, - expr: &choiceExpr{ - pos: position{line: 937, col: 6, offset: 22142}, - alternatives: []interface{}{ - &litMatcher{ - pos: position{line: 937, col: 6, offset: 22142}, - val: "0", - ignoreCase: false, - }, - &seqExpr{ - pos: position{line: 937, col: 12, offset: 22148}, - exprs: []interface{}{ - &charClassMatcher{ - pos: position{line: 937, col: 12, offset: 22148}, - val: "[1-9]", - ranges: []rune{'1', '9'}, - ignoreCase: false, - inverted: false, - }, - &zeroOrMoreExpr{ - pos: position{line: 937, col: 17, offset: 22153}, - expr: &charClassMatcher{ - pos: position{line: 937, col: 17, offset: 22153}, - val: "[0-9]", - ranges: []rune{'0', '9'}, - ignoreCase: false, - inverted: false, - }, - }, - }, - }, - }, - }, - }, - }, - { - name: "Fixnum", - pos: position{line: 940, col: 1, offset: 22186}, - expr: &choiceExpr{ - pos: position{line: 941, col: 4, offset: 22196}, - alternatives: []interface{}{ - &seqExpr{ - pos: position{line: 941, col: 4, offset: 22196}, - exprs: []interface{}{ - &ruleRefExpr{ - pos: position{line: 941, col: 4, offset: 22196}, - name: "Integer", - }, - &litMatcher{ - pos: position{line: 941, col: 12, offset: 22204}, - val: ".", - ignoreCase: false, - }, - &ruleRefExpr{ - pos: position{line: 941, col: 16, offset: 22208}, - name: "Integer", - }, - }, - }, - &seqExpr{ - pos: position{line: 942, col: 4, offset: 22219}, - exprs: []interface{}{ - &ruleRefExpr{ - pos: position{line: 942, col: 4, offset: 22219}, - name: "Integer", - }, - &zeroOrOneExpr{ - pos: position{line: 942, col: 12, offset: 22227}, - expr: &litMatcher{ - pos: position{line: 942, col: 12, offset: 22227}, - val: ".", - ignoreCase: false, - }, - }, - }, - }, - &seqExpr{ - pos: position{line: 943, col: 4, offset: 22235}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 943, col: 4, offset: 22235}, - val: ".", - ignoreCase: false, - }, - &ruleRefExpr{ - pos: position{line: 943, col: 8, offset: 22239}, - name: "Integer", - }, - }, - }, - }, - }, - }, - { - name: "Decimal", - pos: position{line: 945, col: 1, offset: 22248}, - expr: &actionExpr{ - pos: position{line: 946, col: 4, offset: 22259}, - run: (*parser).callonDecimal1, - expr: &seqExpr{ - pos: position{line: 946, col: 4, offset: 22259}, - exprs: []interface{}{ - &ruleRefExpr{ - pos: position{line: 946, col: 4, offset: 22259}, - name: "Fixnum", - }, - &zeroOrOneExpr{ - pos: position{line: 946, col: 11, offset: 22266}, - expr: &seqExpr{ - pos: position{line: 946, col: 13, offset: 22268}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 946, col: 13, offset: 22268}, - val: "e", - ignoreCase: true, - }, - &zeroOrOneExpr{ - pos: position{line: 946, col: 18, offset: 22273}, - expr: &ruleRefExpr{ - pos: position{line: 946, col: 18, offset: 22273}, - name: "Sign", - }, - }, - &ruleRefExpr{ - pos: position{line: 946, col: 24, offset: 22279}, - name: "Integer", - }, - }, - }, - }, - }, - }, - }, - }, - { - name: "Hex", - pos: position{line: 967, col: 1, offset: 22771}, - expr: &actionExpr{ - pos: position{line: 968, col: 4, offset: 22778}, - run: (*parser).callonHex1, - expr: &seqExpr{ - pos: position{line: 968, col: 4, offset: 22778}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 968, col: 4, offset: 22778}, - val: "0x", - ignoreCase: false, - }, - &oneOrMoreExpr{ - pos: position{line: 968, col: 9, offset: 22783}, - expr: &charClassMatcher{ - pos: position{line: 968, col: 11, offset: 22785}, - val: "[0-9A-Fa-f]", - ranges: []rune{'0', '9', 'A', 'F', 'a', 'f'}, - ignoreCase: false, - inverted: false, - }, - }, - ¬Expr{ - pos: position{line: 968, col: 26, offset: 22800}, - expr: &ruleRefExpr{ - pos: position{line: 968, col: 27, offset: 22801}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - }, - }, - { - name: "StringLiteral", - pos: position{line: 976, col: 1, offset: 22952}, - expr: &choiceExpr{ - pos: position{line: 977, col: 4, offset: 22969}, - alternatives: []interface{}{ - &ruleRefExpr{ - pos: position{line: 977, col: 4, offset: 22969}, - name: "HexString", - }, - &ruleRefExpr{ - pos: position{line: 978, col: 4, offset: 22982}, - name: "NormalString", - }, - }, - }, - }, - { - name: "HexString", - pos: position{line: 980, col: 1, offset: 22996}, - expr: &actionExpr{ - pos: position{line: 981, col: 4, offset: 23009}, - run: (*parser).callonHexString1, - expr: &seqExpr{ - pos: position{line: 981, col: 4, offset: 23009}, - exprs: []interface{}{ - &choiceExpr{ - pos: position{line: 981, col: 6, offset: 23011}, - alternatives: []interface{}{ - &litMatcher{ - pos: position{line: 981, col: 6, offset: 23011}, - val: "hex", - ignoreCase: true, - }, - &litMatcher{ - pos: position{line: 981, col: 15, offset: 23020}, - val: "x", - ignoreCase: true, - }, - }, - }, - &litMatcher{ - pos: position{line: 981, col: 22, offset: 23027}, - val: "'", - ignoreCase: false, - }, - &labeledExpr{ - pos: position{line: 981, col: 26, offset: 23031}, - label: "s", - expr: &zeroOrMoreExpr{ - pos: position{line: 981, col: 28, offset: 23033}, - expr: &actionExpr{ - pos: position{line: 981, col: 29, offset: 23034}, - run: (*parser).callonHexString9, - expr: &seqExpr{ - pos: position{line: 981, col: 29, offset: 23034}, - exprs: []interface{}{ - &charClassMatcher{ - pos: position{line: 981, col: 29, offset: 23034}, - val: "[0-9a-fA-F]", - ranges: []rune{'0', '9', 'a', 'f', 'A', 'F'}, - ignoreCase: false, - inverted: false, - }, - &charClassMatcher{ - pos: position{line: 981, col: 40, offset: 23045}, - val: "[0-9a-fA-F]", - ranges: []rune{'0', '9', 'a', 'f', 'A', 'F'}, - ignoreCase: false, - inverted: false, - }, - }, - }, - }, - }, - }, - &litMatcher{ - pos: position{line: 981, col: 78, offset: 23083}, - val: "'", - ignoreCase: false, - }, - }, - }, - }, - }, - { - name: "NormalString", - pos: position{line: 990, col: 1, offset: 23266}, - expr: &actionExpr{ - pos: position{line: 991, col: 4, offset: 23282}, - run: (*parser).callonNormalString1, - expr: &seqExpr{ - pos: position{line: 991, col: 4, offset: 23282}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 991, col: 4, offset: 23282}, - val: "'", - ignoreCase: false, - }, - &labeledExpr{ - pos: position{line: 991, col: 8, offset: 23286}, - label: "s", - expr: &zeroOrMoreExpr{ - pos: position{line: 991, col: 10, offset: 23288}, - expr: &actionExpr{ - pos: position{line: 991, col: 12, offset: 23290}, - run: (*parser).callonNormalString6, - expr: &choiceExpr{ - pos: position{line: 991, col: 14, offset: 23292}, - alternatives: []interface{}{ - &charClassMatcher{ - pos: position{line: 991, col: 14, offset: 23292}, - val: "[^'\\r\\n\\\\]", - chars: []rune{'\'', '\r', '\n', '\\'}, - ignoreCase: false, - inverted: true, - }, - &seqExpr{ - pos: position{line: 991, col: 27, offset: 23305}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 991, col: 27, offset: 23305}, - val: "\\", - ignoreCase: false, - }, - &anyMatcher{ - line: 991, col: 32, offset: 23310, - }, - }, - }, - }, - }, - }, - }, - }, - &litMatcher{ - pos: position{line: 991, col: 62, offset: 23340}, - val: "'", - ignoreCase: false, - }, - }, - }, - }, - }, - { - name: "SelectToken", - pos: position{line: 1016, col: 1, offset: 23920}, - expr: &seqExpr{ - pos: position{line: 1017, col: 4, offset: 23935}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 1017, col: 4, offset: 23935}, - val: "select", - ignoreCase: true, - }, - ¬Expr{ - pos: position{line: 1017, col: 14, offset: 23945}, - expr: &ruleRefExpr{ - pos: position{line: 1017, col: 15, offset: 23946}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - }, - { - name: "FromToken", - pos: position{line: 1019, col: 1, offset: 23968}, - expr: &seqExpr{ - pos: position{line: 1020, col: 4, offset: 23981}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 1020, col: 4, offset: 23981}, - val: "from", - ignoreCase: true, - }, - ¬Expr{ - pos: position{line: 1020, col: 12, offset: 23989}, - expr: &ruleRefExpr{ - pos: position{line: 1020, col: 13, offset: 23990}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - }, - { - name: "WhereToken", - pos: position{line: 1022, col: 1, offset: 24012}, - expr: &seqExpr{ - pos: position{line: 1023, col: 4, offset: 24026}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 1023, col: 4, offset: 24026}, - val: "where", - ignoreCase: true, - }, - ¬Expr{ - pos: position{line: 1023, col: 13, offset: 24035}, - expr: &ruleRefExpr{ - pos: position{line: 1023, col: 14, offset: 24036}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - }, - { - name: "OrderToken", - pos: position{line: 1025, col: 1, offset: 24058}, - expr: &seqExpr{ - pos: position{line: 1026, col: 4, offset: 24072}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 1026, col: 4, offset: 24072}, - val: "order", - ignoreCase: true, - }, - ¬Expr{ - pos: position{line: 1026, col: 13, offset: 24081}, - expr: &ruleRefExpr{ - pos: position{line: 1026, col: 14, offset: 24082}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - }, - { - name: "ByToken", - pos: position{line: 1028, col: 1, offset: 24104}, - expr: &seqExpr{ - pos: position{line: 1029, col: 4, offset: 24115}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 1029, col: 4, offset: 24115}, - val: "by", - ignoreCase: true, - }, - ¬Expr{ - pos: position{line: 1029, col: 10, offset: 24121}, - expr: &ruleRefExpr{ - pos: position{line: 1029, col: 11, offset: 24122}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - }, - { - name: "GroupToken", - pos: position{line: 1031, col: 1, offset: 24144}, - expr: &seqExpr{ - pos: position{line: 1032, col: 4, offset: 24158}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 1032, col: 4, offset: 24158}, - val: "group", - ignoreCase: true, - }, - ¬Expr{ - pos: position{line: 1032, col: 13, offset: 24167}, - expr: &ruleRefExpr{ - pos: position{line: 1032, col: 14, offset: 24168}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - }, - { - name: "LimitToken", - pos: position{line: 1034, col: 1, offset: 24190}, - expr: &seqExpr{ - pos: position{line: 1035, col: 4, offset: 24204}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 1035, col: 4, offset: 24204}, - val: "limit", - ignoreCase: true, - }, - ¬Expr{ - pos: position{line: 1035, col: 13, offset: 24213}, - expr: &ruleRefExpr{ - pos: position{line: 1035, col: 14, offset: 24214}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - }, - { - name: "OffsetToken", - pos: position{line: 1037, col: 1, offset: 24236}, - expr: &seqExpr{ - pos: position{line: 1038, col: 4, offset: 24251}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 1038, col: 4, offset: 24251}, - val: "offset", - ignoreCase: true, - }, - ¬Expr{ - pos: position{line: 1038, col: 14, offset: 24261}, - expr: &ruleRefExpr{ - pos: position{line: 1038, col: 15, offset: 24262}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - }, - { - name: "UpdateToken", - pos: position{line: 1040, col: 1, offset: 24284}, - expr: &seqExpr{ - pos: position{line: 1041, col: 4, offset: 24299}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 1041, col: 4, offset: 24299}, - val: "update", - ignoreCase: true, - }, - ¬Expr{ - pos: position{line: 1041, col: 14, offset: 24309}, - expr: &ruleRefExpr{ - pos: position{line: 1041, col: 15, offset: 24310}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - }, - { - name: "SetToken", - pos: position{line: 1043, col: 1, offset: 24332}, - expr: &seqExpr{ - pos: position{line: 1044, col: 4, offset: 24344}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 1044, col: 4, offset: 24344}, - val: "set", - ignoreCase: true, - }, - ¬Expr{ - pos: position{line: 1044, col: 11, offset: 24351}, - expr: &ruleRefExpr{ - pos: position{line: 1044, col: 12, offset: 24352}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - }, - { - name: "DeleteToken", - pos: position{line: 1046, col: 1, offset: 24374}, - expr: &seqExpr{ - pos: position{line: 1047, col: 4, offset: 24389}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 1047, col: 4, offset: 24389}, - val: "delete", - ignoreCase: true, - }, - ¬Expr{ - pos: position{line: 1047, col: 14, offset: 24399}, - expr: &ruleRefExpr{ - pos: position{line: 1047, col: 15, offset: 24400}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - }, - { - name: "InsertToken", - pos: position{line: 1049, col: 1, offset: 24422}, - expr: &seqExpr{ - pos: position{line: 1050, col: 4, offset: 24437}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 1050, col: 4, offset: 24437}, - val: "insert", - ignoreCase: true, - }, - ¬Expr{ - pos: position{line: 1050, col: 14, offset: 24447}, - expr: &ruleRefExpr{ - pos: position{line: 1050, col: 15, offset: 24448}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - }, - { - name: "IntoToken", - pos: position{line: 1052, col: 1, offset: 24470}, - expr: &seqExpr{ - pos: position{line: 1053, col: 4, offset: 24483}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 1053, col: 4, offset: 24483}, - val: "into", - ignoreCase: true, - }, - ¬Expr{ - pos: position{line: 1053, col: 12, offset: 24491}, - expr: &ruleRefExpr{ - pos: position{line: 1053, col: 13, offset: 24492}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - }, - { - name: "ValuesToken", - pos: position{line: 1055, col: 1, offset: 24514}, - expr: &seqExpr{ - pos: position{line: 1056, col: 4, offset: 24529}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 1056, col: 4, offset: 24529}, - val: "values", - ignoreCase: true, - }, - ¬Expr{ - pos: position{line: 1056, col: 14, offset: 24539}, - expr: &ruleRefExpr{ - pos: position{line: 1056, col: 15, offset: 24540}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - }, - { - name: "CreateToken", - pos: position{line: 1058, col: 1, offset: 24562}, - expr: &seqExpr{ - pos: position{line: 1059, col: 4, offset: 24577}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 1059, col: 4, offset: 24577}, - val: "create", - ignoreCase: true, - }, - ¬Expr{ - pos: position{line: 1059, col: 14, offset: 24587}, - expr: &ruleRefExpr{ - pos: position{line: 1059, col: 15, offset: 24588}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - }, - { - name: "TableToken", - pos: position{line: 1061, col: 1, offset: 24610}, - expr: &seqExpr{ - pos: position{line: 1062, col: 4, offset: 24624}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 1062, col: 4, offset: 24624}, - val: "table", - ignoreCase: true, - }, - ¬Expr{ - pos: position{line: 1062, col: 13, offset: 24633}, - expr: &ruleRefExpr{ - pos: position{line: 1062, col: 14, offset: 24634}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - }, - { - name: "IndexToken", - pos: position{line: 1064, col: 1, offset: 24656}, - expr: &seqExpr{ - pos: position{line: 1065, col: 4, offset: 24670}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 1065, col: 4, offset: 24670}, - val: "index", - ignoreCase: true, - }, - ¬Expr{ - pos: position{line: 1065, col: 13, offset: 24679}, - expr: &ruleRefExpr{ - pos: position{line: 1065, col: 14, offset: 24680}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - }, - { - name: "UniqueToken", - pos: position{line: 1067, col: 1, offset: 24702}, - expr: &seqExpr{ - pos: position{line: 1068, col: 4, offset: 24717}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 1068, col: 4, offset: 24717}, - val: "unique", - ignoreCase: true, - }, - ¬Expr{ - pos: position{line: 1068, col: 14, offset: 24727}, - expr: &ruleRefExpr{ - pos: position{line: 1068, col: 15, offset: 24728}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - }, - { - name: "DefaultToken", - pos: position{line: 1070, col: 1, offset: 24750}, - expr: &seqExpr{ - pos: position{line: 1071, col: 4, offset: 24766}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 1071, col: 4, offset: 24766}, - val: "default", - ignoreCase: true, - }, - ¬Expr{ - pos: position{line: 1071, col: 15, offset: 24777}, - expr: &ruleRefExpr{ - pos: position{line: 1071, col: 16, offset: 24778}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - }, - { - name: "PrimaryToken", - pos: position{line: 1073, col: 1, offset: 24800}, - expr: &seqExpr{ - pos: position{line: 1074, col: 4, offset: 24816}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 1074, col: 4, offset: 24816}, - val: "primary", - ignoreCase: true, - }, - ¬Expr{ - pos: position{line: 1074, col: 15, offset: 24827}, - expr: &ruleRefExpr{ - pos: position{line: 1074, col: 16, offset: 24828}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - }, - { - name: "KeyToken", - pos: position{line: 1076, col: 1, offset: 24850}, - expr: &seqExpr{ - pos: position{line: 1077, col: 4, offset: 24862}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 1077, col: 4, offset: 24862}, - val: "key", - ignoreCase: true, - }, - ¬Expr{ - pos: position{line: 1077, col: 11, offset: 24869}, - expr: &ruleRefExpr{ - pos: position{line: 1077, col: 12, offset: 24870}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - }, - { - name: "ReferencesToken", - pos: position{line: 1079, col: 1, offset: 24892}, - expr: &seqExpr{ - pos: position{line: 1080, col: 4, offset: 24911}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 1080, col: 4, offset: 24911}, - val: "references", - ignoreCase: true, - }, - ¬Expr{ - pos: position{line: 1080, col: 18, offset: 24925}, - expr: &ruleRefExpr{ - pos: position{line: 1080, col: 19, offset: 24926}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - }, - { - name: "AutoincrementToken", - pos: position{line: 1082, col: 1, offset: 24948}, - expr: &seqExpr{ - pos: position{line: 1083, col: 4, offset: 24970}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 1083, col: 4, offset: 24970}, - val: "autoincrement", - ignoreCase: true, - }, - ¬Expr{ - pos: position{line: 1083, col: 21, offset: 24987}, - expr: &ruleRefExpr{ - pos: position{line: 1083, col: 22, offset: 24988}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - }, - { - name: "OnToken", - pos: position{line: 1085, col: 1, offset: 25010}, - expr: &seqExpr{ - pos: position{line: 1086, col: 4, offset: 25021}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 1086, col: 4, offset: 25021}, - val: "on", - ignoreCase: true, - }, - ¬Expr{ - pos: position{line: 1086, col: 10, offset: 25027}, - expr: &ruleRefExpr{ - pos: position{line: 1086, col: 11, offset: 25028}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - }, - { - name: "TrueToken", - pos: position{line: 1088, col: 1, offset: 25050}, - expr: &actionExpr{ - pos: position{line: 1089, col: 4, offset: 25063}, - run: (*parser).callonTrueToken1, - expr: &seqExpr{ - pos: position{line: 1089, col: 4, offset: 25063}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 1089, col: 4, offset: 25063}, - val: "true", - ignoreCase: true, - }, - ¬Expr{ - pos: position{line: 1089, col: 12, offset: 25071}, - expr: &ruleRefExpr{ - pos: position{line: 1089, col: 13, offset: 25072}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - }, - }, - { - name: "FalseToken", - pos: position{line: 1092, col: 1, offset: 25126}, - expr: &actionExpr{ - pos: position{line: 1093, col: 4, offset: 25140}, - run: (*parser).callonFalseToken1, - expr: &seqExpr{ - pos: position{line: 1093, col: 4, offset: 25140}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 1093, col: 4, offset: 25140}, - val: "false", - ignoreCase: true, - }, - ¬Expr{ - pos: position{line: 1093, col: 13, offset: 25149}, - expr: &ruleRefExpr{ - pos: position{line: 1093, col: 14, offset: 25150}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - }, - }, - { - name: "NullToken", - pos: position{line: 1096, col: 1, offset: 25204}, - expr: &seqExpr{ - pos: position{line: 1097, col: 4, offset: 25217}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 1097, col: 4, offset: 25217}, - val: "null", - ignoreCase: true, - }, - ¬Expr{ - pos: position{line: 1097, col: 12, offset: 25225}, - expr: &ruleRefExpr{ - pos: position{line: 1097, col: 13, offset: 25226}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - }, - { - name: "IsToken", - pos: position{line: 1099, col: 1, offset: 25248}, - expr: &seqExpr{ - pos: position{line: 1100, col: 4, offset: 25259}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 1100, col: 4, offset: 25259}, - val: "is", - ignoreCase: true, - }, - ¬Expr{ - pos: position{line: 1100, col: 10, offset: 25265}, - expr: &ruleRefExpr{ - pos: position{line: 1100, col: 11, offset: 25266}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - }, - { - name: "NullsToken", - pos: position{line: 1102, col: 1, offset: 25288}, - expr: &seqExpr{ - pos: position{line: 1103, col: 4, offset: 25302}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 1103, col: 4, offset: 25302}, - val: "nulls", - ignoreCase: true, - }, - ¬Expr{ - pos: position{line: 1103, col: 13, offset: 25311}, - expr: &ruleRefExpr{ - pos: position{line: 1103, col: 14, offset: 25312}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - }, - { - name: "LastToken", - pos: position{line: 1105, col: 1, offset: 25334}, - expr: &actionExpr{ - pos: position{line: 1106, col: 4, offset: 25347}, - run: (*parser).callonLastToken1, - expr: &seqExpr{ - pos: position{line: 1106, col: 4, offset: 25347}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 1106, col: 4, offset: 25347}, - val: "last", - ignoreCase: true, - }, - ¬Expr{ - pos: position{line: 1106, col: 12, offset: 25355}, - expr: &ruleRefExpr{ - pos: position{line: 1106, col: 13, offset: 25356}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - }, - }, - { - name: "FirstToken", - pos: position{line: 1109, col: 1, offset: 25410}, - expr: &actionExpr{ - pos: position{line: 1110, col: 4, offset: 25424}, - run: (*parser).callonFirstToken1, - expr: &seqExpr{ - pos: position{line: 1110, col: 4, offset: 25424}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 1110, col: 4, offset: 25424}, - val: "first", - ignoreCase: true, - }, - ¬Expr{ - pos: position{line: 1110, col: 13, offset: 25433}, - expr: &ruleRefExpr{ - pos: position{line: 1110, col: 14, offset: 25434}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - }, - }, - { - name: "AndToken", - pos: position{line: 1113, col: 1, offset: 25488}, - expr: &seqExpr{ - pos: position{line: 1114, col: 4, offset: 25500}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 1114, col: 4, offset: 25500}, - val: "and", - ignoreCase: true, - }, - ¬Expr{ - pos: position{line: 1114, col: 11, offset: 25507}, - expr: &ruleRefExpr{ - pos: position{line: 1114, col: 12, offset: 25508}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - }, - { - name: "OrToken", - pos: position{line: 1116, col: 1, offset: 25530}, - expr: &seqExpr{ - pos: position{line: 1117, col: 4, offset: 25541}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 1117, col: 4, offset: 25541}, - val: "or", - ignoreCase: true, - }, - ¬Expr{ - pos: position{line: 1117, col: 10, offset: 25547}, - expr: &ruleRefExpr{ - pos: position{line: 1117, col: 11, offset: 25548}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - }, - { - name: "NotToken", - pos: position{line: 1119, col: 1, offset: 25570}, - expr: &seqExpr{ - pos: position{line: 1120, col: 4, offset: 25582}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 1120, col: 4, offset: 25582}, - val: "not", - ignoreCase: true, - }, - ¬Expr{ - pos: position{line: 1120, col: 11, offset: 25589}, - expr: &ruleRefExpr{ - pos: position{line: 1120, col: 12, offset: 25590}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - }, - { - name: "InToken", - pos: position{line: 1122, col: 1, offset: 25612}, - expr: &seqExpr{ - pos: position{line: 1123, col: 4, offset: 25623}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 1123, col: 4, offset: 25623}, - val: "in", - ignoreCase: true, - }, - ¬Expr{ - pos: position{line: 1123, col: 10, offset: 25629}, - expr: &ruleRefExpr{ - pos: position{line: 1123, col: 11, offset: 25630}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - }, - { - name: "LikeToken", - pos: position{line: 1125, col: 1, offset: 25652}, - expr: &seqExpr{ - pos: position{line: 1126, col: 4, offset: 25665}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 1126, col: 4, offset: 25665}, - val: "like", - ignoreCase: true, - }, - ¬Expr{ - pos: position{line: 1126, col: 12, offset: 25673}, - expr: &ruleRefExpr{ - pos: position{line: 1126, col: 13, offset: 25674}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - }, - { - name: "AscToken", - pos: position{line: 1128, col: 1, offset: 25696}, - expr: &actionExpr{ - pos: position{line: 1129, col: 4, offset: 25708}, - run: (*parser).callonAscToken1, - expr: &seqExpr{ - pos: position{line: 1129, col: 4, offset: 25708}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 1129, col: 4, offset: 25708}, - val: "asc", - ignoreCase: true, - }, - ¬Expr{ - pos: position{line: 1129, col: 11, offset: 25715}, - expr: &ruleRefExpr{ - pos: position{line: 1129, col: 12, offset: 25716}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - }, - }, - { - name: "DescToken", - pos: position{line: 1132, col: 1, offset: 25770}, - expr: &actionExpr{ - pos: position{line: 1133, col: 4, offset: 25783}, - run: (*parser).callonDescToken1, - expr: &seqExpr{ - pos: position{line: 1133, col: 4, offset: 25783}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 1133, col: 4, offset: 25783}, - val: "desc", - ignoreCase: true, - }, - ¬Expr{ - pos: position{line: 1133, col: 12, offset: 25791}, - expr: &ruleRefExpr{ - pos: position{line: 1133, col: 13, offset: 25792}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - }, - }, - { - name: "CastToken", - pos: position{line: 1136, col: 1, offset: 25846}, - expr: &seqExpr{ - pos: position{line: 1137, col: 4, offset: 25859}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 1137, col: 4, offset: 25859}, - val: "cast", - ignoreCase: true, - }, - ¬Expr{ - pos: position{line: 1137, col: 12, offset: 25867}, - expr: &ruleRefExpr{ - pos: position{line: 1137, col: 13, offset: 25868}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - }, - { - name: "AsToken", - pos: position{line: 1139, col: 1, offset: 25890}, - expr: &seqExpr{ - pos: position{line: 1140, col: 4, offset: 25901}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 1140, col: 4, offset: 25901}, - val: "as", - ignoreCase: true, - }, - ¬Expr{ - pos: position{line: 1140, col: 10, offset: 25907}, - expr: &ruleRefExpr{ - pos: position{line: 1140, col: 11, offset: 25908}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - }, - { - name: "SeparatorToken", - pos: position{line: 1142, col: 1, offset: 25930}, - expr: &litMatcher{ - pos: position{line: 1143, col: 4, offset: 25948}, - val: ",", - ignoreCase: false, - }, - }, - { - name: "AnyToken", - pos: position{line: 1145, col: 1, offset: 25953}, - expr: &litMatcher{ - pos: position{line: 1146, col: 4, offset: 25965}, - val: "*", - ignoreCase: false, - }, - }, - { - name: "Identifier", - pos: position{line: 1149, col: 1, offset: 25988}, - expr: &choiceExpr{ - pos: position{line: 1150, col: 4, offset: 26002}, - alternatives: []interface{}{ - &ruleRefExpr{ - pos: position{line: 1150, col: 4, offset: 26002}, - name: "NormalIdentifier", - }, - &ruleRefExpr{ - pos: position{line: 1151, col: 4, offset: 26022}, - name: "StringIdentifier", - }, - }, - }, - }, - { - name: "NormalIdentifier", - pos: position{line: 1153, col: 1, offset: 26040}, - expr: &actionExpr{ - pos: position{line: 1154, col: 4, offset: 26060}, - run: (*parser).callonNormalIdentifier1, - expr: &seqExpr{ - pos: position{line: 1154, col: 4, offset: 26060}, - exprs: []interface{}{ - &ruleRefExpr{ - pos: position{line: 1154, col: 4, offset: 26060}, - name: "NormalIdentifierStart", - }, - &zeroOrMoreExpr{ - pos: position{line: 1154, col: 26, offset: 26082}, - expr: &ruleRefExpr{ - pos: position{line: 1154, col: 26, offset: 26082}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - }, - }, - { - name: "NormalIdentifierStart", - pos: position{line: 1163, col: 1, offset: 26269}, - expr: &charClassMatcher{ - pos: position{line: 1164, col: 4, offset: 26294}, - val: "[a-zA-Z\\x80-\\xff]", - ranges: []rune{'a', 'z', 'A', 'Z', '\u0080', 'ÿ'}, - ignoreCase: false, - inverted: false, - }, - }, - { - name: "NormalIdentifierRest", - pos: position{line: 1166, col: 1, offset: 26313}, - expr: &charClassMatcher{ - pos: position{line: 1167, col: 4, offset: 26337}, - val: "[a-zA-Z0-9_\\x80-\\xff]", - chars: []rune{'_'}, - ranges: []rune{'a', 'z', 'A', 'Z', '0', '9', '\u0080', 'ÿ'}, - ignoreCase: false, - inverted: false, - }, - }, - { - name: "StringIdentifier", - pos: position{line: 1169, col: 1, offset: 26360}, - expr: &actionExpr{ - pos: position{line: 1170, col: 4, offset: 26380}, - run: (*parser).callonStringIdentifier1, - expr: &seqExpr{ - pos: position{line: 1170, col: 4, offset: 26380}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 1170, col: 4, offset: 26380}, - val: "\"", - ignoreCase: false, - }, - &labeledExpr{ - pos: position{line: 1170, col: 9, offset: 26385}, - label: "s", - expr: &zeroOrMoreExpr{ - pos: position{line: 1170, col: 11, offset: 26387}, - expr: &actionExpr{ - pos: position{line: 1170, col: 13, offset: 26389}, - run: (*parser).callonStringIdentifier6, - expr: &choiceExpr{ - pos: position{line: 1170, col: 15, offset: 26391}, - alternatives: []interface{}{ - &charClassMatcher{ - pos: position{line: 1170, col: 15, offset: 26391}, - val: "[^\"\\r\\n\\\\]", - chars: []rune{'"', '\r', '\n', '\\'}, - ignoreCase: false, - inverted: true, - }, - &seqExpr{ - pos: position{line: 1170, col: 28, offset: 26404}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 1170, col: 28, offset: 26404}, - val: "\\", - ignoreCase: false, - }, - &anyMatcher{ - line: 1170, col: 33, offset: 26409, - }, - }, - }, - }, - }, - }, - }, - }, - &litMatcher{ - pos: position{line: 1170, col: 63, offset: 26439}, - val: "\"", - ignoreCase: false, - }, - }, - }, - }, - }, - { - name: "_", - pos: position{line: 1195, col: 1, offset: 27031}, - expr: &zeroOrMoreExpr{ - pos: position{line: 1196, col: 4, offset: 27036}, - expr: &ruleRefExpr{ - pos: position{line: 1196, col: 4, offset: 27036}, - name: "Whitespace", - }, - }, - }, - { - name: "Whitespace", - pos: position{line: 1198, col: 1, offset: 27049}, - expr: &choiceExpr{ - pos: position{line: 1199, col: 4, offset: 27063}, - alternatives: []interface{}{ - &litMatcher{ - pos: position{line: 1199, col: 4, offset: 27063}, - val: "\t", - ignoreCase: false, - }, - &litMatcher{ - pos: position{line: 1200, col: 4, offset: 27084}, - val: "\n", - ignoreCase: false, - }, - &litMatcher{ - pos: position{line: 1201, col: 4, offset: 27105}, - val: "\v", - ignoreCase: false, - }, - &litMatcher{ - pos: position{line: 1202, col: 4, offset: 27126}, - val: "\f", - ignoreCase: false, - }, - &litMatcher{ - pos: position{line: 1203, col: 4, offset: 27147}, - val: "\r", - ignoreCase: false, - }, - &litMatcher{ - pos: position{line: 1204, col: 4, offset: 27168}, - val: " ", - ignoreCase: false, - }, - }, - }, - }, - { - name: "EOF", - pos: position{line: 1206, col: 1, offset: 27190}, - expr: ¬Expr{ - pos: position{line: 1207, col: 4, offset: 27197}, - expr: &anyMatcher{ - line: 1207, col: 5, offset: 27198, - }, - }, - }, - }, -} - -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, assertSlice(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) { - node := &ast.SelectStmtNode{} - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - node.Column = assertExprSlice(prepend(f, assertSlice(fs))) - if table != nil { - node.Table = table.(*ast.IdentifierNode) - } - if where != nil { - node.Where = where.(*ast.WhereOptionNode) - } - groupSlice := assertSlice(group) - node.Group = make([]*ast.GroupOptionNode, len(groupSlice)) - for idx := range groupSlice { - node.Group[idx] = groupSlice[idx].(*ast.GroupOptionNode) - } - orderSlice := assertSlice(order) - node.Order = make([]*ast.OrderOptionNode, len(orderSlice)) - for idx := range orderSlice { - node.Order[idx] = orderSlice[idx].(*ast.OrderOptionNode) - } - if limit != nil { - node.Limit = limit.(*ast.LimitOptionNode) - } - if offset != nil { - node.Offset = offset.(*ast.OffsetOptionNode) - } - return node, 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) { - node := &ast.UpdateStmtNode{} - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - node.Table = table.(*ast.IdentifierNode) - assignSlice := prepend(a, assertSlice(as)) - node.Assignment = make([]*ast.AssignOperatorNode, len(assignSlice)) - for idx := range assignSlice { - node.Assignment[idx] = assignSlice[idx].(*ast.AssignOperatorNode) - } - if where != nil { - node.Where = where.(*ast.WhereOptionNode) - } - return node, 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) { - node := &ast.DeleteStmtNode{} - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - node.Table = table.(*ast.IdentifierNode) - if where != nil { - node.Where = where.(*ast.WhereOptionNode) - } - return node, 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) { - node := &ast.InsertStmtNode{} - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - node.Table = table.(*ast.IdentifierNode) - switch i := insert.(type) { - case *ast.InsertWithColumnOptionNode: - node.Insert = i - case *ast.InsertWithDefaultOptionNode: - node.Insert = i - default: - panic(fmt.Sprintf("unknown insert type %T", insert)) - } - return node, 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, assertSlice(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) { - node := &ast.CreateTableStmtNode{} - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - node.Table = table.(*ast.IdentifierNode) - columnSlice := assertSlice(column) - node.Column = make([]*ast.ColumnSchemaNode, len(columnSlice)) - for idx := range columnSlice { - node.Column[idx] = columnSlice[idx].(*ast.ColumnSchemaNode) - } - return node, 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) { - node := &ast.ColumnSchemaNode{} - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - node.Column = i.(*ast.IdentifierNode) - node.DataType = t.(ast.TypeNode) - constraintSlice := assertSlice(cs) - node.Constraint = make([]ast.Node, len(constraintSlice)) - for idx, constraint := range constraintSlice { - switch c := constraint.(type) { - case *ast.PrimaryOptionNode: - node.Constraint[idx] = c - case *ast.NotNullOptionNode: - node.Constraint[idx] = c - case *ast.UniqueOptionNode: - node.Constraint[idx] = c - case *ast.DefaultOptionNode: - node.Constraint[idx] = c - case *ast.ForeignOptionNode: - node.Constraint[idx] = c - case *ast.AutoIncrementOptionNode: - node.Constraint[idx] = c - default: - panic(fmt.Sprintf("unknown constraint type %T", c)) - } - } - return node, 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) { - node := &ast.CreateIndexStmtNode{} - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - node.Index = index.(*ast.IdentifierNode) - node.Table = table.(*ast.IdentifierNode) - columnSlice := assertSlice(prepend(i, assertSlice(is))) - node.Column = make([]*ast.IdentifierNode, len(columnSlice)) - for idx := range columnSlice { - node.Column[idx] = columnSlice[idx].(*ast.IdentifierNode) - } - if unique != nil { - node.Unique = unique.(*ast.UniqueOptionNode) - } - return node, 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) { - node := &ast.WhereOptionNode{} - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - node.Condition = e.(ast.ExprNode) - return node, 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, assertSlice(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) { - node := &ast.OrderOptionNode{} - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - node.Expr = i.(ast.ExprNode) - node.Desc = s != nil && string(s.([]byte)) == "desc" - node.NullsFirst = n != nil && string(n.([]byte)) == "first" - return node, 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 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(f, fs interface{}) (interface{}, error) { - return prepend(f, assertSlice(fs)), nil -} - -func (p *parser) callonGroupByClause1() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onGroupByClause1(stack["f"], stack["fs"]) -} - -func (c *current) onGroupColumn1(i interface{}) (interface{}, error) { - node := &ast.GroupOptionNode{} - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - node.Expr = i.(ast.ExprNode) - return node, nil -} - -func (p *parser) callonGroupColumn1() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onGroupColumn1(stack["i"]) -} - -func (c *current) onOffsetClause1(i interface{}) (interface{}, error) { - node := &ast.OffsetOptionNode{} - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - node.Value = i.(*ast.IntegerValueNode) - return node, 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) { - node := &ast.LimitOptionNode{} - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - node.Value = i.(*ast.IntegerValueNode) - return node, 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, assertSlice(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) { - node := &ast.InsertWithColumnOptionNode{} - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - columnSlice := assertSlice(cs) - node.Column = make([]*ast.IdentifierNode, len(columnSlice)) - for idx := range columnSlice { - node.Column[idx] = columnSlice[idx].(*ast.IdentifierNode) - } - valueSlice := assertSlice(vs) - node.Value = make([][]ast.ExprNode, len(valueSlice)+1) - node.Value[0] = v.([]ast.ExprNode) - for idx := range valueSlice { - node.Value[idx+1] = valueSlice[idx].([]ast.ExprNode) - } - return node, 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) { - node := &ast.InsertWithDefaultOptionNode{} - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - return node, 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) { - node := &ast.PrimaryOptionNode{} - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - return node, 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) { - node := &ast.NotNullOptionNode{} - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - return node, 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) { - node := &ast.UniqueOptionNode{} - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - return node, 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) { - node := &ast.DefaultOptionNode{} - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - node.Value = e.(ast.ExprNode) - return node, 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) { - node := &ast.ForeignOptionNode{} - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - node.Table = t.(*ast.IdentifierNode) - node.Column = f.(*ast.IdentifierNode) - return node, 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) { - node := &ast.AutoIncrementOptionNode{} - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - return node, 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.(ast.BinaryOperator), s.(ast.ExprNode)), 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.(ast.ExprNode), assertExprSlice(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.(ast.BinaryOperator), s.(ast.ExprNode)), 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.(ast.ExprNode), assertExprSlice(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.(ast.UnaryOperator), s.(ast.ExprNode)), 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.(ast.ExprNode), assertExprSlice(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) { - node := &ast.InOperatorNode{} - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - node.Right = s.([]ast.ExprNode) - if n != nil { - return opSetTarget(n.(ast.UnaryOperator), node), nil - } - return node, 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) onLogicExpr1Is6(t interface{}) (interface{}, error) { - return t, nil -} - -func (p *parser) callonLogicExpr1Is6() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onLogicExpr1Is6(stack["t"]) -} - -func (c *current) onLogicExpr1Is1(n, u interface{}) (interface{}, error) { - node := &ast.IsOperatorNode{} - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - opSetSubject(node, u.(*ast.NullValueNode)) - if n != nil { - return opSetTarget(n.(ast.UnaryOperator), node), nil - } - return node, nil -} - -func (p *parser) callonLogicExpr1Is1() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onLogicExpr1Is1(stack["n"], stack["u"]) -} - -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) { - node := &ast.LikeOperatorNode{} - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - opSetSubject(node, s.(ast.ExprNode)) - if n != nil { - return opSetTarget(n.(ast.UnaryOperator), node), nil - } - return node, 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.(ast.BinaryOperator), s.(ast.ExprNode)), 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.(ast.BinaryOperator), s.(ast.ExprNode)), 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.(ast.ExprNode), assertExprSlice(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.(ast.BinaryOperator), s.(ast.ExprNode)), 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.(ast.ExprNode), assertExprSlice(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.(ast.BinaryOperator), s.(ast.ExprNode)), 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.(ast.ExprNode), assertExprSlice(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 assertExprSlice(prepend(x, assertSlice(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 assertExprSlice(prepend(x, assertSlice(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.(ast.UnaryOperator), s.(ast.ExprNode)), 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) { - node := &ast.ParenOperatorNode{} - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - opSetTarget(node, e.(ast.ExprNode)) - return node, 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) { - node := &ast.CastOperatorNode{} - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - node.SourceExpr = o.(ast.ExprNode) - node.TargetType = s.(ast.TypeNode) - return node, 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) { - node := &ast.FunctionOperatorNode{} - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - node.Name = i.(*ast.IdentifierNode) - if r != nil { - node.Args = r.([]ast.ExprNode) - } - return node, 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 []ast.ExprNode{a.(*ast.AnyValueNode)}, 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) { - node := &ast.AssignOperatorNode{} - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - node.Column = i.(*ast.IdentifierNode) - node.Expr = e.(ast.ExprNode) - return node, 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) { - var node ast.UnaryOperator - switch string(c.text) { - case "+": - node = &ast.PosOperatorNode{} - case "-": - node = &ast.NegOperatorNode{} - default: - panic(fmt.Sprintf("unknown sign %s", c.text)) - } - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - return node, nil -} - -func (p *parser) callonSignOperator1() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onSignOperator1() -} - -func (c *current) onNotOperator1() (interface{}, error) { - node := &ast.NotOperatorNode{} - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - return node, 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) { - node := &ast.AndOperatorNode{} - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - return node, 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) { - node := &ast.OrOperatorNode{} - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - return node, 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) { - var node ast.BinaryOperator - switch string(c.text) { - case "<=": - node = &ast.LessOrEqualOperatorNode{} - case ">=": - node = &ast.GreaterOrEqualOperatorNode{} - case "<>": - node = &ast.NotEqualOperatorNode{} - case "!=": - node = &ast.NotEqualOperatorNode{} - case "<": - node = &ast.LessOperatorNode{} - case ">": - node = &ast.GreaterOperatorNode{} - case "=": - node = &ast.EqualOperatorNode{} - default: - panic(fmt.Sprintf("unknown comparison operator %s", c.text)) - } - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - return node, nil -} - -func (p *parser) callonCmpOperator1() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onCmpOperator1() -} - -func (c *current) onConcatOperator1() (interface{}, error) { - node := &ast.ConcatOperatorNode{} - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - return node, 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) { - var node ast.BinaryOperator - switch string(c.text) { - case "+": - node = &ast.AddOperatorNode{} - case "-": - node = &ast.SubOperatorNode{} - default: - panic(fmt.Sprintf("unknown addition or subtraction operator %s", c.text)) - } - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - return node, nil -} - -func (p *parser) callonAddSubOperator1() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onAddSubOperator1() -} - -func (c *current) onMulDivModOperator1() (interface{}, error) { - var node ast.BinaryOperator - switch string(c.text) { - case "*": - node = &ast.MulOperatorNode{} - case "/": - node = &ast.DivOperatorNode{} - case "%": - node = &ast.ModOperatorNode{} - default: - panic(fmt.Sprintf("unknown multiplication, division, modulo operator: %s", c.text)) - } - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - return node, nil -} - -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) { - node := &ast.IntTypeNode{} - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - node.Unsigned = true - size, code := toUint(s.([]byte)) - if code != errors.ErrorCodeNil { - err := errors.Error{ - Position: uint32(c.pos.offset), - Category: errors.ErrorCategoryGrammar, - Code: code, - Token: string(c.text), - Prefix: "UIntType", - Message: fmt.Sprintf("cannot parse %s as uint32: %v", s, code), - } - return node, err - } - node.Size = size - return node, 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) { - node := &ast.IntTypeNode{} - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - node.Unsigned = false - size, code := toUint(s.([]byte)) - if code != errors.ErrorCodeNil { - err := errors.Error{ - Position: uint32(c.pos.offset), - Category: errors.ErrorCategoryGrammar, - Code: code, - Token: string(c.text), - Prefix: "IntType", - Message: fmt.Sprintf("cannot parse %s as uint32: %v", s, code), - } - return node, err - } - node.Size = size - return node, 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) { - node := &ast.FixedTypeNode{} - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - node.Unsigned = true - size, code := toUint(s.([]byte)) - if code != errors.ErrorCodeNil { - err := errors.Error{ - Position: uint32(c.pos.offset), - Category: errors.ErrorCategoryGrammar, - Code: code, - Token: string(c.text), - Prefix: "UFixedType", - Message: fmt.Sprintf("cannot parse %s as uint32: %v", s, code), - } - return node, err - } - fractionalDigits, code := toUint(t.([]byte)) - if code != errors.ErrorCodeNil { - err := errors.Error{ - Position: uint32(c.pos.offset), - Category: errors.ErrorCategoryGrammar, - Code: code, - Token: string(c.text), - Prefix: "UFixedType", - Message: fmt.Sprintf("cannot parse %s as uint32: %v", t, code), - } - return node, err - } - node.Size = size - node.FractionalDigits = fractionalDigits - return node, 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) { - node := &ast.FixedTypeNode{} - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - node.Unsigned = false - size, code := toUint(s.([]byte)) - if code != errors.ErrorCodeNil { - err := errors.Error{ - Position: uint32(c.pos.offset), - Category: errors.ErrorCategoryGrammar, - Code: code, - Token: string(c.text), - Prefix: "FixedType", - Message: fmt.Sprintf("cannot parse %s as uint32: %v", s, code), - } - return node, err - } - fractionalDigits, code := toUint(t.([]byte)) - if code != errors.ErrorCodeNil { - err := errors.Error{ - Position: uint32(c.pos.offset), - Category: errors.ErrorCategoryGrammar, - Code: code, - Token: string(c.text), - Prefix: "FixedType", - Message: fmt.Sprintf("cannot parse %s as uint32: %v", t, code), - } - return node, err - } - node.Size = size - node.FractionalDigits = fractionalDigits - return node, 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) { - node := &ast.FixedBytesTypeNode{} - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - size, code := toUint(s.([]byte)) - if code != errors.ErrorCodeNil { - err := errors.Error{ - Position: uint32(c.pos.offset), - Category: errors.ErrorCategoryGrammar, - Code: code, - Token: string(c.text), - Prefix: "FixedBytesType", - Message: fmt.Sprintf("cannot parse %s as uint32: %v", s, code), - } - return node, err - } - node.Size = size - return node, 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) { - node := &ast.FixedBytesTypeNode{} - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - node.Size = 1 - return node, 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) { - node := &ast.DynamicBytesTypeNode{} - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - return node, 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) { - node := &ast.AddressTypeNode{} - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - return node, 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) { - node := &ast.BoolTypeNode{} - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - return node, 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) { - node := &ast.AnyValueNode{} - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - return node, 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) { - node := &ast.DefaultValueNode{} - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - return node, 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) { - node := &ast.BoolValueNode{} - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - node.V = string(b.([]byte)) == "true" - return node, 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) { - node := &ast.NullValueNode{} - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - return node, 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) { - node := &ast.IntegerValueNode{} - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - node.IsAddress = false - v, code := toDecimal(c.text) - if code != errors.ErrorCodeNil { - err := errors.Error{ - Position: uint32(c.pos.offset), - Category: errors.ErrorCategoryGrammar, - Code: code, - Token: string(c.text), - Prefix: "Integer", - Message: fmt.Sprintf("cannot parse %s as decimal: %v", c.text, code), - } - return node, err - } - node.V = v - return node, 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) { - node := &ast.DecimalValueNode{} - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - v, code := toDecimal(c.text) - if code != errors.ErrorCodeNil { - err := errors.Error{ - Position: uint32(c.pos.offset), - Category: errors.ErrorCategoryGrammar, - Code: code, - Token: string(c.text), - Prefix: "Decimal", - Message: fmt.Sprintf("cannot parse %s as decimal: %v", c.text, code), - } - return node, err - } - node.V = v - return node, nil -} - -func (p *parser) callonDecimal1() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onDecimal1() -} - -func (c *current) onHex1() (interface{}, error) { - node := hexToInteger(c.text) - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - return node, nil -} - -func (p *parser) callonHex1() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onHex1() -} - -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) { - node := &ast.BytesValueNode{} - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - node.V = hexToBytes(joinBytes(assertSlice(s))) - return node, 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) { - node := &ast.BytesValueNode{} - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - bs := joinBytes(assertSlice(s)) - v, bad, code := resolveString(bs) - if code != errors.ErrorCodeNil { - msg := fmt.Sprintf("cannot resolve escape sequence '%s': %v", - sanitizeBadEscape(bad), code) - err := errors.Error{ - Position: uint32(c.pos.offset), - Category: errors.ErrorCategoryGrammar, - Code: code, - Token: string(c.text), - Prefix: "NormalString", - Message: msg, - } - return node, err - } - node.V = v - return node, 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) { - node := &ast.IdentifierNode{} - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - node.Name = decodeString(c.text) - return node, 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) { - node := &ast.IdentifierNode{} - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - bs := joinBytes(assertSlice(s)) - name, bad, code := resolveString(bs) - if code != errors.ErrorCodeNil { - msg := fmt.Sprintf("cannot resolve escape sequence '%s': %v", - sanitizeBadEscape(bad), code) - err := errors.Error{ - Position: uint32(c.pos.offset), - Category: errors.ErrorCategoryGrammar, - Code: code, - Token: string(c.text), - Prefix: "StringIdentifier", - Message: msg, - } - return node, err - } - node.Name = name - return node, 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 = goerrors.New("grammar has no rule") - - // errInvalidEntrypoint is returned when the specified entrypoint rule - // does not exit. - errInvalidEntrypoint = goerrors.New("invalid entrypoint") - - // errInvalidEncoding is returned when the source is not properly - // utf8-encoded. - errInvalidEncoding = goerrors.New("invalid encoding") - - // errMaxExprCnt is used to signal that the maximum number of - // expressions have been parsed. - errMaxExprCnt = goerrors.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(goerrors.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/parser/grammar.peg b/core/vm/sqlvm/parser/grammar.peg deleted file mode 100644 index 148dfaffb..000000000 --- a/core/vm/sqlvm/parser/grammar.peg +++ /dev/null @@ -1,1207 +0,0 @@ -{ -package parser - -import ( - "github.com/dexon-foundation/dexon/core/vm/sqlvm/ast" - "github.com/dexon-foundation/dexon/core/vm/sqlvm/errors" -) -} - -S - <- _ x:Stmt? _ xs:( ';' _ s:Stmt? _ { return s, nil } )* EOF -{ return prepend(x, assertSlice(xs)), nil } - -/* Statements */ -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 } )? -{ - node := &ast.SelectStmtNode{} - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - node.Column = assertExprSlice(prepend(f, assertSlice(fs))) - if table != nil { - node.Table = table.(*ast.IdentifierNode) - } - if where != nil { - node.Where = where.(*ast.WhereOptionNode) - } - groupSlice := assertSlice(group) - node.Group = make([]*ast.GroupOptionNode, len(groupSlice)) - for idx := range groupSlice { - node.Group[idx] = groupSlice[idx].(*ast.GroupOptionNode) - } - orderSlice := assertSlice(order) - node.Order = make([]*ast.OrderOptionNode, len(orderSlice)) - for idx := range orderSlice { - node.Order[idx] = orderSlice[idx].(*ast.OrderOptionNode) - } - if limit != nil { - node.Limit = limit.(*ast.LimitOptionNode) - } - if offset != nil { - node.Offset = offset.(*ast.OffsetOptionNode) - } - return node, nil -} - -SelectColumn - = AnyLiteral - / Expr - -UpdateStmt - = UpdateToken - _ table:Identifier - _ SetToken - _ a:Assignment as:( _ SeparatorToken _ s:Assignment { return s, nil } )* - where:( _ w:WhereClause { return w, nil } )? -{ - node := &ast.UpdateStmtNode{} - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - node.Table = table.(*ast.IdentifierNode) - assignSlice := prepend(a, assertSlice(as)) - node.Assignment = make([]*ast.AssignOperatorNode, len(assignSlice)) - for idx := range assignSlice { - node.Assignment[idx] = assignSlice[idx].(*ast.AssignOperatorNode) - } - if where != nil { - node.Where = where.(*ast.WhereOptionNode) - } - return node, nil -} - -DeleteStmt - = DeleteToken - _ FromToken - _ table:Identifier - where:( _ w:WhereClause { return w, nil } )? -{ - node := &ast.DeleteStmtNode{} - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - node.Table = table.(*ast.IdentifierNode) - if where != nil { - node.Where = where.(*ast.WhereOptionNode) - } - return node, nil -} - -InsertStmt - = InsertToken - _ IntoToken - _ table:Identifier - _ insert:( InsertWithColumnClause / InsertWithDefaultClause ) -{ - node := &ast.InsertStmtNode{} - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - node.Table = table.(*ast.IdentifierNode) - switch i := insert.(type) { - case *ast.InsertWithColumnOptionNode: - node.Insert = i - case *ast.InsertWithDefaultOptionNode: - node.Insert = i - default: - panic(fmt.Sprintf("unknown insert type %T", insert)) - } - return node, 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, assertSlice(ss)), nil } - )? - _ ')' -{ - node := &ast.CreateTableStmtNode{} - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - node.Table = table.(*ast.IdentifierNode) - columnSlice := assertSlice(column) - node.Column = make([]*ast.ColumnSchemaNode, len(columnSlice)) - for idx := range columnSlice { - node.Column[idx] = columnSlice[idx].(*ast.ColumnSchemaNode) - } - return node, nil -} - -ColumnSchema - = i:Identifier - _ t:DataType - cs:( _ s:ColumnConstraint { return s, nil } )* -{ - node := &ast.ColumnSchemaNode{} - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - node.Column = i.(*ast.IdentifierNode) - node.DataType = t.(ast.TypeNode) - constraintSlice := assertSlice(cs) - node.Constraint = make([]ast.Node, len(constraintSlice)) - for idx, constraint := range constraintSlice { - switch c := constraint.(type) { - case *ast.PrimaryOptionNode: - node.Constraint[idx] = c - case *ast.NotNullOptionNode: - node.Constraint[idx] = c - case *ast.UniqueOptionNode: - node.Constraint[idx] = c - case *ast.DefaultOptionNode: - node.Constraint[idx] = c - case *ast.ForeignOptionNode: - node.Constraint[idx] = c - case *ast.AutoIncrementOptionNode: - node.Constraint[idx] = c - default: - panic(fmt.Sprintf("unknown constraint type %T", c)) - } - } - return node, 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 } )* _ ')' -{ - node := &ast.CreateIndexStmtNode{} - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - node.Index = index.(*ast.IdentifierNode) - node.Table = table.(*ast.IdentifierNode) - columnSlice := assertSlice(prepend(i, assertSlice(is))) - node.Column = make([]*ast.IdentifierNode, len(columnSlice)) - for idx := range columnSlice { - node.Column[idx] = columnSlice[idx].(*ast.IdentifierNode) - } - if unique != nil { - node.Unique = unique.(*ast.UniqueOptionNode) - } - return node, nil -} - -/* Clauses */ -WhereClause - = WhereToken _ e:Expr -{ - node := &ast.WhereOptionNode{} - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - node.Condition = e.(ast.ExprNode) - return node, nil -} - -OrderByClause - = OrderToken - _ ByToken - _ f:OrderColumn - fs:( _ SeparatorToken _ s:OrderColumn { return s, nil } )* -{ - return prepend(f, assertSlice(fs)), nil -} - -OrderColumn - = i:Expr - s:( _ t:( AscToken / DescToken ) { return t, nil } )? - n:( _ NullsToken _ l:( LastToken / FirstToken ) { return l, nil } )? -{ - node := &ast.OrderOptionNode{} - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - node.Expr = i.(ast.ExprNode) - node.Desc = s != nil && string(s.([]byte)) == "desc" - node.NullsFirst = n != nil && string(n.([]byte)) == "first" - return node, nil -} - -GroupByClause - = GroupToken - _ ByToken - _ f:GroupColumn - fs:( _ SeparatorToken _ s:GroupColumn { return s, nil } )* -{ - return prepend(f, assertSlice(fs)), nil -} - -GroupColumn - = i:Expr -{ - node := &ast.GroupOptionNode{} - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - node.Expr = i.(ast.ExprNode) - return node, nil -} - -OffsetClause - = OffsetToken _ i:Integer -{ - node := &ast.OffsetOptionNode{} - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - node.Value = i.(*ast.IntegerValueNode) - return node, nil -} - -LimitClause - = LimitToken _ i:Integer -{ - node := &ast.LimitOptionNode{} - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - node.Value = i.(*ast.IntegerValueNode) - return node, nil -} - -InsertWithColumnClause - = cs:( '(' - _ f:Identifier - fs:( _ SeparatorToken _ x:Identifier { return x, nil } )* - _ ')' - _ { return prepend(f, assertSlice(fs)), nil } - )? - ValuesToken - _ v:InsertValue - vs:( _ SeparatorToken _ y:InsertValue { return y, nil } )* -{ - node := &ast.InsertWithColumnOptionNode{} - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - columnSlice := assertSlice(cs) - node.Column = make([]*ast.IdentifierNode, len(columnSlice)) - for idx := range columnSlice { - node.Column[idx] = columnSlice[idx].(*ast.IdentifierNode) - } - valueSlice := assertSlice(vs) - node.Value = make([][]ast.ExprNode, len(valueSlice)+1) - node.Value[0] = v.([]ast.ExprNode) - for idx := range valueSlice { - node.Value[idx+1] = valueSlice[idx].([]ast.ExprNode) - } - return node, nil -} - -InsertWithDefaultClause - = DefaultToken _ ValuesToken -{ - node := &ast.InsertWithDefaultOptionNode{} - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - return node, nil -} - -PrimaryKeyClause - = PrimaryToken _ KeyToken -{ - node := &ast.PrimaryOptionNode{} - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - return node, nil -} - -NotNullClause - = NotToken _ NullToken -{ - node := &ast.NotNullOptionNode{} - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - return node, nil -} - -UniqueClause - = UniqueToken -{ - node := &ast.UniqueOptionNode{} - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - return node, nil -} - -DefaultClause - = DefaultToken _ e:Expr -{ - node := &ast.DefaultOptionNode{} - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - node.Value = e.(ast.ExprNode) - return node, nil -} - -ForeignClause - = ReferencesToken _ t:Identifier _ '(' _ f:Identifier _ ')' -{ - node := &ast.ForeignOptionNode{} - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - node.Table = t.(*ast.IdentifierNode) - node.Column = f.(*ast.IdentifierNode) - return node, nil -} - -AutoincrementClause - = AutoincrementToken -{ - node := &ast.AutoIncrementOptionNode{} - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - return node, nil -} - -/* Expressions */ -Expr - = LogicExpr - -ExprWithDefault - = &(DefaultLiteral) d:DefaultLiteral { return d, nil } - / Expr - -LogicExpr - = LogicExpr4 - -LogicExpr4 - = o:LogicExpr3 - os:( _ op:OrOperator _ s:LogicExpr3 - { return opSetSubject(op.(ast.BinaryOperator), s.(ast.ExprNode)), nil } )* -{ return rightJoinOperators(o.(ast.ExprNode), assertExprSlice(os)), nil } - -LogicExpr3 - = o:LogicExpr2 - os:( _ op:AndOperator _ s:LogicExpr2 - { return opSetSubject(op.(ast.BinaryOperator), s.(ast.ExprNode)), nil } )* -{ return rightJoinOperators(o.(ast.ExprNode), assertExprSlice(os)), nil } - -LogicExpr2 - = op:NotOperator _ s:LogicExpr2 - { return opSetTarget(op.(ast.UnaryOperator), s.(ast.ExprNode)), nil } - / LogicExpr1 - -LogicExpr1 - = o:ArithmeticExpr os:( _ l:LogicExpr1Op { return l, nil } )* -{ return rightJoinOperators(o.(ast.ExprNode), assertExprSlice(os)), nil } - -LogicExpr1Op - = LogicExpr1In - / LogicExpr1Is - / LogicExpr1Like - / LogicExpr1Cmp - -LogicExpr1In - = n:( t:NotOperator _ { return t, nil } )? InToken _ '(' _ s:MultiExpr _ ')' -{ - node := &ast.InOperatorNode{} - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - node.Right = s.([]ast.ExprNode) - if n != nil { - return opSetTarget(n.(ast.UnaryOperator), node), nil - } - return node, nil -} - -LogicExpr1Is - = IsToken n:( _ t:NotOperator { return t, nil } )? _ u:NullLiteral -{ - node := &ast.IsOperatorNode{} - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - opSetSubject(node, u.(*ast.NullValueNode)) - if n != nil { - return opSetTarget(n.(ast.UnaryOperator), node), nil - } - return node, nil -} - -LogicExpr1Like - = n:( t:NotOperator _ { return t, nil } )? LikeToken _ s:Expr -{ - node := &ast.LikeOperatorNode{} - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - opSetSubject(node, s.(ast.ExprNode)) - if n != nil { - return opSetTarget(n.(ast.UnaryOperator), node), nil - } - return node, nil -} - -LogicExpr1Cmp - = op:CmpOperator _ s:ArithmeticExpr -{ return opSetSubject(op.(ast.BinaryOperator), s.(ast.ExprNode)), nil } - -ArithmeticExpr - = ArithmeticExpr3 - -ArithmeticExpr3 - = o:ArithmeticExpr2 - os:( _ op:ConcatOperator _ s:ArithmeticExpr2 - { return opSetSubject(op.(ast.BinaryOperator), s.(ast.ExprNode)), nil } )* -{ return rightJoinOperators(o.(ast.ExprNode), assertExprSlice(os)), nil } - -ArithmeticExpr2 - = o:ArithmeticExpr1 - os:( _ op:AddSubOperator _ s:ArithmeticExpr1 - { return opSetSubject(op.(ast.BinaryOperator), s.(ast.ExprNode)), nil } )* -{ return rightJoinOperators(o.(ast.ExprNode), assertExprSlice(os)), nil } - -ArithmeticExpr1 - = o:Operand - os:( _ op:MulDivModOperator _ s:Operand - { return opSetSubject(op.(ast.BinaryOperator), s.(ast.ExprNode)), nil } )* -{ return rightJoinOperators(o.(ast.ExprNode), assertExprSlice(os)), nil } - -MultiExpr - = x:Expr xs:( _ SeparatorToken _ e:Expr { return e, nil } )* -{ return assertExprSlice(prepend(x, assertSlice(xs))), nil } - -MultiExprWithDefault - = x:ExprWithDefault xs:( _ SeparatorToken _ e:ExprWithDefault { return e, nil } )* -{ return assertExprSlice(prepend(x, assertSlice(xs))), nil } - -Operand - = op:UnaryOperator _ s:Operand - { return opSetTarget(op.(ast.UnaryOperator), s.(ast.ExprNode)), nil } - / '(' _ e:Expr _ ')' - { - node := &ast.ParenOperatorNode{} - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - opSetTarget(node, e.(ast.ExprNode)) - return node, nil - } - / &(CastToken) t:TypeCast { return t, nil } - / FunctionCall - / Value - / Identifier - -TypeCast - = CastToken _ '(' _ o:Expr _ AsToken _ s:DataType _ ')' -{ - node := &ast.CastOperatorNode{} - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - node.SourceExpr = o.(ast.ExprNode) - node.TargetType = s.(ast.TypeNode) - return node, nil -} - -FunctionCall - = i:Identifier _ '(' _ r:FunctionArgs? _ ')' -{ - node := &ast.FunctionOperatorNode{} - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - node.Name = i.(*ast.IdentifierNode) - if r != nil { - node.Args = r.([]ast.ExprNode) - } - return node, nil -} - -FunctionArgs - = a:AnyLiteral { return []ast.ExprNode{a.(*ast.AnyValueNode)}, nil } - / MultiExpr - -Assignment - = i:Identifier _ '=' _ e:ExprWithDefault -{ - node := &ast.AssignOperatorNode{} - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - node.Column = i.(*ast.IdentifierNode) - node.Expr = e.(ast.ExprNode) - return node, nil -} - -/* Operators */ -UnaryOperator - = SignOperator - -SignOperator - = Sign -{ - var node ast.UnaryOperator - switch string(c.text) { - case "+": - node = &ast.PosOperatorNode{} - case "-": - node = &ast.NegOperatorNode{} - default: - panic(fmt.Sprintf("unknown sign %s", c.text)) - } - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - return node, nil -} - -NotOperator - = NotToken -{ - node := &ast.NotOperatorNode{} - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - return node, nil -} - -AndOperator - = AndToken -{ - node := &ast.AndOperatorNode{} - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - return node, nil -} - -OrOperator - = OrToken -{ - node := &ast.OrOperatorNode{} - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - return node, nil -} - -CmpOperator - = ( "<=" / ">=" / "<>" / "!=" / [<>=] ) -{ - var node ast.BinaryOperator - switch string(c.text) { - case "<=": - node = &ast.LessOrEqualOperatorNode{} - case ">=": - node = &ast.GreaterOrEqualOperatorNode{} - case "<>": - node = &ast.NotEqualOperatorNode{} - case "!=": - node = &ast.NotEqualOperatorNode{} - case "<": - node = &ast.LessOperatorNode{} - case ">": - node = &ast.GreaterOperatorNode{} - case "=": - node = &ast.EqualOperatorNode{} - default: - panic(fmt.Sprintf("unknown comparison operator %s", c.text)) - } - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - return node, nil -} - -ConcatOperator - = "||" -{ - node := &ast.ConcatOperatorNode{} - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - return node, nil -} - -AddSubOperator - = [+-] -{ - var node ast.BinaryOperator - switch string(c.text) { - case "+": - node = &ast.AddOperatorNode{} - case "-": - node = &ast.SubOperatorNode{} - default: - panic(fmt.Sprintf("unknown addition or subtraction operator %s", c.text)) - } - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - return node, nil -} - -MulDivModOperator - = [*/%] -{ - var node ast.BinaryOperator - switch string(c.text) { - case "*": - node = &ast.MulOperatorNode{} - case "/": - node = &ast.DivOperatorNode{} - case "%": - node = &ast.ModOperatorNode{} - default: - panic(fmt.Sprintf("unknown multiplication, division, modulo operator: %s", c.text)) - } - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - return node, nil -} - -/* Types */ -DataType - = UIntType - / IntType - / UFixedType - / FixedType - / FixedBytesType - / DynamicBytesType - / BoolType - / AddressType - -UIntType - = "UINT"i s:NonZeroLeadingInteger !NormalIdentifierRest -{ - node := &ast.IntTypeNode{} - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - node.Unsigned = true - size, code := toUint(s.([]byte)) - if code != errors.ErrorCodeNil { - err := errors.Error{ - Position: uint32(c.pos.offset), - Category: errors.ErrorCategoryGrammar, - Code: code, - Token: string(c.text), - Prefix: "UIntType", - Message: fmt.Sprintf("cannot parse %s as uint32: %v", s, code), - } - return node, err - } - node.Size = size - return node, nil -} - -IntType - = "INT"i s:NonZeroLeadingInteger !NormalIdentifierRest -{ - node := &ast.IntTypeNode{} - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - node.Unsigned = false - size, code := toUint(s.([]byte)) - if code != errors.ErrorCodeNil { - err := errors.Error{ - Position: uint32(c.pos.offset), - Category: errors.ErrorCategoryGrammar, - Code: code, - Token: string(c.text), - Prefix: "IntType", - Message: fmt.Sprintf("cannot parse %s as uint32: %v", s, code), - } - return node, err - } - node.Size = size - return node, nil -} - -UFixedType - = "UFIXED"i s:NonZeroLeadingInteger "X"i t:NonZeroLeadingInteger !NormalIdentifierRest -{ - node := &ast.FixedTypeNode{} - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - node.Unsigned = true - size, code := toUint(s.([]byte)) - if code != errors.ErrorCodeNil { - err := errors.Error{ - Position: uint32(c.pos.offset), - Category: errors.ErrorCategoryGrammar, - Code: code, - Token: string(c.text), - Prefix: "UFixedType", - Message: fmt.Sprintf("cannot parse %s as uint32: %v", s, code), - } - return node, err - } - fractionalDigits, code := toUint(t.([]byte)) - if code != errors.ErrorCodeNil { - err := errors.Error{ - Position: uint32(c.pos.offset), - Category: errors.ErrorCategoryGrammar, - Code: code, - Token: string(c.text), - Prefix: "UFixedType", - Message: fmt.Sprintf("cannot parse %s as uint32: %v", t, code), - } - return node, err - } - node.Size = size - node.FractionalDigits = fractionalDigits - return node, nil -} - -FixedType - = "FIXED"i s:NonZeroLeadingInteger "X"i t:NonZeroLeadingInteger !NormalIdentifierRest -{ - node := &ast.FixedTypeNode{} - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - node.Unsigned = false - size, code := toUint(s.([]byte)) - if code != errors.ErrorCodeNil { - err := errors.Error{ - Position: uint32(c.pos.offset), - Category: errors.ErrorCategoryGrammar, - Code: code, - Token: string(c.text), - Prefix: "FixedType", - Message: fmt.Sprintf("cannot parse %s as uint32: %v", s, code), - } - return node, err - } - fractionalDigits, code := toUint(t.([]byte)) - if code != errors.ErrorCodeNil { - err := errors.Error{ - Position: uint32(c.pos.offset), - Category: errors.ErrorCategoryGrammar, - Code: code, - Token: string(c.text), - Prefix: "FixedType", - Message: fmt.Sprintf("cannot parse %s as uint32: %v", t, code), - } - return node, err - } - node.Size = size - node.FractionalDigits = fractionalDigits - return node, nil -} - -FixedBytesType - = "BYTES"i s:NonZeroLeadingInteger !NormalIdentifierRest -{ - node := &ast.FixedBytesTypeNode{} - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - size, code := toUint(s.([]byte)) - if code != errors.ErrorCodeNil { - err := errors.Error{ - Position: uint32(c.pos.offset), - Category: errors.ErrorCategoryGrammar, - Code: code, - Token: string(c.text), - Prefix: "FixedBytesType", - Message: fmt.Sprintf("cannot parse %s as uint32: %v", s, code), - } - return node, err - } - node.Size = size - return node, nil -} - / "BYTE"i !NormalIdentifierRest -{ - node := &ast.FixedBytesTypeNode{} - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - node.Size = 1 - return node, nil -} - -DynamicBytesType - = ( "BYTES"i !NormalIdentifierRest - / "STRING"i !NormalIdentifierRest - / "TEXT"i !NormalIdentifierRest - ) -{ - node := &ast.DynamicBytesTypeNode{} - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - return node, nil -} - -AddressType - = "ADDRESS"i !NormalIdentifierRest -{ - node := &ast.AddressTypeNode{} - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - return node, nil -} - -BoolType - = ( "BOOL"i !NormalIdentifierRest - / "BOOLEAN"i !NormalIdentifierRest - ) -{ - node := &ast.BoolTypeNode{} - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - return node, nil -} - -/* Values */ -Value - = NumberLiteral - / StringLiteral - / BoolLiteral - / NullLiteral - -AnyLiteral - = AnyToken -{ - node := &ast.AnyValueNode{} - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - return node, nil -} - -DefaultLiteral - = DefaultToken -{ - node := &ast.DefaultValueNode{} - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - return node, nil -} - -BoolLiteral - = b:( TrueToken / FalseToken ) -{ - node := &ast.BoolValueNode{} - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - node.V = string(b.([]byte)) == "true" - return node, nil -} - -NullLiteral - = NullToken -{ - node := &ast.NullValueNode{} - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - return node, nil -} - -NumberLiteral - = &("0" "X"i) h:Hex { return h, nil } - / Decimal - -Sign - = [-+] - -Integer - = [0-9]+ -{ - node := &ast.IntegerValueNode{} - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - node.IsAddress = false - v, code := toDecimal(c.text) - if code != errors.ErrorCodeNil { - err := errors.Error{ - Position: uint32(c.pos.offset), - Category: errors.ErrorCategoryGrammar, - Code: code, - Token: string(c.text), - Prefix: "Integer", - Message: fmt.Sprintf("cannot parse %s as decimal: %v", c.text, code), - } - return node, err - } - node.V = v - return node, nil -} - -NonZeroLeadingInteger - = ( "0" / [1-9][0-9]* ) -{ return c.text, nil } - -Fixnum - = Integer "." Integer - / Integer "."? - / "." Integer - -Decimal - = Fixnum ( "E"i Sign? Integer )? -{ - node := &ast.DecimalValueNode{} - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - v, code := toDecimal(c.text) - if code != errors.ErrorCodeNil { - err := errors.Error{ - Position: uint32(c.pos.offset), - Category: errors.ErrorCategoryGrammar, - Code: code, - Token: string(c.text), - Prefix: "Decimal", - Message: fmt.Sprintf("cannot parse %s as decimal: %v", c.text, code), - } - return node, err - } - node.V = v - return node, nil -} - -Hex - = "0x" ( [0-9A-Fa-f] )+ !NormalIdentifierRest -{ - node := hexToInteger(c.text) - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - return node, nil -} - -StringLiteral - = HexString - / NormalString - -HexString - = ( "HEX"i / "X"i ) "'" s:([0-9a-fA-F][0-9a-fA-F] { return c.text, nil } )* "'" -{ - node := &ast.BytesValueNode{} - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - node.V = hexToBytes(joinBytes(assertSlice(s))) - return node, nil -} - -NormalString - = "'" s:( ( [^'\r\n\\] / "\\" . ) { return c.text, nil } )* "'" -{ - node := &ast.BytesValueNode{} - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - bs := joinBytes(assertSlice(s)) - v, bad, code := resolveString(bs) - if code != errors.ErrorCodeNil { - msg := fmt.Sprintf("cannot resolve escape sequence '%s': %v", - sanitizeBadEscape(bad), code) - err := errors.Error{ - Position: uint32(c.pos.offset), - Category: errors.ErrorCategoryGrammar, - Code: code, - Token: string(c.text), - Prefix: "NormalString", - Message: msg, - } - return node, err - } - node.V = v - return node, nil -} - -/* Tokens */ -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 - = "*" - -/* Identifiers */ -Identifier - = NormalIdentifier - / StringIdentifier - -NormalIdentifier - = NormalIdentifierStart NormalIdentifierRest* -{ - node := &ast.IdentifierNode{} - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - node.Name = decodeString(c.text) - return node, nil -} - -NormalIdentifierStart - = [a-zA-Z\x80-\xff] - -NormalIdentifierRest - = [a-zA-Z0-9_\x80-\xff] - -StringIdentifier - = "\"" s:( ( [^"\r\n\\] / "\\" . ) { return c.text, nil } )* "\"" -{ - node := &ast.IdentifierNode{} - node.SetPosition(uint32(c.pos.offset)) - node.SetLength(uint32(len(c.text))) - bs := joinBytes(assertSlice(s)) - name, bad, code := resolveString(bs) - if code != errors.ErrorCodeNil { - msg := fmt.Sprintf("cannot resolve escape sequence '%s': %v", - sanitizeBadEscape(bad), code) - err := errors.Error{ - Position: uint32(c.pos.offset), - Category: errors.ErrorCategoryGrammar, - Code: code, - Token: string(c.text), - Prefix: "StringIdentifier", - Message: msg, - } - return node, err - } - node.Name = name - return node, nil -} - -/* Skip */ -_ - = Whitespace* - -Whitespace - = "\t" // \x09 (HT) - / "\n" // \x0a (LF) - / "\v" // \x0b (VT) - / "\f" // \x0c (FF) - / "\r" // \x0d (CR) - / " " // \x20 (SPACE) - -EOF - = !. diff --git a/core/vm/sqlvm/parser/grammar.sed b/core/vm/sqlvm/parser/grammar.sed deleted file mode 100644 index f2b501109..000000000 --- a/core/vm/sqlvm/parser/grammar.sed +++ /dev/null @@ -1,4 +0,0 @@ -/^import (/a\ -goerrors "errors" -s|errors\.New(|goerrors.New(|g -s|\([^[:alnum:]]\)Parse\([[:upper:]]\{0,1\}[[:lower:]]*\)\([( ]\)|\1parse\2\3|g diff --git a/core/vm/sqlvm/parser/internal/grammar.go b/core/vm/sqlvm/parser/internal/grammar.go new file mode 100644 index 000000000..c1288c991 --- /dev/null +++ b/core/vm/sqlvm/parser/internal/grammar.go @@ -0,0 +1,7860 @@ +// Code generated by pigeon; DO NOT EDIT. + +package internal + +import ( + "bytes" + "errors" + "fmt" + "io" + "io/ioutil" + "math" + "os" + "sort" + "strconv" + "strings" + "unicode" + "unicode/utf8" + + "github.com/dexon-foundation/dexon/core/vm/sqlvm/ast" + se "github.com/dexon-foundation/dexon/core/vm/sqlvm/errors" +) + +var g = &grammar{ + rules: []*rule{ + { + name: "S", + pos: position{line: 10, col: 1, offset: 150}, + expr: &actionExpr{ + pos: position{line: 11, col: 5, offset: 156}, + run: (*parser).callonS1, + expr: &seqExpr{ + pos: position{line: 11, col: 5, offset: 156}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 11, col: 5, offset: 156}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 11, col: 7, offset: 158}, + label: "x", + expr: &zeroOrOneExpr{ + pos: position{line: 11, col: 9, offset: 160}, + expr: &ruleRefExpr{ + pos: position{line: 11, col: 9, offset: 160}, + name: "Stmt", + }, + }, + }, + &ruleRefExpr{ + pos: position{line: 11, col: 15, offset: 166}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 11, col: 17, offset: 168}, + label: "xs", + expr: &zeroOrMoreExpr{ + pos: position{line: 11, col: 20, offset: 171}, + expr: &actionExpr{ + pos: position{line: 11, col: 22, offset: 173}, + run: (*parser).callonS10, + expr: &seqExpr{ + pos: position{line: 11, col: 22, offset: 173}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 11, col: 22, offset: 173}, + val: ";", + ignoreCase: false, + }, + &ruleRefExpr{ + pos: position{line: 11, col: 26, offset: 177}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 11, col: 28, offset: 179}, + label: "s", + expr: &zeroOrOneExpr{ + pos: position{line: 11, col: 30, offset: 181}, + expr: &ruleRefExpr{ + pos: position{line: 11, col: 30, offset: 181}, + name: "Stmt", + }, + }, + }, + &ruleRefExpr{ + pos: position{line: 11, col: 36, offset: 187}, + name: "_", + }, + }, + }, + }, + }, + }, + &ruleRefExpr{ + pos: position{line: 11, col: 59, offset: 210}, + name: "EOF", + }, + }, + }, + }, + }, + { + name: "Stmt", + pos: position{line: 15, col: 1, offset: 293}, + expr: &choiceExpr{ + pos: position{line: 16, col: 4, offset: 301}, + alternatives: []interface{}{ + &ruleRefExpr{ + pos: position{line: 16, col: 4, offset: 301}, + name: "SelectStmt", + }, + &ruleRefExpr{ + pos: position{line: 17, col: 4, offset: 315}, + name: "UpdateStmt", + }, + &ruleRefExpr{ + pos: position{line: 18, col: 4, offset: 329}, + name: "DeleteStmt", + }, + &ruleRefExpr{ + pos: position{line: 19, col: 4, offset: 343}, + name: "InsertStmt", + }, + &ruleRefExpr{ + pos: position{line: 20, col: 4, offset: 357}, + name: "CreateTableStmt", + }, + &ruleRefExpr{ + pos: position{line: 21, col: 4, offset: 376}, + name: "CreateIndexStmt", + }, + }, + }, + }, + { + name: "SelectStmt", + pos: position{line: 23, col: 1, offset: 393}, + expr: &actionExpr{ + pos: position{line: 24, col: 4, offset: 407}, + run: (*parser).callonSelectStmt1, + expr: &seqExpr{ + pos: position{line: 24, col: 4, offset: 407}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 24, col: 4, offset: 407}, + name: "SelectToken", + }, + &ruleRefExpr{ + pos: position{line: 25, col: 2, offset: 420}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 25, col: 4, offset: 422}, + label: "f", + expr: &ruleRefExpr{ + pos: position{line: 25, col: 6, offset: 424}, + name: "SelectColumn", + }, + }, + &labeledExpr{ + pos: position{line: 25, col: 19, offset: 437}, + label: "fs", + expr: &zeroOrMoreExpr{ + pos: position{line: 25, col: 22, offset: 440}, + expr: &actionExpr{ + pos: position{line: 25, col: 24, offset: 442}, + run: (*parser).callonSelectStmt9, + expr: &seqExpr{ + pos: position{line: 25, col: 24, offset: 442}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 25, col: 24, offset: 442}, + name: "_", + }, + &ruleRefExpr{ + pos: position{line: 25, col: 26, offset: 444}, + name: "SeparatorToken", + }, + &ruleRefExpr{ + pos: position{line: 25, col: 41, offset: 459}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 25, col: 43, offset: 461}, + label: "s", + expr: &ruleRefExpr{ + pos: position{line: 25, col: 45, offset: 463}, + name: "SelectColumn", + }, + }, + }, + }, + }, + }, + }, + &labeledExpr{ + pos: position{line: 26, col: 2, offset: 498}, + label: "table", + expr: &zeroOrOneExpr{ + pos: position{line: 26, col: 8, offset: 504}, + expr: &actionExpr{ + pos: position{line: 26, col: 10, offset: 506}, + run: (*parser).callonSelectStmt18, + expr: &seqExpr{ + pos: position{line: 26, col: 10, offset: 506}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 26, col: 10, offset: 506}, + name: "_", + }, + &ruleRefExpr{ + pos: position{line: 26, col: 12, offset: 508}, + name: "FromToken", + }, + &ruleRefExpr{ + pos: position{line: 26, col: 22, offset: 518}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 26, col: 24, offset: 520}, + label: "i", + expr: &ruleRefExpr{ + pos: position{line: 26, col: 26, offset: 522}, + name: "Identifier", + }, + }, + }, + }, + }, + }, + }, + &labeledExpr{ + pos: position{line: 27, col: 2, offset: 555}, + label: "where", + expr: &zeroOrOneExpr{ + pos: position{line: 27, col: 8, offset: 561}, + expr: &actionExpr{ + pos: position{line: 27, col: 10, offset: 563}, + run: (*parser).callonSelectStmt27, + expr: &seqExpr{ + pos: position{line: 27, col: 10, offset: 563}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 27, col: 10, offset: 563}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 27, col: 12, offset: 565}, + label: "w", + expr: &ruleRefExpr{ + pos: position{line: 27, col: 14, offset: 567}, + name: "WhereClause", + }, + }, + }, + }, + }, + }, + }, + &labeledExpr{ + pos: position{line: 28, col: 2, offset: 601}, + label: "group", + expr: &zeroOrOneExpr{ + pos: position{line: 28, col: 8, offset: 607}, + expr: &actionExpr{ + pos: position{line: 28, col: 10, offset: 609}, + run: (*parser).callonSelectStmt34, + expr: &seqExpr{ + pos: position{line: 28, col: 10, offset: 609}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 28, col: 10, offset: 609}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 28, col: 12, offset: 611}, + label: "g", + expr: &ruleRefExpr{ + pos: position{line: 28, col: 14, offset: 613}, + name: "GroupByClause", + }, + }, + }, + }, + }, + }, + }, + &labeledExpr{ + pos: position{line: 29, col: 2, offset: 649}, + label: "order", + expr: &zeroOrOneExpr{ + pos: position{line: 29, col: 8, offset: 655}, + expr: &actionExpr{ + pos: position{line: 29, col: 10, offset: 657}, + run: (*parser).callonSelectStmt41, + expr: &seqExpr{ + pos: position{line: 29, col: 10, offset: 657}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 29, col: 10, offset: 657}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 29, col: 12, offset: 659}, + label: "or", + expr: &ruleRefExpr{ + pos: position{line: 29, col: 15, offset: 662}, + name: "OrderByClause", + }, + }, + }, + }, + }, + }, + }, + &labeledExpr{ + pos: position{line: 30, col: 2, offset: 699}, + label: "limit", + expr: &zeroOrOneExpr{ + pos: position{line: 30, col: 8, offset: 705}, + expr: &actionExpr{ + pos: position{line: 30, col: 10, offset: 707}, + run: (*parser).callonSelectStmt48, + expr: &seqExpr{ + pos: position{line: 30, col: 10, offset: 707}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 30, col: 10, offset: 707}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 30, col: 12, offset: 709}, + label: "l", + expr: &ruleRefExpr{ + pos: position{line: 30, col: 14, offset: 711}, + name: "LimitClause", + }, + }, + }, + }, + }, + }, + }, + &labeledExpr{ + pos: position{line: 31, col: 2, offset: 745}, + label: "offset", + expr: &zeroOrOneExpr{ + pos: position{line: 31, col: 9, offset: 752}, + expr: &actionExpr{ + pos: position{line: 31, col: 11, offset: 754}, + run: (*parser).callonSelectStmt55, + expr: &seqExpr{ + pos: position{line: 31, col: 11, offset: 754}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 31, col: 11, offset: 754}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 31, col: 13, offset: 756}, + label: "of", + expr: &ruleRefExpr{ + pos: position{line: 31, col: 16, offset: 759}, + name: "OffsetClause", + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + { + name: "SelectColumn", + pos: position{line: 62, col: 1, offset: 1626}, + expr: &choiceExpr{ + pos: position{line: 63, col: 4, offset: 1642}, + alternatives: []interface{}{ + &ruleRefExpr{ + pos: position{line: 63, col: 4, offset: 1642}, + name: "AnyLiteral", + }, + &ruleRefExpr{ + pos: position{line: 64, col: 4, offset: 1656}, + name: "Expr", + }, + }, + }, + }, + { + name: "UpdateStmt", + pos: position{line: 66, col: 1, offset: 1662}, + expr: &actionExpr{ + pos: position{line: 67, col: 4, offset: 1676}, + run: (*parser).callonUpdateStmt1, + expr: &seqExpr{ + pos: position{line: 67, col: 4, offset: 1676}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 67, col: 4, offset: 1676}, + name: "UpdateToken", + }, + &ruleRefExpr{ + pos: position{line: 68, col: 2, offset: 1689}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 68, col: 4, offset: 1691}, + label: "table", + expr: &ruleRefExpr{ + pos: position{line: 68, col: 10, offset: 1697}, + name: "Identifier", + }, + }, + &ruleRefExpr{ + pos: position{line: 69, col: 2, offset: 1709}, + name: "_", + }, + &ruleRefExpr{ + pos: position{line: 69, col: 4, offset: 1711}, + name: "SetToken", + }, + &ruleRefExpr{ + pos: position{line: 70, col: 2, offset: 1721}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 70, col: 4, offset: 1723}, + label: "a", + expr: &ruleRefExpr{ + pos: position{line: 70, col: 6, offset: 1725}, + name: "Assignment", + }, + }, + &labeledExpr{ + pos: position{line: 70, col: 17, offset: 1736}, + label: "as", + expr: &zeroOrMoreExpr{ + pos: position{line: 70, col: 20, offset: 1739}, + expr: &actionExpr{ + pos: position{line: 70, col: 22, offset: 1741}, + run: (*parser).callonUpdateStmt14, + expr: &seqExpr{ + pos: position{line: 70, col: 22, offset: 1741}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 70, col: 22, offset: 1741}, + name: "_", + }, + &ruleRefExpr{ + pos: position{line: 70, col: 24, offset: 1743}, + name: "SeparatorToken", + }, + &ruleRefExpr{ + pos: position{line: 70, col: 39, offset: 1758}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 70, col: 41, offset: 1760}, + label: "s", + expr: &ruleRefExpr{ + pos: position{line: 70, col: 43, offset: 1762}, + name: "Assignment", + }, + }, + }, + }, + }, + }, + }, + &labeledExpr{ + pos: position{line: 71, col: 2, offset: 1795}, + label: "where", + expr: &zeroOrOneExpr{ + pos: position{line: 71, col: 8, offset: 1801}, + expr: &actionExpr{ + pos: position{line: 71, col: 10, offset: 1803}, + run: (*parser).callonUpdateStmt23, + expr: &seqExpr{ + pos: position{line: 71, col: 10, offset: 1803}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 71, col: 10, offset: 1803}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 71, col: 12, offset: 1805}, + label: "w", + expr: &ruleRefExpr{ + pos: position{line: 71, col: 14, offset: 1807}, + name: "WhereClause", + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + { + name: "DeleteStmt", + pos: position{line: 88, col: 1, offset: 2295}, + expr: &actionExpr{ + pos: position{line: 89, col: 4, offset: 2309}, + run: (*parser).callonDeleteStmt1, + expr: &seqExpr{ + pos: position{line: 89, col: 4, offset: 2309}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 89, col: 4, offset: 2309}, + name: "DeleteToken", + }, + &ruleRefExpr{ + pos: position{line: 90, col: 2, offset: 2322}, + name: "_", + }, + &ruleRefExpr{ + pos: position{line: 90, col: 4, offset: 2324}, + name: "FromToken", + }, + &ruleRefExpr{ + pos: position{line: 91, col: 2, offset: 2335}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 91, col: 4, offset: 2337}, + label: "table", + expr: &ruleRefExpr{ + pos: position{line: 91, col: 10, offset: 2343}, + name: "Identifier", + }, + }, + &labeledExpr{ + pos: position{line: 92, col: 2, offset: 2355}, + label: "where", + expr: &zeroOrOneExpr{ + pos: position{line: 92, col: 8, offset: 2361}, + expr: &actionExpr{ + pos: position{line: 92, col: 10, offset: 2363}, + run: (*parser).callonDeleteStmt11, + expr: &seqExpr{ + pos: position{line: 92, col: 10, offset: 2363}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 92, col: 10, offset: 2363}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 92, col: 12, offset: 2365}, + label: "w", + expr: &ruleRefExpr{ + pos: position{line: 92, col: 14, offset: 2367}, + name: "WhereClause", + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + { + name: "InsertStmt", + pos: position{line: 104, col: 1, offset: 2639}, + expr: &actionExpr{ + pos: position{line: 105, col: 4, offset: 2653}, + run: (*parser).callonInsertStmt1, + expr: &seqExpr{ + pos: position{line: 105, col: 4, offset: 2653}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 105, col: 4, offset: 2653}, + name: "InsertToken", + }, + &ruleRefExpr{ + pos: position{line: 106, col: 2, offset: 2666}, + name: "_", + }, + &ruleRefExpr{ + pos: position{line: 106, col: 4, offset: 2668}, + name: "IntoToken", + }, + &ruleRefExpr{ + pos: position{line: 107, col: 2, offset: 2679}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 107, col: 4, offset: 2681}, + label: "table", + expr: &ruleRefExpr{ + pos: position{line: 107, col: 10, offset: 2687}, + name: "Identifier", + }, + }, + &ruleRefExpr{ + pos: position{line: 108, col: 2, offset: 2699}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 108, col: 4, offset: 2701}, + label: "insert", + expr: &choiceExpr{ + pos: position{line: 108, col: 13, offset: 2710}, + alternatives: []interface{}{ + &ruleRefExpr{ + pos: position{line: 108, col: 13, offset: 2710}, + name: "InsertWithColumnClause", + }, + &ruleRefExpr{ + pos: position{line: 108, col: 38, offset: 2735}, + name: "InsertWithDefaultClause", + }, + }, + }, + }, + }, + }, + }, + }, + { + name: "InsertValue", + pos: position{line: 125, col: 1, offset: 3146}, + expr: &actionExpr{ + pos: position{line: 126, col: 4, offset: 3161}, + run: (*parser).callonInsertValue1, + expr: &seqExpr{ + pos: position{line: 126, col: 4, offset: 3161}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 126, col: 4, offset: 3161}, + val: "(", + ignoreCase: false, + }, + &ruleRefExpr{ + pos: position{line: 126, col: 8, offset: 3165}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 126, col: 10, offset: 3167}, + label: "e", + expr: &ruleRefExpr{ + pos: position{line: 126, col: 12, offset: 3169}, + name: "MultiExprWithDefault", + }, + }, + &ruleRefExpr{ + pos: position{line: 126, col: 33, offset: 3190}, + name: "_", + }, + &litMatcher{ + pos: position{line: 126, col: 35, offset: 3192}, + val: ")", + ignoreCase: false, + }, + }, + }, + }, + }, + { + name: "CreateTableStmt", + pos: position{line: 129, col: 1, offset: 3215}, + expr: &actionExpr{ + pos: position{line: 130, col: 4, offset: 3234}, + run: (*parser).callonCreateTableStmt1, + expr: &seqExpr{ + pos: position{line: 130, col: 4, offset: 3234}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 130, col: 4, offset: 3234}, + name: "CreateToken", + }, + &ruleRefExpr{ + pos: position{line: 131, col: 2, offset: 3247}, + name: "_", + }, + &ruleRefExpr{ + pos: position{line: 131, col: 4, offset: 3249}, + name: "TableToken", + }, + &ruleRefExpr{ + pos: position{line: 132, col: 2, offset: 3261}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 132, col: 4, offset: 3263}, + label: "table", + expr: &ruleRefExpr{ + pos: position{line: 132, col: 10, offset: 3269}, + name: "Identifier", + }, + }, + &ruleRefExpr{ + pos: position{line: 133, col: 2, offset: 3281}, + name: "_", + }, + &litMatcher{ + pos: position{line: 133, col: 4, offset: 3283}, + val: "(", + ignoreCase: false, + }, + &ruleRefExpr{ + pos: position{line: 134, col: 2, offset: 3288}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 134, col: 4, offset: 3290}, + label: "column", + expr: &zeroOrOneExpr{ + pos: position{line: 134, col: 11, offset: 3297}, + expr: &actionExpr{ + pos: position{line: 135, col: 3, offset: 3301}, + run: (*parser).callonCreateTableStmt14, + expr: &seqExpr{ + pos: position{line: 135, col: 3, offset: 3301}, + exprs: []interface{}{ + &labeledExpr{ + pos: position{line: 135, col: 3, offset: 3301}, + label: "s", + expr: &ruleRefExpr{ + pos: position{line: 135, col: 5, offset: 3303}, + name: "ColumnSchema", + }, + }, + &labeledExpr{ + pos: position{line: 136, col: 3, offset: 3318}, + label: "ss", + expr: &zeroOrMoreExpr{ + pos: position{line: 136, col: 6, offset: 3321}, + expr: &actionExpr{ + pos: position{line: 136, col: 8, offset: 3323}, + run: (*parser).callonCreateTableStmt20, + expr: &seqExpr{ + pos: position{line: 136, col: 8, offset: 3323}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 136, col: 8, offset: 3323}, + name: "_", + }, + &ruleRefExpr{ + pos: position{line: 136, col: 10, offset: 3325}, + name: "SeparatorToken", + }, + &ruleRefExpr{ + pos: position{line: 136, col: 25, offset: 3340}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 136, col: 27, offset: 3342}, + label: "t", + expr: &ruleRefExpr{ + pos: position{line: 136, col: 29, offset: 3344}, + name: "ColumnSchema", + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + &ruleRefExpr{ + pos: position{line: 139, col: 2, offset: 3429}, + name: "_", + }, + &litMatcher{ + pos: position{line: 139, col: 4, offset: 3431}, + val: ")", + ignoreCase: false, + }, + }, + }, + }, + }, + { + name: "ColumnSchema", + pos: position{line: 153, col: 1, offset: 3809}, + expr: &actionExpr{ + pos: position{line: 154, col: 4, offset: 3825}, + run: (*parser).callonColumnSchema1, + expr: &seqExpr{ + pos: position{line: 154, col: 4, offset: 3825}, + exprs: []interface{}{ + &labeledExpr{ + pos: position{line: 154, col: 4, offset: 3825}, + label: "i", + expr: &ruleRefExpr{ + pos: position{line: 154, col: 6, offset: 3827}, + name: "Identifier", + }, + }, + &ruleRefExpr{ + pos: position{line: 155, col: 2, offset: 3839}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 155, col: 4, offset: 3841}, + label: "t", + expr: &ruleRefExpr{ + pos: position{line: 155, col: 6, offset: 3843}, + name: "DataType", + }, + }, + &labeledExpr{ + pos: position{line: 156, col: 2, offset: 3853}, + label: "cs", + expr: &zeroOrMoreExpr{ + pos: position{line: 156, col: 5, offset: 3856}, + expr: &actionExpr{ + pos: position{line: 156, col: 7, offset: 3858}, + run: (*parser).callonColumnSchema10, + expr: &seqExpr{ + pos: position{line: 156, col: 7, offset: 3858}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 156, col: 7, offset: 3858}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 156, col: 9, offset: 3860}, + label: "s", + expr: &ruleRefExpr{ + pos: position{line: 156, col: 11, offset: 3862}, + name: "ColumnConstraint", + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + { + name: "ColumnConstraint", + pos: position{line: 186, col: 1, offset: 4714}, + expr: &choiceExpr{ + pos: position{line: 187, col: 4, offset: 4734}, + alternatives: []interface{}{ + &ruleRefExpr{ + pos: position{line: 187, col: 4, offset: 4734}, + name: "PrimaryKeyClause", + }, + &ruleRefExpr{ + pos: position{line: 188, col: 4, offset: 4754}, + name: "NotNullClause", + }, + &ruleRefExpr{ + pos: position{line: 189, col: 4, offset: 4771}, + name: "UniqueClause", + }, + &ruleRefExpr{ + pos: position{line: 190, col: 4, offset: 4787}, + name: "DefaultClause", + }, + &ruleRefExpr{ + pos: position{line: 191, col: 4, offset: 4804}, + name: "ForeignClause", + }, + &ruleRefExpr{ + pos: position{line: 192, col: 4, offset: 4821}, + name: "AutoincrementClause", + }, + }, + }, + }, + { + name: "CreateIndexStmt", + pos: position{line: 194, col: 1, offset: 4842}, + expr: &actionExpr{ + pos: position{line: 195, col: 4, offset: 4861}, + run: (*parser).callonCreateIndexStmt1, + expr: &seqExpr{ + pos: position{line: 195, col: 4, offset: 4861}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 195, col: 4, offset: 4861}, + name: "CreateToken", + }, + &labeledExpr{ + pos: position{line: 196, col: 2, offset: 4874}, + label: "unique", + expr: &zeroOrOneExpr{ + pos: position{line: 196, col: 9, offset: 4881}, + expr: &actionExpr{ + pos: position{line: 196, col: 11, offset: 4883}, + run: (*parser).callonCreateIndexStmt6, + expr: &seqExpr{ + pos: position{line: 196, col: 11, offset: 4883}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 196, col: 11, offset: 4883}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 196, col: 13, offset: 4885}, + label: "u", + expr: &ruleRefExpr{ + pos: position{line: 196, col: 15, offset: 4887}, + name: "UniqueClause", + }, + }, + }, + }, + }, + }, + }, + &ruleRefExpr{ + pos: position{line: 197, col: 2, offset: 4922}, + name: "_", + }, + &ruleRefExpr{ + pos: position{line: 197, col: 4, offset: 4924}, + name: "IndexToken", + }, + &ruleRefExpr{ + pos: position{line: 198, col: 2, offset: 4936}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 198, col: 4, offset: 4938}, + label: "index", + expr: &ruleRefExpr{ + pos: position{line: 198, col: 10, offset: 4944}, + name: "Identifier", + }, + }, + &ruleRefExpr{ + pos: position{line: 199, col: 2, offset: 4956}, + name: "_", + }, + &ruleRefExpr{ + pos: position{line: 199, col: 4, offset: 4958}, + name: "OnToken", + }, + &ruleRefExpr{ + pos: position{line: 200, col: 2, offset: 4967}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 200, col: 4, offset: 4969}, + label: "table", + expr: &ruleRefExpr{ + pos: position{line: 200, col: 10, offset: 4975}, + name: "Identifier", + }, + }, + &ruleRefExpr{ + pos: position{line: 201, col: 2, offset: 4987}, + name: "_", + }, + &litMatcher{ + pos: position{line: 201, col: 4, offset: 4989}, + val: "(", + ignoreCase: false, + }, + &ruleRefExpr{ + pos: position{line: 201, col: 8, offset: 4993}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 201, col: 10, offset: 4995}, + label: "i", + expr: &ruleRefExpr{ + pos: position{line: 201, col: 12, offset: 4997}, + name: "Identifier", + }, + }, + &labeledExpr{ + pos: position{line: 201, col: 23, offset: 5008}, + label: "is", + expr: &zeroOrMoreExpr{ + pos: position{line: 201, col: 26, offset: 5011}, + expr: &actionExpr{ + pos: position{line: 201, col: 28, offset: 5013}, + run: (*parser).callonCreateIndexStmt28, + expr: &seqExpr{ + pos: position{line: 201, col: 28, offset: 5013}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 201, col: 28, offset: 5013}, + name: "_", + }, + &ruleRefExpr{ + pos: position{line: 201, col: 30, offset: 5015}, + name: "SeparatorToken", + }, + &ruleRefExpr{ + pos: position{line: 201, col: 45, offset: 5030}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 201, col: 47, offset: 5032}, + label: "x", + expr: &ruleRefExpr{ + pos: position{line: 201, col: 49, offset: 5034}, + name: "Identifier", + }, + }, + }, + }, + }, + }, + }, + &ruleRefExpr{ + pos: position{line: 201, col: 81, offset: 5066}, + name: "_", + }, + &litMatcher{ + pos: position{line: 201, col: 83, offset: 5068}, + val: ")", + ignoreCase: false, + }, + }, + }, + }, + }, + { + name: "WhereClause", + pos: position{line: 220, col: 1, offset: 5589}, + expr: &actionExpr{ + pos: position{line: 221, col: 4, offset: 5604}, + run: (*parser).callonWhereClause1, + expr: &seqExpr{ + pos: position{line: 221, col: 4, offset: 5604}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 221, col: 4, offset: 5604}, + name: "WhereToken", + }, + &ruleRefExpr{ + pos: position{line: 221, col: 15, offset: 5615}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 221, col: 17, offset: 5617}, + label: "e", + expr: &ruleRefExpr{ + pos: position{line: 221, col: 19, offset: 5619}, + name: "Expr", + }, + }, + }, + }, + }, + }, + { + name: "OrderByClause", + pos: position{line: 230, col: 1, offset: 5791}, + expr: &actionExpr{ + pos: position{line: 231, col: 4, offset: 5808}, + run: (*parser).callonOrderByClause1, + expr: &seqExpr{ + pos: position{line: 231, col: 4, offset: 5808}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 231, col: 4, offset: 5808}, + name: "OrderToken", + }, + &ruleRefExpr{ + pos: position{line: 232, col: 2, offset: 5820}, + name: "_", + }, + &ruleRefExpr{ + pos: position{line: 232, col: 4, offset: 5822}, + name: "ByToken", + }, + &ruleRefExpr{ + pos: position{line: 233, col: 2, offset: 5831}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 233, col: 4, offset: 5833}, + label: "f", + expr: &ruleRefExpr{ + pos: position{line: 233, col: 6, offset: 5835}, + name: "OrderColumn", + }, + }, + &labeledExpr{ + pos: position{line: 234, col: 2, offset: 5848}, + label: "fs", + expr: &zeroOrMoreExpr{ + pos: position{line: 234, col: 5, offset: 5851}, + expr: &actionExpr{ + pos: position{line: 234, col: 7, offset: 5853}, + run: (*parser).callonOrderByClause11, + expr: &seqExpr{ + pos: position{line: 234, col: 7, offset: 5853}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 234, col: 7, offset: 5853}, + name: "_", + }, + &ruleRefExpr{ + pos: position{line: 234, col: 9, offset: 5855}, + name: "SeparatorToken", + }, + &ruleRefExpr{ + pos: position{line: 234, col: 24, offset: 5870}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 234, col: 26, offset: 5872}, + label: "s", + expr: &ruleRefExpr{ + pos: position{line: 234, col: 28, offset: 5874}, + name: "OrderColumn", + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + { + name: "OrderColumn", + pos: position{line: 239, col: 1, offset: 5953}, + expr: &actionExpr{ + pos: position{line: 240, col: 4, offset: 5968}, + run: (*parser).callonOrderColumn1, + expr: &seqExpr{ + pos: position{line: 240, col: 4, offset: 5968}, + exprs: []interface{}{ + &labeledExpr{ + pos: position{line: 240, col: 4, offset: 5968}, + label: "i", + expr: &ruleRefExpr{ + pos: position{line: 240, col: 6, offset: 5970}, + name: "Expr", + }, + }, + &labeledExpr{ + pos: position{line: 241, col: 2, offset: 5976}, + label: "s", + expr: &zeroOrOneExpr{ + pos: position{line: 241, col: 4, offset: 5978}, + expr: &actionExpr{ + pos: position{line: 241, col: 6, offset: 5980}, + run: (*parser).callonOrderColumn7, + expr: &seqExpr{ + pos: position{line: 241, col: 6, offset: 5980}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 241, col: 6, offset: 5980}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 241, col: 8, offset: 5982}, + label: "t", + expr: &choiceExpr{ + pos: position{line: 241, col: 12, offset: 5986}, + alternatives: []interface{}{ + &ruleRefExpr{ + pos: position{line: 241, col: 12, offset: 5986}, + name: "AscToken", + }, + &ruleRefExpr{ + pos: position{line: 241, col: 23, offset: 5997}, + name: "DescToken", + }, + }, + }, + }, + }, + }, + }, + }, + }, + &labeledExpr{ + pos: position{line: 242, col: 2, offset: 6031}, + label: "n", + expr: &zeroOrOneExpr{ + pos: position{line: 242, col: 4, offset: 6033}, + expr: &actionExpr{ + pos: position{line: 242, col: 6, offset: 6035}, + run: (*parser).callonOrderColumn16, + expr: &seqExpr{ + pos: position{line: 242, col: 6, offset: 6035}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 242, col: 6, offset: 6035}, + name: "_", + }, + &ruleRefExpr{ + pos: position{line: 242, col: 8, offset: 6037}, + name: "NullsToken", + }, + &ruleRefExpr{ + pos: position{line: 242, col: 19, offset: 6048}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 242, col: 21, offset: 6050}, + label: "l", + expr: &choiceExpr{ + pos: position{line: 242, col: 25, offset: 6054}, + alternatives: []interface{}{ + &ruleRefExpr{ + pos: position{line: 242, col: 25, offset: 6054}, + name: "LastToken", + }, + &ruleRefExpr{ + pos: position{line: 242, col: 37, offset: 6066}, + name: "FirstToken", + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + { + name: "GroupByClause", + pos: position{line: 253, col: 1, offset: 6377}, + expr: &actionExpr{ + pos: position{line: 254, col: 4, offset: 6394}, + run: (*parser).callonGroupByClause1, + expr: &seqExpr{ + pos: position{line: 254, col: 4, offset: 6394}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 254, col: 4, offset: 6394}, + name: "GroupToken", + }, + &ruleRefExpr{ + pos: position{line: 255, col: 2, offset: 6406}, + name: "_", + }, + &ruleRefExpr{ + pos: position{line: 255, col: 4, offset: 6408}, + name: "ByToken", + }, + &ruleRefExpr{ + pos: position{line: 256, col: 2, offset: 6417}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 256, col: 4, offset: 6419}, + label: "f", + expr: &ruleRefExpr{ + pos: position{line: 256, col: 6, offset: 6421}, + name: "GroupColumn", + }, + }, + &labeledExpr{ + pos: position{line: 257, col: 2, offset: 6434}, + label: "fs", + expr: &zeroOrMoreExpr{ + pos: position{line: 257, col: 5, offset: 6437}, + expr: &actionExpr{ + pos: position{line: 257, col: 7, offset: 6439}, + run: (*parser).callonGroupByClause11, + expr: &seqExpr{ + pos: position{line: 257, col: 7, offset: 6439}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 257, col: 7, offset: 6439}, + name: "_", + }, + &ruleRefExpr{ + pos: position{line: 257, col: 9, offset: 6441}, + name: "SeparatorToken", + }, + &ruleRefExpr{ + pos: position{line: 257, col: 24, offset: 6456}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 257, col: 26, offset: 6458}, + label: "s", + expr: &ruleRefExpr{ + pos: position{line: 257, col: 28, offset: 6460}, + name: "GroupColumn", + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + { + name: "GroupColumn", + pos: position{line: 262, col: 1, offset: 6539}, + expr: &actionExpr{ + pos: position{line: 263, col: 4, offset: 6554}, + run: (*parser).callonGroupColumn1, + expr: &labeledExpr{ + pos: position{line: 263, col: 4, offset: 6554}, + label: "i", + expr: &ruleRefExpr{ + pos: position{line: 263, col: 6, offset: 6556}, + name: "Expr", + }, + }, + }, + }, + { + name: "OffsetClause", + pos: position{line: 272, col: 1, offset: 6723}, + expr: &actionExpr{ + pos: position{line: 273, col: 4, offset: 6739}, + run: (*parser).callonOffsetClause1, + expr: &seqExpr{ + pos: position{line: 273, col: 4, offset: 6739}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 273, col: 4, offset: 6739}, + name: "OffsetToken", + }, + &ruleRefExpr{ + pos: position{line: 273, col: 16, offset: 6751}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 273, col: 18, offset: 6753}, + label: "i", + expr: &ruleRefExpr{ + pos: position{line: 273, col: 20, offset: 6755}, + name: "Integer", + }, + }, + }, + }, + }, + }, + { + name: "LimitClause", + pos: position{line: 282, col: 1, offset: 6936}, + expr: &actionExpr{ + pos: position{line: 283, col: 4, offset: 6951}, + run: (*parser).callonLimitClause1, + expr: &seqExpr{ + pos: position{line: 283, col: 4, offset: 6951}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 283, col: 4, offset: 6951}, + name: "LimitToken", + }, + &ruleRefExpr{ + pos: position{line: 283, col: 15, offset: 6962}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 283, col: 17, offset: 6964}, + label: "i", + expr: &ruleRefExpr{ + pos: position{line: 283, col: 19, offset: 6966}, + name: "Integer", + }, + }, + }, + }, + }, + }, + { + name: "InsertWithColumnClause", + pos: position{line: 292, col: 1, offset: 7146}, + expr: &actionExpr{ + pos: position{line: 293, col: 4, offset: 7172}, + run: (*parser).callonInsertWithColumnClause1, + expr: &seqExpr{ + pos: position{line: 293, col: 4, offset: 7172}, + exprs: []interface{}{ + &labeledExpr{ + pos: position{line: 293, col: 4, offset: 7172}, + label: "cs", + expr: &zeroOrOneExpr{ + pos: position{line: 293, col: 7, offset: 7175}, + expr: &actionExpr{ + pos: position{line: 293, col: 9, offset: 7177}, + run: (*parser).callonInsertWithColumnClause5, + expr: &seqExpr{ + pos: position{line: 293, col: 9, offset: 7177}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 293, col: 9, offset: 7177}, + val: "(", + ignoreCase: false, + }, + &ruleRefExpr{ + pos: position{line: 294, col: 4, offset: 7184}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 294, col: 6, offset: 7186}, + label: "f", + expr: &ruleRefExpr{ + pos: position{line: 294, col: 8, offset: 7188}, + name: "Identifier", + }, + }, + &labeledExpr{ + pos: position{line: 295, col: 4, offset: 7202}, + label: "fs", + expr: &zeroOrMoreExpr{ + pos: position{line: 295, col: 7, offset: 7205}, + expr: &actionExpr{ + pos: position{line: 295, col: 9, offset: 7207}, + run: (*parser).callonInsertWithColumnClause13, + expr: &seqExpr{ + pos: position{line: 295, col: 9, offset: 7207}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 295, col: 9, offset: 7207}, + name: "_", + }, + &ruleRefExpr{ + pos: position{line: 295, col: 11, offset: 7209}, + name: "SeparatorToken", + }, + &ruleRefExpr{ + pos: position{line: 295, col: 26, offset: 7224}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 295, col: 28, offset: 7226}, + label: "x", + expr: &ruleRefExpr{ + pos: position{line: 295, col: 30, offset: 7228}, + name: "Identifier", + }, + }, + }, + }, + }, + }, + }, + &ruleRefExpr{ + pos: position{line: 296, col: 4, offset: 7263}, + name: "_", + }, + &litMatcher{ + pos: position{line: 296, col: 6, offset: 7265}, + val: ")", + ignoreCase: false, + }, + &ruleRefExpr{ + pos: position{line: 297, col: 4, offset: 7272}, + name: "_", + }, + }, + }, + }, + }, + }, + &ruleRefExpr{ + pos: position{line: 299, col: 3, offset: 7325}, + name: "ValuesToken", + }, + &ruleRefExpr{ + pos: position{line: 300, col: 2, offset: 7338}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 300, col: 4, offset: 7340}, + label: "v", + expr: &ruleRefExpr{ + pos: position{line: 300, col: 6, offset: 7342}, + name: "InsertValue", + }, + }, + &labeledExpr{ + pos: position{line: 301, col: 2, offset: 7355}, + label: "vs", + expr: &zeroOrMoreExpr{ + pos: position{line: 301, col: 5, offset: 7358}, + expr: &actionExpr{ + pos: position{line: 301, col: 7, offset: 7360}, + run: (*parser).callonInsertWithColumnClause29, + expr: &seqExpr{ + pos: position{line: 301, col: 7, offset: 7360}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 301, col: 7, offset: 7360}, + name: "_", + }, + &ruleRefExpr{ + pos: position{line: 301, col: 9, offset: 7362}, + name: "SeparatorToken", + }, + &ruleRefExpr{ + pos: position{line: 301, col: 24, offset: 7377}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 301, col: 26, offset: 7379}, + label: "y", + expr: &ruleRefExpr{ + pos: position{line: 301, col: 28, offset: 7381}, + name: "InsertValue", + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + { + name: "InsertWithDefaultClause", + pos: position{line: 320, col: 1, offset: 7957}, + expr: &actionExpr{ + pos: position{line: 321, col: 4, offset: 7984}, + run: (*parser).callonInsertWithDefaultClause1, + expr: &seqExpr{ + pos: position{line: 321, col: 4, offset: 7984}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 321, col: 4, offset: 7984}, + name: "DefaultToken", + }, + &ruleRefExpr{ + pos: position{line: 321, col: 17, offset: 7997}, + name: "_", + }, + &ruleRefExpr{ + pos: position{line: 321, col: 19, offset: 7999}, + name: "ValuesToken", + }, + }, + }, + }, + }, + { + name: "PrimaryKeyClause", + pos: position{line: 329, col: 1, offset: 8155}, + expr: &actionExpr{ + pos: position{line: 330, col: 4, offset: 8175}, + run: (*parser).callonPrimaryKeyClause1, + expr: &seqExpr{ + pos: position{line: 330, col: 4, offset: 8175}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 330, col: 4, offset: 8175}, + name: "PrimaryToken", + }, + &ruleRefExpr{ + pos: position{line: 330, col: 17, offset: 8188}, + name: "_", + }, + &ruleRefExpr{ + pos: position{line: 330, col: 19, offset: 8190}, + name: "KeyToken", + }, + }, + }, + }, + }, + { + name: "NotNullClause", + pos: position{line: 338, col: 1, offset: 8333}, + expr: &actionExpr{ + pos: position{line: 339, col: 4, offset: 8350}, + run: (*parser).callonNotNullClause1, + expr: &seqExpr{ + pos: position{line: 339, col: 4, offset: 8350}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 339, col: 4, offset: 8350}, + name: "NotToken", + }, + &ruleRefExpr{ + pos: position{line: 339, col: 13, offset: 8359}, + name: "_", + }, + &ruleRefExpr{ + pos: position{line: 339, col: 15, offset: 8361}, + name: "NullToken", + }, + }, + }, + }, + }, + { + name: "UniqueClause", + pos: position{line: 347, col: 1, offset: 8505}, + expr: &actionExpr{ + pos: position{line: 348, col: 4, offset: 8521}, + run: (*parser).callonUniqueClause1, + expr: &ruleRefExpr{ + pos: position{line: 348, col: 4, offset: 8521}, + name: "UniqueToken", + }, + }, + }, + { + name: "DefaultClause", + pos: position{line: 356, col: 1, offset: 8666}, + expr: &actionExpr{ + pos: position{line: 357, col: 4, offset: 8683}, + run: (*parser).callonDefaultClause1, + expr: &seqExpr{ + pos: position{line: 357, col: 4, offset: 8683}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 357, col: 4, offset: 8683}, + name: "DefaultToken", + }, + &ruleRefExpr{ + pos: position{line: 357, col: 17, offset: 8696}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 357, col: 19, offset: 8698}, + label: "e", + expr: &ruleRefExpr{ + pos: position{line: 357, col: 21, offset: 8700}, + name: "Expr", + }, + }, + }, + }, + }, + }, + { + name: "ForeignClause", + pos: position{line: 366, col: 1, offset: 8870}, + expr: &actionExpr{ + pos: position{line: 367, col: 4, offset: 8887}, + run: (*parser).callonForeignClause1, + expr: &seqExpr{ + pos: position{line: 367, col: 4, offset: 8887}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 367, col: 4, offset: 8887}, + name: "ReferencesToken", + }, + &ruleRefExpr{ + pos: position{line: 367, col: 20, offset: 8903}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 367, col: 22, offset: 8905}, + label: "t", + expr: &ruleRefExpr{ + pos: position{line: 367, col: 24, offset: 8907}, + name: "Identifier", + }, + }, + &ruleRefExpr{ + pos: position{line: 367, col: 35, offset: 8918}, + name: "_", + }, + &litMatcher{ + pos: position{line: 367, col: 37, offset: 8920}, + val: "(", + ignoreCase: false, + }, + &ruleRefExpr{ + pos: position{line: 367, col: 41, offset: 8924}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 367, col: 43, offset: 8926}, + label: "f", + expr: &ruleRefExpr{ + pos: position{line: 367, col: 45, offset: 8928}, + name: "Identifier", + }, + }, + &ruleRefExpr{ + pos: position{line: 367, col: 56, offset: 8939}, + name: "_", + }, + &litMatcher{ + pos: position{line: 367, col: 58, offset: 8941}, + val: ")", + ignoreCase: false, + }, + }, + }, + }, + }, + { + name: "AutoincrementClause", + pos: position{line: 377, col: 1, offset: 9156}, + expr: &actionExpr{ + pos: position{line: 378, col: 4, offset: 9179}, + run: (*parser).callonAutoincrementClause1, + expr: &ruleRefExpr{ + pos: position{line: 378, col: 4, offset: 9179}, + name: "AutoincrementToken", + }, + }, + }, + { + name: "Expr", + pos: position{line: 387, col: 1, offset: 9356}, + expr: &ruleRefExpr{ + pos: position{line: 388, col: 4, offset: 9364}, + name: "LogicExpr", + }, + }, + { + name: "ExprWithDefault", + pos: position{line: 390, col: 1, offset: 9375}, + expr: &choiceExpr{ + pos: position{line: 391, col: 4, offset: 9394}, + alternatives: []interface{}{ + &actionExpr{ + pos: position{line: 391, col: 4, offset: 9394}, + run: (*parser).callonExprWithDefault2, + expr: &seqExpr{ + pos: position{line: 391, col: 4, offset: 9394}, + exprs: []interface{}{ + &andExpr{ + pos: position{line: 391, col: 4, offset: 9394}, + expr: &ruleRefExpr{ + pos: position{line: 391, col: 6, offset: 9396}, + name: "DefaultLiteral", + }, + }, + &labeledExpr{ + pos: position{line: 391, col: 22, offset: 9412}, + label: "d", + expr: &ruleRefExpr{ + pos: position{line: 391, col: 24, offset: 9414}, + name: "DefaultLiteral", + }, + }, + }, + }, + }, + &ruleRefExpr{ + pos: position{line: 392, col: 4, offset: 9450}, + name: "Expr", + }, + }, + }, + }, + { + name: "LogicExpr", + pos: position{line: 394, col: 1, offset: 9456}, + expr: &ruleRefExpr{ + pos: position{line: 395, col: 4, offset: 9469}, + name: "LogicExpr4", + }, + }, + { + name: "LogicExpr4", + pos: position{line: 397, col: 1, offset: 9481}, + expr: &actionExpr{ + pos: position{line: 398, col: 4, offset: 9495}, + run: (*parser).callonLogicExpr41, + expr: &seqExpr{ + pos: position{line: 398, col: 4, offset: 9495}, + exprs: []interface{}{ + &labeledExpr{ + pos: position{line: 398, col: 4, offset: 9495}, + label: "o", + expr: &ruleRefExpr{ + pos: position{line: 398, col: 6, offset: 9497}, + name: "LogicExpr3", + }, + }, + &labeledExpr{ + pos: position{line: 399, col: 3, offset: 9510}, + label: "os", + expr: &zeroOrMoreExpr{ + pos: position{line: 399, col: 6, offset: 9513}, + expr: &actionExpr{ + pos: position{line: 399, col: 8, offset: 9515}, + run: (*parser).callonLogicExpr47, + expr: &seqExpr{ + pos: position{line: 399, col: 8, offset: 9515}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 399, col: 8, offset: 9515}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 399, col: 10, offset: 9517}, + label: "op", + expr: &ruleRefExpr{ + pos: position{line: 399, col: 13, offset: 9520}, + name: "OrOperator", + }, + }, + &ruleRefExpr{ + pos: position{line: 399, col: 24, offset: 9531}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 399, col: 26, offset: 9533}, + label: "s", + expr: &ruleRefExpr{ + pos: position{line: 399, col: 28, offset: 9535}, + name: "LogicExpr3", + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + { + name: "LogicExpr3", + pos: position{line: 403, col: 1, offset: 9698}, + expr: &actionExpr{ + pos: position{line: 404, col: 4, offset: 9712}, + run: (*parser).callonLogicExpr31, + expr: &seqExpr{ + pos: position{line: 404, col: 4, offset: 9712}, + exprs: []interface{}{ + &labeledExpr{ + pos: position{line: 404, col: 4, offset: 9712}, + label: "o", + expr: &ruleRefExpr{ + pos: position{line: 404, col: 6, offset: 9714}, + name: "LogicExpr2", + }, + }, + &labeledExpr{ + pos: position{line: 405, col: 3, offset: 9727}, + label: "os", + expr: &zeroOrMoreExpr{ + pos: position{line: 405, col: 6, offset: 9730}, + expr: &actionExpr{ + pos: position{line: 405, col: 8, offset: 9732}, + run: (*parser).callonLogicExpr37, + expr: &seqExpr{ + pos: position{line: 405, col: 8, offset: 9732}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 405, col: 8, offset: 9732}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 405, col: 10, offset: 9734}, + label: "op", + expr: &ruleRefExpr{ + pos: position{line: 405, col: 13, offset: 9737}, + name: "AndOperator", + }, + }, + &ruleRefExpr{ + pos: position{line: 405, col: 25, offset: 9749}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 405, col: 27, offset: 9751}, + label: "s", + expr: &ruleRefExpr{ + pos: position{line: 405, col: 29, offset: 9753}, + name: "LogicExpr2", + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + { + name: "LogicExpr2", + pos: position{line: 409, col: 1, offset: 9916}, + expr: &choiceExpr{ + pos: position{line: 410, col: 4, offset: 9930}, + alternatives: []interface{}{ + &actionExpr{ + pos: position{line: 410, col: 4, offset: 9930}, + run: (*parser).callonLogicExpr22, + expr: &seqExpr{ + pos: position{line: 410, col: 4, offset: 9930}, + exprs: []interface{}{ + &labeledExpr{ + pos: position{line: 410, col: 4, offset: 9930}, + label: "op", + expr: &ruleRefExpr{ + pos: position{line: 410, col: 7, offset: 9933}, + name: "NotOperator", + }, + }, + &ruleRefExpr{ + pos: position{line: 410, col: 19, offset: 9945}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 410, col: 21, offset: 9947}, + label: "s", + expr: &ruleRefExpr{ + pos: position{line: 410, col: 23, offset: 9949}, + name: "LogicExpr2", + }, + }, + }, + }, + }, + &ruleRefExpr{ + pos: position{line: 412, col: 4, offset: 10034}, + name: "LogicExpr1", + }, + }, + }, + }, + { + name: "LogicExpr1", + pos: position{line: 414, col: 1, offset: 10046}, + expr: &actionExpr{ + pos: position{line: 415, col: 4, offset: 10060}, + run: (*parser).callonLogicExpr11, + expr: &seqExpr{ + pos: position{line: 415, col: 4, offset: 10060}, + exprs: []interface{}{ + &labeledExpr{ + pos: position{line: 415, col: 4, offset: 10060}, + label: "o", + expr: &ruleRefExpr{ + pos: position{line: 415, col: 6, offset: 10062}, + name: "ArithmeticExpr", + }, + }, + &labeledExpr{ + pos: position{line: 415, col: 21, offset: 10077}, + label: "os", + expr: &zeroOrMoreExpr{ + pos: position{line: 415, col: 24, offset: 10080}, + expr: &actionExpr{ + pos: position{line: 415, col: 26, offset: 10082}, + run: (*parser).callonLogicExpr17, + expr: &seqExpr{ + pos: position{line: 415, col: 26, offset: 10082}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 415, col: 26, offset: 10082}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 415, col: 28, offset: 10084}, + label: "l", + expr: &ruleRefExpr{ + pos: position{line: 415, col: 30, offset: 10086}, + name: "LogicExpr1Op", + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + { + name: "LogicExpr1Op", + pos: position{line: 418, col: 1, offset: 10195}, + expr: &choiceExpr{ + pos: position{line: 419, col: 4, offset: 10211}, + alternatives: []interface{}{ + &ruleRefExpr{ + pos: position{line: 419, col: 4, offset: 10211}, + name: "LogicExpr1In", + }, + &ruleRefExpr{ + pos: position{line: 420, col: 4, offset: 10227}, + name: "LogicExpr1Is", + }, + &ruleRefExpr{ + pos: position{line: 421, col: 4, offset: 10243}, + name: "LogicExpr1Like", + }, + &ruleRefExpr{ + pos: position{line: 422, col: 4, offset: 10261}, + name: "LogicExpr1Cmp", + }, + }, + }, + }, + { + name: "LogicExpr1In", + pos: position{line: 424, col: 1, offset: 10276}, + expr: &actionExpr{ + pos: position{line: 425, col: 4, offset: 10292}, + run: (*parser).callonLogicExpr1In1, + expr: &seqExpr{ + pos: position{line: 425, col: 4, offset: 10292}, + exprs: []interface{}{ + &labeledExpr{ + pos: position{line: 425, col: 4, offset: 10292}, + label: "n", + expr: &zeroOrOneExpr{ + pos: position{line: 425, col: 6, offset: 10294}, + expr: &actionExpr{ + pos: position{line: 425, col: 8, offset: 10296}, + run: (*parser).callonLogicExpr1In5, + expr: &seqExpr{ + pos: position{line: 425, col: 8, offset: 10296}, + exprs: []interface{}{ + &labeledExpr{ + pos: position{line: 425, col: 8, offset: 10296}, + label: "t", + expr: &ruleRefExpr{ + pos: position{line: 425, col: 10, offset: 10298}, + name: "NotOperator", + }, + }, + &ruleRefExpr{ + pos: position{line: 425, col: 22, offset: 10310}, + name: "_", + }, + }, + }, + }, + }, + }, + &ruleRefExpr{ + pos: position{line: 425, col: 45, offset: 10333}, + name: "InToken", + }, + &ruleRefExpr{ + pos: position{line: 425, col: 53, offset: 10341}, + name: "_", + }, + &litMatcher{ + pos: position{line: 425, col: 55, offset: 10343}, + val: "(", + ignoreCase: false, + }, + &ruleRefExpr{ + pos: position{line: 425, col: 59, offset: 10347}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 425, col: 61, offset: 10349}, + label: "s", + expr: &ruleRefExpr{ + pos: position{line: 425, col: 63, offset: 10351}, + name: "MultiExpr", + }, + }, + &ruleRefExpr{ + pos: position{line: 425, col: 73, offset: 10361}, + name: "_", + }, + &litMatcher{ + pos: position{line: 425, col: 75, offset: 10363}, + val: ")", + ignoreCase: false, + }, + }, + }, + }, + }, + { + name: "LogicExpr1Is", + pos: position{line: 437, col: 1, offset: 10604}, + expr: &actionExpr{ + pos: position{line: 438, col: 4, offset: 10620}, + run: (*parser).callonLogicExpr1Is1, + expr: &seqExpr{ + pos: position{line: 438, col: 4, offset: 10620}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 438, col: 4, offset: 10620}, + name: "IsToken", + }, + &labeledExpr{ + pos: position{line: 438, col: 12, offset: 10628}, + label: "n", + expr: &zeroOrOneExpr{ + pos: position{line: 438, col: 14, offset: 10630}, + expr: &actionExpr{ + pos: position{line: 438, col: 16, offset: 10632}, + run: (*parser).callonLogicExpr1Is6, + expr: &seqExpr{ + pos: position{line: 438, col: 16, offset: 10632}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 438, col: 16, offset: 10632}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 438, col: 18, offset: 10634}, + label: "t", + expr: &ruleRefExpr{ + pos: position{line: 438, col: 20, offset: 10636}, + name: "NotOperator", + }, + }, + }, + }, + }, + }, + }, + &ruleRefExpr{ + pos: position{line: 438, col: 53, offset: 10669}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 438, col: 55, offset: 10671}, + label: "u", + expr: &ruleRefExpr{ + pos: position{line: 438, col: 57, offset: 10673}, + name: "NullLiteral", + }, + }, + }, + }, + }, + }, + { + name: "LogicExpr1Like", + pos: position{line: 450, col: 1, offset: 10933}, + expr: &actionExpr{ + pos: position{line: 451, col: 4, offset: 10951}, + run: (*parser).callonLogicExpr1Like1, + expr: &seqExpr{ + pos: position{line: 451, col: 4, offset: 10951}, + exprs: []interface{}{ + &labeledExpr{ + pos: position{line: 451, col: 4, offset: 10951}, + label: "n", + expr: &zeroOrOneExpr{ + pos: position{line: 451, col: 6, offset: 10953}, + expr: &actionExpr{ + pos: position{line: 451, col: 8, offset: 10955}, + run: (*parser).callonLogicExpr1Like5, + expr: &seqExpr{ + pos: position{line: 451, col: 8, offset: 10955}, + exprs: []interface{}{ + &labeledExpr{ + pos: position{line: 451, col: 8, offset: 10955}, + label: "t", + expr: &ruleRefExpr{ + pos: position{line: 451, col: 10, offset: 10957}, + name: "NotOperator", + }, + }, + &ruleRefExpr{ + pos: position{line: 451, col: 22, offset: 10969}, + name: "_", + }, + }, + }, + }, + }, + }, + &ruleRefExpr{ + pos: position{line: 451, col: 45, offset: 10992}, + name: "LikeToken", + }, + &ruleRefExpr{ + pos: position{line: 451, col: 55, offset: 11002}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 451, col: 57, offset: 11004}, + label: "s", + expr: &ruleRefExpr{ + pos: position{line: 451, col: 59, offset: 11006}, + name: "Expr", + }, + }, + }, + }, + }, + }, + { + name: "LogicExpr1Cmp", + pos: position{line: 463, col: 1, offset: 11255}, + expr: &actionExpr{ + pos: position{line: 464, col: 4, offset: 11272}, + run: (*parser).callonLogicExpr1Cmp1, + expr: &seqExpr{ + pos: position{line: 464, col: 4, offset: 11272}, + exprs: []interface{}{ + &labeledExpr{ + pos: position{line: 464, col: 4, offset: 11272}, + label: "op", + expr: &ruleRefExpr{ + pos: position{line: 464, col: 7, offset: 11275}, + name: "CmpOperator", + }, + }, + &ruleRefExpr{ + pos: position{line: 464, col: 19, offset: 11287}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 464, col: 21, offset: 11289}, + label: "s", + expr: &ruleRefExpr{ + pos: position{line: 464, col: 23, offset: 11291}, + name: "ArithmeticExpr", + }, + }, + }, + }, + }, + }, + { + name: "ArithmeticExpr", + pos: position{line: 467, col: 1, offset: 11379}, + expr: &ruleRefExpr{ + pos: position{line: 468, col: 4, offset: 11397}, + name: "ArithmeticExpr3", + }, + }, + { + name: "ArithmeticExpr3", + pos: position{line: 470, col: 1, offset: 11414}, + expr: &actionExpr{ + pos: position{line: 471, col: 4, offset: 11433}, + run: (*parser).callonArithmeticExpr31, + expr: &seqExpr{ + pos: position{line: 471, col: 4, offset: 11433}, + exprs: []interface{}{ + &labeledExpr{ + pos: position{line: 471, col: 4, offset: 11433}, + label: "o", + expr: &ruleRefExpr{ + pos: position{line: 471, col: 6, offset: 11435}, + name: "ArithmeticExpr2", + }, + }, + &labeledExpr{ + pos: position{line: 472, col: 3, offset: 11453}, + label: "os", + expr: &zeroOrMoreExpr{ + pos: position{line: 472, col: 6, offset: 11456}, + expr: &actionExpr{ + pos: position{line: 472, col: 8, offset: 11458}, + run: (*parser).callonArithmeticExpr37, + expr: &seqExpr{ + pos: position{line: 472, col: 8, offset: 11458}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 472, col: 8, offset: 11458}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 472, col: 10, offset: 11460}, + label: "op", + expr: &ruleRefExpr{ + pos: position{line: 472, col: 13, offset: 11463}, + name: "ConcatOperator", + }, + }, + &ruleRefExpr{ + pos: position{line: 472, col: 28, offset: 11478}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 472, col: 30, offset: 11480}, + label: "s", + expr: &ruleRefExpr{ + pos: position{line: 472, col: 32, offset: 11482}, + name: "ArithmeticExpr2", + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + { + name: "ArithmeticExpr2", + pos: position{line: 476, col: 1, offset: 11650}, + expr: &actionExpr{ + pos: position{line: 477, col: 4, offset: 11669}, + run: (*parser).callonArithmeticExpr21, + expr: &seqExpr{ + pos: position{line: 477, col: 4, offset: 11669}, + exprs: []interface{}{ + &labeledExpr{ + pos: position{line: 477, col: 4, offset: 11669}, + label: "o", + expr: &ruleRefExpr{ + pos: position{line: 477, col: 6, offset: 11671}, + name: "ArithmeticExpr1", + }, + }, + &labeledExpr{ + pos: position{line: 478, col: 3, offset: 11689}, + label: "os", + expr: &zeroOrMoreExpr{ + pos: position{line: 478, col: 6, offset: 11692}, + expr: &actionExpr{ + pos: position{line: 478, col: 8, offset: 11694}, + run: (*parser).callonArithmeticExpr27, + expr: &seqExpr{ + pos: position{line: 478, col: 8, offset: 11694}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 478, col: 8, offset: 11694}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 478, col: 10, offset: 11696}, + label: "op", + expr: &ruleRefExpr{ + pos: position{line: 478, col: 13, offset: 11699}, + name: "AddSubOperator", + }, + }, + &ruleRefExpr{ + pos: position{line: 478, col: 28, offset: 11714}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 478, col: 30, offset: 11716}, + label: "s", + expr: &ruleRefExpr{ + pos: position{line: 478, col: 32, offset: 11718}, + name: "ArithmeticExpr1", + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + { + name: "ArithmeticExpr1", + pos: position{line: 482, col: 1, offset: 11886}, + expr: &actionExpr{ + pos: position{line: 483, col: 4, offset: 11905}, + run: (*parser).callonArithmeticExpr11, + expr: &seqExpr{ + pos: position{line: 483, col: 4, offset: 11905}, + exprs: []interface{}{ + &labeledExpr{ + pos: position{line: 483, col: 4, offset: 11905}, + label: "o", + expr: &ruleRefExpr{ + pos: position{line: 483, col: 6, offset: 11907}, + name: "Operand", + }, + }, + &labeledExpr{ + pos: position{line: 484, col: 3, offset: 11917}, + label: "os", + expr: &zeroOrMoreExpr{ + pos: position{line: 484, col: 6, offset: 11920}, + expr: &actionExpr{ + pos: position{line: 484, col: 8, offset: 11922}, + run: (*parser).callonArithmeticExpr17, + expr: &seqExpr{ + pos: position{line: 484, col: 8, offset: 11922}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 484, col: 8, offset: 11922}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 484, col: 10, offset: 11924}, + label: "op", + expr: &ruleRefExpr{ + pos: position{line: 484, col: 13, offset: 11927}, + name: "MulDivModOperator", + }, + }, + &ruleRefExpr{ + pos: position{line: 484, col: 31, offset: 11945}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 484, col: 33, offset: 11947}, + label: "s", + expr: &ruleRefExpr{ + pos: position{line: 484, col: 35, offset: 11949}, + name: "Operand", + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + { + name: "MultiExpr", + pos: position{line: 488, col: 1, offset: 12109}, + expr: &actionExpr{ + pos: position{line: 489, col: 4, offset: 12122}, + run: (*parser).callonMultiExpr1, + expr: &seqExpr{ + pos: position{line: 489, col: 4, offset: 12122}, + exprs: []interface{}{ + &labeledExpr{ + pos: position{line: 489, col: 4, offset: 12122}, + label: "x", + expr: &ruleRefExpr{ + pos: position{line: 489, col: 6, offset: 12124}, + name: "Expr", + }, + }, + &labeledExpr{ + pos: position{line: 489, col: 11, offset: 12129}, + label: "xs", + expr: &zeroOrMoreExpr{ + pos: position{line: 489, col: 14, offset: 12132}, + expr: &actionExpr{ + pos: position{line: 489, col: 16, offset: 12134}, + run: (*parser).callonMultiExpr7, + expr: &seqExpr{ + pos: position{line: 489, col: 16, offset: 12134}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 489, col: 16, offset: 12134}, + name: "_", + }, + &ruleRefExpr{ + pos: position{line: 489, col: 18, offset: 12136}, + name: "SeparatorToken", + }, + &ruleRefExpr{ + pos: position{line: 489, col: 33, offset: 12151}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 489, col: 35, offset: 12153}, + label: "e", + expr: &ruleRefExpr{ + pos: position{line: 489, col: 37, offset: 12155}, + name: "Expr", + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + { + name: "MultiExprWithDefault", + pos: position{line: 492, col: 1, offset: 12243}, + expr: &actionExpr{ + pos: position{line: 493, col: 4, offset: 12267}, + run: (*parser).callonMultiExprWithDefault1, + expr: &seqExpr{ + pos: position{line: 493, col: 4, offset: 12267}, + exprs: []interface{}{ + &labeledExpr{ + pos: position{line: 493, col: 4, offset: 12267}, + label: "x", + expr: &ruleRefExpr{ + pos: position{line: 493, col: 6, offset: 12269}, + name: "ExprWithDefault", + }, + }, + &labeledExpr{ + pos: position{line: 493, col: 22, offset: 12285}, + label: "xs", + expr: &zeroOrMoreExpr{ + pos: position{line: 493, col: 25, offset: 12288}, + expr: &actionExpr{ + pos: position{line: 493, col: 27, offset: 12290}, + run: (*parser).callonMultiExprWithDefault7, + expr: &seqExpr{ + pos: position{line: 493, col: 27, offset: 12290}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 493, col: 27, offset: 12290}, + name: "_", + }, + &ruleRefExpr{ + pos: position{line: 493, col: 29, offset: 12292}, + name: "SeparatorToken", + }, + &ruleRefExpr{ + pos: position{line: 493, col: 44, offset: 12307}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 493, col: 46, offset: 12309}, + label: "e", + expr: &ruleRefExpr{ + pos: position{line: 493, col: 48, offset: 12311}, + name: "ExprWithDefault", + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + { + name: "Operand", + pos: position{line: 496, col: 1, offset: 12410}, + expr: &choiceExpr{ + pos: position{line: 497, col: 4, offset: 12421}, + alternatives: []interface{}{ + &actionExpr{ + pos: position{line: 497, col: 4, offset: 12421}, + run: (*parser).callonOperand2, + expr: &seqExpr{ + pos: position{line: 497, col: 4, offset: 12421}, + exprs: []interface{}{ + &labeledExpr{ + pos: position{line: 497, col: 4, offset: 12421}, + label: "op", + expr: &ruleRefExpr{ + pos: position{line: 497, col: 7, offset: 12424}, + name: "UnaryOperator", + }, + }, + &ruleRefExpr{ + pos: position{line: 497, col: 21, offset: 12438}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 497, col: 23, offset: 12440}, + label: "s", + expr: &ruleRefExpr{ + pos: position{line: 497, col: 25, offset: 12442}, + name: "Operand", + }, + }, + }, + }, + }, + &actionExpr{ + pos: position{line: 499, col: 4, offset: 12525}, + run: (*parser).callonOperand9, + expr: &seqExpr{ + pos: position{line: 499, col: 4, offset: 12525}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 499, col: 4, offset: 12525}, + val: "(", + ignoreCase: false, + }, + &ruleRefExpr{ + pos: position{line: 499, col: 8, offset: 12529}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 499, col: 10, offset: 12531}, + label: "e", + expr: &ruleRefExpr{ + pos: position{line: 499, col: 12, offset: 12533}, + name: "Expr", + }, + }, + &ruleRefExpr{ + pos: position{line: 499, col: 17, offset: 12538}, + name: "_", + }, + &litMatcher{ + pos: position{line: 499, col: 19, offset: 12540}, + val: ")", + ignoreCase: false, + }, + }, + }, + }, + &actionExpr{ + pos: position{line: 507, col: 4, offset: 12731}, + run: (*parser).callonOperand17, + expr: &seqExpr{ + pos: position{line: 507, col: 4, offset: 12731}, + exprs: []interface{}{ + &andExpr{ + pos: position{line: 507, col: 4, offset: 12731}, + expr: &ruleRefExpr{ + pos: position{line: 507, col: 6, offset: 12733}, + name: "CastToken", + }, + }, + &labeledExpr{ + pos: position{line: 507, col: 17, offset: 12744}, + label: "t", + expr: &ruleRefExpr{ + pos: position{line: 507, col: 19, offset: 12746}, + name: "TypeCast", + }, + }, + }, + }, + }, + &ruleRefExpr{ + pos: position{line: 508, col: 4, offset: 12776}, + name: "FunctionCall", + }, + &ruleRefExpr{ + pos: position{line: 509, col: 4, offset: 12792}, + name: "Value", + }, + &ruleRefExpr{ + pos: position{line: 510, col: 4, offset: 12801}, + name: "Identifier", + }, + }, + }, + }, + { + name: "TypeCast", + pos: position{line: 512, col: 1, offset: 12813}, + expr: &actionExpr{ + pos: position{line: 513, col: 4, offset: 12825}, + run: (*parser).callonTypeCast1, + expr: &seqExpr{ + pos: position{line: 513, col: 4, offset: 12825}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 513, col: 4, offset: 12825}, + name: "CastToken", + }, + &ruleRefExpr{ + pos: position{line: 513, col: 14, offset: 12835}, + name: "_", + }, + &litMatcher{ + pos: position{line: 513, col: 16, offset: 12837}, + val: "(", + ignoreCase: false, + }, + &ruleRefExpr{ + pos: position{line: 513, col: 20, offset: 12841}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 513, col: 22, offset: 12843}, + label: "o", + expr: &ruleRefExpr{ + pos: position{line: 513, col: 24, offset: 12845}, + name: "Expr", + }, + }, + &ruleRefExpr{ + pos: position{line: 513, col: 29, offset: 12850}, + name: "_", + }, + &ruleRefExpr{ + pos: position{line: 513, col: 31, offset: 12852}, + name: "AsToken", + }, + &ruleRefExpr{ + pos: position{line: 513, col: 39, offset: 12860}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 513, col: 41, offset: 12862}, + label: "s", + expr: &ruleRefExpr{ + pos: position{line: 513, col: 43, offset: 12864}, + name: "DataType", + }, + }, + &ruleRefExpr{ + pos: position{line: 513, col: 52, offset: 12873}, + name: "_", + }, + &litMatcher{ + pos: position{line: 513, col: 54, offset: 12875}, + val: ")", + ignoreCase: false, + }, + }, + }, + }, + }, + { + name: "FunctionCall", + pos: position{line: 523, col: 1, offset: 13084}, + expr: &actionExpr{ + pos: position{line: 524, col: 4, offset: 13100}, + run: (*parser).callonFunctionCall1, + expr: &seqExpr{ + pos: position{line: 524, col: 4, offset: 13100}, + exprs: []interface{}{ + &labeledExpr{ + pos: position{line: 524, col: 4, offset: 13100}, + label: "i", + expr: &ruleRefExpr{ + pos: position{line: 524, col: 6, offset: 13102}, + name: "Identifier", + }, + }, + &ruleRefExpr{ + pos: position{line: 524, col: 17, offset: 13113}, + name: "_", + }, + &litMatcher{ + pos: position{line: 524, col: 19, offset: 13115}, + val: "(", + ignoreCase: false, + }, + &ruleRefExpr{ + pos: position{line: 524, col: 23, offset: 13119}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 524, col: 25, offset: 13121}, + label: "r", + expr: &zeroOrOneExpr{ + pos: position{line: 524, col: 27, offset: 13123}, + expr: &ruleRefExpr{ + pos: position{line: 524, col: 27, offset: 13123}, + name: "FunctionArgs", + }, + }, + }, + &ruleRefExpr{ + pos: position{line: 524, col: 41, offset: 13137}, + name: "_", + }, + &litMatcher{ + pos: position{line: 524, col: 43, offset: 13139}, + val: ")", + ignoreCase: false, + }, + }, + }, + }, + }, + { + name: "FunctionArgs", + pos: position{line: 536, col: 1, offset: 13368}, + expr: &choiceExpr{ + pos: position{line: 537, col: 4, offset: 13384}, + alternatives: []interface{}{ + &actionExpr{ + pos: position{line: 537, col: 4, offset: 13384}, + run: (*parser).callonFunctionArgs2, + expr: &labeledExpr{ + pos: position{line: 537, col: 4, offset: 13384}, + label: "a", + expr: &ruleRefExpr{ + pos: position{line: 537, col: 6, offset: 13386}, + name: "AnyLiteral", + }, + }, + }, + &ruleRefExpr{ + pos: position{line: 538, col: 4, offset: 13454}, + name: "MultiExpr", + }, + }, + }, + }, + { + name: "Assignment", + pos: position{line: 540, col: 1, offset: 13465}, + expr: &actionExpr{ + pos: position{line: 541, col: 4, offset: 13479}, + run: (*parser).callonAssignment1, + expr: &seqExpr{ + pos: position{line: 541, col: 4, offset: 13479}, + exprs: []interface{}{ + &labeledExpr{ + pos: position{line: 541, col: 4, offset: 13479}, + label: "i", + expr: &ruleRefExpr{ + pos: position{line: 541, col: 6, offset: 13481}, + name: "Identifier", + }, + }, + &ruleRefExpr{ + pos: position{line: 541, col: 17, offset: 13492}, + name: "_", + }, + &litMatcher{ + pos: position{line: 541, col: 19, offset: 13494}, + val: "=", + ignoreCase: false, + }, + &ruleRefExpr{ + pos: position{line: 541, col: 23, offset: 13498}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 541, col: 25, offset: 13500}, + label: "e", + expr: &ruleRefExpr{ + pos: position{line: 541, col: 27, offset: 13502}, + name: "ExprWithDefault", + }, + }, + }, + }, + }, + }, + { + name: "UnaryOperator", + pos: position{line: 552, col: 1, offset: 13738}, + expr: &ruleRefExpr{ + pos: position{line: 553, col: 4, offset: 13755}, + name: "SignOperator", + }, + }, + { + name: "SignOperator", + pos: position{line: 555, col: 1, offset: 13769}, + expr: &actionExpr{ + pos: position{line: 556, col: 4, offset: 13785}, + run: (*parser).callonSignOperator1, + expr: &ruleRefExpr{ + pos: position{line: 556, col: 4, offset: 13785}, + name: "Sign", + }, + }, + }, + { + name: "NotOperator", + pos: position{line: 572, col: 1, offset: 14090}, + expr: &actionExpr{ + pos: position{line: 573, col: 4, offset: 14105}, + run: (*parser).callonNotOperator1, + expr: &ruleRefExpr{ + pos: position{line: 573, col: 4, offset: 14105}, + name: "NotToken", + }, + }, + }, + { + name: "AndOperator", + pos: position{line: 581, col: 1, offset: 14246}, + expr: &actionExpr{ + pos: position{line: 582, col: 4, offset: 14261}, + run: (*parser).callonAndOperator1, + expr: &ruleRefExpr{ + pos: position{line: 582, col: 4, offset: 14261}, + name: "AndToken", + }, + }, + }, + { + name: "OrOperator", + pos: position{line: 590, col: 1, offset: 14402}, + expr: &actionExpr{ + pos: position{line: 591, col: 4, offset: 14416}, + run: (*parser).callonOrOperator1, + expr: &ruleRefExpr{ + pos: position{line: 591, col: 4, offset: 14416}, + name: "OrToken", + }, + }, + }, + { + name: "CmpOperator", + pos: position{line: 599, col: 1, offset: 14555}, + expr: &actionExpr{ + pos: position{line: 600, col: 4, offset: 14570}, + run: (*parser).callonCmpOperator1, + expr: &choiceExpr{ + pos: position{line: 600, col: 6, offset: 14572}, + alternatives: []interface{}{ + &litMatcher{ + pos: position{line: 600, col: 6, offset: 14572}, + val: "<=", + ignoreCase: false, + }, + &litMatcher{ + pos: position{line: 600, col: 13, offset: 14579}, + val: ">=", + ignoreCase: false, + }, + &litMatcher{ + pos: position{line: 600, col: 20, offset: 14586}, + val: "<>", + ignoreCase: false, + }, + &litMatcher{ + pos: position{line: 600, col: 27, offset: 14593}, + val: "!=", + ignoreCase: false, + }, + &charClassMatcher{ + pos: position{line: 600, col: 34, offset: 14600}, + val: "[<>=]", + chars: []rune{'<', '>', '='}, + ignoreCase: false, + inverted: false, + }, + }, + }, + }, + }, + { + name: "ConcatOperator", + pos: position{line: 626, col: 1, offset: 15179}, + expr: &actionExpr{ + pos: position{line: 627, col: 4, offset: 15197}, + run: (*parser).callonConcatOperator1, + expr: &litMatcher{ + pos: position{line: 627, col: 4, offset: 15197}, + val: "||", + ignoreCase: false, + }, + }, + }, + { + name: "AddSubOperator", + pos: position{line: 635, col: 1, offset: 15337}, + expr: &actionExpr{ + pos: position{line: 636, col: 4, offset: 15355}, + run: (*parser).callonAddSubOperator1, + expr: &charClassMatcher{ + pos: position{line: 636, col: 4, offset: 15355}, + val: "[+-]", + chars: []rune{'+', '-'}, + ignoreCase: false, + inverted: false, + }, + }, + }, + { + name: "MulDivModOperator", + pos: position{line: 652, col: 1, offset: 15689}, + expr: &actionExpr{ + pos: position{line: 653, col: 4, offset: 15710}, + run: (*parser).callonMulDivModOperator1, + expr: &charClassMatcher{ + pos: position{line: 653, col: 4, offset: 15710}, + val: "[*/%]", + chars: []rune{'*', '/', '%'}, + ignoreCase: false, + inverted: false, + }, + }, + }, + { + name: "DataType", + pos: position{line: 672, col: 1, offset: 16110}, + expr: &choiceExpr{ + pos: position{line: 673, col: 4, offset: 16122}, + alternatives: []interface{}{ + &ruleRefExpr{ + pos: position{line: 673, col: 4, offset: 16122}, + name: "UIntType", + }, + &ruleRefExpr{ + pos: position{line: 674, col: 4, offset: 16134}, + name: "IntType", + }, + &ruleRefExpr{ + pos: position{line: 675, col: 4, offset: 16145}, + name: "UFixedType", + }, + &ruleRefExpr{ + pos: position{line: 676, col: 4, offset: 16159}, + name: "FixedType", + }, + &ruleRefExpr{ + pos: position{line: 677, col: 4, offset: 16172}, + name: "FixedBytesType", + }, + &ruleRefExpr{ + pos: position{line: 678, col: 4, offset: 16190}, + name: "DynamicBytesType", + }, + &ruleRefExpr{ + pos: position{line: 679, col: 4, offset: 16210}, + name: "BoolType", + }, + &ruleRefExpr{ + pos: position{line: 680, col: 4, offset: 16222}, + name: "AddressType", + }, + }, + }, + }, + { + name: "UIntType", + pos: position{line: 682, col: 1, offset: 16235}, + expr: &actionExpr{ + pos: position{line: 683, col: 4, offset: 16247}, + run: (*parser).callonUIntType1, + expr: &seqExpr{ + pos: position{line: 683, col: 4, offset: 16247}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 683, col: 4, offset: 16247}, + val: "uint", + ignoreCase: true, + }, + &labeledExpr{ + pos: position{line: 683, col: 12, offset: 16255}, + label: "s", + expr: &ruleRefExpr{ + pos: position{line: 683, col: 14, offset: 16257}, + name: "NonZeroLeadingInteger", + }, + }, + ¬Expr{ + pos: position{line: 683, col: 36, offset: 16279}, + expr: &ruleRefExpr{ + pos: position{line: 683, col: 37, offset: 16280}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + }, + }, + { + name: "IntType", + pos: position{line: 705, col: 1, offset: 16792}, + expr: &actionExpr{ + pos: position{line: 706, col: 4, offset: 16803}, + run: (*parser).callonIntType1, + expr: &seqExpr{ + pos: position{line: 706, col: 4, offset: 16803}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 706, col: 4, offset: 16803}, + val: "int", + ignoreCase: true, + }, + &labeledExpr{ + pos: position{line: 706, col: 11, offset: 16810}, + label: "s", + expr: &ruleRefExpr{ + pos: position{line: 706, col: 13, offset: 16812}, + name: "NonZeroLeadingInteger", + }, + }, + ¬Expr{ + pos: position{line: 706, col: 35, offset: 16834}, + expr: &ruleRefExpr{ + pos: position{line: 706, col: 36, offset: 16835}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + }, + }, + { + name: "UFixedType", + pos: position{line: 728, col: 1, offset: 17347}, + expr: &actionExpr{ + pos: position{line: 729, col: 4, offset: 17361}, + run: (*parser).callonUFixedType1, + expr: &seqExpr{ + pos: position{line: 729, col: 4, offset: 17361}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 729, col: 4, offset: 17361}, + val: "ufixed", + ignoreCase: true, + }, + &labeledExpr{ + pos: position{line: 729, col: 14, offset: 17371}, + label: "s", + expr: &ruleRefExpr{ + pos: position{line: 729, col: 16, offset: 17373}, + name: "NonZeroLeadingInteger", + }, + }, + &litMatcher{ + pos: position{line: 729, col: 38, offset: 17395}, + val: "x", + ignoreCase: true, + }, + &labeledExpr{ + pos: position{line: 729, col: 43, offset: 17400}, + label: "t", + expr: &ruleRefExpr{ + pos: position{line: 729, col: 45, offset: 17402}, + name: "NonZeroLeadingInteger", + }, + }, + ¬Expr{ + pos: position{line: 729, col: 67, offset: 17424}, + expr: &ruleRefExpr{ + pos: position{line: 729, col: 68, offset: 17425}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + }, + }, + { + name: "FixedType", + pos: position{line: 764, col: 1, offset: 18320}, + expr: &actionExpr{ + pos: position{line: 765, col: 4, offset: 18333}, + run: (*parser).callonFixedType1, + expr: &seqExpr{ + pos: position{line: 765, col: 4, offset: 18333}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 765, col: 4, offset: 18333}, + val: "fixed", + ignoreCase: true, + }, + &labeledExpr{ + pos: position{line: 765, col: 13, offset: 18342}, + label: "s", + expr: &ruleRefExpr{ + pos: position{line: 765, col: 15, offset: 18344}, + name: "NonZeroLeadingInteger", + }, + }, + &litMatcher{ + pos: position{line: 765, col: 37, offset: 18366}, + val: "x", + ignoreCase: true, + }, + &labeledExpr{ + pos: position{line: 765, col: 42, offset: 18371}, + label: "t", + expr: &ruleRefExpr{ + pos: position{line: 765, col: 44, offset: 18373}, + name: "NonZeroLeadingInteger", + }, + }, + ¬Expr{ + pos: position{line: 765, col: 66, offset: 18395}, + expr: &ruleRefExpr{ + pos: position{line: 765, col: 67, offset: 18396}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + }, + }, + { + name: "FixedBytesType", + pos: position{line: 800, col: 1, offset: 19290}, + expr: &choiceExpr{ + pos: position{line: 801, col: 4, offset: 19308}, + alternatives: []interface{}{ + &actionExpr{ + pos: position{line: 801, col: 4, offset: 19308}, + run: (*parser).callonFixedBytesType2, + expr: &seqExpr{ + pos: position{line: 801, col: 4, offset: 19308}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 801, col: 4, offset: 19308}, + val: "bytes", + ignoreCase: true, + }, + &labeledExpr{ + pos: position{line: 801, col: 13, offset: 19317}, + label: "s", + expr: &ruleRefExpr{ + pos: position{line: 801, col: 15, offset: 19319}, + name: "NonZeroLeadingInteger", + }, + }, + ¬Expr{ + pos: position{line: 801, col: 37, offset: 19341}, + expr: &ruleRefExpr{ + pos: position{line: 801, col: 38, offset: 19342}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + }, + &actionExpr{ + pos: position{line: 821, col: 4, offset: 19847}, + run: (*parser).callonFixedBytesType9, + expr: &seqExpr{ + pos: position{line: 821, col: 4, offset: 19847}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 821, col: 4, offset: 19847}, + val: "byte", + ignoreCase: true, + }, + ¬Expr{ + pos: position{line: 821, col: 12, offset: 19855}, + expr: &ruleRefExpr{ + pos: position{line: 821, col: 13, offset: 19856}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + }, + }, + }, + }, + { + name: "DynamicBytesType", + pos: position{line: 830, col: 1, offset: 20027}, + expr: &actionExpr{ + pos: position{line: 831, col: 4, offset: 20047}, + run: (*parser).callonDynamicBytesType1, + expr: &choiceExpr{ + pos: position{line: 831, col: 6, offset: 20049}, + alternatives: []interface{}{ + &seqExpr{ + pos: position{line: 831, col: 6, offset: 20049}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 831, col: 6, offset: 20049}, + val: "bytes", + ignoreCase: true, + }, + ¬Expr{ + pos: position{line: 831, col: 15, offset: 20058}, + expr: &ruleRefExpr{ + pos: position{line: 831, col: 16, offset: 20059}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + &seqExpr{ + pos: position{line: 832, col: 5, offset: 20084}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 832, col: 5, offset: 20084}, + val: "string", + ignoreCase: true, + }, + ¬Expr{ + pos: position{line: 832, col: 15, offset: 20094}, + expr: &ruleRefExpr{ + pos: position{line: 832, col: 16, offset: 20095}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + &seqExpr{ + pos: position{line: 833, col: 5, offset: 20120}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 833, col: 5, offset: 20120}, + val: "text", + ignoreCase: true, + }, + ¬Expr{ + pos: position{line: 833, col: 13, offset: 20128}, + expr: &ruleRefExpr{ + pos: position{line: 833, col: 14, offset: 20129}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + }, + }, + }, + }, + { + name: "AddressType", + pos: position{line: 842, col: 1, offset: 20290}, + expr: &actionExpr{ + pos: position{line: 843, col: 4, offset: 20305}, + run: (*parser).callonAddressType1, + expr: &seqExpr{ + pos: position{line: 843, col: 4, offset: 20305}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 843, col: 4, offset: 20305}, + val: "address", + ignoreCase: true, + }, + ¬Expr{ + pos: position{line: 843, col: 15, offset: 20316}, + expr: &ruleRefExpr{ + pos: position{line: 843, col: 16, offset: 20317}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + }, + }, + { + name: "BoolType", + pos: position{line: 851, col: 1, offset: 20470}, + expr: &actionExpr{ + pos: position{line: 852, col: 4, offset: 20482}, + run: (*parser).callonBoolType1, + expr: &choiceExpr{ + pos: position{line: 852, col: 6, offset: 20484}, + alternatives: []interface{}{ + &seqExpr{ + pos: position{line: 852, col: 6, offset: 20484}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 852, col: 6, offset: 20484}, + val: "bool", + ignoreCase: true, + }, + ¬Expr{ + pos: position{line: 852, col: 14, offset: 20492}, + expr: &ruleRefExpr{ + pos: position{line: 852, col: 15, offset: 20493}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + &seqExpr{ + pos: position{line: 853, col: 5, offset: 20518}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 853, col: 5, offset: 20518}, + val: "boolean", + ignoreCase: true, + }, + ¬Expr{ + pos: position{line: 853, col: 16, offset: 20529}, + expr: &ruleRefExpr{ + pos: position{line: 853, col: 17, offset: 20530}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + }, + }, + }, + }, + { + name: "Value", + pos: position{line: 863, col: 1, offset: 20696}, + expr: &choiceExpr{ + pos: position{line: 864, col: 4, offset: 20705}, + alternatives: []interface{}{ + &ruleRefExpr{ + pos: position{line: 864, col: 4, offset: 20705}, + name: "NumberLiteral", + }, + &ruleRefExpr{ + pos: position{line: 865, col: 4, offset: 20722}, + name: "StringLiteral", + }, + &ruleRefExpr{ + pos: position{line: 866, col: 4, offset: 20739}, + name: "BoolLiteral", + }, + &ruleRefExpr{ + pos: position{line: 867, col: 4, offset: 20754}, + name: "NullLiteral", + }, + }, + }, + }, + { + name: "AnyLiteral", + pos: position{line: 869, col: 1, offset: 20767}, + expr: &actionExpr{ + pos: position{line: 870, col: 4, offset: 20781}, + run: (*parser).callonAnyLiteral1, + expr: &ruleRefExpr{ + pos: position{line: 870, col: 4, offset: 20781}, + name: "AnyToken", + }, + }, + }, + { + name: "DefaultLiteral", + pos: position{line: 878, col: 1, offset: 20919}, + expr: &actionExpr{ + pos: position{line: 879, col: 4, offset: 20937}, + run: (*parser).callonDefaultLiteral1, + expr: &ruleRefExpr{ + pos: position{line: 879, col: 4, offset: 20937}, + name: "DefaultToken", + }, + }, + }, + { + name: "BoolLiteral", + pos: position{line: 887, col: 1, offset: 21083}, + expr: &actionExpr{ + pos: position{line: 888, col: 4, offset: 21098}, + run: (*parser).callonBoolLiteral1, + expr: &labeledExpr{ + pos: position{line: 888, col: 4, offset: 21098}, + label: "b", + expr: &choiceExpr{ + pos: position{line: 888, col: 8, offset: 21102}, + alternatives: []interface{}{ + &ruleRefExpr{ + pos: position{line: 888, col: 8, offset: 21102}, + name: "TrueToken", + }, + &ruleRefExpr{ + pos: position{line: 888, col: 20, offset: 21114}, + name: "FalseToken", + }, + }, + }, + }, + }, + }, + { + name: "NullLiteral", + pos: position{line: 897, col: 1, offset: 21296}, + expr: &actionExpr{ + pos: position{line: 898, col: 4, offset: 21311}, + run: (*parser).callonNullLiteral1, + expr: &ruleRefExpr{ + pos: position{line: 898, col: 4, offset: 21311}, + name: "NullToken", + }, + }, + }, + { + name: "NumberLiteral", + pos: position{line: 906, col: 1, offset: 21451}, + expr: &choiceExpr{ + pos: position{line: 907, col: 4, offset: 21468}, + alternatives: []interface{}{ + &actionExpr{ + pos: position{line: 907, col: 4, offset: 21468}, + run: (*parser).callonNumberLiteral2, + expr: &seqExpr{ + pos: position{line: 907, col: 4, offset: 21468}, + exprs: []interface{}{ + &andExpr{ + pos: position{line: 907, col: 4, offset: 21468}, + expr: &seqExpr{ + pos: position{line: 907, col: 6, offset: 21470}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 907, col: 6, offset: 21470}, + val: "0", + ignoreCase: false, + }, + &litMatcher{ + pos: position{line: 907, col: 10, offset: 21474}, + val: "x", + ignoreCase: true, + }, + }, + }, + }, + &labeledExpr{ + pos: position{line: 907, col: 16, offset: 21480}, + label: "h", + expr: &ruleRefExpr{ + pos: position{line: 907, col: 18, offset: 21482}, + name: "Hex", + }, + }, + }, + }, + }, + &ruleRefExpr{ + pos: position{line: 908, col: 4, offset: 21507}, + name: "Decimal", + }, + }, + }, + }, + { + name: "Sign", + pos: position{line: 910, col: 1, offset: 21516}, + expr: &charClassMatcher{ + pos: position{line: 911, col: 4, offset: 21524}, + val: "[-+]", + chars: []rune{'-', '+'}, + ignoreCase: false, + inverted: false, + }, + }, + { + name: "Integer", + pos: position{line: 913, col: 1, offset: 21530}, + expr: &actionExpr{ + pos: position{line: 914, col: 4, offset: 21541}, + run: (*parser).callonInteger1, + expr: &oneOrMoreExpr{ + pos: position{line: 914, col: 4, offset: 21541}, + expr: &charClassMatcher{ + pos: position{line: 914, col: 4, offset: 21541}, + val: "[0-9]", + ranges: []rune{'0', '9'}, + ignoreCase: false, + inverted: false, + }, + }, + }, + }, + { + name: "NonZeroLeadingInteger", + pos: position{line: 936, col: 1, offset: 22041}, + expr: &actionExpr{ + pos: position{line: 937, col: 4, offset: 22066}, + run: (*parser).callonNonZeroLeadingInteger1, + expr: &choiceExpr{ + pos: position{line: 937, col: 6, offset: 22068}, + alternatives: []interface{}{ + &litMatcher{ + pos: position{line: 937, col: 6, offset: 22068}, + val: "0", + ignoreCase: false, + }, + &seqExpr{ + pos: position{line: 937, col: 12, offset: 22074}, + exprs: []interface{}{ + &charClassMatcher{ + pos: position{line: 937, col: 12, offset: 22074}, + val: "[1-9]", + ranges: []rune{'1', '9'}, + ignoreCase: false, + inverted: false, + }, + &zeroOrMoreExpr{ + pos: position{line: 937, col: 17, offset: 22079}, + expr: &charClassMatcher{ + pos: position{line: 937, col: 17, offset: 22079}, + val: "[0-9]", + ranges: []rune{'0', '9'}, + ignoreCase: false, + inverted: false, + }, + }, + }, + }, + }, + }, + }, + }, + { + name: "Fixnum", + pos: position{line: 940, col: 1, offset: 22112}, + expr: &choiceExpr{ + pos: position{line: 941, col: 4, offset: 22122}, + alternatives: []interface{}{ + &seqExpr{ + pos: position{line: 941, col: 4, offset: 22122}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 941, col: 4, offset: 22122}, + name: "Integer", + }, + &litMatcher{ + pos: position{line: 941, col: 12, offset: 22130}, + val: ".", + ignoreCase: false, + }, + &ruleRefExpr{ + pos: position{line: 941, col: 16, offset: 22134}, + name: "Integer", + }, + }, + }, + &seqExpr{ + pos: position{line: 942, col: 4, offset: 22145}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 942, col: 4, offset: 22145}, + name: "Integer", + }, + &zeroOrOneExpr{ + pos: position{line: 942, col: 12, offset: 22153}, + expr: &litMatcher{ + pos: position{line: 942, col: 12, offset: 22153}, + val: ".", + ignoreCase: false, + }, + }, + }, + }, + &seqExpr{ + pos: position{line: 943, col: 4, offset: 22161}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 943, col: 4, offset: 22161}, + val: ".", + ignoreCase: false, + }, + &ruleRefExpr{ + pos: position{line: 943, col: 8, offset: 22165}, + name: "Integer", + }, + }, + }, + }, + }, + }, + { + name: "Decimal", + pos: position{line: 945, col: 1, offset: 22174}, + expr: &actionExpr{ + pos: position{line: 946, col: 4, offset: 22185}, + run: (*parser).callonDecimal1, + expr: &seqExpr{ + pos: position{line: 946, col: 4, offset: 22185}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 946, col: 4, offset: 22185}, + name: "Fixnum", + }, + &zeroOrOneExpr{ + pos: position{line: 946, col: 11, offset: 22192}, + expr: &seqExpr{ + pos: position{line: 946, col: 13, offset: 22194}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 946, col: 13, offset: 22194}, + val: "e", + ignoreCase: true, + }, + &zeroOrOneExpr{ + pos: position{line: 946, col: 18, offset: 22199}, + expr: &ruleRefExpr{ + pos: position{line: 946, col: 18, offset: 22199}, + name: "Sign", + }, + }, + &ruleRefExpr{ + pos: position{line: 946, col: 24, offset: 22205}, + name: "Integer", + }, + }, + }, + }, + }, + }, + }, + }, + { + name: "Hex", + pos: position{line: 967, col: 1, offset: 22685}, + expr: &actionExpr{ + pos: position{line: 968, col: 4, offset: 22692}, + run: (*parser).callonHex1, + expr: &seqExpr{ + pos: position{line: 968, col: 4, offset: 22692}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 968, col: 4, offset: 22692}, + val: "0x", + ignoreCase: false, + }, + &oneOrMoreExpr{ + pos: position{line: 968, col: 9, offset: 22697}, + expr: &charClassMatcher{ + pos: position{line: 968, col: 11, offset: 22699}, + val: "[0-9A-Fa-f]", + ranges: []rune{'0', '9', 'A', 'F', 'a', 'f'}, + ignoreCase: false, + inverted: false, + }, + }, + ¬Expr{ + pos: position{line: 968, col: 26, offset: 22714}, + expr: &ruleRefExpr{ + pos: position{line: 968, col: 27, offset: 22715}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + }, + }, + { + name: "StringLiteral", + pos: position{line: 976, col: 1, offset: 22866}, + expr: &choiceExpr{ + pos: position{line: 977, col: 4, offset: 22883}, + alternatives: []interface{}{ + &ruleRefExpr{ + pos: position{line: 977, col: 4, offset: 22883}, + name: "HexString", + }, + &ruleRefExpr{ + pos: position{line: 978, col: 4, offset: 22896}, + name: "NormalString", + }, + }, + }, + }, + { + name: "HexString", + pos: position{line: 980, col: 1, offset: 22910}, + expr: &actionExpr{ + pos: position{line: 981, col: 4, offset: 22923}, + run: (*parser).callonHexString1, + expr: &seqExpr{ + pos: position{line: 981, col: 4, offset: 22923}, + exprs: []interface{}{ + &choiceExpr{ + pos: position{line: 981, col: 6, offset: 22925}, + alternatives: []interface{}{ + &litMatcher{ + pos: position{line: 981, col: 6, offset: 22925}, + val: "hex", + ignoreCase: true, + }, + &litMatcher{ + pos: position{line: 981, col: 15, offset: 22934}, + val: "x", + ignoreCase: true, + }, + }, + }, + &litMatcher{ + pos: position{line: 981, col: 22, offset: 22941}, + val: "'", + ignoreCase: false, + }, + &labeledExpr{ + pos: position{line: 981, col: 26, offset: 22945}, + label: "s", + expr: &zeroOrMoreExpr{ + pos: position{line: 981, col: 28, offset: 22947}, + expr: &actionExpr{ + pos: position{line: 981, col: 29, offset: 22948}, + run: (*parser).callonHexString9, + expr: &seqExpr{ + pos: position{line: 981, col: 29, offset: 22948}, + exprs: []interface{}{ + &charClassMatcher{ + pos: position{line: 981, col: 29, offset: 22948}, + val: "[0-9a-fA-F]", + ranges: []rune{'0', '9', 'a', 'f', 'A', 'F'}, + ignoreCase: false, + inverted: false, + }, + &charClassMatcher{ + pos: position{line: 981, col: 40, offset: 22959}, + val: "[0-9a-fA-F]", + ranges: []rune{'0', '9', 'a', 'f', 'A', 'F'}, + ignoreCase: false, + inverted: false, + }, + }, + }, + }, + }, + }, + &litMatcher{ + pos: position{line: 981, col: 78, offset: 22997}, + val: "'", + ignoreCase: false, + }, + }, + }, + }, + }, + { + name: "NormalString", + pos: position{line: 990, col: 1, offset: 23180}, + expr: &actionExpr{ + pos: position{line: 991, col: 4, offset: 23196}, + run: (*parser).callonNormalString1, + expr: &seqExpr{ + pos: position{line: 991, col: 4, offset: 23196}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 991, col: 4, offset: 23196}, + val: "'", + ignoreCase: false, + }, + &labeledExpr{ + pos: position{line: 991, col: 8, offset: 23200}, + label: "s", + expr: &zeroOrMoreExpr{ + pos: position{line: 991, col: 10, offset: 23202}, + expr: &actionExpr{ + pos: position{line: 991, col: 12, offset: 23204}, + run: (*parser).callonNormalString6, + expr: &choiceExpr{ + pos: position{line: 991, col: 14, offset: 23206}, + alternatives: []interface{}{ + &charClassMatcher{ + pos: position{line: 991, col: 14, offset: 23206}, + val: "[^'\\r\\n\\\\]", + chars: []rune{'\'', '\r', '\n', '\\'}, + ignoreCase: false, + inverted: true, + }, + &seqExpr{ + pos: position{line: 991, col: 27, offset: 23219}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 991, col: 27, offset: 23219}, + val: "\\", + ignoreCase: false, + }, + &anyMatcher{ + line: 991, col: 32, offset: 23224, + }, + }, + }, + }, + }, + }, + }, + }, + &litMatcher{ + pos: position{line: 991, col: 62, offset: 23254}, + val: "'", + ignoreCase: false, + }, + }, + }, + }, + }, + { + name: "SelectToken", + pos: position{line: 1016, col: 1, offset: 23822}, + expr: &seqExpr{ + pos: position{line: 1017, col: 4, offset: 23837}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 1017, col: 4, offset: 23837}, + val: "select", + ignoreCase: true, + }, + ¬Expr{ + pos: position{line: 1017, col: 14, offset: 23847}, + expr: &ruleRefExpr{ + pos: position{line: 1017, col: 15, offset: 23848}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + }, + { + name: "FromToken", + pos: position{line: 1019, col: 1, offset: 23870}, + expr: &seqExpr{ + pos: position{line: 1020, col: 4, offset: 23883}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 1020, col: 4, offset: 23883}, + val: "from", + ignoreCase: true, + }, + ¬Expr{ + pos: position{line: 1020, col: 12, offset: 23891}, + expr: &ruleRefExpr{ + pos: position{line: 1020, col: 13, offset: 23892}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + }, + { + name: "WhereToken", + pos: position{line: 1022, col: 1, offset: 23914}, + expr: &seqExpr{ + pos: position{line: 1023, col: 4, offset: 23928}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 1023, col: 4, offset: 23928}, + val: "where", + ignoreCase: true, + }, + ¬Expr{ + pos: position{line: 1023, col: 13, offset: 23937}, + expr: &ruleRefExpr{ + pos: position{line: 1023, col: 14, offset: 23938}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + }, + { + name: "OrderToken", + pos: position{line: 1025, col: 1, offset: 23960}, + expr: &seqExpr{ + pos: position{line: 1026, col: 4, offset: 23974}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 1026, col: 4, offset: 23974}, + val: "order", + ignoreCase: true, + }, + ¬Expr{ + pos: position{line: 1026, col: 13, offset: 23983}, + expr: &ruleRefExpr{ + pos: position{line: 1026, col: 14, offset: 23984}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + }, + { + name: "ByToken", + pos: position{line: 1028, col: 1, offset: 24006}, + expr: &seqExpr{ + pos: position{line: 1029, col: 4, offset: 24017}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 1029, col: 4, offset: 24017}, + val: "by", + ignoreCase: true, + }, + ¬Expr{ + pos: position{line: 1029, col: 10, offset: 24023}, + expr: &ruleRefExpr{ + pos: position{line: 1029, col: 11, offset: 24024}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + }, + { + name: "GroupToken", + pos: position{line: 1031, col: 1, offset: 24046}, + expr: &seqExpr{ + pos: position{line: 1032, col: 4, offset: 24060}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 1032, col: 4, offset: 24060}, + val: "group", + ignoreCase: true, + }, + ¬Expr{ + pos: position{line: 1032, col: 13, offset: 24069}, + expr: &ruleRefExpr{ + pos: position{line: 1032, col: 14, offset: 24070}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + }, + { + name: "LimitToken", + pos: position{line: 1034, col: 1, offset: 24092}, + expr: &seqExpr{ + pos: position{line: 1035, col: 4, offset: 24106}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 1035, col: 4, offset: 24106}, + val: "limit", + ignoreCase: true, + }, + ¬Expr{ + pos: position{line: 1035, col: 13, offset: 24115}, + expr: &ruleRefExpr{ + pos: position{line: 1035, col: 14, offset: 24116}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + }, + { + name: "OffsetToken", + pos: position{line: 1037, col: 1, offset: 24138}, + expr: &seqExpr{ + pos: position{line: 1038, col: 4, offset: 24153}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 1038, col: 4, offset: 24153}, + val: "offset", + ignoreCase: true, + }, + ¬Expr{ + pos: position{line: 1038, col: 14, offset: 24163}, + expr: &ruleRefExpr{ + pos: position{line: 1038, col: 15, offset: 24164}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + }, + { + name: "UpdateToken", + pos: position{line: 1040, col: 1, offset: 24186}, + expr: &seqExpr{ + pos: position{line: 1041, col: 4, offset: 24201}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 1041, col: 4, offset: 24201}, + val: "update", + ignoreCase: true, + }, + ¬Expr{ + pos: position{line: 1041, col: 14, offset: 24211}, + expr: &ruleRefExpr{ + pos: position{line: 1041, col: 15, offset: 24212}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + }, + { + name: "SetToken", + pos: position{line: 1043, col: 1, offset: 24234}, + expr: &seqExpr{ + pos: position{line: 1044, col: 4, offset: 24246}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 1044, col: 4, offset: 24246}, + val: "set", + ignoreCase: true, + }, + ¬Expr{ + pos: position{line: 1044, col: 11, offset: 24253}, + expr: &ruleRefExpr{ + pos: position{line: 1044, col: 12, offset: 24254}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + }, + { + name: "DeleteToken", + pos: position{line: 1046, col: 1, offset: 24276}, + expr: &seqExpr{ + pos: position{line: 1047, col: 4, offset: 24291}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 1047, col: 4, offset: 24291}, + val: "delete", + ignoreCase: true, + }, + ¬Expr{ + pos: position{line: 1047, col: 14, offset: 24301}, + expr: &ruleRefExpr{ + pos: position{line: 1047, col: 15, offset: 24302}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + }, + { + name: "InsertToken", + pos: position{line: 1049, col: 1, offset: 24324}, + expr: &seqExpr{ + pos: position{line: 1050, col: 4, offset: 24339}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 1050, col: 4, offset: 24339}, + val: "insert", + ignoreCase: true, + }, + ¬Expr{ + pos: position{line: 1050, col: 14, offset: 24349}, + expr: &ruleRefExpr{ + pos: position{line: 1050, col: 15, offset: 24350}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + }, + { + name: "IntoToken", + pos: position{line: 1052, col: 1, offset: 24372}, + expr: &seqExpr{ + pos: position{line: 1053, col: 4, offset: 24385}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 1053, col: 4, offset: 24385}, + val: "into", + ignoreCase: true, + }, + ¬Expr{ + pos: position{line: 1053, col: 12, offset: 24393}, + expr: &ruleRefExpr{ + pos: position{line: 1053, col: 13, offset: 24394}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + }, + { + name: "ValuesToken", + pos: position{line: 1055, col: 1, offset: 24416}, + expr: &seqExpr{ + pos: position{line: 1056, col: 4, offset: 24431}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 1056, col: 4, offset: 24431}, + val: "values", + ignoreCase: true, + }, + ¬Expr{ + pos: position{line: 1056, col: 14, offset: 24441}, + expr: &ruleRefExpr{ + pos: position{line: 1056, col: 15, offset: 24442}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + }, + { + name: "CreateToken", + pos: position{line: 1058, col: 1, offset: 24464}, + expr: &seqExpr{ + pos: position{line: 1059, col: 4, offset: 24479}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 1059, col: 4, offset: 24479}, + val: "create", + ignoreCase: true, + }, + ¬Expr{ + pos: position{line: 1059, col: 14, offset: 24489}, + expr: &ruleRefExpr{ + pos: position{line: 1059, col: 15, offset: 24490}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + }, + { + name: "TableToken", + pos: position{line: 1061, col: 1, offset: 24512}, + expr: &seqExpr{ + pos: position{line: 1062, col: 4, offset: 24526}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 1062, col: 4, offset: 24526}, + val: "table", + ignoreCase: true, + }, + ¬Expr{ + pos: position{line: 1062, col: 13, offset: 24535}, + expr: &ruleRefExpr{ + pos: position{line: 1062, col: 14, offset: 24536}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + }, + { + name: "IndexToken", + pos: position{line: 1064, col: 1, offset: 24558}, + expr: &seqExpr{ + pos: position{line: 1065, col: 4, offset: 24572}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 1065, col: 4, offset: 24572}, + val: "index", + ignoreCase: true, + }, + ¬Expr{ + pos: position{line: 1065, col: 13, offset: 24581}, + expr: &ruleRefExpr{ + pos: position{line: 1065, col: 14, offset: 24582}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + }, + { + name: "UniqueToken", + pos: position{line: 1067, col: 1, offset: 24604}, + expr: &seqExpr{ + pos: position{line: 1068, col: 4, offset: 24619}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 1068, col: 4, offset: 24619}, + val: "unique", + ignoreCase: true, + }, + ¬Expr{ + pos: position{line: 1068, col: 14, offset: 24629}, + expr: &ruleRefExpr{ + pos: position{line: 1068, col: 15, offset: 24630}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + }, + { + name: "DefaultToken", + pos: position{line: 1070, col: 1, offset: 24652}, + expr: &seqExpr{ + pos: position{line: 1071, col: 4, offset: 24668}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 1071, col: 4, offset: 24668}, + val: "default", + ignoreCase: true, + }, + ¬Expr{ + pos: position{line: 1071, col: 15, offset: 24679}, + expr: &ruleRefExpr{ + pos: position{line: 1071, col: 16, offset: 24680}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + }, + { + name: "PrimaryToken", + pos: position{line: 1073, col: 1, offset: 24702}, + expr: &seqExpr{ + pos: position{line: 1074, col: 4, offset: 24718}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 1074, col: 4, offset: 24718}, + val: "primary", + ignoreCase: true, + }, + ¬Expr{ + pos: position{line: 1074, col: 15, offset: 24729}, + expr: &ruleRefExpr{ + pos: position{line: 1074, col: 16, offset: 24730}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + }, + { + name: "KeyToken", + pos: position{line: 1076, col: 1, offset: 24752}, + expr: &seqExpr{ + pos: position{line: 1077, col: 4, offset: 24764}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 1077, col: 4, offset: 24764}, + val: "key", + ignoreCase: true, + }, + ¬Expr{ + pos: position{line: 1077, col: 11, offset: 24771}, + expr: &ruleRefExpr{ + pos: position{line: 1077, col: 12, offset: 24772}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + }, + { + name: "ReferencesToken", + pos: position{line: 1079, col: 1, offset: 24794}, + expr: &seqExpr{ + pos: position{line: 1080, col: 4, offset: 24813}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 1080, col: 4, offset: 24813}, + val: "references", + ignoreCase: true, + }, + ¬Expr{ + pos: position{line: 1080, col: 18, offset: 24827}, + expr: &ruleRefExpr{ + pos: position{line: 1080, col: 19, offset: 24828}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + }, + { + name: "AutoincrementToken", + pos: position{line: 1082, col: 1, offset: 24850}, + expr: &seqExpr{ + pos: position{line: 1083, col: 4, offset: 24872}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 1083, col: 4, offset: 24872}, + val: "autoincrement", + ignoreCase: true, + }, + ¬Expr{ + pos: position{line: 1083, col: 21, offset: 24889}, + expr: &ruleRefExpr{ + pos: position{line: 1083, col: 22, offset: 24890}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + }, + { + name: "OnToken", + pos: position{line: 1085, col: 1, offset: 24912}, + expr: &seqExpr{ + pos: position{line: 1086, col: 4, offset: 24923}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 1086, col: 4, offset: 24923}, + val: "on", + ignoreCase: true, + }, + ¬Expr{ + pos: position{line: 1086, col: 10, offset: 24929}, + expr: &ruleRefExpr{ + pos: position{line: 1086, col: 11, offset: 24930}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + }, + { + name: "TrueToken", + pos: position{line: 1088, col: 1, offset: 24952}, + expr: &actionExpr{ + pos: position{line: 1089, col: 4, offset: 24965}, + run: (*parser).callonTrueToken1, + expr: &seqExpr{ + pos: position{line: 1089, col: 4, offset: 24965}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 1089, col: 4, offset: 24965}, + val: "true", + ignoreCase: true, + }, + ¬Expr{ + pos: position{line: 1089, col: 12, offset: 24973}, + expr: &ruleRefExpr{ + pos: position{line: 1089, col: 13, offset: 24974}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + }, + }, + { + name: "FalseToken", + pos: position{line: 1092, col: 1, offset: 25028}, + expr: &actionExpr{ + pos: position{line: 1093, col: 4, offset: 25042}, + run: (*parser).callonFalseToken1, + expr: &seqExpr{ + pos: position{line: 1093, col: 4, offset: 25042}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 1093, col: 4, offset: 25042}, + val: "false", + ignoreCase: true, + }, + ¬Expr{ + pos: position{line: 1093, col: 13, offset: 25051}, + expr: &ruleRefExpr{ + pos: position{line: 1093, col: 14, offset: 25052}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + }, + }, + { + name: "NullToken", + pos: position{line: 1096, col: 1, offset: 25106}, + expr: &seqExpr{ + pos: position{line: 1097, col: 4, offset: 25119}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 1097, col: 4, offset: 25119}, + val: "null", + ignoreCase: true, + }, + ¬Expr{ + pos: position{line: 1097, col: 12, offset: 25127}, + expr: &ruleRefExpr{ + pos: position{line: 1097, col: 13, offset: 25128}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + }, + { + name: "IsToken", + pos: position{line: 1099, col: 1, offset: 25150}, + expr: &seqExpr{ + pos: position{line: 1100, col: 4, offset: 25161}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 1100, col: 4, offset: 25161}, + val: "is", + ignoreCase: true, + }, + ¬Expr{ + pos: position{line: 1100, col: 10, offset: 25167}, + expr: &ruleRefExpr{ + pos: position{line: 1100, col: 11, offset: 25168}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + }, + { + name: "NullsToken", + pos: position{line: 1102, col: 1, offset: 25190}, + expr: &seqExpr{ + pos: position{line: 1103, col: 4, offset: 25204}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 1103, col: 4, offset: 25204}, + val: "nulls", + ignoreCase: true, + }, + ¬Expr{ + pos: position{line: 1103, col: 13, offset: 25213}, + expr: &ruleRefExpr{ + pos: position{line: 1103, col: 14, offset: 25214}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + }, + { + name: "LastToken", + pos: position{line: 1105, col: 1, offset: 25236}, + expr: &actionExpr{ + pos: position{line: 1106, col: 4, offset: 25249}, + run: (*parser).callonLastToken1, + expr: &seqExpr{ + pos: position{line: 1106, col: 4, offset: 25249}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 1106, col: 4, offset: 25249}, + val: "last", + ignoreCase: true, + }, + ¬Expr{ + pos: position{line: 1106, col: 12, offset: 25257}, + expr: &ruleRefExpr{ + pos: position{line: 1106, col: 13, offset: 25258}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + }, + }, + { + name: "FirstToken", + pos: position{line: 1109, col: 1, offset: 25312}, + expr: &actionExpr{ + pos: position{line: 1110, col: 4, offset: 25326}, + run: (*parser).callonFirstToken1, + expr: &seqExpr{ + pos: position{line: 1110, col: 4, offset: 25326}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 1110, col: 4, offset: 25326}, + val: "first", + ignoreCase: true, + }, + ¬Expr{ + pos: position{line: 1110, col: 13, offset: 25335}, + expr: &ruleRefExpr{ + pos: position{line: 1110, col: 14, offset: 25336}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + }, + }, + { + name: "AndToken", + pos: position{line: 1113, col: 1, offset: 25390}, + expr: &seqExpr{ + pos: position{line: 1114, col: 4, offset: 25402}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 1114, col: 4, offset: 25402}, + val: "and", + ignoreCase: true, + }, + ¬Expr{ + pos: position{line: 1114, col: 11, offset: 25409}, + expr: &ruleRefExpr{ + pos: position{line: 1114, col: 12, offset: 25410}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + }, + { + name: "OrToken", + pos: position{line: 1116, col: 1, offset: 25432}, + expr: &seqExpr{ + pos: position{line: 1117, col: 4, offset: 25443}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 1117, col: 4, offset: 25443}, + val: "or", + ignoreCase: true, + }, + ¬Expr{ + pos: position{line: 1117, col: 10, offset: 25449}, + expr: &ruleRefExpr{ + pos: position{line: 1117, col: 11, offset: 25450}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + }, + { + name: "NotToken", + pos: position{line: 1119, col: 1, offset: 25472}, + expr: &seqExpr{ + pos: position{line: 1120, col: 4, offset: 25484}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 1120, col: 4, offset: 25484}, + val: "not", + ignoreCase: true, + }, + ¬Expr{ + pos: position{line: 1120, col: 11, offset: 25491}, + expr: &ruleRefExpr{ + pos: position{line: 1120, col: 12, offset: 25492}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + }, + { + name: "InToken", + pos: position{line: 1122, col: 1, offset: 25514}, + expr: &seqExpr{ + pos: position{line: 1123, col: 4, offset: 25525}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 1123, col: 4, offset: 25525}, + val: "in", + ignoreCase: true, + }, + ¬Expr{ + pos: position{line: 1123, col: 10, offset: 25531}, + expr: &ruleRefExpr{ + pos: position{line: 1123, col: 11, offset: 25532}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + }, + { + name: "LikeToken", + pos: position{line: 1125, col: 1, offset: 25554}, + expr: &seqExpr{ + pos: position{line: 1126, col: 4, offset: 25567}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 1126, col: 4, offset: 25567}, + val: "like", + ignoreCase: true, + }, + ¬Expr{ + pos: position{line: 1126, col: 12, offset: 25575}, + expr: &ruleRefExpr{ + pos: position{line: 1126, col: 13, offset: 25576}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + }, + { + name: "AscToken", + pos: position{line: 1128, col: 1, offset: 25598}, + expr: &actionExpr{ + pos: position{line: 1129, col: 4, offset: 25610}, + run: (*parser).callonAscToken1, + expr: &seqExpr{ + pos: position{line: 1129, col: 4, offset: 25610}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 1129, col: 4, offset: 25610}, + val: "asc", + ignoreCase: true, + }, + ¬Expr{ + pos: position{line: 1129, col: 11, offset: 25617}, + expr: &ruleRefExpr{ + pos: position{line: 1129, col: 12, offset: 25618}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + }, + }, + { + name: "DescToken", + pos: position{line: 1132, col: 1, offset: 25672}, + expr: &actionExpr{ + pos: position{line: 1133, col: 4, offset: 25685}, + run: (*parser).callonDescToken1, + expr: &seqExpr{ + pos: position{line: 1133, col: 4, offset: 25685}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 1133, col: 4, offset: 25685}, + val: "desc", + ignoreCase: true, + }, + ¬Expr{ + pos: position{line: 1133, col: 12, offset: 25693}, + expr: &ruleRefExpr{ + pos: position{line: 1133, col: 13, offset: 25694}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + }, + }, + { + name: "CastToken", + pos: position{line: 1136, col: 1, offset: 25748}, + expr: &seqExpr{ + pos: position{line: 1137, col: 4, offset: 25761}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 1137, col: 4, offset: 25761}, + val: "cast", + ignoreCase: true, + }, + ¬Expr{ + pos: position{line: 1137, col: 12, offset: 25769}, + expr: &ruleRefExpr{ + pos: position{line: 1137, col: 13, offset: 25770}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + }, + { + name: "AsToken", + pos: position{line: 1139, col: 1, offset: 25792}, + expr: &seqExpr{ + pos: position{line: 1140, col: 4, offset: 25803}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 1140, col: 4, offset: 25803}, + val: "as", + ignoreCase: true, + }, + ¬Expr{ + pos: position{line: 1140, col: 10, offset: 25809}, + expr: &ruleRefExpr{ + pos: position{line: 1140, col: 11, offset: 25810}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + }, + { + name: "SeparatorToken", + pos: position{line: 1142, col: 1, offset: 25832}, + expr: &litMatcher{ + pos: position{line: 1143, col: 4, offset: 25850}, + val: ",", + ignoreCase: false, + }, + }, + { + name: "AnyToken", + pos: position{line: 1145, col: 1, offset: 25855}, + expr: &litMatcher{ + pos: position{line: 1146, col: 4, offset: 25867}, + val: "*", + ignoreCase: false, + }, + }, + { + name: "Identifier", + pos: position{line: 1149, col: 1, offset: 25890}, + expr: &choiceExpr{ + pos: position{line: 1150, col: 4, offset: 25904}, + alternatives: []interface{}{ + &ruleRefExpr{ + pos: position{line: 1150, col: 4, offset: 25904}, + name: "NormalIdentifier", + }, + &ruleRefExpr{ + pos: position{line: 1151, col: 4, offset: 25924}, + name: "StringIdentifier", + }, + }, + }, + }, + { + name: "NormalIdentifier", + pos: position{line: 1153, col: 1, offset: 25942}, + expr: &actionExpr{ + pos: position{line: 1154, col: 4, offset: 25962}, + run: (*parser).callonNormalIdentifier1, + expr: &seqExpr{ + pos: position{line: 1154, col: 4, offset: 25962}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 1154, col: 4, offset: 25962}, + name: "NormalIdentifierStart", + }, + &zeroOrMoreExpr{ + pos: position{line: 1154, col: 26, offset: 25984}, + expr: &ruleRefExpr{ + pos: position{line: 1154, col: 26, offset: 25984}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + }, + }, + { + name: "NormalIdentifierStart", + pos: position{line: 1163, col: 1, offset: 26171}, + expr: &charClassMatcher{ + pos: position{line: 1164, col: 4, offset: 26196}, + val: "[a-zA-Z\\x80-\\xff]", + ranges: []rune{'a', 'z', 'A', 'Z', '\u0080', 'ÿ'}, + ignoreCase: false, + inverted: false, + }, + }, + { + name: "NormalIdentifierRest", + pos: position{line: 1166, col: 1, offset: 26215}, + expr: &charClassMatcher{ + pos: position{line: 1167, col: 4, offset: 26239}, + val: "[a-zA-Z0-9_\\x80-\\xff]", + chars: []rune{'_'}, + ranges: []rune{'a', 'z', 'A', 'Z', '0', '9', '\u0080', 'ÿ'}, + ignoreCase: false, + inverted: false, + }, + }, + { + name: "StringIdentifier", + pos: position{line: 1169, col: 1, offset: 26262}, + expr: &actionExpr{ + pos: position{line: 1170, col: 4, offset: 26282}, + run: (*parser).callonStringIdentifier1, + expr: &seqExpr{ + pos: position{line: 1170, col: 4, offset: 26282}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 1170, col: 4, offset: 26282}, + val: "\"", + ignoreCase: false, + }, + &labeledExpr{ + pos: position{line: 1170, col: 9, offset: 26287}, + label: "s", + expr: &zeroOrMoreExpr{ + pos: position{line: 1170, col: 11, offset: 26289}, + expr: &actionExpr{ + pos: position{line: 1170, col: 13, offset: 26291}, + run: (*parser).callonStringIdentifier6, + expr: &choiceExpr{ + pos: position{line: 1170, col: 15, offset: 26293}, + alternatives: []interface{}{ + &charClassMatcher{ + pos: position{line: 1170, col: 15, offset: 26293}, + val: "[^\"\\r\\n\\\\]", + chars: []rune{'"', '\r', '\n', '\\'}, + ignoreCase: false, + inverted: true, + }, + &seqExpr{ + pos: position{line: 1170, col: 28, offset: 26306}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 1170, col: 28, offset: 26306}, + val: "\\", + ignoreCase: false, + }, + &anyMatcher{ + line: 1170, col: 33, offset: 26311, + }, + }, + }, + }, + }, + }, + }, + }, + &litMatcher{ + pos: position{line: 1170, col: 63, offset: 26341}, + val: "\"", + ignoreCase: false, + }, + }, + }, + }, + }, + { + name: "_", + pos: position{line: 1195, col: 1, offset: 26921}, + expr: &zeroOrMoreExpr{ + pos: position{line: 1196, col: 4, offset: 26926}, + expr: &ruleRefExpr{ + pos: position{line: 1196, col: 4, offset: 26926}, + name: "Whitespace", + }, + }, + }, + { + name: "Whitespace", + pos: position{line: 1198, col: 1, offset: 26939}, + expr: &choiceExpr{ + pos: position{line: 1199, col: 4, offset: 26953}, + alternatives: []interface{}{ + &litMatcher{ + pos: position{line: 1199, col: 4, offset: 26953}, + val: "\t", + ignoreCase: false, + }, + &litMatcher{ + pos: position{line: 1200, col: 4, offset: 26974}, + val: "\n", + ignoreCase: false, + }, + &litMatcher{ + pos: position{line: 1201, col: 4, offset: 26995}, + val: "\v", + ignoreCase: false, + }, + &litMatcher{ + pos: position{line: 1202, col: 4, offset: 27016}, + val: "\f", + ignoreCase: false, + }, + &litMatcher{ + pos: position{line: 1203, col: 4, offset: 27037}, + val: "\r", + ignoreCase: false, + }, + &litMatcher{ + pos: position{line: 1204, col: 4, offset: 27058}, + val: " ", + ignoreCase: false, + }, + }, + }, + }, + { + name: "EOF", + pos: position{line: 1206, col: 1, offset: 27080}, + expr: ¬Expr{ + pos: position{line: 1207, col: 4, offset: 27087}, + expr: &anyMatcher{ + line: 1207, col: 5, offset: 27088, + }, + }, + }, + }, +} + +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 assertNodeSlice(prepend(x, assertSlice(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) { + node := &ast.SelectStmtNode{} + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + node.Column = assertExprSlice(prepend(f, assertSlice(fs))) + if table != nil { + node.Table = table.(*ast.IdentifierNode) + } + if where != nil { + node.Where = where.(*ast.WhereOptionNode) + } + groupSlice := assertSlice(group) + node.Group = make([]*ast.GroupOptionNode, len(groupSlice)) + for idx := range groupSlice { + node.Group[idx] = groupSlice[idx].(*ast.GroupOptionNode) + } + orderSlice := assertSlice(order) + node.Order = make([]*ast.OrderOptionNode, len(orderSlice)) + for idx := range orderSlice { + node.Order[idx] = orderSlice[idx].(*ast.OrderOptionNode) + } + if limit != nil { + node.Limit = limit.(*ast.LimitOptionNode) + } + if offset != nil { + node.Offset = offset.(*ast.OffsetOptionNode) + } + return node, 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) { + node := &ast.UpdateStmtNode{} + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + node.Table = table.(*ast.IdentifierNode) + assignSlice := prepend(a, assertSlice(as)) + node.Assignment = make([]*ast.AssignOperatorNode, len(assignSlice)) + for idx := range assignSlice { + node.Assignment[idx] = assignSlice[idx].(*ast.AssignOperatorNode) + } + if where != nil { + node.Where = where.(*ast.WhereOptionNode) + } + return node, 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) { + node := &ast.DeleteStmtNode{} + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + node.Table = table.(*ast.IdentifierNode) + if where != nil { + node.Where = where.(*ast.WhereOptionNode) + } + return node, 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) { + node := &ast.InsertStmtNode{} + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + node.Table = table.(*ast.IdentifierNode) + switch i := insert.(type) { + case *ast.InsertWithColumnOptionNode: + node.Insert = i + case *ast.InsertWithDefaultOptionNode: + node.Insert = i + default: + panic(fmt.Sprintf("unknown insert type %T", insert)) + } + return node, 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, assertSlice(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) { + node := &ast.CreateTableStmtNode{} + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + node.Table = table.(*ast.IdentifierNode) + columnSlice := assertSlice(column) + node.Column = make([]*ast.ColumnSchemaNode, len(columnSlice)) + for idx := range columnSlice { + node.Column[idx] = columnSlice[idx].(*ast.ColumnSchemaNode) + } + return node, 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) { + node := &ast.ColumnSchemaNode{} + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + node.Column = i.(*ast.IdentifierNode) + node.DataType = t.(ast.TypeNode) + constraintSlice := assertSlice(cs) + node.Constraint = make([]ast.Node, len(constraintSlice)) + for idx, constraint := range constraintSlice { + switch c := constraint.(type) { + case *ast.PrimaryOptionNode: + node.Constraint[idx] = c + case *ast.NotNullOptionNode: + node.Constraint[idx] = c + case *ast.UniqueOptionNode: + node.Constraint[idx] = c + case *ast.DefaultOptionNode: + node.Constraint[idx] = c + case *ast.ForeignOptionNode: + node.Constraint[idx] = c + case *ast.AutoIncrementOptionNode: + node.Constraint[idx] = c + default: + panic(fmt.Sprintf("unknown constraint type %T", c)) + } + } + return node, 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) { + node := &ast.CreateIndexStmtNode{} + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + node.Index = index.(*ast.IdentifierNode) + node.Table = table.(*ast.IdentifierNode) + columnSlice := assertSlice(prepend(i, assertSlice(is))) + node.Column = make([]*ast.IdentifierNode, len(columnSlice)) + for idx := range columnSlice { + node.Column[idx] = columnSlice[idx].(*ast.IdentifierNode) + } + if unique != nil { + node.Unique = unique.(*ast.UniqueOptionNode) + } + return node, 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) { + node := &ast.WhereOptionNode{} + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + node.Condition = e.(ast.ExprNode) + return node, 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, assertSlice(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) { + node := &ast.OrderOptionNode{} + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + node.Expr = i.(ast.ExprNode) + node.Desc = s != nil && string(s.([]byte)) == "desc" + node.NullsFirst = n != nil && string(n.([]byte)) == "first" + return node, 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 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(f, fs interface{}) (interface{}, error) { + return prepend(f, assertSlice(fs)), nil +} + +func (p *parser) callonGroupByClause1() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onGroupByClause1(stack["f"], stack["fs"]) +} + +func (c *current) onGroupColumn1(i interface{}) (interface{}, error) { + node := &ast.GroupOptionNode{} + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + node.Expr = i.(ast.ExprNode) + return node, nil +} + +func (p *parser) callonGroupColumn1() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onGroupColumn1(stack["i"]) +} + +func (c *current) onOffsetClause1(i interface{}) (interface{}, error) { + node := &ast.OffsetOptionNode{} + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + node.Value = i.(*ast.IntegerValueNode) + return node, 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) { + node := &ast.LimitOptionNode{} + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + node.Value = i.(*ast.IntegerValueNode) + return node, 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, assertSlice(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) { + node := &ast.InsertWithColumnOptionNode{} + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + columnSlice := assertSlice(cs) + node.Column = make([]*ast.IdentifierNode, len(columnSlice)) + for idx := range columnSlice { + node.Column[idx] = columnSlice[idx].(*ast.IdentifierNode) + } + valueSlice := assertSlice(vs) + node.Value = make([][]ast.ExprNode, len(valueSlice)+1) + node.Value[0] = v.([]ast.ExprNode) + for idx := range valueSlice { + node.Value[idx+1] = valueSlice[idx].([]ast.ExprNode) + } + return node, 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) { + node := &ast.InsertWithDefaultOptionNode{} + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + return node, 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) { + node := &ast.PrimaryOptionNode{} + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + return node, 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) { + node := &ast.NotNullOptionNode{} + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + return node, 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) { + node := &ast.UniqueOptionNode{} + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + return node, 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) { + node := &ast.DefaultOptionNode{} + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + node.Value = e.(ast.ExprNode) + return node, 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) { + node := &ast.ForeignOptionNode{} + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + node.Table = t.(*ast.IdentifierNode) + node.Column = f.(*ast.IdentifierNode) + return node, 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) { + node := &ast.AutoIncrementOptionNode{} + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + return node, 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.(ast.BinaryOperator), s.(ast.ExprNode)), 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.(ast.ExprNode), assertExprSlice(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.(ast.BinaryOperator), s.(ast.ExprNode)), 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.(ast.ExprNode), assertExprSlice(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.(ast.UnaryOperator), s.(ast.ExprNode)), 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.(ast.ExprNode), assertExprSlice(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) { + node := &ast.InOperatorNode{} + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + node.Right = s.([]ast.ExprNode) + if n != nil { + return opSetTarget(n.(ast.UnaryOperator), node), nil + } + return node, 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) onLogicExpr1Is6(t interface{}) (interface{}, error) { + return t, nil +} + +func (p *parser) callonLogicExpr1Is6() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onLogicExpr1Is6(stack["t"]) +} + +func (c *current) onLogicExpr1Is1(n, u interface{}) (interface{}, error) { + node := &ast.IsOperatorNode{} + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + opSetSubject(node, u.(*ast.NullValueNode)) + if n != nil { + return opSetTarget(n.(ast.UnaryOperator), node), nil + } + return node, nil +} + +func (p *parser) callonLogicExpr1Is1() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onLogicExpr1Is1(stack["n"], stack["u"]) +} + +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) { + node := &ast.LikeOperatorNode{} + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + opSetSubject(node, s.(ast.ExprNode)) + if n != nil { + return opSetTarget(n.(ast.UnaryOperator), node), nil + } + return node, 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.(ast.BinaryOperator), s.(ast.ExprNode)), 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.(ast.BinaryOperator), s.(ast.ExprNode)), 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.(ast.ExprNode), assertExprSlice(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.(ast.BinaryOperator), s.(ast.ExprNode)), 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.(ast.ExprNode), assertExprSlice(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.(ast.BinaryOperator), s.(ast.ExprNode)), 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.(ast.ExprNode), assertExprSlice(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 assertExprSlice(prepend(x, assertSlice(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 assertExprSlice(prepend(x, assertSlice(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.(ast.UnaryOperator), s.(ast.ExprNode)), 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) { + node := &ast.ParenOperatorNode{} + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + opSetTarget(node, e.(ast.ExprNode)) + return node, 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) { + node := &ast.CastOperatorNode{} + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + node.SourceExpr = o.(ast.ExprNode) + node.TargetType = s.(ast.TypeNode) + return node, 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) { + node := &ast.FunctionOperatorNode{} + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + node.Name = i.(*ast.IdentifierNode) + if r != nil { + node.Args = r.([]ast.ExprNode) + } + return node, 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 []ast.ExprNode{a.(*ast.AnyValueNode)}, 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) { + node := &ast.AssignOperatorNode{} + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + node.Column = i.(*ast.IdentifierNode) + node.Expr = e.(ast.ExprNode) + return node, 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) { + var node ast.UnaryOperator + switch string(c.text) { + case "+": + node = &ast.PosOperatorNode{} + case "-": + node = &ast.NegOperatorNode{} + default: + panic(fmt.Sprintf("unknown sign %s", c.text)) + } + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + return node, nil +} + +func (p *parser) callonSignOperator1() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onSignOperator1() +} + +func (c *current) onNotOperator1() (interface{}, error) { + node := &ast.NotOperatorNode{} + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + return node, 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) { + node := &ast.AndOperatorNode{} + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + return node, 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) { + node := &ast.OrOperatorNode{} + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + return node, 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) { + var node ast.BinaryOperator + switch string(c.text) { + case "<=": + node = &ast.LessOrEqualOperatorNode{} + case ">=": + node = &ast.GreaterOrEqualOperatorNode{} + case "<>": + node = &ast.NotEqualOperatorNode{} + case "!=": + node = &ast.NotEqualOperatorNode{} + case "<": + node = &ast.LessOperatorNode{} + case ">": + node = &ast.GreaterOperatorNode{} + case "=": + node = &ast.EqualOperatorNode{} + default: + panic(fmt.Sprintf("unknown comparison operator %s", c.text)) + } + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + return node, nil +} + +func (p *parser) callonCmpOperator1() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onCmpOperator1() +} + +func (c *current) onConcatOperator1() (interface{}, error) { + node := &ast.ConcatOperatorNode{} + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + return node, 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) { + var node ast.BinaryOperator + switch string(c.text) { + case "+": + node = &ast.AddOperatorNode{} + case "-": + node = &ast.SubOperatorNode{} + default: + panic(fmt.Sprintf("unknown addition or subtraction operator %s", c.text)) + } + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + return node, nil +} + +func (p *parser) callonAddSubOperator1() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onAddSubOperator1() +} + +func (c *current) onMulDivModOperator1() (interface{}, error) { + var node ast.BinaryOperator + switch string(c.text) { + case "*": + node = &ast.MulOperatorNode{} + case "/": + node = &ast.DivOperatorNode{} + case "%": + node = &ast.ModOperatorNode{} + default: + panic(fmt.Sprintf("unknown multiplication, division, modulo operator: %s", c.text)) + } + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + return node, nil +} + +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) { + node := &ast.IntTypeNode{} + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + node.Unsigned = true + size, code := toUint(s.([]byte)) + if code != se.ErrorCodeNil { + err := se.Error{ + Position: uint32(c.pos.offset), + Category: se.ErrorCategoryGrammar, + Code: code, + Token: string(c.text), + Prefix: "UIntType", + Message: fmt.Sprintf("cannot parse %s as uint32: %v", s, code), + } + return node, err + } + node.Size = size + return node, 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) { + node := &ast.IntTypeNode{} + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + node.Unsigned = false + size, code := toUint(s.([]byte)) + if code != se.ErrorCodeNil { + err := se.Error{ + Position: uint32(c.pos.offset), + Category: se.ErrorCategoryGrammar, + Code: code, + Token: string(c.text), + Prefix: "IntType", + Message: fmt.Sprintf("cannot parse %s as uint32: %v", s, code), + } + return node, err + } + node.Size = size + return node, 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) { + node := &ast.FixedTypeNode{} + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + node.Unsigned = true + size, code := toUint(s.([]byte)) + if code != se.ErrorCodeNil { + err := se.Error{ + Position: uint32(c.pos.offset), + Category: se.ErrorCategoryGrammar, + Code: code, + Token: string(c.text), + Prefix: "UFixedType", + Message: fmt.Sprintf("cannot parse %s as uint32: %v", s, code), + } + return node, err + } + fractionalDigits, code := toUint(t.([]byte)) + if code != se.ErrorCodeNil { + err := se.Error{ + Position: uint32(c.pos.offset), + Category: se.ErrorCategoryGrammar, + Code: code, + Token: string(c.text), + Prefix: "UFixedType", + Message: fmt.Sprintf("cannot parse %s as uint32: %v", t, code), + } + return node, err + } + node.Size = size + node.FractionalDigits = fractionalDigits + return node, 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) { + node := &ast.FixedTypeNode{} + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + node.Unsigned = false + size, code := toUint(s.([]byte)) + if code != se.ErrorCodeNil { + err := se.Error{ + Position: uint32(c.pos.offset), + Category: se.ErrorCategoryGrammar, + Code: code, + Token: string(c.text), + Prefix: "FixedType", + Message: fmt.Sprintf("cannot parse %s as uint32: %v", s, code), + } + return node, err + } + fractionalDigits, code := toUint(t.([]byte)) + if code != se.ErrorCodeNil { + err := se.Error{ + Position: uint32(c.pos.offset), + Category: se.ErrorCategoryGrammar, + Code: code, + Token: string(c.text), + Prefix: "FixedType", + Message: fmt.Sprintf("cannot parse %s as uint32: %v", t, code), + } + return node, err + } + node.Size = size + node.FractionalDigits = fractionalDigits + return node, 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) { + node := &ast.FixedBytesTypeNode{} + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + size, code := toUint(s.([]byte)) + if code != se.ErrorCodeNil { + err := se.Error{ + Position: uint32(c.pos.offset), + Category: se.ErrorCategoryGrammar, + Code: code, + Token: string(c.text), + Prefix: "FixedBytesType", + Message: fmt.Sprintf("cannot parse %s as uint32: %v", s, code), + } + return node, err + } + node.Size = size + return node, 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) { + node := &ast.FixedBytesTypeNode{} + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + node.Size = 1 + return node, 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) { + node := &ast.DynamicBytesTypeNode{} + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + return node, 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) { + node := &ast.AddressTypeNode{} + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + return node, 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) { + node := &ast.BoolTypeNode{} + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + return node, 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) { + node := &ast.AnyValueNode{} + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + return node, 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) { + node := &ast.DefaultValueNode{} + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + return node, 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) { + node := &ast.BoolValueNode{} + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + node.V = string(b.([]byte)) == "true" + return node, 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) { + node := &ast.NullValueNode{} + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + return node, 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) { + node := &ast.IntegerValueNode{} + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + node.IsAddress = false + v, code := toDecimal(c.text) + if code != se.ErrorCodeNil { + err := se.Error{ + Position: uint32(c.pos.offset), + Category: se.ErrorCategoryGrammar, + Code: code, + Token: string(c.text), + Prefix: "Integer", + Message: fmt.Sprintf("cannot parse %s as decimal: %v", c.text, code), + } + return node, err + } + node.V = v + return node, 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) { + node := &ast.DecimalValueNode{} + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + v, code := toDecimal(c.text) + if code != se.ErrorCodeNil { + err := se.Error{ + Position: uint32(c.pos.offset), + Category: se.ErrorCategoryGrammar, + Code: code, + Token: string(c.text), + Prefix: "Decimal", + Message: fmt.Sprintf("cannot parse %s as decimal: %v", c.text, code), + } + return node, err + } + node.V = v + return node, nil +} + +func (p *parser) callonDecimal1() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onDecimal1() +} + +func (c *current) onHex1() (interface{}, error) { + node := hexToInteger(c.text) + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + return node, nil +} + +func (p *parser) callonHex1() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onHex1() +} + +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) { + node := &ast.BytesValueNode{} + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + node.V = hexToBytes(joinBytes(assertSlice(s))) + return node, 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) { + node := &ast.BytesValueNode{} + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + bs := joinBytes(assertSlice(s)) + v, bad, code := resolveString(bs) + if code != se.ErrorCodeNil { + msg := fmt.Sprintf("cannot resolve escape sequence '%s': %v", + sanitizeBadEscape(bad), code) + err := se.Error{ + Position: uint32(c.pos.offset), + Category: se.ErrorCategoryGrammar, + Code: code, + Token: string(c.text), + Prefix: "NormalString", + Message: msg, + } + return node, err + } + node.V = v + return node, 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) { + node := &ast.IdentifierNode{} + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + node.Name = decodeString(c.text) + return node, 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) { + node := &ast.IdentifierNode{} + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + bs := joinBytes(assertSlice(s)) + name, bad, code := resolveString(bs) + if code != se.ErrorCodeNil { + msg := fmt.Sprintf("cannot resolve escape sequence '%s': %v", + sanitizeBadEscape(bad), code) + err := se.Error{ + Position: uint32(c.pos.offset), + Category: se.ErrorCategoryGrammar, + Code: code, + Token: string(c.text), + Prefix: "StringIdentifier", + Message: msg, + } + return node, err + } + node.Name = name + return node, 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/parser/internal/grammar.peg b/core/vm/sqlvm/parser/internal/grammar.peg new file mode 100644 index 000000000..c0a8b5e2c --- /dev/null +++ b/core/vm/sqlvm/parser/internal/grammar.peg @@ -0,0 +1,1207 @@ +{ +package internal + +import ( + "github.com/dexon-foundation/dexon/core/vm/sqlvm/ast" + se "github.com/dexon-foundation/dexon/core/vm/sqlvm/errors" +) +} + +S + <- _ x:Stmt? _ xs:( ';' _ s:Stmt? _ { return s, nil } )* EOF +{ return assertNodeSlice(prepend(x, assertSlice(xs))), nil } + +/* Statements */ +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 } )? +{ + node := &ast.SelectStmtNode{} + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + node.Column = assertExprSlice(prepend(f, assertSlice(fs))) + if table != nil { + node.Table = table.(*ast.IdentifierNode) + } + if where != nil { + node.Where = where.(*ast.WhereOptionNode) + } + groupSlice := assertSlice(group) + node.Group = make([]*ast.GroupOptionNode, len(groupSlice)) + for idx := range groupSlice { + node.Group[idx] = groupSlice[idx].(*ast.GroupOptionNode) + } + orderSlice := assertSlice(order) + node.Order = make([]*ast.OrderOptionNode, len(orderSlice)) + for idx := range orderSlice { + node.Order[idx] = orderSlice[idx].(*ast.OrderOptionNode) + } + if limit != nil { + node.Limit = limit.(*ast.LimitOptionNode) + } + if offset != nil { + node.Offset = offset.(*ast.OffsetOptionNode) + } + return node, nil +} + +SelectColumn + = AnyLiteral + / Expr + +UpdateStmt + = UpdateToken + _ table:Identifier + _ SetToken + _ a:Assignment as:( _ SeparatorToken _ s:Assignment { return s, nil } )* + where:( _ w:WhereClause { return w, nil } )? +{ + node := &ast.UpdateStmtNode{} + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + node.Table = table.(*ast.IdentifierNode) + assignSlice := prepend(a, assertSlice(as)) + node.Assignment = make([]*ast.AssignOperatorNode, len(assignSlice)) + for idx := range assignSlice { + node.Assignment[idx] = assignSlice[idx].(*ast.AssignOperatorNode) + } + if where != nil { + node.Where = where.(*ast.WhereOptionNode) + } + return node, nil +} + +DeleteStmt + = DeleteToken + _ FromToken + _ table:Identifier + where:( _ w:WhereClause { return w, nil } )? +{ + node := &ast.DeleteStmtNode{} + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + node.Table = table.(*ast.IdentifierNode) + if where != nil { + node.Where = where.(*ast.WhereOptionNode) + } + return node, nil +} + +InsertStmt + = InsertToken + _ IntoToken + _ table:Identifier + _ insert:( InsertWithColumnClause / InsertWithDefaultClause ) +{ + node := &ast.InsertStmtNode{} + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + node.Table = table.(*ast.IdentifierNode) + switch i := insert.(type) { + case *ast.InsertWithColumnOptionNode: + node.Insert = i + case *ast.InsertWithDefaultOptionNode: + node.Insert = i + default: + panic(fmt.Sprintf("unknown insert type %T", insert)) + } + return node, 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, assertSlice(ss)), nil } + )? + _ ')' +{ + node := &ast.CreateTableStmtNode{} + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + node.Table = table.(*ast.IdentifierNode) + columnSlice := assertSlice(column) + node.Column = make([]*ast.ColumnSchemaNode, len(columnSlice)) + for idx := range columnSlice { + node.Column[idx] = columnSlice[idx].(*ast.ColumnSchemaNode) + } + return node, nil +} + +ColumnSchema + = i:Identifier + _ t:DataType + cs:( _ s:ColumnConstraint { return s, nil } )* +{ + node := &ast.ColumnSchemaNode{} + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + node.Column = i.(*ast.IdentifierNode) + node.DataType = t.(ast.TypeNode) + constraintSlice := assertSlice(cs) + node.Constraint = make([]ast.Node, len(constraintSlice)) + for idx, constraint := range constraintSlice { + switch c := constraint.(type) { + case *ast.PrimaryOptionNode: + node.Constraint[idx] = c + case *ast.NotNullOptionNode: + node.Constraint[idx] = c + case *ast.UniqueOptionNode: + node.Constraint[idx] = c + case *ast.DefaultOptionNode: + node.Constraint[idx] = c + case *ast.ForeignOptionNode: + node.Constraint[idx] = c + case *ast.AutoIncrementOptionNode: + node.Constraint[idx] = c + default: + panic(fmt.Sprintf("unknown constraint type %T", c)) + } + } + return node, 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 } )* _ ')' +{ + node := &ast.CreateIndexStmtNode{} + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + node.Index = index.(*ast.IdentifierNode) + node.Table = table.(*ast.IdentifierNode) + columnSlice := assertSlice(prepend(i, assertSlice(is))) + node.Column = make([]*ast.IdentifierNode, len(columnSlice)) + for idx := range columnSlice { + node.Column[idx] = columnSlice[idx].(*ast.IdentifierNode) + } + if unique != nil { + node.Unique = unique.(*ast.UniqueOptionNode) + } + return node, nil +} + +/* Clauses */ +WhereClause + = WhereToken _ e:Expr +{ + node := &ast.WhereOptionNode{} + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + node.Condition = e.(ast.ExprNode) + return node, nil +} + +OrderByClause + = OrderToken + _ ByToken + _ f:OrderColumn + fs:( _ SeparatorToken _ s:OrderColumn { return s, nil } )* +{ + return prepend(f, assertSlice(fs)), nil +} + +OrderColumn + = i:Expr + s:( _ t:( AscToken / DescToken ) { return t, nil } )? + n:( _ NullsToken _ l:( LastToken / FirstToken ) { return l, nil } )? +{ + node := &ast.OrderOptionNode{} + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + node.Expr = i.(ast.ExprNode) + node.Desc = s != nil && string(s.([]byte)) == "desc" + node.NullsFirst = n != nil && string(n.([]byte)) == "first" + return node, nil +} + +GroupByClause + = GroupToken + _ ByToken + _ f:GroupColumn + fs:( _ SeparatorToken _ s:GroupColumn { return s, nil } )* +{ + return prepend(f, assertSlice(fs)), nil +} + +GroupColumn + = i:Expr +{ + node := &ast.GroupOptionNode{} + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + node.Expr = i.(ast.ExprNode) + return node, nil +} + +OffsetClause + = OffsetToken _ i:Integer +{ + node := &ast.OffsetOptionNode{} + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + node.Value = i.(*ast.IntegerValueNode) + return node, nil +} + +LimitClause + = LimitToken _ i:Integer +{ + node := &ast.LimitOptionNode{} + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + node.Value = i.(*ast.IntegerValueNode) + return node, nil +} + +InsertWithColumnClause + = cs:( '(' + _ f:Identifier + fs:( _ SeparatorToken _ x:Identifier { return x, nil } )* + _ ')' + _ { return prepend(f, assertSlice(fs)), nil } + )? + ValuesToken + _ v:InsertValue + vs:( _ SeparatorToken _ y:InsertValue { return y, nil } )* +{ + node := &ast.InsertWithColumnOptionNode{} + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + columnSlice := assertSlice(cs) + node.Column = make([]*ast.IdentifierNode, len(columnSlice)) + for idx := range columnSlice { + node.Column[idx] = columnSlice[idx].(*ast.IdentifierNode) + } + valueSlice := assertSlice(vs) + node.Value = make([][]ast.ExprNode, len(valueSlice)+1) + node.Value[0] = v.([]ast.ExprNode) + for idx := range valueSlice { + node.Value[idx+1] = valueSlice[idx].([]ast.ExprNode) + } + return node, nil +} + +InsertWithDefaultClause + = DefaultToken _ ValuesToken +{ + node := &ast.InsertWithDefaultOptionNode{} + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + return node, nil +} + +PrimaryKeyClause + = PrimaryToken _ KeyToken +{ + node := &ast.PrimaryOptionNode{} + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + return node, nil +} + +NotNullClause + = NotToken _ NullToken +{ + node := &ast.NotNullOptionNode{} + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + return node, nil +} + +UniqueClause + = UniqueToken +{ + node := &ast.UniqueOptionNode{} + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + return node, nil +} + +DefaultClause + = DefaultToken _ e:Expr +{ + node := &ast.DefaultOptionNode{} + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + node.Value = e.(ast.ExprNode) + return node, nil +} + +ForeignClause + = ReferencesToken _ t:Identifier _ '(' _ f:Identifier _ ')' +{ + node := &ast.ForeignOptionNode{} + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + node.Table = t.(*ast.IdentifierNode) + node.Column = f.(*ast.IdentifierNode) + return node, nil +} + +AutoincrementClause + = AutoincrementToken +{ + node := &ast.AutoIncrementOptionNode{} + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + return node, nil +} + +/* Expressions */ +Expr + = LogicExpr + +ExprWithDefault + = &(DefaultLiteral) d:DefaultLiteral { return d, nil } + / Expr + +LogicExpr + = LogicExpr4 + +LogicExpr4 + = o:LogicExpr3 + os:( _ op:OrOperator _ s:LogicExpr3 + { return opSetSubject(op.(ast.BinaryOperator), s.(ast.ExprNode)), nil } )* +{ return rightJoinOperators(o.(ast.ExprNode), assertExprSlice(os)), nil } + +LogicExpr3 + = o:LogicExpr2 + os:( _ op:AndOperator _ s:LogicExpr2 + { return opSetSubject(op.(ast.BinaryOperator), s.(ast.ExprNode)), nil } )* +{ return rightJoinOperators(o.(ast.ExprNode), assertExprSlice(os)), nil } + +LogicExpr2 + = op:NotOperator _ s:LogicExpr2 + { return opSetTarget(op.(ast.UnaryOperator), s.(ast.ExprNode)), nil } + / LogicExpr1 + +LogicExpr1 + = o:ArithmeticExpr os:( _ l:LogicExpr1Op { return l, nil } )* +{ return rightJoinOperators(o.(ast.ExprNode), assertExprSlice(os)), nil } + +LogicExpr1Op + = LogicExpr1In + / LogicExpr1Is + / LogicExpr1Like + / LogicExpr1Cmp + +LogicExpr1In + = n:( t:NotOperator _ { return t, nil } )? InToken _ '(' _ s:MultiExpr _ ')' +{ + node := &ast.InOperatorNode{} + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + node.Right = s.([]ast.ExprNode) + if n != nil { + return opSetTarget(n.(ast.UnaryOperator), node), nil + } + return node, nil +} + +LogicExpr1Is + = IsToken n:( _ t:NotOperator { return t, nil } )? _ u:NullLiteral +{ + node := &ast.IsOperatorNode{} + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + opSetSubject(node, u.(*ast.NullValueNode)) + if n != nil { + return opSetTarget(n.(ast.UnaryOperator), node), nil + } + return node, nil +} + +LogicExpr1Like + = n:( t:NotOperator _ { return t, nil } )? LikeToken _ s:Expr +{ + node := &ast.LikeOperatorNode{} + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + opSetSubject(node, s.(ast.ExprNode)) + if n != nil { + return opSetTarget(n.(ast.UnaryOperator), node), nil + } + return node, nil +} + +LogicExpr1Cmp + = op:CmpOperator _ s:ArithmeticExpr +{ return opSetSubject(op.(ast.BinaryOperator), s.(ast.ExprNode)), nil } + +ArithmeticExpr + = ArithmeticExpr3 + +ArithmeticExpr3 + = o:ArithmeticExpr2 + os:( _ op:ConcatOperator _ s:ArithmeticExpr2 + { return opSetSubject(op.(ast.BinaryOperator), s.(ast.ExprNode)), nil } )* +{ return rightJoinOperators(o.(ast.ExprNode), assertExprSlice(os)), nil } + +ArithmeticExpr2 + = o:ArithmeticExpr1 + os:( _ op:AddSubOperator _ s:ArithmeticExpr1 + { return opSetSubject(op.(ast.BinaryOperator), s.(ast.ExprNode)), nil } )* +{ return rightJoinOperators(o.(ast.ExprNode), assertExprSlice(os)), nil } + +ArithmeticExpr1 + = o:Operand + os:( _ op:MulDivModOperator _ s:Operand + { return opSetSubject(op.(ast.BinaryOperator), s.(ast.ExprNode)), nil } )* +{ return rightJoinOperators(o.(ast.ExprNode), assertExprSlice(os)), nil } + +MultiExpr + = x:Expr xs:( _ SeparatorToken _ e:Expr { return e, nil } )* +{ return assertExprSlice(prepend(x, assertSlice(xs))), nil } + +MultiExprWithDefault + = x:ExprWithDefault xs:( _ SeparatorToken _ e:ExprWithDefault { return e, nil } )* +{ return assertExprSlice(prepend(x, assertSlice(xs))), nil } + +Operand + = op:UnaryOperator _ s:Operand + { return opSetTarget(op.(ast.UnaryOperator), s.(ast.ExprNode)), nil } + / '(' _ e:Expr _ ')' + { + node := &ast.ParenOperatorNode{} + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + opSetTarget(node, e.(ast.ExprNode)) + return node, nil + } + / &(CastToken) t:TypeCast { return t, nil } + / FunctionCall + / Value + / Identifier + +TypeCast + = CastToken _ '(' _ o:Expr _ AsToken _ s:DataType _ ')' +{ + node := &ast.CastOperatorNode{} + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + node.SourceExpr = o.(ast.ExprNode) + node.TargetType = s.(ast.TypeNode) + return node, nil +} + +FunctionCall + = i:Identifier _ '(' _ r:FunctionArgs? _ ')' +{ + node := &ast.FunctionOperatorNode{} + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + node.Name = i.(*ast.IdentifierNode) + if r != nil { + node.Args = r.([]ast.ExprNode) + } + return node, nil +} + +FunctionArgs + = a:AnyLiteral { return []ast.ExprNode{a.(*ast.AnyValueNode)}, nil } + / MultiExpr + +Assignment + = i:Identifier _ '=' _ e:ExprWithDefault +{ + node := &ast.AssignOperatorNode{} + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + node.Column = i.(*ast.IdentifierNode) + node.Expr = e.(ast.ExprNode) + return node, nil +} + +/* Operators */ +UnaryOperator + = SignOperator + +SignOperator + = Sign +{ + var node ast.UnaryOperator + switch string(c.text) { + case "+": + node = &ast.PosOperatorNode{} + case "-": + node = &ast.NegOperatorNode{} + default: + panic(fmt.Sprintf("unknown sign %s", c.text)) + } + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + return node, nil +} + +NotOperator + = NotToken +{ + node := &ast.NotOperatorNode{} + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + return node, nil +} + +AndOperator + = AndToken +{ + node := &ast.AndOperatorNode{} + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + return node, nil +} + +OrOperator + = OrToken +{ + node := &ast.OrOperatorNode{} + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + return node, nil +} + +CmpOperator + = ( "<=" / ">=" / "<>" / "!=" / [<>=] ) +{ + var node ast.BinaryOperator + switch string(c.text) { + case "<=": + node = &ast.LessOrEqualOperatorNode{} + case ">=": + node = &ast.GreaterOrEqualOperatorNode{} + case "<>": + node = &ast.NotEqualOperatorNode{} + case "!=": + node = &ast.NotEqualOperatorNode{} + case "<": + node = &ast.LessOperatorNode{} + case ">": + node = &ast.GreaterOperatorNode{} + case "=": + node = &ast.EqualOperatorNode{} + default: + panic(fmt.Sprintf("unknown comparison operator %s", c.text)) + } + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + return node, nil +} + +ConcatOperator + = "||" +{ + node := &ast.ConcatOperatorNode{} + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + return node, nil +} + +AddSubOperator + = [+-] +{ + var node ast.BinaryOperator + switch string(c.text) { + case "+": + node = &ast.AddOperatorNode{} + case "-": + node = &ast.SubOperatorNode{} + default: + panic(fmt.Sprintf("unknown addition or subtraction operator %s", c.text)) + } + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + return node, nil +} + +MulDivModOperator + = [*/%] +{ + var node ast.BinaryOperator + switch string(c.text) { + case "*": + node = &ast.MulOperatorNode{} + case "/": + node = &ast.DivOperatorNode{} + case "%": + node = &ast.ModOperatorNode{} + default: + panic(fmt.Sprintf("unknown multiplication, division, modulo operator: %s", c.text)) + } + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + return node, nil +} + +/* Types */ +DataType + = UIntType + / IntType + / UFixedType + / FixedType + / FixedBytesType + / DynamicBytesType + / BoolType + / AddressType + +UIntType + = "UINT"i s:NonZeroLeadingInteger !NormalIdentifierRest +{ + node := &ast.IntTypeNode{} + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + node.Unsigned = true + size, code := toUint(s.([]byte)) + if code != se.ErrorCodeNil { + err := se.Error{ + Position: uint32(c.pos.offset), + Category: se.ErrorCategoryGrammar, + Code: code, + Token: string(c.text), + Prefix: "UIntType", + Message: fmt.Sprintf("cannot parse %s as uint32: %v", s, code), + } + return node, err + } + node.Size = size + return node, nil +} + +IntType + = "INT"i s:NonZeroLeadingInteger !NormalIdentifierRest +{ + node := &ast.IntTypeNode{} + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + node.Unsigned = false + size, code := toUint(s.([]byte)) + if code != se.ErrorCodeNil { + err := se.Error{ + Position: uint32(c.pos.offset), + Category: se.ErrorCategoryGrammar, + Code: code, + Token: string(c.text), + Prefix: "IntType", + Message: fmt.Sprintf("cannot parse %s as uint32: %v", s, code), + } + return node, err + } + node.Size = size + return node, nil +} + +UFixedType + = "UFIXED"i s:NonZeroLeadingInteger "X"i t:NonZeroLeadingInteger !NormalIdentifierRest +{ + node := &ast.FixedTypeNode{} + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + node.Unsigned = true + size, code := toUint(s.([]byte)) + if code != se.ErrorCodeNil { + err := se.Error{ + Position: uint32(c.pos.offset), + Category: se.ErrorCategoryGrammar, + Code: code, + Token: string(c.text), + Prefix: "UFixedType", + Message: fmt.Sprintf("cannot parse %s as uint32: %v", s, code), + } + return node, err + } + fractionalDigits, code := toUint(t.([]byte)) + if code != se.ErrorCodeNil { + err := se.Error{ + Position: uint32(c.pos.offset), + Category: se.ErrorCategoryGrammar, + Code: code, + Token: string(c.text), + Prefix: "UFixedType", + Message: fmt.Sprintf("cannot parse %s as uint32: %v", t, code), + } + return node, err + } + node.Size = size + node.FractionalDigits = fractionalDigits + return node, nil +} + +FixedType + = "FIXED"i s:NonZeroLeadingInteger "X"i t:NonZeroLeadingInteger !NormalIdentifierRest +{ + node := &ast.FixedTypeNode{} + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + node.Unsigned = false + size, code := toUint(s.([]byte)) + if code != se.ErrorCodeNil { + err := se.Error{ + Position: uint32(c.pos.offset), + Category: se.ErrorCategoryGrammar, + Code: code, + Token: string(c.text), + Prefix: "FixedType", + Message: fmt.Sprintf("cannot parse %s as uint32: %v", s, code), + } + return node, err + } + fractionalDigits, code := toUint(t.([]byte)) + if code != se.ErrorCodeNil { + err := se.Error{ + Position: uint32(c.pos.offset), + Category: se.ErrorCategoryGrammar, + Code: code, + Token: string(c.text), + Prefix: "FixedType", + Message: fmt.Sprintf("cannot parse %s as uint32: %v", t, code), + } + return node, err + } + node.Size = size + node.FractionalDigits = fractionalDigits + return node, nil +} + +FixedBytesType + = "BYTES"i s:NonZeroLeadingInteger !NormalIdentifierRest +{ + node := &ast.FixedBytesTypeNode{} + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + size, code := toUint(s.([]byte)) + if code != se.ErrorCodeNil { + err := se.Error{ + Position: uint32(c.pos.offset), + Category: se.ErrorCategoryGrammar, + Code: code, + Token: string(c.text), + Prefix: "FixedBytesType", + Message: fmt.Sprintf("cannot parse %s as uint32: %v", s, code), + } + return node, err + } + node.Size = size + return node, nil +} + / "BYTE"i !NormalIdentifierRest +{ + node := &ast.FixedBytesTypeNode{} + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + node.Size = 1 + return node, nil +} + +DynamicBytesType + = ( "BYTES"i !NormalIdentifierRest + / "STRING"i !NormalIdentifierRest + / "TEXT"i !NormalIdentifierRest + ) +{ + node := &ast.DynamicBytesTypeNode{} + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + return node, nil +} + +AddressType + = "ADDRESS"i !NormalIdentifierRest +{ + node := &ast.AddressTypeNode{} + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + return node, nil +} + +BoolType + = ( "BOOL"i !NormalIdentifierRest + / "BOOLEAN"i !NormalIdentifierRest + ) +{ + node := &ast.BoolTypeNode{} + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + return node, nil +} + +/* Values */ +Value + = NumberLiteral + / StringLiteral + / BoolLiteral + / NullLiteral + +AnyLiteral + = AnyToken +{ + node := &ast.AnyValueNode{} + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + return node, nil +} + +DefaultLiteral + = DefaultToken +{ + node := &ast.DefaultValueNode{} + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + return node, nil +} + +BoolLiteral + = b:( TrueToken / FalseToken ) +{ + node := &ast.BoolValueNode{} + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + node.V = string(b.([]byte)) == "true" + return node, nil +} + +NullLiteral + = NullToken +{ + node := &ast.NullValueNode{} + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + return node, nil +} + +NumberLiteral + = &("0" "X"i) h:Hex { return h, nil } + / Decimal + +Sign + = [-+] + +Integer + = [0-9]+ +{ + node := &ast.IntegerValueNode{} + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + node.IsAddress = false + v, code := toDecimal(c.text) + if code != se.ErrorCodeNil { + err := se.Error{ + Position: uint32(c.pos.offset), + Category: se.ErrorCategoryGrammar, + Code: code, + Token: string(c.text), + Prefix: "Integer", + Message: fmt.Sprintf("cannot parse %s as decimal: %v", c.text, code), + } + return node, err + } + node.V = v + return node, nil +} + +NonZeroLeadingInteger + = ( "0" / [1-9][0-9]* ) +{ return c.text, nil } + +Fixnum + = Integer "." Integer + / Integer "."? + / "." Integer + +Decimal + = Fixnum ( "E"i Sign? Integer )? +{ + node := &ast.DecimalValueNode{} + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + v, code := toDecimal(c.text) + if code != se.ErrorCodeNil { + err := se.Error{ + Position: uint32(c.pos.offset), + Category: se.ErrorCategoryGrammar, + Code: code, + Token: string(c.text), + Prefix: "Decimal", + Message: fmt.Sprintf("cannot parse %s as decimal: %v", c.text, code), + } + return node, err + } + node.V = v + return node, nil +} + +Hex + = "0x" ( [0-9A-Fa-f] )+ !NormalIdentifierRest +{ + node := hexToInteger(c.text) + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + return node, nil +} + +StringLiteral + = HexString + / NormalString + +HexString + = ( "HEX"i / "X"i ) "'" s:([0-9a-fA-F][0-9a-fA-F] { return c.text, nil } )* "'" +{ + node := &ast.BytesValueNode{} + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + node.V = hexToBytes(joinBytes(assertSlice(s))) + return node, nil +} + +NormalString + = "'" s:( ( [^'\r\n\\] / "\\" . ) { return c.text, nil } )* "'" +{ + node := &ast.BytesValueNode{} + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + bs := joinBytes(assertSlice(s)) + v, bad, code := resolveString(bs) + if code != se.ErrorCodeNil { + msg := fmt.Sprintf("cannot resolve escape sequence '%s': %v", + sanitizeBadEscape(bad), code) + err := se.Error{ + Position: uint32(c.pos.offset), + Category: se.ErrorCategoryGrammar, + Code: code, + Token: string(c.text), + Prefix: "NormalString", + Message: msg, + } + return node, err + } + node.V = v + return node, nil +} + +/* Tokens */ +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 + = "*" + +/* Identifiers */ +Identifier + = NormalIdentifier + / StringIdentifier + +NormalIdentifier + = NormalIdentifierStart NormalIdentifierRest* +{ + node := &ast.IdentifierNode{} + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + node.Name = decodeString(c.text) + return node, nil +} + +NormalIdentifierStart + = [a-zA-Z\x80-\xff] + +NormalIdentifierRest + = [a-zA-Z0-9_\x80-\xff] + +StringIdentifier + = "\"" s:( ( [^"\r\n\\] / "\\" . ) { return c.text, nil } )* "\"" +{ + node := &ast.IdentifierNode{} + node.SetPosition(uint32(c.pos.offset)) + node.SetLength(uint32(len(c.text))) + bs := joinBytes(assertSlice(s)) + name, bad, code := resolveString(bs) + if code != se.ErrorCodeNil { + msg := fmt.Sprintf("cannot resolve escape sequence '%s': %v", + sanitizeBadEscape(bad), code) + err := se.Error{ + Position: uint32(c.pos.offset), + Category: se.ErrorCategoryGrammar, + Code: code, + Token: string(c.text), + Prefix: "StringIdentifier", + Message: msg, + } + return node, err + } + node.Name = name + return node, nil +} + +/* Skip */ +_ + = Whitespace* + +Whitespace + = "\t" // \x09 (HT) + / "\n" // \x0a (LF) + / "\v" // \x0b (VT) + / "\f" // \x0c (FF) + / "\r" // \x0d (CR) + / " " // \x20 (SPACE) + +EOF + = !. diff --git a/core/vm/sqlvm/parser/internal/helpers.go b/core/vm/sqlvm/parser/internal/helpers.go new file mode 100644 index 000000000..9b65824a7 --- /dev/null +++ b/core/vm/sqlvm/parser/internal/helpers.go @@ -0,0 +1,317 @@ +package internal + +import ( + "bytes" + "encoding/hex" + "fmt" + "strconv" + "strings" + "unicode/utf8" + + "github.com/dexon-foundation/dexon/common" + "github.com/dexon-foundation/dexon/core/vm/sqlvm/ast" + "github.com/dexon-foundation/dexon/core/vm/sqlvm/errors" + "github.com/shopspring/decimal" +) + +// Parser was generated with pigeon v1.0.0-99-gbb0192c. +//go:generate pigeon -no-recover -o grammar.go grammar.peg + +func prepend(x interface{}, xs []interface{}) []interface{} { + return append([]interface{}{x}, xs...) +} + +func assertSlice(x interface{}) []interface{} { + if x == nil { + return nil + } + return x.([]interface{}) +} + +func assertNodeSlice(x interface{}) []ast.Node { + xs := assertSlice(x) + ns := make([]ast.Node, len(xs)) + for i := 0; i < len(xs); i++ { + if xs[i] != nil { + ns[i] = xs[i].(ast.Node) + } + } + return ns +} + +func assertExprSlice(x interface{}) []ast.ExprNode { + xs := assertSlice(x) + es := make([]ast.ExprNode, len(xs)) + for i := 0; i < len(xs); i++ { + if xs[i] != nil { + es[i] = xs[i].(ast.ExprNode) + } + } + return es +} + +func isAddress(h []byte) bool { + ma, err := common.NewMixedcaseAddressFromString(string(h)) + if err != nil { + return false + } + return ma.ValidChecksum() +} + +func hexToInteger(h []byte) *ast.IntegerValueNode { + d := decimal.Zero + x := h[2:] + l := len(x) + base := decimal.New(16, 0) + for idx, b := range x { + i, err := strconv.ParseInt(string([]byte{b}), 16, 32) + if err != nil { + panic(fmt.Sprintf("invalid hex digit %s: %v", []byte{b}, err)) + } + d = d.Add( + decimal.New(i, 0). + Mul(base.Pow(decimal.New(int64(l-idx-1), 0))), + ) + } + node := &ast.IntegerValueNode{} + node.IsAddress = isAddress(h) + node.V = d + return node +} + +func hexToBytes(h []byte) []byte { + bs := make([]byte, hex.DecodedLen(len(h))) + _, err := hex.Decode(bs, h) + if err != nil { + panic(fmt.Sprintf("invalid hex string %s: %v", h, err)) + } + return bs +} + +func convertNumError(err error) errors.ErrorCode { + if err == nil { + return errors.ErrorCodeNil + } + switch err.(*strconv.NumError).Err { + case strconv.ErrSyntax: + return errors.ErrorCodeInvalidIntegerSyntax + case strconv.ErrRange: + return errors.ErrorCodeIntegerOutOfRange + } + panic(fmt.Sprintf("unknown NumError: %v", err)) +} + +func convertDecimalError(err error) errors.ErrorCode { + if err == nil { + return errors.ErrorCodeNil + } + errStr := err.Error() + if strings.HasSuffix(errStr, "decimal: fractional part too long") { + return errors.ErrorCodeFractionalPartTooLong + } else if strings.HasSuffix(errStr, "decimal: exponent is not numeric") { + return errors.ErrorCodeInvalidNumberSyntax + } else if strings.HasSuffix(errStr, "decimal: too many .s") { + return errors.ErrorCodeInvalidNumberSyntax + } + panic(fmt.Sprintf("unknown decimal error: %v", err)) +} + +func toUint(b []byte) (uint32, errors.ErrorCode) { + i, err := strconv.ParseUint(string(b), 10, 32) + return uint32(i), convertNumError(err) +} + +func toDecimal(b []byte) (decimal.Decimal, errors.ErrorCode) { + if len(b) > 0 && b[0] == byte('.') { + b = append([]byte{'0'}, b...) + } + d, err := decimal.NewFromString(string(b)) + return d, convertDecimalError(err) +} + +func toLower(b []byte) []byte { + return bytes.ToLower(b) +} + +func joinBytes(x []interface{}) []byte { + bs := []byte{} + for _, b := range x { + bs = append(bs, b.([]byte)...) + } + return bs +} + +func opSetSubject(op ast.BinaryOperator, s ast.ExprNode) ast.BinaryOperator { + op.SetSubject(s) + return op +} + +func opSetObject(op ast.BinaryOperator, o ast.ExprNode) ast.BinaryOperator { + op.SetObject(o) + return op +} + +func opSetTarget(op ast.UnaryOperator, t ast.ExprNode) ast.UnaryOperator { + op.SetTarget(t) + return op +} + +func joinOperator(x ast.ExprNode, o ast.ExprNode) { + switch op := x.(type) { + case ast.UnaryOperator: + joinOperator(op.GetTarget(), o) + case ast.BinaryOperator: + opSetObject(op, o) + case *ast.InOperatorNode: + op.Left = o + default: + panic(fmt.Sprintf("unable to join operators %T and %T", x, o)) + } +} + +func rightJoinOperators(o ast.ExprNode, x []ast.ExprNode) ast.ExprNode { + if len(x) == 0 { + return o + } + l := len(x) + joinOperator(x[0], o) + for idx := 0; idx < l-1; idx++ { + joinOperator(x[idx+1], x[idx]) + } + return x[l-1] +} + +func sanitizeBadEscape(s []byte) []byte { + o := bytes.Buffer{} + for _, b := range s { + if b >= 0x20 && b <= 0x7e && b != '\'' { + o.WriteByte(b) + } else { + o.WriteString(fmt.Sprintf("<%02X>", b)) + } + } + return o.Bytes() +} + +func decodeString(s []byte) []byte { + o := bytes.Buffer{} + for r, i, size := rune(0), 0, 0; i < len(s); i += size { + r, size = utf8.DecodeRune(s[i:]) + if r > 0xff { + panic(fmt.Sprintf("invalid encoded rune U+%04X", r)) + } + o.WriteByte(byte(r)) + } + return o.Bytes() +} + +func resolveString(s []byte) ([]byte, []byte, errors.ErrorCode) { + s = decodeString(s) + o := bytes.Buffer{} + for i, size := 0, 0; i < len(s); i += size { + if s[i] == '\\' { + if i+1 >= len(s) { + panic("trailing backslash in string literal") + } + switch s[i+1] { + case '\n': + size = 2 + + case '\\': + o.WriteByte('\\') + size = 2 + case '\'': + o.WriteByte('\'') + size = 2 + case '"': + o.WriteByte('"') + size = 2 + case 'b': + o.WriteByte('\b') + size = 2 + case 'f': + o.WriteByte('\f') + size = 2 + case 'n': + o.WriteByte('\n') + size = 2 + case 'r': + o.WriteByte('\r') + size = 2 + case 't': + o.WriteByte('\t') + size = 2 + case 'v': + o.WriteByte('\v') + size = 2 + + case 'x': + if i+3 >= len(s) { + return nil, s[i:], errors.ErrorCodeEscapeSequenceTooShort + } + b, err := strconv.ParseUint(string(s[i+2:i+4]), 16, 8) + if err != nil { + return nil, s[i : i+4], convertNumError(err) + } + o.WriteByte(uint8(b)) + size = 4 + + case 'u': + if i+5 >= len(s) { + return nil, s[i:], errors.ErrorCodeEscapeSequenceTooShort + } + u, err := strconv.ParseUint(string(s[i+2:i+6]), 16, 16) + if err != nil { + return nil, s[i : i+6], convertNumError(err) + } + if u >= 0xd800 && u <= 0xdfff { + return nil, s[i : i+6], errors.ErrorCodeInvalidUnicodeCodePoint + } + o.WriteRune(rune(u)) + size = 6 + + case 'U': + if i+9 >= len(s) { + return nil, s[i:], errors.ErrorCodeEscapeSequenceTooShort + } + r, err := strconv.ParseUint(string(s[i+2:i+10]), 16, 32) + if err != nil { + return nil, s[i : i+10], convertNumError(err) + } + if r > 0x10ffff || (r >= 0xd800 && r <= 0xdfff) { + return nil, s[i : i+10], errors.ErrorCodeInvalidUnicodeCodePoint + } + o.WriteRune(rune(r)) + size = 10 + + default: + return nil, s[i : i+2], errors.ErrorCodeUnknownEscapeSequence + } + } else { + o.WriteByte(s[i]) + size = 1 + } + } + return o.Bytes(), nil, errors.ErrorCodeNil +} + +// ErrList exports pigeon errList for the parser package. +type ErrList = errList + +// ParserError exports pigeon parserError for parser package. +type ParserError = parserError + +// DecodeString exports helper decodeString for parser package. +var DecodeString = decodeString + +// SQLVMError converts a pigeon parserError to a SQLVM error. +func (p *parserError) SQLVMError() errors.Error { + return errors.Error{ + Position: uint32(p.pos.offset), + Category: errors.ErrorCategoryGrammar, + Code: errors.ErrorCodeParser, + Token: "", + Prefix: p.prefix, + Message: p.Inner.Error(), + } +} diff --git a/core/vm/sqlvm/parser/parser.go b/core/vm/sqlvm/parser/parser.go index e8aa49c89..a90fec71c 100644 --- a/core/vm/sqlvm/parser/parser.go +++ b/core/vm/sqlvm/parser/parser.go @@ -2,302 +2,13 @@ package parser import ( "bytes" - "encoding/hex" "fmt" - "strconv" - "strings" - "unicode/utf8" - "github.com/dexon-foundation/dexon/common" "github.com/dexon-foundation/dexon/core/vm/sqlvm/ast" "github.com/dexon-foundation/dexon/core/vm/sqlvm/errors" - "github.com/shopspring/decimal" + "github.com/dexon-foundation/dexon/core/vm/sqlvm/parser/internal" ) -// Parser was generated with pigeon v1.0.0-99-gbb0192c. -//go:generate pigeon -no-recover -o grammar.go grammar.peg -//go:generate sh -c "sed -f grammar.sed grammar.go > grammar_new.go" -//go:generate mv grammar_new.go grammar.go -//go:generate goimports -w grammar.go - -func prepend(x interface{}, xs []interface{}) []interface{} { - return append([]interface{}{x}, xs...) -} - -func assertSlice(x interface{}) []interface{} { - if x == nil { - return nil - } - return x.([]interface{}) -} - -func assertNodeSlice(x interface{}) []ast.Node { - xs := assertSlice(x) - ns := make([]ast.Node, len(xs)) - for i := 0; i < len(xs); i++ { - if xs[i] != nil { - ns[i] = xs[i].(ast.Node) - } - } - return ns -} - -func assertExprSlice(x interface{}) []ast.ExprNode { - xs := assertSlice(x) - es := make([]ast.ExprNode, len(xs)) - for i := 0; i < len(xs); i++ { - if xs[i] != nil { - es[i] = xs[i].(ast.ExprNode) - } - } - return es -} - -func isAddress(h []byte) bool { - ma, err := common.NewMixedcaseAddressFromString(string(h)) - if err != nil { - return false - } - return ma.ValidChecksum() -} - -func hexToInteger(h []byte) *ast.IntegerValueNode { - d := decimal.Zero - x := h[2:] - l := len(x) - base := decimal.New(16, 0) - for idx, b := range x { - i, err := strconv.ParseInt(string([]byte{b}), 16, 32) - if err != nil { - panic(fmt.Sprintf("invalid hex digit %s: %v", []byte{b}, err)) - } - d = d.Add( - decimal.New(i, 0). - Mul(base.Pow(decimal.New(int64(l-idx-1), 0))), - ) - } - node := &ast.IntegerValueNode{} - node.IsAddress = isAddress(h) - node.V = d - return node -} - -func hexToBytes(h []byte) []byte { - bs := make([]byte, hex.DecodedLen(len(h))) - _, err := hex.Decode(bs, h) - if err != nil { - panic(fmt.Sprintf("invalid hex string %s: %v", h, err)) - } - return bs -} - -func convertNumError(err error) errors.ErrorCode { - if err == nil { - return errors.ErrorCodeNil - } - switch err.(*strconv.NumError).Err { - case strconv.ErrSyntax: - return errors.ErrorCodeInvalidIntegerSyntax - case strconv.ErrRange: - return errors.ErrorCodeIntegerOutOfRange - } - panic(fmt.Sprintf("unknown NumError: %v", err)) -} - -func convertDecimalError(err error) errors.ErrorCode { - if err == nil { - return errors.ErrorCodeNil - } - errStr := err.Error() - if strings.HasSuffix(errStr, "decimal: fractional part too long") { - return errors.ErrorCodeFractionalPartTooLong - } else if strings.HasSuffix(errStr, "decimal: exponent is not numeric") { - return errors.ErrorCodeInvalidNumberSyntax - } else if strings.HasSuffix(errStr, "decimal: too many .s") { - return errors.ErrorCodeInvalidNumberSyntax - } - panic(fmt.Sprintf("unknown decimal error: %v", err)) -} - -func toUint(b []byte) (uint32, errors.ErrorCode) { - i, err := strconv.ParseUint(string(b), 10, 32) - return uint32(i), convertNumError(err) -} - -func toDecimal(b []byte) (decimal.Decimal, errors.ErrorCode) { - if len(b) > 0 && b[0] == byte('.') { - b = append([]byte{'0'}, b...) - } - d, err := decimal.NewFromString(string(b)) - return d, convertDecimalError(err) -} - -func toLower(b []byte) []byte { - return bytes.ToLower(b) -} - -func joinBytes(x []interface{}) []byte { - bs := []byte{} - for _, b := range x { - bs = append(bs, b.([]byte)...) - } - return bs -} - -func opSetSubject(op ast.BinaryOperator, s ast.ExprNode) ast.BinaryOperator { - op.SetSubject(s) - return op -} - -func opSetObject(op ast.BinaryOperator, o ast.ExprNode) ast.BinaryOperator { - op.SetObject(o) - return op -} - -func opSetTarget(op ast.UnaryOperator, t ast.ExprNode) ast.UnaryOperator { - op.SetTarget(t) - return op -} - -func joinOperator(x ast.ExprNode, o ast.ExprNode) { - switch op := x.(type) { - case ast.UnaryOperator: - joinOperator(op.GetTarget(), o) - case ast.BinaryOperator: - opSetObject(op, o) - case *ast.InOperatorNode: - op.Left = o - default: - panic(fmt.Sprintf("unable to join operators %T and %T", x, o)) - } -} - -func rightJoinOperators(o ast.ExprNode, x []ast.ExprNode) ast.ExprNode { - if len(x) == 0 { - return o - } - l := len(x) - joinOperator(x[0], o) - for idx := 0; idx < l-1; idx++ { - joinOperator(x[idx+1], x[idx]) - } - return x[l-1] -} - -func sanitizeBadEscape(s []byte) []byte { - o := bytes.Buffer{} - for _, b := range s { - if b >= 0x20 && b <= 0x7e && b != '\'' { - o.WriteByte(b) - } else { - o.WriteString(fmt.Sprintf("<%02X>", b)) - } - } - return o.Bytes() -} - -func decodeString(s []byte) []byte { - o := bytes.Buffer{} - for r, i, size := rune(0), 0, 0; i < len(s); i += size { - r, size = utf8.DecodeRune(s[i:]) - if r > 0xff { - panic(fmt.Sprintf("invalid encoded rune U+%04X", r)) - } - o.WriteByte(byte(r)) - } - return o.Bytes() -} - -func resolveString(s []byte) ([]byte, []byte, errors.ErrorCode) { - s = decodeString(s) - o := bytes.Buffer{} - for i, size := 0, 0; i < len(s); i += size { - if s[i] == '\\' { - if i+1 >= len(s) { - panic("trailing backslash in string literal") - } - switch s[i+1] { - case '\n': - size = 2 - - case '\\': - o.WriteByte('\\') - size = 2 - case '\'': - o.WriteByte('\'') - size = 2 - case '"': - o.WriteByte('"') - size = 2 - case 'b': - o.WriteByte('\b') - size = 2 - case 'f': - o.WriteByte('\f') - size = 2 - case 'n': - o.WriteByte('\n') - size = 2 - case 'r': - o.WriteByte('\r') - size = 2 - case 't': - o.WriteByte('\t') - size = 2 - case 'v': - o.WriteByte('\v') - size = 2 - - case 'x': - if i+3 >= len(s) { - return nil, s[i:], errors.ErrorCodeEscapeSequenceTooShort - } - b, err := strconv.ParseUint(string(s[i+2:i+4]), 16, 8) - if err != nil { - return nil, s[i : i+4], convertNumError(err) - } - o.WriteByte(uint8(b)) - size = 4 - - case 'u': - if i+5 >= len(s) { - return nil, s[i:], errors.ErrorCodeEscapeSequenceTooShort - } - u, err := strconv.ParseUint(string(s[i+2:i+6]), 16, 16) - if err != nil { - return nil, s[i : i+6], convertNumError(err) - } - if u >= 0xd800 && u <= 0xdfff { - return nil, s[i : i+6], errors.ErrorCodeInvalidUnicodeCodePoint - } - o.WriteRune(rune(u)) - size = 6 - - case 'U': - if i+9 >= len(s) { - return nil, s[i:], errors.ErrorCodeEscapeSequenceTooShort - } - r, err := strconv.ParseUint(string(s[i+2:i+10]), 16, 32) - if err != nil { - return nil, s[i : i+10], convertNumError(err) - } - if r > 0x10ffff || (r >= 0xd800 && r <= 0xdfff) { - return nil, s[i : i+10], errors.ErrorCodeInvalidUnicodeCodePoint - } - o.WriteRune(rune(r)) - size = 10 - - default: - return nil, s[i : i+2], errors.ErrorCodeUnknownEscapeSequence - } - } else { - o.WriteByte(s[i]) - size = 1 - } - } - return o.Bytes(), nil, errors.ErrorCodeNil -} - func walkSelfFirst(n ast.Node, v func(ast.Node, []ast.Node)) { c := n.GetChildren() v(n, c) @@ -315,7 +26,7 @@ func walkChildrenFirst(n ast.Node, v func(ast.Node, []ast.Node)) { } // Parse parses SQL commands text and return an AST. -func Parse(b []byte, o ...Option) ([]ast.Node, error) { +func Parse(b []byte) ([]ast.Node, error) { // The string sent from the caller is not guaranteed to be valid UTF-8. // We don't really care non-ASCII characters in the string because all // keywords and special symbols are defined in ASCII. Therefore, as long @@ -342,11 +53,14 @@ func Parse(b []byte, o ...Option) ([]ast.Node, error) { // Prepare arguments and call the parser. eb := encBuf.Bytes() - options := append([]Option{Recover(false)}, o...) - root, pigeonErr := parse("", eb, options...) - stmts := assertNodeSlice(root) + options := []internal.Option{internal.Recover(false)} + root, pigeonErr := internal.Parse("", eb, options...) // Process the AST. + var stmts []ast.Node + if root != nil { + stmts = root.([]ast.Node) + } for i := range stmts { if stmts[i] == nil { continue @@ -389,24 +103,17 @@ func Parse(b []byte, o ...Option) ([]ast.Node, error) { } // Process errors. - pigeonErrList := pigeonErr.(errList) + pigeonErrList := pigeonErr.(internal.ErrList) sqlvmErrList := make(errors.ErrorList, len(pigeonErrList)) for i := range pigeonErrList { - parserErr := pigeonErrList[i].(*parserError) + parserErr := pigeonErrList[i].(*internal.ParserError) if sqlvmErr, ok := parserErr.Inner.(errors.Error); ok { sqlvmErrList[i] = sqlvmErr } else { - sqlvmErrList[i] = errors.Error{ - Position: uint32(parserErr.pos.offset), - Category: errors.ErrorCategoryGrammar, - Code: errors.ErrorCodeParser, - Token: "", - Prefix: parserErr.prefix, - Message: parserErr.Inner.Error(), - } + sqlvmErrList[i] = parserErr.SQLVMError() } sqlvmErrList[i].Token = - string(decodeString([]byte(sqlvmErrList[i].Token))) + string(internal.DecodeString([]byte(sqlvmErrList[i].Token))) if offset, ok := encMap[sqlvmErrList[i].Position]; ok { sqlvmErrList[i].Position = offset } else { -- cgit v1.2.3