From d25ee5f726545b165dba6a45def0e55027b6941b Mon Sep 17 00:00:00 2001 From: Ting-Wei Lan Date: Tue, 22 Jan 2019 11:26:45 +0800 Subject: core: vm: sqlvm: move AST and parser to their own packages In order to avoid putting too many different things in single package and allow other projects to reuse the syntax tree and the parser, these two components are moved to different packages and all nodes used in AST are now exported. A lot of comments are added in this commit to pass golint checks. --- core/vm/sqlvm/ast/ast.go | 490 +++ core/vm/sqlvm/ast/printer.go | 69 + core/vm/sqlvm/cmd/ast-printer/main.go | 7 +- core/vm/sqlvm/grammar.go | 7505 -------------------------------- core/vm/sqlvm/grammar.peg | 763 ---- core/vm/sqlvm/parser.go | 125 - core/vm/sqlvm/parser/grammar.go | 7514 +++++++++++++++++++++++++++++++++ core/vm/sqlvm/parser/grammar.peg | 774 ++++ core/vm/sqlvm/parser/parser.go | 126 + core/vm/sqlvm/parser/parser_test.go | 82 + core/vm/sqlvm/parser_test.go | 82 - core/vm/sqlvm/type.go | 408 -- 12 files changed, 9059 insertions(+), 8886 deletions(-) create mode 100644 core/vm/sqlvm/ast/ast.go create mode 100644 core/vm/sqlvm/ast/printer.go delete mode 100644 core/vm/sqlvm/grammar.go delete mode 100644 core/vm/sqlvm/grammar.peg delete mode 100644 core/vm/sqlvm/parser.go create mode 100644 core/vm/sqlvm/parser/grammar.go create mode 100644 core/vm/sqlvm/parser/grammar.peg create mode 100644 core/vm/sqlvm/parser/parser.go create mode 100644 core/vm/sqlvm/parser/parser_test.go delete mode 100644 core/vm/sqlvm/parser_test.go delete mode 100644 core/vm/sqlvm/type.go (limited to 'core') diff --git a/core/vm/sqlvm/ast/ast.go b/core/vm/sqlvm/ast/ast.go new file mode 100644 index 000000000..61a990e20 --- /dev/null +++ b/core/vm/sqlvm/ast/ast.go @@ -0,0 +1,490 @@ +package ast + +import ( + "github.com/shopspring/decimal" +) + +// --------------------------------------------------------------------------- +// Identifiers +// --------------------------------------------------------------------------- + +// IdentifierNode references table, column, or function. +type IdentifierNode struct { + Name []byte +} + +// --------------------------------------------------------------------------- +// Values +// --------------------------------------------------------------------------- + +// Valuer defines the interface of a constant value. +type Valuer interface { + Value() interface{} +} + +// BoolValueNode is a boolean constant. +type BoolValueNode struct { + V bool +} + +// Value returns the value of BoolValueNode. +func (n BoolValueNode) Value() interface{} { return n.V } + +// IntegerValueNode is an integer constant. +type IntegerValueNode struct { + IsAddress bool + V decimal.Decimal +} + +// Value returns the value of IntegerValueNode. +func (n IntegerValueNode) Value() interface{} { return n.V } +func (n IntegerValueNode) String() string { return n.V.String() } + +// DecimalValueNode is a number constant. +type DecimalValueNode struct { + V decimal.Decimal +} + +// Value returns the value of DecimalValueNode. +func (n DecimalValueNode) Value() interface{} { return n.V } +func (n DecimalValueNode) String() string { return n.V.String() } + +// BytesValueNode is a dynamic or fixed bytes constant. +type BytesValueNode struct { + V []byte +} + +// Value returns the value of BytesValueNode. +func (n BytesValueNode) Value() interface{} { return n.V } +func (n BytesValueNode) String() string { return string(n.V) } + +// AnyValueNode is '*' used in SELECT and function call. +type AnyValueNode struct{} + +// Value returns itself. +func (n AnyValueNode) Value() interface{} { return n } + +// DefaultValueNode represents the default value used in INSERT and UPDATE. +type DefaultValueNode struct{} + +// Value returns itself. +func (n DefaultValueNode) Value() interface{} { return n } + +// NullValueNode is NULL. +type NullValueNode struct{} + +// Value returns itself. +func (n NullValueNode) Value() interface{} { return n } + +// --------------------------------------------------------------------------- +// Types +// --------------------------------------------------------------------------- + +// IntTypeNode represents solidity int{X} and uint{X} types. +type IntTypeNode struct { + Unsigned bool + Size uint32 +} + +// FixedTypeNode represents solidity fixed{M}x{N} and ufixed{M}x{N} types. +type FixedTypeNode struct { + Unsigned bool + Size uint32 + FractionalDigits uint32 +} + +// DynamicBytesTypeNode represents solidity bytes type. +type DynamicBytesTypeNode struct{} + +// FixedBytesTypeNode represents solidity bytes{X} type. +type FixedBytesTypeNode struct { + Size uint32 +} + +// AddressTypeNode represents solidity address type. +type AddressTypeNode struct{} + +// BoolTypeNode represents solidity bool type. +type BoolTypeNode struct{} + +// --------------------------------------------------------------------------- +// Operators +// --------------------------------------------------------------------------- + +// UnaryOperator defines the interface of a unary operator. +type UnaryOperator interface { + GetTarget() interface{} + SetTarget(interface{}) +} + +// BinaryOperator defines the interface of a binary operator. +type BinaryOperator interface { + GetObject() interface{} + GetSubject() interface{} + SetObject(interface{}) + SetSubject(interface{}) +} + +// UnaryOperatorNode is a base struct of unary operators. +type UnaryOperatorNode struct { + Target interface{} +} + +// GetTarget gets the target of the operation. +func (n UnaryOperatorNode) GetTarget() interface{} { + return n.Target +} + +// SetTarget sets the target of the operation. +func (n *UnaryOperatorNode) SetTarget(t interface{}) { + n.Target = t +} + +// BinaryOperatorNode is a base struct of binary operators. +type BinaryOperatorNode struct { + Object interface{} + Subject interface{} +} + +// GetObject gets the node on which the operation is applied. +func (n BinaryOperatorNode) GetObject() interface{} { + return n.Object +} + +// GetSubject gets the node whose value is applied on the object. +func (n BinaryOperatorNode) GetSubject() interface{} { + return n.Subject +} + +// SetObject sets the object of the operation. +func (n *BinaryOperatorNode) SetObject(o interface{}) { + n.Object = o +} + +// SetSubject sets the subject of the operation. +func (n *BinaryOperatorNode) SetSubject(s interface{}) { + n.Subject = s +} + +// PosOperatorNode is '+'. +type PosOperatorNode struct{ UnaryOperatorNode } + +// NegOperatorNode is '-'. +type NegOperatorNode struct{ UnaryOperatorNode } + +// NotOperatorNode is 'NOT'. +type NotOperatorNode struct{ UnaryOperatorNode } + +// AndOperatorNode is 'AND'. +type AndOperatorNode struct{ BinaryOperatorNode } + +// OrOperatorNode is 'OR'. +type OrOperatorNode struct{ BinaryOperatorNode } + +// GreaterOrEqualOperatorNode is '>='. +type GreaterOrEqualOperatorNode struct{ BinaryOperatorNode } + +// LessOrEqualOperatorNode is '<='. +type LessOrEqualOperatorNode struct{ BinaryOperatorNode } + +// NotEqualOperatorNode is '<>'. +type NotEqualOperatorNode struct{ BinaryOperatorNode } + +// EqualOperatorNode is '=' used in expressions. +type EqualOperatorNode struct{ BinaryOperatorNode } + +// GreaterOperatorNode is '>'. +type GreaterOperatorNode struct{ BinaryOperatorNode } + +// LessOperatorNode is '<'. +type LessOperatorNode struct{ BinaryOperatorNode } + +// ConcatOperatorNode is '||'. +type ConcatOperatorNode struct{ BinaryOperatorNode } + +// AddOperatorNode is '+'. +type AddOperatorNode struct{ BinaryOperatorNode } + +// SubOperatorNode is '-'. +type SubOperatorNode struct{ BinaryOperatorNode } + +// MulOperatorNode is '*'. +type MulOperatorNode struct{ BinaryOperatorNode } + +// DivOperatorNode is '/'. +type DivOperatorNode struct{ BinaryOperatorNode } + +// ModOperatorNode is '%'. +type ModOperatorNode struct{ BinaryOperatorNode } + +// InOperatorNode is 'IN'. +type InOperatorNode struct{ BinaryOperatorNode } + +// IsOperatorNode is 'IS NULL'. +type IsOperatorNode struct{ BinaryOperatorNode } + +// LikeOperatorNode is 'LIKE'. +type LikeOperatorNode struct{ BinaryOperatorNode } + +// CastOperatorNode is 'CAST(expr AS type)'. +type CastOperatorNode struct{ BinaryOperatorNode } + +// AssignOperatorNode is '=' used in UPDATE to set values. +type AssignOperatorNode struct{ BinaryOperatorNode } + +// FunctionOperatorNode is a function call. +type FunctionOperatorNode struct{ BinaryOperatorNode } + +// --------------------------------------------------------------------------- +// Options +// --------------------------------------------------------------------------- + +// Optional defines the interface for printing AST. +type Optional interface { + GetOption() map[string]interface{} +} + +// NilOptionNode is a base struct implementing Optional interface. +type NilOptionNode struct{} + +// GetOption returns a value for printing AST. +func (n NilOptionNode) GetOption() map[string]interface{} { return nil } + +// WhereOptionNode is 'WHERE' used in SELECT, UPDATE, DELETE. +type WhereOptionNode struct { + Condition interface{} +} + +// GetOption returns a value for printing AST. +func (n WhereOptionNode) GetOption() map[string]interface{} { + return map[string]interface{}{ + "Condition": n.Condition, + } +} + +// OrderOptionNode is an expression in 'ORDER BY' used in SELECT. +type OrderOptionNode struct { + Expr interface{} + Desc bool + NullsFirst bool +} + +// GetOption returns a value for printing AST. +func (n OrderOptionNode) GetOption() map[string]interface{} { + return map[string]interface{}{ + "Expr": n.Expr, + "Desc": n.Desc, + "NullsFirst": n.NullsFirst, + } +} + +// GroupOptionNode is 'GROUP BY' used in SELECT. +type GroupOptionNode struct { + Expr interface{} +} + +// GetOption returns a value for printing AST. +func (n GroupOptionNode) GetOption() map[string]interface{} { + return map[string]interface{}{ + "Expr": n.Expr, + } +} + +// OffsetOptionNode is 'OFFSET' used in SELECT. +type OffsetOptionNode struct { + Value IntegerValueNode +} + +// GetOption returns a value for printing AST. +func (n OffsetOptionNode) GetOption() map[string]interface{} { + return map[string]interface{}{ + "Value": n.Value, + } +} + +// LimitOptionNode is 'LIMIT' used in SELECT. +type LimitOptionNode struct { + Value IntegerValueNode +} + +// GetOption returns a value for printing AST. +func (n LimitOptionNode) GetOption() map[string]interface{} { + return map[string]interface{}{ + "Value": n.Value, + } +} + +// InsertWithColumnOptionNode stores columns and values used in INSERT. +type InsertWithColumnOptionNode struct { + Column []interface{} + Value []interface{} +} + +// GetOption returns a value for printing AST. +func (n InsertWithColumnOptionNode) GetOption() map[string]interface{} { + return map[string]interface{}{ + "Column": n.Column, + "Value": n.Value, + } +} + +// InsertWithDefaultOptionNode is 'DEFAULT VALUES' used in INSERT. +type InsertWithDefaultOptionNode struct{ NilOptionNode } + +// PrimaryOptionNode is 'PRIMARY KEY' used in CREATE TABLE. +type PrimaryOptionNode struct{ NilOptionNode } + +// NotNullOptionNode is 'NOT NULL' used in CREATE TABLE. +type NotNullOptionNode struct{ NilOptionNode } + +// UniqueOptionNode is 'UNIQUE' used in CREATE TABLE and CREATE INDEX. +type UniqueOptionNode struct{ NilOptionNode } + +// AutoIncrementOptionNode is 'AUTOINCREMENT' used in CREATE TABLE. +type AutoIncrementOptionNode struct{ NilOptionNode } + +// DefaultOptionNode is 'DEFAULT' used in CREATE TABLE. +type DefaultOptionNode struct { + Value interface{} +} + +// GetOption returns a value for printing AST. +func (n DefaultOptionNode) GetOption() map[string]interface{} { + return map[string]interface{}{ + "Value": n.Value, + } +} + +// ForeignOptionNode is 'REFERENCES' used in CREATE TABLE. +type ForeignOptionNode struct { + Table IdentifierNode + Column IdentifierNode +} + +// GetOption returns a value for printing AST. +func (n ForeignOptionNode) GetOption() map[string]interface{} { + return map[string]interface{}{ + "Table": n.Table, + "Column": n.Column, + } +} + +// --------------------------------------------------------------------------- +// Statements +// --------------------------------------------------------------------------- + +// SelectStmtNode is SELECT. +type SelectStmtNode struct { + Column []interface{} + Table *IdentifierNode + Where *WhereOptionNode + Group []interface{} + Order []interface{} + Limit *LimitOptionNode + Offset *OffsetOptionNode +} + +// GetOption returns a value for printing AST. +func (n SelectStmtNode) GetOption() map[string]interface{} { + return map[string]interface{}{ + "Column": n.Column, + "Table": n.Table, + "Where": n.Where, + "Group": n.Group, + "Order": n.Order, + "Limit": n.Limit, + "Offset": n.Offset, + } +} + +// UpdateStmtNode is UPDATE. +type UpdateStmtNode struct { + Table IdentifierNode + Assignment []interface{} + Where *WhereOptionNode +} + +// GetOption returns a value for printing AST. +func (n UpdateStmtNode) GetOption() map[string]interface{} { + return map[string]interface{}{ + "Table": n.Table, + "Assignment": n.Assignment, + "Where": n.Where, + } +} + +// DeleteStmtNode is DELETE. +type DeleteStmtNode struct { + Table IdentifierNode + Where *WhereOptionNode +} + +// GetOption returns a value for printing AST. +func (n DeleteStmtNode) GetOption() map[string]interface{} { + return map[string]interface{}{ + "Table": n.Table, + "Where": n.Where, + } +} + +// InsertStmtNode is INSERT. +type InsertStmtNode struct { + Table IdentifierNode + Insert interface{} +} + +// GetOption returns a value for printing AST. +func (n InsertStmtNode) GetOption() map[string]interface{} { + return map[string]interface{}{ + "Table": n.Table, + "Insert": n.Insert, + } +} + +// CreateTableStmtNode is CREATE TABLE. +type CreateTableStmtNode struct { + Table IdentifierNode + Column []interface{} +} + +// GetOption returns a value for printing AST. +func (n CreateTableStmtNode) GetOption() map[string]interface{} { + return map[string]interface{}{ + "Table": n.Table, + "Column": n.Column, + } +} + +// ColumnSchemaNode specifies a column in CREATE TABLE. +type ColumnSchemaNode struct { + Column IdentifierNode + DataType interface{} + Constraint []interface{} +} + +// GetOption returns a value for printing AST. +func (n ColumnSchemaNode) GetOption() map[string]interface{} { + return map[string]interface{}{ + "Column": n.Column, + "DataYype": n.DataType, + "Constraint": n.Constraint, + } +} + +// CreateIndexStmtNode is CREATE INDEX. +type CreateIndexStmtNode struct { + Index IdentifierNode + Table IdentifierNode + Column []interface{} + Unique *UniqueOptionNode +} + +// GetOption returns a value for printing AST. +func (n CreateIndexStmtNode) GetOption() map[string]interface{} { + return map[string]interface{}{ + "Index": n.Index, + "Table": n.Table, + "Column": n.Column, + "Unique": n.Unique, + } +} diff --git a/core/vm/sqlvm/ast/printer.go b/core/vm/sqlvm/ast/printer.go new file mode 100644 index 000000000..25f04e863 --- /dev/null +++ b/core/vm/sqlvm/ast/printer.go @@ -0,0 +1,69 @@ +package ast + +import ( + "fmt" + "reflect" +) + +// PrintAST prints ast to stdout. +func PrintAST(n interface{}, indent string) { + if n == nil { + fmt.Printf("%snil\n", indent) + return + } + typeOf := reflect.TypeOf(n) + valueOf := reflect.ValueOf(n) + name := "" + if typeOf.Kind() == reflect.Ptr { + if valueOf.IsNil() { + fmt.Printf("%snil\n", indent) + return + } + name = "*" + valueOf = valueOf.Elem() + typeOf = typeOf.Elem() + } + name = name + typeOf.Name() + + if op, ok := n.(Optional); ok { + fmt.Printf("%s%s", indent, name) + m := op.GetOption() + if m == nil { + fmt.Printf("\n") + return + } + fmt.Printf(":\n") + for k := range m { + fmt.Printf("%s %s:\n", indent, k) + PrintAST(m[k], indent+" ") + } + return + } + if op, ok := n.(UnaryOperator); ok { + fmt.Printf("%s%s:\n", indent, name) + fmt.Printf("%s Target:\n", indent) + PrintAST(op.GetTarget(), indent+" ") + return + } + if op, ok := n.(BinaryOperator); ok { + fmt.Printf("%s%s:\n", indent, name) + fmt.Printf("%s Object:\n", indent) + PrintAST(op.GetObject(), indent+" ") + fmt.Printf("%s Subject:\n", indent) + PrintAST(op.GetSubject(), indent+" ") + return + } + if arr, ok := n.([]interface{}); ok { + fmt.Printf("%s[\n", indent) + for idx := range arr { + PrintAST(arr[idx], indent+" ") + } + fmt.Printf("%s]\n", indent) + return + } + if stringer, ok := n.(fmt.Stringer); ok { + fmt.Printf("%s%s: %s\n", indent, name, stringer.String()) + return + } + fmt.Printf("%s%s: %+v\n", indent, name, valueOf.Interface()) +} diff --git a/core/vm/sqlvm/cmd/ast-printer/main.go b/core/vm/sqlvm/cmd/ast-printer/main.go index ad10a54ce..4911273c5 100644 --- a/core/vm/sqlvm/cmd/ast-printer/main.go +++ b/core/vm/sqlvm/cmd/ast-printer/main.go @@ -4,13 +4,14 @@ import ( "fmt" "os" - "github.com/dexon-foundation/dexon/core/vm/sqlvm" + "github.com/dexon-foundation/dexon/core/vm/sqlvm/ast" + "github.com/dexon-foundation/dexon/core/vm/sqlvm/parser" ) func main() { - n, err := sqlvm.ParseString(os.Args[1]) + n, err := parser.ParseString(os.Args[1]) fmt.Printf("err: %+v\n", err) if err == nil { - sqlvm.PrintAST(n, "") + ast.PrintAST(n, "") } } diff --git a/core/vm/sqlvm/grammar.go b/core/vm/sqlvm/grammar.go deleted file mode 100644 index dad07b1eb..000000000 --- a/core/vm/sqlvm/grammar.go +++ /dev/null @@ -1,7505 +0,0 @@ -// Code generated by pigeon; DO NOT EDIT. - -package sqlvm - -import ( - "bytes" - "errors" - "fmt" - "io" - "io/ioutil" - "math" - "os" - "sort" - "strconv" - "strings" - "unicode" - "unicode/utf8" -) - -var g = &grammar{ - rules: []*rule{ - { - name: "S", - pos: position{line: 5, col: 1, offset: 19}, - expr: &actionExpr{ - pos: position{line: 6, col: 5, offset: 25}, - run: (*parser).callonS1, - expr: &seqExpr{ - pos: position{line: 6, col: 5, offset: 25}, - exprs: []interface{}{ - &ruleRefExpr{ - pos: position{line: 6, col: 5, offset: 25}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 6, col: 7, offset: 27}, - label: "x", - expr: &zeroOrOneExpr{ - pos: position{line: 6, col: 9, offset: 29}, - expr: &ruleRefExpr{ - pos: position{line: 6, col: 9, offset: 29}, - name: "Stmt", - }, - }, - }, - &ruleRefExpr{ - pos: position{line: 6, col: 15, offset: 35}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 6, col: 17, offset: 37}, - label: "xs", - expr: &zeroOrMoreExpr{ - pos: position{line: 6, col: 20, offset: 40}, - expr: &actionExpr{ - pos: position{line: 6, col: 22, offset: 42}, - run: (*parser).callonS10, - expr: &seqExpr{ - pos: position{line: 6, col: 22, offset: 42}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 6, col: 22, offset: 42}, - val: ";", - ignoreCase: false, - }, - &ruleRefExpr{ - pos: position{line: 6, col: 26, offset: 46}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 6, col: 28, offset: 48}, - label: "s", - expr: &zeroOrOneExpr{ - pos: position{line: 6, col: 30, offset: 50}, - expr: &ruleRefExpr{ - pos: position{line: 6, col: 30, offset: 50}, - name: "Stmt", - }, - }, - }, - &ruleRefExpr{ - pos: position{line: 6, col: 36, offset: 56}, - name: "_", - }, - }, - }, - }, - }, - }, - &ruleRefExpr{ - pos: position{line: 6, col: 59, offset: 79}, - name: "EOF", - }, - }, - }, - }, - }, - { - name: "Stmt", - pos: position{line: 10, col: 1, offset: 131}, - expr: &choiceExpr{ - pos: position{line: 11, col: 4, offset: 139}, - alternatives: []interface{}{ - &ruleRefExpr{ - pos: position{line: 11, col: 4, offset: 139}, - name: "SelectStmt", - }, - &ruleRefExpr{ - pos: position{line: 12, col: 4, offset: 153}, - name: "UpdateStmt", - }, - &ruleRefExpr{ - pos: position{line: 13, col: 4, offset: 167}, - name: "DeleteStmt", - }, - &ruleRefExpr{ - pos: position{line: 14, col: 4, offset: 181}, - name: "InsertStmt", - }, - &ruleRefExpr{ - pos: position{line: 15, col: 4, offset: 195}, - name: "CreateTableStmt", - }, - &ruleRefExpr{ - pos: position{line: 16, col: 4, offset: 214}, - name: "CreateIndexStmt", - }, - }, - }, - }, - { - name: "SelectStmt", - pos: position{line: 18, col: 1, offset: 231}, - expr: &actionExpr{ - pos: position{line: 19, col: 4, offset: 245}, - run: (*parser).callonSelectStmt1, - expr: &seqExpr{ - pos: position{line: 19, col: 4, offset: 245}, - exprs: []interface{}{ - &ruleRefExpr{ - pos: position{line: 19, col: 4, offset: 245}, - name: "SelectToken", - }, - &ruleRefExpr{ - pos: position{line: 20, col: 2, offset: 258}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 20, col: 4, offset: 260}, - label: "f", - expr: &ruleRefExpr{ - pos: position{line: 20, col: 6, offset: 262}, - name: "SelectColumn", - }, - }, - &labeledExpr{ - pos: position{line: 20, col: 19, offset: 275}, - label: "fs", - expr: &zeroOrMoreExpr{ - pos: position{line: 20, col: 22, offset: 278}, - expr: &actionExpr{ - pos: position{line: 20, col: 24, offset: 280}, - run: (*parser).callonSelectStmt9, - expr: &seqExpr{ - pos: position{line: 20, col: 24, offset: 280}, - exprs: []interface{}{ - &ruleRefExpr{ - pos: position{line: 20, col: 24, offset: 280}, - name: "_", - }, - &ruleRefExpr{ - pos: position{line: 20, col: 26, offset: 282}, - name: "SeparatorToken", - }, - &ruleRefExpr{ - pos: position{line: 20, col: 41, offset: 297}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 20, col: 43, offset: 299}, - label: "s", - expr: &ruleRefExpr{ - pos: position{line: 20, col: 45, offset: 301}, - name: "SelectColumn", - }, - }, - }, - }, - }, - }, - }, - &labeledExpr{ - pos: position{line: 21, col: 2, offset: 336}, - label: "table", - expr: &zeroOrOneExpr{ - pos: position{line: 21, col: 8, offset: 342}, - expr: &actionExpr{ - pos: position{line: 21, col: 10, offset: 344}, - run: (*parser).callonSelectStmt18, - expr: &seqExpr{ - pos: position{line: 21, col: 10, offset: 344}, - exprs: []interface{}{ - &ruleRefExpr{ - pos: position{line: 21, col: 10, offset: 344}, - name: "_", - }, - &ruleRefExpr{ - pos: position{line: 21, col: 12, offset: 346}, - name: "FromToken", - }, - &ruleRefExpr{ - pos: position{line: 21, col: 22, offset: 356}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 21, col: 24, offset: 358}, - label: "i", - expr: &ruleRefExpr{ - pos: position{line: 21, col: 26, offset: 360}, - name: "Identifier", - }, - }, - }, - }, - }, - }, - }, - &labeledExpr{ - pos: position{line: 22, col: 2, offset: 393}, - label: "where", - expr: &zeroOrOneExpr{ - pos: position{line: 22, col: 8, offset: 399}, - expr: &actionExpr{ - pos: position{line: 22, col: 10, offset: 401}, - run: (*parser).callonSelectStmt27, - expr: &seqExpr{ - pos: position{line: 22, col: 10, offset: 401}, - exprs: []interface{}{ - &ruleRefExpr{ - pos: position{line: 22, col: 10, offset: 401}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 22, col: 12, offset: 403}, - label: "w", - expr: &ruleRefExpr{ - pos: position{line: 22, col: 14, offset: 405}, - name: "WhereClause", - }, - }, - }, - }, - }, - }, - }, - &labeledExpr{ - pos: position{line: 23, col: 2, offset: 439}, - label: "group", - expr: &zeroOrOneExpr{ - pos: position{line: 23, col: 8, offset: 445}, - expr: &actionExpr{ - pos: position{line: 23, col: 10, offset: 447}, - run: (*parser).callonSelectStmt34, - expr: &seqExpr{ - pos: position{line: 23, col: 10, offset: 447}, - exprs: []interface{}{ - &ruleRefExpr{ - pos: position{line: 23, col: 10, offset: 447}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 23, col: 12, offset: 449}, - label: "g", - expr: &ruleRefExpr{ - pos: position{line: 23, col: 14, offset: 451}, - name: "GroupByClause", - }, - }, - }, - }, - }, - }, - }, - &labeledExpr{ - pos: position{line: 24, col: 2, offset: 487}, - label: "order", - expr: &zeroOrOneExpr{ - pos: position{line: 24, col: 8, offset: 493}, - expr: &actionExpr{ - pos: position{line: 24, col: 10, offset: 495}, - run: (*parser).callonSelectStmt41, - expr: &seqExpr{ - pos: position{line: 24, col: 10, offset: 495}, - exprs: []interface{}{ - &ruleRefExpr{ - pos: position{line: 24, col: 10, offset: 495}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 24, col: 12, offset: 497}, - label: "or", - expr: &ruleRefExpr{ - pos: position{line: 24, col: 15, offset: 500}, - name: "OrderByClause", - }, - }, - }, - }, - }, - }, - }, - &labeledExpr{ - pos: position{line: 25, col: 2, offset: 537}, - label: "limit", - expr: &zeroOrOneExpr{ - pos: position{line: 25, col: 8, offset: 543}, - expr: &actionExpr{ - pos: position{line: 25, col: 10, offset: 545}, - run: (*parser).callonSelectStmt48, - expr: &seqExpr{ - pos: position{line: 25, col: 10, offset: 545}, - exprs: []interface{}{ - &ruleRefExpr{ - pos: position{line: 25, col: 10, offset: 545}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 25, col: 12, offset: 547}, - label: "l", - expr: &ruleRefExpr{ - pos: position{line: 25, col: 14, offset: 549}, - name: "LimitClause", - }, - }, - }, - }, - }, - }, - }, - &labeledExpr{ - pos: position{line: 26, col: 2, offset: 583}, - label: "offset", - expr: &zeroOrOneExpr{ - pos: position{line: 26, col: 9, offset: 590}, - expr: &actionExpr{ - pos: position{line: 26, col: 11, offset: 592}, - run: (*parser).callonSelectStmt55, - expr: &seqExpr{ - pos: position{line: 26, col: 11, offset: 592}, - exprs: []interface{}{ - &ruleRefExpr{ - pos: position{line: 26, col: 11, offset: 592}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 26, col: 13, offset: 594}, - label: "of", - expr: &ruleRefExpr{ - pos: position{line: 26, col: 16, offset: 597}, - name: "OffsetClause", - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - { - name: "SelectColumn", - pos: position{line: 61, col: 1, offset: 1247}, - expr: &choiceExpr{ - pos: position{line: 62, col: 4, offset: 1263}, - alternatives: []interface{}{ - &ruleRefExpr{ - pos: position{line: 62, col: 4, offset: 1263}, - name: "AnyLiteral", - }, - &ruleRefExpr{ - pos: position{line: 63, col: 4, offset: 1277}, - name: "Expr", - }, - }, - }, - }, - { - name: "UpdateStmt", - pos: position{line: 65, col: 1, offset: 1283}, - expr: &actionExpr{ - pos: position{line: 66, col: 4, offset: 1297}, - run: (*parser).callonUpdateStmt1, - expr: &seqExpr{ - pos: position{line: 66, col: 4, offset: 1297}, - exprs: []interface{}{ - &ruleRefExpr{ - pos: position{line: 66, col: 4, offset: 1297}, - name: "UpdateToken", - }, - &ruleRefExpr{ - pos: position{line: 67, col: 2, offset: 1310}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 67, col: 4, offset: 1312}, - label: "table", - expr: &ruleRefExpr{ - pos: position{line: 67, col: 10, offset: 1318}, - name: "Identifier", - }, - }, - &ruleRefExpr{ - pos: position{line: 68, col: 2, offset: 1330}, - name: "_", - }, - &ruleRefExpr{ - pos: position{line: 68, col: 4, offset: 1332}, - name: "SetToken", - }, - &ruleRefExpr{ - pos: position{line: 69, col: 2, offset: 1342}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 69, col: 4, offset: 1344}, - label: "a", - expr: &ruleRefExpr{ - pos: position{line: 69, col: 6, offset: 1346}, - name: "Assignment", - }, - }, - &labeledExpr{ - pos: position{line: 69, col: 17, offset: 1357}, - label: "as", - expr: &zeroOrMoreExpr{ - pos: position{line: 69, col: 20, offset: 1360}, - expr: &actionExpr{ - pos: position{line: 69, col: 22, offset: 1362}, - run: (*parser).callonUpdateStmt14, - expr: &seqExpr{ - pos: position{line: 69, col: 22, offset: 1362}, - exprs: []interface{}{ - &ruleRefExpr{ - pos: position{line: 69, col: 22, offset: 1362}, - name: "_", - }, - &ruleRefExpr{ - pos: position{line: 69, col: 24, offset: 1364}, - name: "SeparatorToken", - }, - &ruleRefExpr{ - pos: position{line: 69, col: 39, offset: 1379}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 69, col: 41, offset: 1381}, - label: "s", - expr: &ruleRefExpr{ - pos: position{line: 69, col: 43, offset: 1383}, - name: "Assignment", - }, - }, - }, - }, - }, - }, - }, - &labeledExpr{ - pos: position{line: 70, col: 2, offset: 1416}, - label: "where", - expr: &zeroOrOneExpr{ - pos: position{line: 70, col: 8, offset: 1422}, - expr: &actionExpr{ - pos: position{line: 70, col: 10, offset: 1424}, - run: (*parser).callonUpdateStmt23, - expr: &seqExpr{ - pos: position{line: 70, col: 10, offset: 1424}, - exprs: []interface{}{ - &ruleRefExpr{ - pos: position{line: 70, col: 10, offset: 1424}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 70, col: 12, offset: 1426}, - label: "w", - expr: &ruleRefExpr{ - pos: position{line: 70, col: 14, offset: 1428}, - name: "WhereClause", - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - { - name: "DeleteStmt", - pos: position{line: 86, col: 1, offset: 1700}, - expr: &actionExpr{ - pos: position{line: 87, col: 4, offset: 1714}, - run: (*parser).callonDeleteStmt1, - expr: &seqExpr{ - pos: position{line: 87, col: 4, offset: 1714}, - exprs: []interface{}{ - &ruleRefExpr{ - pos: position{line: 87, col: 4, offset: 1714}, - name: "DeleteToken", - }, - &ruleRefExpr{ - pos: position{line: 88, col: 2, offset: 1727}, - name: "_", - }, - &ruleRefExpr{ - pos: position{line: 88, col: 4, offset: 1729}, - name: "FromToken", - }, - &ruleRefExpr{ - pos: position{line: 89, col: 2, offset: 1740}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 89, col: 4, offset: 1742}, - label: "table", - expr: &ruleRefExpr{ - pos: position{line: 89, col: 10, offset: 1748}, - name: "Identifier", - }, - }, - &labeledExpr{ - pos: position{line: 90, col: 2, offset: 1760}, - label: "where", - expr: &zeroOrOneExpr{ - pos: position{line: 90, col: 8, offset: 1766}, - expr: &actionExpr{ - pos: position{line: 90, col: 10, offset: 1768}, - run: (*parser).callonDeleteStmt11, - expr: &seqExpr{ - pos: position{line: 90, col: 10, offset: 1768}, - exprs: []interface{}{ - &ruleRefExpr{ - pos: position{line: 90, col: 10, offset: 1768}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 90, col: 12, offset: 1770}, - label: "w", - expr: &ruleRefExpr{ - pos: position{line: 90, col: 14, offset: 1772}, - name: "WhereClause", - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - { - name: "InsertStmt", - pos: position{line: 105, col: 1, offset: 2004}, - expr: &actionExpr{ - pos: position{line: 106, col: 4, offset: 2018}, - run: (*parser).callonInsertStmt1, - expr: &seqExpr{ - pos: position{line: 106, col: 4, offset: 2018}, - exprs: []interface{}{ - &ruleRefExpr{ - pos: position{line: 106, col: 4, offset: 2018}, - name: "InsertToken", - }, - &ruleRefExpr{ - pos: position{line: 107, col: 2, offset: 2031}, - name: "_", - }, - &ruleRefExpr{ - pos: position{line: 107, col: 4, offset: 2033}, - name: "IntoToken", - }, - &ruleRefExpr{ - pos: position{line: 108, col: 2, offset: 2044}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 108, col: 4, offset: 2046}, - label: "table", - expr: &ruleRefExpr{ - pos: position{line: 108, col: 10, offset: 2052}, - name: "Identifier", - }, - }, - &ruleRefExpr{ - pos: position{line: 109, col: 2, offset: 2064}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 109, col: 4, offset: 2066}, - label: "insert", - expr: &choiceExpr{ - pos: position{line: 109, col: 13, offset: 2075}, - alternatives: []interface{}{ - &ruleRefExpr{ - pos: position{line: 109, col: 13, offset: 2075}, - name: "InsertWithColumnClause", - }, - &ruleRefExpr{ - pos: position{line: 109, col: 38, offset: 2100}, - name: "InsertWithDefaultClause", - }, - }, - }, - }, - }, - }, - }, - }, - { - name: "InsertValue", - pos: position{line: 117, col: 1, offset: 2215}, - expr: &actionExpr{ - pos: position{line: 118, col: 4, offset: 2230}, - run: (*parser).callonInsertValue1, - expr: &seqExpr{ - pos: position{line: 118, col: 4, offset: 2230}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 118, col: 4, offset: 2230}, - val: "(", - ignoreCase: false, - }, - &ruleRefExpr{ - pos: position{line: 118, col: 8, offset: 2234}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 118, col: 10, offset: 2236}, - label: "e", - expr: &ruleRefExpr{ - pos: position{line: 118, col: 12, offset: 2238}, - name: "MultiExprWithDefault", - }, - }, - &ruleRefExpr{ - pos: position{line: 118, col: 33, offset: 2259}, - name: "_", - }, - &litMatcher{ - pos: position{line: 118, col: 35, offset: 2261}, - val: ")", - ignoreCase: false, - }, - }, - }, - }, - }, - { - name: "CreateTableStmt", - pos: position{line: 121, col: 1, offset: 2284}, - expr: &actionExpr{ - pos: position{line: 122, col: 4, offset: 2303}, - run: (*parser).callonCreateTableStmt1, - expr: &seqExpr{ - pos: position{line: 122, col: 4, offset: 2303}, - exprs: []interface{}{ - &ruleRefExpr{ - pos: position{line: 122, col: 4, offset: 2303}, - name: "CreateToken", - }, - &ruleRefExpr{ - pos: position{line: 123, col: 2, offset: 2316}, - name: "_", - }, - &ruleRefExpr{ - pos: position{line: 123, col: 4, offset: 2318}, - name: "TableToken", - }, - &ruleRefExpr{ - pos: position{line: 124, col: 2, offset: 2330}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 124, col: 4, offset: 2332}, - label: "table", - expr: &ruleRefExpr{ - pos: position{line: 124, col: 10, offset: 2338}, - name: "Identifier", - }, - }, - &ruleRefExpr{ - pos: position{line: 125, col: 2, offset: 2350}, - name: "_", - }, - &litMatcher{ - pos: position{line: 125, col: 4, offset: 2352}, - val: "(", - ignoreCase: false, - }, - &ruleRefExpr{ - pos: position{line: 126, col: 2, offset: 2357}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 126, col: 4, offset: 2359}, - label: "column", - expr: &zeroOrOneExpr{ - pos: position{line: 126, col: 11, offset: 2366}, - expr: &actionExpr{ - pos: position{line: 127, col: 3, offset: 2370}, - run: (*parser).callonCreateTableStmt14, - expr: &seqExpr{ - pos: position{line: 127, col: 3, offset: 2370}, - exprs: []interface{}{ - &labeledExpr{ - pos: position{line: 127, col: 3, offset: 2370}, - label: "s", - expr: &ruleRefExpr{ - pos: position{line: 127, col: 5, offset: 2372}, - name: "ColumnSchema", - }, - }, - &labeledExpr{ - pos: position{line: 128, col: 3, offset: 2387}, - label: "ss", - expr: &zeroOrMoreExpr{ - pos: position{line: 128, col: 6, offset: 2390}, - expr: &actionExpr{ - pos: position{line: 128, col: 8, offset: 2392}, - run: (*parser).callonCreateTableStmt20, - expr: &seqExpr{ - pos: position{line: 128, col: 8, offset: 2392}, - exprs: []interface{}{ - &ruleRefExpr{ - pos: position{line: 128, col: 8, offset: 2392}, - name: "_", - }, - &ruleRefExpr{ - pos: position{line: 128, col: 10, offset: 2394}, - name: "SeparatorToken", - }, - &ruleRefExpr{ - pos: position{line: 128, col: 25, offset: 2409}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 128, col: 27, offset: 2411}, - label: "t", - expr: &ruleRefExpr{ - pos: position{line: 128, col: 29, offset: 2413}, - name: "ColumnSchema", - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - &ruleRefExpr{ - pos: position{line: 131, col: 2, offset: 2485}, - name: "_", - }, - &litMatcher{ - pos: position{line: 131, col: 4, offset: 2487}, - val: ")", - ignoreCase: false, - }, - }, - }, - }, - }, - { - name: "ColumnSchema", - pos: position{line: 139, col: 1, offset: 2594}, - expr: &actionExpr{ - pos: position{line: 140, col: 4, offset: 2610}, - run: (*parser).callonColumnSchema1, - expr: &seqExpr{ - pos: position{line: 140, col: 4, offset: 2610}, - exprs: []interface{}{ - &labeledExpr{ - pos: position{line: 140, col: 4, offset: 2610}, - label: "i", - expr: &ruleRefExpr{ - pos: position{line: 140, col: 6, offset: 2612}, - name: "Identifier", - }, - }, - &ruleRefExpr{ - pos: position{line: 141, col: 2, offset: 2624}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 141, col: 4, offset: 2626}, - label: "t", - expr: &ruleRefExpr{ - pos: position{line: 141, col: 6, offset: 2628}, - name: "DataType", - }, - }, - &labeledExpr{ - pos: position{line: 142, col: 2, offset: 2638}, - label: "cs", - expr: &zeroOrMoreExpr{ - pos: position{line: 142, col: 5, offset: 2641}, - expr: &actionExpr{ - pos: position{line: 142, col: 7, offset: 2643}, - run: (*parser).callonColumnSchema10, - expr: &seqExpr{ - pos: position{line: 142, col: 7, offset: 2643}, - exprs: []interface{}{ - &ruleRefExpr{ - pos: position{line: 142, col: 7, offset: 2643}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 142, col: 9, offset: 2645}, - label: "s", - expr: &ruleRefExpr{ - pos: position{line: 142, col: 11, offset: 2647}, - name: "ColumnConstraint", - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - { - name: "ColumnConstraint", - pos: position{line: 151, col: 1, offset: 2802}, - expr: &choiceExpr{ - pos: position{line: 152, col: 4, offset: 2822}, - alternatives: []interface{}{ - &ruleRefExpr{ - pos: position{line: 152, col: 4, offset: 2822}, - name: "PrimaryKeyClause", - }, - &ruleRefExpr{ - pos: position{line: 153, col: 4, offset: 2842}, - name: "NotNullClause", - }, - &ruleRefExpr{ - pos: position{line: 154, col: 4, offset: 2859}, - name: "UniqueClause", - }, - &ruleRefExpr{ - pos: position{line: 155, col: 4, offset: 2875}, - name: "DefaultClause", - }, - &ruleRefExpr{ - pos: position{line: 156, col: 4, offset: 2892}, - name: "ForeignClause", - }, - &ruleRefExpr{ - pos: position{line: 157, col: 4, offset: 2909}, - name: "AutoincrementClause", - }, - }, - }, - }, - { - name: "CreateIndexStmt", - pos: position{line: 159, col: 1, offset: 2930}, - expr: &actionExpr{ - pos: position{line: 160, col: 4, offset: 2949}, - run: (*parser).callonCreateIndexStmt1, - expr: &seqExpr{ - pos: position{line: 160, col: 4, offset: 2949}, - exprs: []interface{}{ - &ruleRefExpr{ - pos: position{line: 160, col: 4, offset: 2949}, - name: "CreateToken", - }, - &labeledExpr{ - pos: position{line: 161, col: 2, offset: 2962}, - label: "unique", - expr: &zeroOrOneExpr{ - pos: position{line: 161, col: 9, offset: 2969}, - expr: &actionExpr{ - pos: position{line: 161, col: 11, offset: 2971}, - run: (*parser).callonCreateIndexStmt6, - expr: &seqExpr{ - pos: position{line: 161, col: 11, offset: 2971}, - exprs: []interface{}{ - &ruleRefExpr{ - pos: position{line: 161, col: 11, offset: 2971}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 161, col: 13, offset: 2973}, - label: "u", - expr: &ruleRefExpr{ - pos: position{line: 161, col: 15, offset: 2975}, - name: "UniqueClause", - }, - }, - }, - }, - }, - }, - }, - &ruleRefExpr{ - pos: position{line: 162, col: 2, offset: 3010}, - name: "_", - }, - &ruleRefExpr{ - pos: position{line: 162, col: 4, offset: 3012}, - name: "IndexToken", - }, - &ruleRefExpr{ - pos: position{line: 163, col: 2, offset: 3024}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 163, col: 4, offset: 3026}, - label: "index", - expr: &ruleRefExpr{ - pos: position{line: 163, col: 10, offset: 3032}, - name: "Identifier", - }, - }, - &ruleRefExpr{ - pos: position{line: 164, col: 2, offset: 3044}, - name: "_", - }, - &ruleRefExpr{ - pos: position{line: 164, col: 4, offset: 3046}, - name: "OnToken", - }, - &ruleRefExpr{ - pos: position{line: 165, col: 2, offset: 3055}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 165, col: 4, offset: 3057}, - label: "table", - expr: &ruleRefExpr{ - pos: position{line: 165, col: 10, offset: 3063}, - name: "Identifier", - }, - }, - &ruleRefExpr{ - pos: position{line: 166, col: 2, offset: 3075}, - name: "_", - }, - &litMatcher{ - pos: position{line: 166, col: 4, offset: 3077}, - val: "(", - ignoreCase: false, - }, - &ruleRefExpr{ - pos: position{line: 166, col: 8, offset: 3081}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 166, col: 10, offset: 3083}, - label: "i", - expr: &ruleRefExpr{ - pos: position{line: 166, col: 12, offset: 3085}, - name: "Identifier", - }, - }, - &labeledExpr{ - pos: position{line: 166, col: 23, offset: 3096}, - label: "is", - expr: &zeroOrMoreExpr{ - pos: position{line: 166, col: 26, offset: 3099}, - expr: &actionExpr{ - pos: position{line: 166, col: 28, offset: 3101}, - run: (*parser).callonCreateIndexStmt28, - expr: &seqExpr{ - pos: position{line: 166, col: 28, offset: 3101}, - exprs: []interface{}{ - &ruleRefExpr{ - pos: position{line: 166, col: 28, offset: 3101}, - name: "_", - }, - &ruleRefExpr{ - pos: position{line: 166, col: 30, offset: 3103}, - name: "SeparatorToken", - }, - &ruleRefExpr{ - pos: position{line: 166, col: 45, offset: 3118}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 166, col: 47, offset: 3120}, - label: "x", - expr: &ruleRefExpr{ - pos: position{line: 166, col: 49, offset: 3122}, - name: "Identifier", - }, - }, - }, - }, - }, - }, - }, - &ruleRefExpr{ - pos: position{line: 166, col: 81, offset: 3154}, - name: "_", - }, - &litMatcher{ - pos: position{line: 166, col: 83, offset: 3156}, - val: ")", - ignoreCase: false, - }, - }, - }, - }, - }, - { - name: "WhereClause", - pos: position{line: 184, col: 1, offset: 3446}, - expr: &actionExpr{ - pos: position{line: 185, col: 4, offset: 3461}, - run: (*parser).callonWhereClause1, - expr: &seqExpr{ - pos: position{line: 185, col: 4, offset: 3461}, - exprs: []interface{}{ - &ruleRefExpr{ - pos: position{line: 185, col: 4, offset: 3461}, - name: "WhereToken", - }, - &ruleRefExpr{ - pos: position{line: 185, col: 15, offset: 3472}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 185, col: 17, offset: 3474}, - label: "e", - expr: &ruleRefExpr{ - pos: position{line: 185, col: 19, offset: 3476}, - name: "Expr", - }, - }, - }, - }, - }, - }, - { - name: "OrderByClause", - pos: position{line: 188, col: 1, offset: 3528}, - expr: &actionExpr{ - pos: position{line: 189, col: 4, offset: 3545}, - run: (*parser).callonOrderByClause1, - expr: &seqExpr{ - pos: position{line: 189, col: 4, offset: 3545}, - exprs: []interface{}{ - &ruleRefExpr{ - pos: position{line: 189, col: 4, offset: 3545}, - name: "OrderToken", - }, - &ruleRefExpr{ - pos: position{line: 190, col: 2, offset: 3557}, - name: "_", - }, - &ruleRefExpr{ - pos: position{line: 190, col: 4, offset: 3559}, - name: "ByToken", - }, - &ruleRefExpr{ - pos: position{line: 191, col: 2, offset: 3568}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 191, col: 4, offset: 3570}, - label: "f", - expr: &ruleRefExpr{ - pos: position{line: 191, col: 6, offset: 3572}, - name: "OrderColumn", - }, - }, - &labeledExpr{ - pos: position{line: 192, col: 2, offset: 3585}, - label: "fs", - expr: &zeroOrMoreExpr{ - pos: position{line: 192, col: 5, offset: 3588}, - expr: &actionExpr{ - pos: position{line: 192, col: 7, offset: 3590}, - run: (*parser).callonOrderByClause11, - expr: &seqExpr{ - pos: position{line: 192, col: 7, offset: 3590}, - exprs: []interface{}{ - &ruleRefExpr{ - pos: position{line: 192, col: 7, offset: 3590}, - name: "_", - }, - &ruleRefExpr{ - pos: position{line: 192, col: 9, offset: 3592}, - name: "SeparatorToken", - }, - &ruleRefExpr{ - pos: position{line: 192, col: 24, offset: 3607}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 192, col: 26, offset: 3609}, - label: "s", - expr: &ruleRefExpr{ - pos: position{line: 192, col: 28, offset: 3611}, - name: "OrderColumn", - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - { - name: "OrderColumn", - pos: position{line: 195, col: 1, offset: 3676}, - expr: &actionExpr{ - pos: position{line: 196, col: 4, offset: 3691}, - run: (*parser).callonOrderColumn1, - expr: &seqExpr{ - pos: position{line: 196, col: 4, offset: 3691}, - exprs: []interface{}{ - &labeledExpr{ - pos: position{line: 196, col: 4, offset: 3691}, - label: "i", - expr: &ruleRefExpr{ - pos: position{line: 196, col: 6, offset: 3693}, - name: "Expr", - }, - }, - &labeledExpr{ - pos: position{line: 197, col: 2, offset: 3699}, - label: "s", - expr: &zeroOrOneExpr{ - pos: position{line: 197, col: 4, offset: 3701}, - expr: &actionExpr{ - pos: position{line: 197, col: 6, offset: 3703}, - run: (*parser).callonOrderColumn7, - expr: &seqExpr{ - pos: position{line: 197, col: 6, offset: 3703}, - exprs: []interface{}{ - &ruleRefExpr{ - pos: position{line: 197, col: 6, offset: 3703}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 197, col: 8, offset: 3705}, - label: "t", - expr: &choiceExpr{ - pos: position{line: 197, col: 12, offset: 3709}, - alternatives: []interface{}{ - &ruleRefExpr{ - pos: position{line: 197, col: 12, offset: 3709}, - name: "AscToken", - }, - &ruleRefExpr{ - pos: position{line: 197, col: 23, offset: 3720}, - name: "DescToken", - }, - }, - }, - }, - }, - }, - }, - }, - }, - &labeledExpr{ - pos: position{line: 198, col: 2, offset: 3754}, - label: "n", - expr: &zeroOrOneExpr{ - pos: position{line: 198, col: 4, offset: 3756}, - expr: &actionExpr{ - pos: position{line: 198, col: 6, offset: 3758}, - run: (*parser).callonOrderColumn16, - expr: &seqExpr{ - pos: position{line: 198, col: 6, offset: 3758}, - exprs: []interface{}{ - &ruleRefExpr{ - pos: position{line: 198, col: 6, offset: 3758}, - name: "_", - }, - &ruleRefExpr{ - pos: position{line: 198, col: 8, offset: 3760}, - name: "NullsToken", - }, - &ruleRefExpr{ - pos: position{line: 198, col: 19, offset: 3771}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 198, col: 21, offset: 3773}, - label: "l", - expr: &choiceExpr{ - pos: position{line: 198, col: 25, offset: 3777}, - alternatives: []interface{}{ - &ruleRefExpr{ - pos: position{line: 198, col: 25, offset: 3777}, - name: "LastToken", - }, - &ruleRefExpr{ - pos: position{line: 198, col: 37, offset: 3789}, - name: "FirstToken", - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - { - name: "GroupByClause", - pos: position{line: 207, col: 1, offset: 3988}, - expr: &actionExpr{ - pos: position{line: 208, col: 4, offset: 4005}, - run: (*parser).callonGroupByClause1, - expr: &seqExpr{ - pos: position{line: 208, col: 4, offset: 4005}, - exprs: []interface{}{ - &ruleRefExpr{ - pos: position{line: 208, col: 4, offset: 4005}, - name: "GroupToken", - }, - &ruleRefExpr{ - pos: position{line: 209, col: 2, offset: 4017}, - name: "_", - }, - &ruleRefExpr{ - pos: position{line: 209, col: 4, offset: 4019}, - name: "ByToken", - }, - &ruleRefExpr{ - pos: position{line: 210, col: 2, offset: 4028}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 210, col: 4, offset: 4030}, - label: "i", - expr: &ruleRefExpr{ - pos: position{line: 210, col: 6, offset: 4032}, - name: "Expr", - }, - }, - &labeledExpr{ - pos: position{line: 211, col: 2, offset: 4038}, - label: "is", - expr: &zeroOrMoreExpr{ - pos: position{line: 211, col: 5, offset: 4041}, - expr: &actionExpr{ - pos: position{line: 211, col: 7, offset: 4043}, - run: (*parser).callonGroupByClause11, - expr: &seqExpr{ - pos: position{line: 211, col: 7, offset: 4043}, - exprs: []interface{}{ - &ruleRefExpr{ - pos: position{line: 211, col: 7, offset: 4043}, - name: "_", - }, - &ruleRefExpr{ - pos: position{line: 211, col: 9, offset: 4045}, - name: "SeparatorToken", - }, - &ruleRefExpr{ - pos: position{line: 211, col: 24, offset: 4060}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 211, col: 26, offset: 4062}, - label: "s", - expr: &ruleRefExpr{ - pos: position{line: 211, col: 28, offset: 4064}, - name: "Expr", - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - { - name: "OffsetClause", - pos: position{line: 214, col: 1, offset: 4168}, - expr: &actionExpr{ - pos: position{line: 215, col: 4, offset: 4184}, - run: (*parser).callonOffsetClause1, - expr: &seqExpr{ - pos: position{line: 215, col: 4, offset: 4184}, - exprs: []interface{}{ - &ruleRefExpr{ - pos: position{line: 215, col: 4, offset: 4184}, - name: "OffsetToken", - }, - &ruleRefExpr{ - pos: position{line: 215, col: 16, offset: 4196}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 215, col: 18, offset: 4198}, - label: "i", - expr: &ruleRefExpr{ - pos: position{line: 215, col: 20, offset: 4200}, - name: "Integer", - }, - }, - }, - }, - }, - }, - { - name: "LimitClause", - pos: position{line: 218, col: 1, offset: 4271}, - expr: &actionExpr{ - pos: position{line: 219, col: 4, offset: 4286}, - run: (*parser).callonLimitClause1, - expr: &seqExpr{ - pos: position{line: 219, col: 4, offset: 4286}, - exprs: []interface{}{ - &ruleRefExpr{ - pos: position{line: 219, col: 4, offset: 4286}, - name: "LimitToken", - }, - &ruleRefExpr{ - pos: position{line: 219, col: 15, offset: 4297}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 219, col: 17, offset: 4299}, - label: "i", - expr: &ruleRefExpr{ - pos: position{line: 219, col: 19, offset: 4301}, - name: "Integer", - }, - }, - }, - }, - }, - }, - { - name: "InsertWithColumnClause", - pos: position{line: 222, col: 1, offset: 4371}, - expr: &actionExpr{ - pos: position{line: 223, col: 4, offset: 4397}, - run: (*parser).callonInsertWithColumnClause1, - expr: &seqExpr{ - pos: position{line: 223, col: 4, offset: 4397}, - exprs: []interface{}{ - &labeledExpr{ - pos: position{line: 223, col: 4, offset: 4397}, - label: "cs", - expr: &zeroOrOneExpr{ - pos: position{line: 223, col: 7, offset: 4400}, - expr: &actionExpr{ - pos: position{line: 223, col: 9, offset: 4402}, - run: (*parser).callonInsertWithColumnClause5, - expr: &seqExpr{ - pos: position{line: 223, col: 9, offset: 4402}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 223, col: 9, offset: 4402}, - val: "(", - ignoreCase: false, - }, - &ruleRefExpr{ - pos: position{line: 224, col: 4, offset: 4409}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 224, col: 6, offset: 4411}, - label: "f", - expr: &ruleRefExpr{ - pos: position{line: 224, col: 8, offset: 4413}, - name: "Identifier", - }, - }, - &labeledExpr{ - pos: position{line: 225, col: 4, offset: 4427}, - label: "fs", - expr: &zeroOrMoreExpr{ - pos: position{line: 225, col: 7, offset: 4430}, - expr: &actionExpr{ - pos: position{line: 225, col: 9, offset: 4432}, - run: (*parser).callonInsertWithColumnClause13, - expr: &seqExpr{ - pos: position{line: 225, col: 9, offset: 4432}, - exprs: []interface{}{ - &ruleRefExpr{ - pos: position{line: 225, col: 9, offset: 4432}, - name: "_", - }, - &ruleRefExpr{ - pos: position{line: 225, col: 11, offset: 4434}, - name: "SeparatorToken", - }, - &ruleRefExpr{ - pos: position{line: 225, col: 26, offset: 4449}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 225, col: 28, offset: 4451}, - label: "x", - expr: &ruleRefExpr{ - pos: position{line: 225, col: 30, offset: 4453}, - name: "Identifier", - }, - }, - }, - }, - }, - }, - }, - &ruleRefExpr{ - pos: position{line: 226, col: 4, offset: 4488}, - name: "_", - }, - &litMatcher{ - pos: position{line: 226, col: 6, offset: 4490}, - val: ")", - ignoreCase: false, - }, - &ruleRefExpr{ - pos: position{line: 227, col: 4, offset: 4497}, - name: "_", - }, - }, - }, - }, - }, - }, - &ruleRefExpr{ - pos: position{line: 229, col: 3, offset: 4537}, - name: "ValuesToken", - }, - &ruleRefExpr{ - pos: position{line: 230, col: 2, offset: 4550}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 230, col: 4, offset: 4552}, - label: "v", - expr: &ruleRefExpr{ - pos: position{line: 230, col: 6, offset: 4554}, - name: "InsertValue", - }, - }, - &labeledExpr{ - pos: position{line: 231, col: 2, offset: 4567}, - label: "vs", - expr: &zeroOrMoreExpr{ - pos: position{line: 231, col: 5, offset: 4570}, - expr: &actionExpr{ - pos: position{line: 231, col: 7, offset: 4572}, - run: (*parser).callonInsertWithColumnClause29, - expr: &seqExpr{ - pos: position{line: 231, col: 7, offset: 4572}, - exprs: []interface{}{ - &ruleRefExpr{ - pos: position{line: 231, col: 7, offset: 4572}, - name: "_", - }, - &ruleRefExpr{ - pos: position{line: 231, col: 9, offset: 4574}, - name: "SeparatorToken", - }, - &ruleRefExpr{ - pos: position{line: 231, col: 24, offset: 4589}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 231, col: 26, offset: 4591}, - label: "y", - expr: &ruleRefExpr{ - pos: position{line: 231, col: 28, offset: 4593}, - name: "InsertValue", - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - { - name: "InsertWithDefaultClause", - pos: position{line: 239, col: 1, offset: 4724}, - expr: &actionExpr{ - pos: position{line: 240, col: 4, offset: 4751}, - run: (*parser).callonInsertWithDefaultClause1, - expr: &seqExpr{ - pos: position{line: 240, col: 4, offset: 4751}, - exprs: []interface{}{ - &ruleRefExpr{ - pos: position{line: 240, col: 4, offset: 4751}, - name: "DefaultToken", - }, - &ruleRefExpr{ - pos: position{line: 240, col: 17, offset: 4764}, - name: "_", - }, - &ruleRefExpr{ - pos: position{line: 240, col: 19, offset: 4766}, - name: "ValuesToken", - }, - }, - }, - }, - }, - { - name: "PrimaryKeyClause", - pos: position{line: 243, col: 1, offset: 4825}, - expr: &actionExpr{ - pos: position{line: 244, col: 4, offset: 4845}, - run: (*parser).callonPrimaryKeyClause1, - expr: &seqExpr{ - pos: position{line: 244, col: 4, offset: 4845}, - exprs: []interface{}{ - &ruleRefExpr{ - pos: position{line: 244, col: 4, offset: 4845}, - name: "PrimaryToken", - }, - &ruleRefExpr{ - pos: position{line: 244, col: 17, offset: 4858}, - name: "_", - }, - &ruleRefExpr{ - pos: position{line: 244, col: 19, offset: 4860}, - name: "KeyToken", - }, - }, - }, - }, - }, - { - name: "NotNullClause", - pos: position{line: 247, col: 1, offset: 4906}, - expr: &actionExpr{ - pos: position{line: 248, col: 4, offset: 4923}, - run: (*parser).callonNotNullClause1, - expr: &seqExpr{ - pos: position{line: 248, col: 4, offset: 4923}, - exprs: []interface{}{ - &ruleRefExpr{ - pos: position{line: 248, col: 4, offset: 4923}, - name: "NotToken", - }, - &ruleRefExpr{ - pos: position{line: 248, col: 13, offset: 4932}, - name: "_", - }, - &ruleRefExpr{ - pos: position{line: 248, col: 15, offset: 4934}, - name: "NullToken", - }, - }, - }, - }, - }, - { - name: "UniqueClause", - pos: position{line: 251, col: 1, offset: 4981}, - expr: &actionExpr{ - pos: position{line: 252, col: 4, offset: 4997}, - run: (*parser).callonUniqueClause1, - expr: &ruleRefExpr{ - pos: position{line: 252, col: 4, offset: 4997}, - name: "UniqueToken", - }, - }, - }, - { - name: "DefaultClause", - pos: position{line: 255, col: 1, offset: 5045}, - expr: &actionExpr{ - pos: position{line: 256, col: 4, offset: 5062}, - run: (*parser).callonDefaultClause1, - expr: &seqExpr{ - pos: position{line: 256, col: 4, offset: 5062}, - exprs: []interface{}{ - &ruleRefExpr{ - pos: position{line: 256, col: 4, offset: 5062}, - name: "DefaultToken", - }, - &ruleRefExpr{ - pos: position{line: 256, col: 17, offset: 5075}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 256, col: 19, offset: 5077}, - label: "e", - expr: &ruleRefExpr{ - pos: position{line: 256, col: 21, offset: 5079}, - name: "Expr", - }, - }, - }, - }, - }, - }, - { - name: "ForeignClause", - pos: position{line: 259, col: 1, offset: 5129}, - expr: &actionExpr{ - pos: position{line: 260, col: 4, offset: 5146}, - run: (*parser).callonForeignClause1, - expr: &seqExpr{ - pos: position{line: 260, col: 4, offset: 5146}, - exprs: []interface{}{ - &ruleRefExpr{ - pos: position{line: 260, col: 4, offset: 5146}, - name: "ReferencesToken", - }, - &ruleRefExpr{ - pos: position{line: 260, col: 20, offset: 5162}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 260, col: 22, offset: 5164}, - label: "t", - expr: &ruleRefExpr{ - pos: position{line: 260, col: 24, offset: 5166}, - name: "Identifier", - }, - }, - &ruleRefExpr{ - pos: position{line: 260, col: 35, offset: 5177}, - name: "_", - }, - &litMatcher{ - pos: position{line: 260, col: 37, offset: 5179}, - val: "(", - ignoreCase: false, - }, - &ruleRefExpr{ - pos: position{line: 260, col: 41, offset: 5183}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 260, col: 43, offset: 5185}, - label: "f", - expr: &ruleRefExpr{ - pos: position{line: 260, col: 45, offset: 5187}, - name: "Identifier", - }, - }, - &ruleRefExpr{ - pos: position{line: 260, col: 56, offset: 5198}, - name: "_", - }, - &litMatcher{ - pos: position{line: 260, col: 58, offset: 5200}, - val: ")", - ignoreCase: false, - }, - }, - }, - }, - }, - { - name: "AutoincrementClause", - pos: position{line: 268, col: 1, offset: 5304}, - expr: &actionExpr{ - pos: position{line: 269, col: 4, offset: 5327}, - run: (*parser).callonAutoincrementClause1, - expr: &ruleRefExpr{ - pos: position{line: 269, col: 4, offset: 5327}, - name: "AutoincrementToken", - }, - }, - }, - { - name: "Expr", - pos: position{line: 273, col: 1, offset: 5406}, - expr: &ruleRefExpr{ - pos: position{line: 274, col: 4, offset: 5414}, - name: "LogicExpr", - }, - }, - { - name: "ExprWithDefault", - pos: position{line: 276, col: 1, offset: 5425}, - expr: &choiceExpr{ - pos: position{line: 277, col: 4, offset: 5444}, - alternatives: []interface{}{ - &actionExpr{ - pos: position{line: 277, col: 4, offset: 5444}, - run: (*parser).callonExprWithDefault2, - expr: &seqExpr{ - pos: position{line: 277, col: 4, offset: 5444}, - exprs: []interface{}{ - &andExpr{ - pos: position{line: 277, col: 4, offset: 5444}, - expr: &ruleRefExpr{ - pos: position{line: 277, col: 6, offset: 5446}, - name: "DefaultLiteral", - }, - }, - &labeledExpr{ - pos: position{line: 277, col: 22, offset: 5462}, - label: "d", - expr: &ruleRefExpr{ - pos: position{line: 277, col: 24, offset: 5464}, - name: "DefaultLiteral", - }, - }, - }, - }, - }, - &ruleRefExpr{ - pos: position{line: 278, col: 4, offset: 5500}, - name: "Expr", - }, - }, - }, - }, - { - name: "LogicExpr", - pos: position{line: 280, col: 1, offset: 5506}, - expr: &ruleRefExpr{ - pos: position{line: 281, col: 4, offset: 5519}, - name: "LogicExpr4", - }, - }, - { - name: "LogicExpr4", - pos: position{line: 283, col: 1, offset: 5531}, - expr: &actionExpr{ - pos: position{line: 284, col: 4, offset: 5545}, - run: (*parser).callonLogicExpr41, - expr: &seqExpr{ - pos: position{line: 284, col: 4, offset: 5545}, - exprs: []interface{}{ - &labeledExpr{ - pos: position{line: 284, col: 4, offset: 5545}, - label: "o", - expr: &ruleRefExpr{ - pos: position{line: 284, col: 6, offset: 5547}, - name: "LogicExpr3", - }, - }, - &labeledExpr{ - pos: position{line: 285, col: 3, offset: 5560}, - label: "os", - expr: &zeroOrMoreExpr{ - pos: position{line: 285, col: 6, offset: 5563}, - expr: &actionExpr{ - pos: position{line: 285, col: 8, offset: 5565}, - run: (*parser).callonLogicExpr47, - expr: &seqExpr{ - pos: position{line: 285, col: 8, offset: 5565}, - exprs: []interface{}{ - &ruleRefExpr{ - pos: position{line: 285, col: 8, offset: 5565}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 285, col: 10, offset: 5567}, - label: "op", - expr: &ruleRefExpr{ - pos: position{line: 285, col: 13, offset: 5570}, - name: "OrOperator", - }, - }, - &ruleRefExpr{ - pos: position{line: 285, col: 24, offset: 5581}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 285, col: 26, offset: 5583}, - label: "s", - expr: &ruleRefExpr{ - pos: position{line: 285, col: 28, offset: 5585}, - name: "LogicExpr3", - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - { - name: "LogicExpr3", - pos: position{line: 288, col: 1, offset: 5678}, - expr: &actionExpr{ - pos: position{line: 289, col: 4, offset: 5692}, - run: (*parser).callonLogicExpr31, - expr: &seqExpr{ - pos: position{line: 289, col: 4, offset: 5692}, - exprs: []interface{}{ - &labeledExpr{ - pos: position{line: 289, col: 4, offset: 5692}, - label: "o", - expr: &ruleRefExpr{ - pos: position{line: 289, col: 6, offset: 5694}, - name: "LogicExpr2", - }, - }, - &labeledExpr{ - pos: position{line: 290, col: 3, offset: 5707}, - label: "os", - expr: &zeroOrMoreExpr{ - pos: position{line: 290, col: 6, offset: 5710}, - expr: &actionExpr{ - pos: position{line: 290, col: 8, offset: 5712}, - run: (*parser).callonLogicExpr37, - expr: &seqExpr{ - pos: position{line: 290, col: 8, offset: 5712}, - exprs: []interface{}{ - &ruleRefExpr{ - pos: position{line: 290, col: 8, offset: 5712}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 290, col: 10, offset: 5714}, - label: "op", - expr: &ruleRefExpr{ - pos: position{line: 290, col: 13, offset: 5717}, - name: "AndOperator", - }, - }, - &ruleRefExpr{ - pos: position{line: 290, col: 25, offset: 5729}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 290, col: 27, offset: 5731}, - label: "s", - expr: &ruleRefExpr{ - pos: position{line: 290, col: 29, offset: 5733}, - name: "LogicExpr2", - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - { - name: "LogicExpr2", - pos: position{line: 293, col: 1, offset: 5826}, - expr: &choiceExpr{ - pos: position{line: 294, col: 4, offset: 5840}, - alternatives: []interface{}{ - &actionExpr{ - pos: position{line: 294, col: 4, offset: 5840}, - run: (*parser).callonLogicExpr22, - expr: &seqExpr{ - pos: position{line: 294, col: 4, offset: 5840}, - exprs: []interface{}{ - &labeledExpr{ - pos: position{line: 294, col: 4, offset: 5840}, - label: "op", - expr: &ruleRefExpr{ - pos: position{line: 294, col: 7, offset: 5843}, - name: "NotOperator", - }, - }, - &ruleRefExpr{ - pos: position{line: 294, col: 19, offset: 5855}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 294, col: 21, offset: 5857}, - label: "s", - expr: &ruleRefExpr{ - pos: position{line: 294, col: 23, offset: 5859}, - name: "LogicExpr2", - }, - }, - }, - }, - }, - &ruleRefExpr{ - pos: position{line: 296, col: 4, offset: 5909}, - name: "LogicExpr1", - }, - }, - }, - }, - { - name: "LogicExpr1", - pos: position{line: 298, col: 1, offset: 5921}, - expr: &actionExpr{ - pos: position{line: 299, col: 4, offset: 5935}, - run: (*parser).callonLogicExpr11, - expr: &seqExpr{ - pos: position{line: 299, col: 4, offset: 5935}, - exprs: []interface{}{ - &labeledExpr{ - pos: position{line: 299, col: 4, offset: 5935}, - label: "o", - expr: &ruleRefExpr{ - pos: position{line: 299, col: 6, offset: 5937}, - name: "ArithmeticExpr", - }, - }, - &labeledExpr{ - pos: position{line: 299, col: 21, offset: 5952}, - label: "os", - expr: &zeroOrMoreExpr{ - pos: position{line: 299, col: 24, offset: 5955}, - expr: &actionExpr{ - pos: position{line: 299, col: 26, offset: 5957}, - run: (*parser).callonLogicExpr17, - expr: &seqExpr{ - pos: position{line: 299, col: 26, offset: 5957}, - exprs: []interface{}{ - &ruleRefExpr{ - pos: position{line: 299, col: 26, offset: 5957}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 299, col: 28, offset: 5959}, - label: "l", - expr: &ruleRefExpr{ - pos: position{line: 299, col: 30, offset: 5961}, - name: "LogicExpr1Op", - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - { - name: "LogicExpr1Op", - pos: position{line: 302, col: 1, offset: 6038}, - expr: &choiceExpr{ - pos: position{line: 303, col: 4, offset: 6054}, - alternatives: []interface{}{ - &ruleRefExpr{ - pos: position{line: 303, col: 4, offset: 6054}, - name: "LogicExpr1In", - }, - &ruleRefExpr{ - pos: position{line: 304, col: 4, offset: 6070}, - name: "LogicExpr1Null", - }, - &ruleRefExpr{ - pos: position{line: 305, col: 4, offset: 6088}, - name: "LogicExpr1Like", - }, - &ruleRefExpr{ - pos: position{line: 306, col: 4, offset: 6106}, - name: "LogicExpr1Cmp", - }, - }, - }, - }, - { - name: "LogicExpr1In", - pos: position{line: 308, col: 1, offset: 6121}, - expr: &actionExpr{ - pos: position{line: 309, col: 4, offset: 6137}, - run: (*parser).callonLogicExpr1In1, - expr: &seqExpr{ - pos: position{line: 309, col: 4, offset: 6137}, - exprs: []interface{}{ - &labeledExpr{ - pos: position{line: 309, col: 4, offset: 6137}, - label: "n", - expr: &zeroOrOneExpr{ - pos: position{line: 309, col: 6, offset: 6139}, - expr: &actionExpr{ - pos: position{line: 309, col: 8, offset: 6141}, - run: (*parser).callonLogicExpr1In5, - expr: &seqExpr{ - pos: position{line: 309, col: 8, offset: 6141}, - exprs: []interface{}{ - &labeledExpr{ - pos: position{line: 309, col: 8, offset: 6141}, - label: "t", - expr: &ruleRefExpr{ - pos: position{line: 309, col: 10, offset: 6143}, - name: "NotOperator", - }, - }, - &ruleRefExpr{ - pos: position{line: 309, col: 22, offset: 6155}, - name: "_", - }, - }, - }, - }, - }, - }, - &ruleRefExpr{ - pos: position{line: 309, col: 45, offset: 6178}, - name: "InToken", - }, - &ruleRefExpr{ - pos: position{line: 309, col: 53, offset: 6186}, - name: "_", - }, - &litMatcher{ - pos: position{line: 309, col: 55, offset: 6188}, - val: "(", - ignoreCase: false, - }, - &ruleRefExpr{ - pos: position{line: 309, col: 59, offset: 6192}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 309, col: 61, offset: 6194}, - label: "s", - expr: &ruleRefExpr{ - pos: position{line: 309, col: 63, offset: 6196}, - name: "MultiExpr", - }, - }, - &ruleRefExpr{ - pos: position{line: 309, col: 73, offset: 6206}, - name: "_", - }, - &litMatcher{ - pos: position{line: 309, col: 75, offset: 6208}, - val: ")", - ignoreCase: false, - }, - }, - }, - }, - }, - { - name: "LogicExpr1Null", - pos: position{line: 318, col: 1, offset: 6326}, - expr: &actionExpr{ - pos: position{line: 319, col: 4, offset: 6344}, - run: (*parser).callonLogicExpr1Null1, - expr: &seqExpr{ - pos: position{line: 319, col: 4, offset: 6344}, - exprs: []interface{}{ - &ruleRefExpr{ - pos: position{line: 319, col: 4, offset: 6344}, - name: "IsToken", - }, - &labeledExpr{ - pos: position{line: 319, col: 12, offset: 6352}, - label: "n", - expr: &zeroOrOneExpr{ - pos: position{line: 319, col: 14, offset: 6354}, - expr: &actionExpr{ - pos: position{line: 319, col: 16, offset: 6356}, - run: (*parser).callonLogicExpr1Null6, - expr: &seqExpr{ - pos: position{line: 319, col: 16, offset: 6356}, - exprs: []interface{}{ - &ruleRefExpr{ - pos: position{line: 319, col: 16, offset: 6356}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 319, col: 18, offset: 6358}, - label: "t", - expr: &ruleRefExpr{ - pos: position{line: 319, col: 20, offset: 6360}, - name: "NotOperator", - }, - }, - }, - }, - }, - }, - }, - &ruleRefExpr{ - pos: position{line: 319, col: 53, offset: 6393}, - name: "_", - }, - &ruleRefExpr{ - pos: position{line: 319, col: 55, offset: 6395}, - name: "NullToken", - }, - }, - }, - }, - }, - { - name: "LogicExpr1Like", - pos: position{line: 328, col: 1, offset: 6533}, - expr: &actionExpr{ - pos: position{line: 329, col: 4, offset: 6551}, - run: (*parser).callonLogicExpr1Like1, - expr: &seqExpr{ - pos: position{line: 329, col: 4, offset: 6551}, - exprs: []interface{}{ - &labeledExpr{ - pos: position{line: 329, col: 4, offset: 6551}, - label: "n", - expr: &zeroOrOneExpr{ - pos: position{line: 329, col: 6, offset: 6553}, - expr: &actionExpr{ - pos: position{line: 329, col: 8, offset: 6555}, - run: (*parser).callonLogicExpr1Like5, - expr: &seqExpr{ - pos: position{line: 329, col: 8, offset: 6555}, - exprs: []interface{}{ - &labeledExpr{ - pos: position{line: 329, col: 8, offset: 6555}, - label: "t", - expr: &ruleRefExpr{ - pos: position{line: 329, col: 10, offset: 6557}, - name: "NotOperator", - }, - }, - &ruleRefExpr{ - pos: position{line: 329, col: 22, offset: 6569}, - name: "_", - }, - }, - }, - }, - }, - }, - &ruleRefExpr{ - pos: position{line: 329, col: 45, offset: 6592}, - name: "LikeToken", - }, - &ruleRefExpr{ - pos: position{line: 329, col: 55, offset: 6602}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 329, col: 57, offset: 6604}, - label: "s", - expr: &ruleRefExpr{ - pos: position{line: 329, col: 59, offset: 6606}, - name: "Expr", - }, - }, - }, - }, - }, - }, - { - name: "LogicExpr1Cmp", - pos: position{line: 338, col: 1, offset: 6727}, - expr: &actionExpr{ - pos: position{line: 339, col: 4, offset: 6744}, - run: (*parser).callonLogicExpr1Cmp1, - expr: &seqExpr{ - pos: position{line: 339, col: 4, offset: 6744}, - exprs: []interface{}{ - &labeledExpr{ - pos: position{line: 339, col: 4, offset: 6744}, - label: "op", - expr: &ruleRefExpr{ - pos: position{line: 339, col: 7, offset: 6747}, - name: "CmpOperator", - }, - }, - &ruleRefExpr{ - pos: position{line: 339, col: 19, offset: 6759}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 339, col: 21, offset: 6761}, - label: "s", - expr: &ruleRefExpr{ - pos: position{line: 339, col: 23, offset: 6763}, - name: "ArithmeticExpr", - }, - }, - }, - }, - }, - }, - { - name: "ArithmeticExpr", - pos: position{line: 342, col: 1, offset: 6815}, - expr: &ruleRefExpr{ - pos: position{line: 343, col: 4, offset: 6833}, - name: "ArithmeticExpr3", - }, - }, - { - name: "ArithmeticExpr3", - pos: position{line: 345, col: 1, offset: 6850}, - expr: &actionExpr{ - pos: position{line: 346, col: 4, offset: 6869}, - run: (*parser).callonArithmeticExpr31, - expr: &seqExpr{ - pos: position{line: 346, col: 4, offset: 6869}, - exprs: []interface{}{ - &labeledExpr{ - pos: position{line: 346, col: 4, offset: 6869}, - label: "o", - expr: &ruleRefExpr{ - pos: position{line: 346, col: 6, offset: 6871}, - name: "ArithmeticExpr2", - }, - }, - &labeledExpr{ - pos: position{line: 346, col: 22, offset: 6887}, - label: "os", - expr: &zeroOrMoreExpr{ - pos: position{line: 346, col: 25, offset: 6890}, - expr: &actionExpr{ - pos: position{line: 346, col: 27, offset: 6892}, - run: (*parser).callonArithmeticExpr37, - expr: &seqExpr{ - pos: position{line: 346, col: 27, offset: 6892}, - exprs: []interface{}{ - &ruleRefExpr{ - pos: position{line: 346, col: 27, offset: 6892}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 346, col: 29, offset: 6894}, - label: "op", - expr: &ruleRefExpr{ - pos: position{line: 346, col: 32, offset: 6897}, - name: "ConcatOperator", - }, - }, - &ruleRefExpr{ - pos: position{line: 346, col: 47, offset: 6912}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 346, col: 49, offset: 6914}, - label: "s", - expr: &ruleRefExpr{ - pos: position{line: 346, col: 51, offset: 6916}, - name: "ArithmeticExpr2", - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - { - name: "ArithmeticExpr2", - pos: position{line: 349, col: 1, offset: 7014}, - expr: &actionExpr{ - pos: position{line: 350, col: 4, offset: 7033}, - run: (*parser).callonArithmeticExpr21, - expr: &seqExpr{ - pos: position{line: 350, col: 4, offset: 7033}, - exprs: []interface{}{ - &labeledExpr{ - pos: position{line: 350, col: 4, offset: 7033}, - label: "o", - expr: &ruleRefExpr{ - pos: position{line: 350, col: 6, offset: 7035}, - name: "ArithmeticExpr1", - }, - }, - &labeledExpr{ - pos: position{line: 350, col: 22, offset: 7051}, - label: "os", - expr: &zeroOrMoreExpr{ - pos: position{line: 350, col: 25, offset: 7054}, - expr: &actionExpr{ - pos: position{line: 350, col: 27, offset: 7056}, - run: (*parser).callonArithmeticExpr27, - expr: &seqExpr{ - pos: position{line: 350, col: 27, offset: 7056}, - exprs: []interface{}{ - &ruleRefExpr{ - pos: position{line: 350, col: 27, offset: 7056}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 350, col: 29, offset: 7058}, - label: "op", - expr: &ruleRefExpr{ - pos: position{line: 350, col: 32, offset: 7061}, - name: "AddSubOperator", - }, - }, - &ruleRefExpr{ - pos: position{line: 350, col: 47, offset: 7076}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 350, col: 49, offset: 7078}, - label: "s", - expr: &ruleRefExpr{ - pos: position{line: 350, col: 51, offset: 7080}, - name: "ArithmeticExpr1", - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - { - name: "ArithmeticExpr1", - pos: position{line: 353, col: 1, offset: 7178}, - expr: &actionExpr{ - pos: position{line: 354, col: 4, offset: 7197}, - run: (*parser).callonArithmeticExpr11, - expr: &seqExpr{ - pos: position{line: 354, col: 4, offset: 7197}, - exprs: []interface{}{ - &labeledExpr{ - pos: position{line: 354, col: 4, offset: 7197}, - label: "o", - expr: &ruleRefExpr{ - pos: position{line: 354, col: 6, offset: 7199}, - name: "Operand", - }, - }, - &labeledExpr{ - pos: position{line: 354, col: 14, offset: 7207}, - label: "os", - expr: &zeroOrMoreExpr{ - pos: position{line: 354, col: 17, offset: 7210}, - expr: &actionExpr{ - pos: position{line: 354, col: 19, offset: 7212}, - run: (*parser).callonArithmeticExpr17, - expr: &seqExpr{ - pos: position{line: 354, col: 19, offset: 7212}, - exprs: []interface{}{ - &ruleRefExpr{ - pos: position{line: 354, col: 19, offset: 7212}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 354, col: 21, offset: 7214}, - label: "op", - expr: &ruleRefExpr{ - pos: position{line: 354, col: 24, offset: 7217}, - name: "MulDivModOperator", - }, - }, - &ruleRefExpr{ - pos: position{line: 354, col: 42, offset: 7235}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 354, col: 44, offset: 7237}, - label: "s", - expr: &ruleRefExpr{ - pos: position{line: 354, col: 46, offset: 7239}, - name: "Operand", - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - { - name: "MultiExpr", - pos: position{line: 357, col: 1, offset: 7329}, - expr: &actionExpr{ - pos: position{line: 358, col: 4, offset: 7342}, - run: (*parser).callonMultiExpr1, - expr: &seqExpr{ - pos: position{line: 358, col: 4, offset: 7342}, - exprs: []interface{}{ - &labeledExpr{ - pos: position{line: 358, col: 4, offset: 7342}, - label: "x", - expr: &ruleRefExpr{ - pos: position{line: 358, col: 6, offset: 7344}, - name: "Expr", - }, - }, - &labeledExpr{ - pos: position{line: 358, col: 11, offset: 7349}, - label: "xs", - expr: &zeroOrMoreExpr{ - pos: position{line: 358, col: 14, offset: 7352}, - expr: &actionExpr{ - pos: position{line: 358, col: 16, offset: 7354}, - run: (*parser).callonMultiExpr7, - expr: &seqExpr{ - pos: position{line: 358, col: 16, offset: 7354}, - exprs: []interface{}{ - &ruleRefExpr{ - pos: position{line: 358, col: 16, offset: 7354}, - name: "_", - }, - &ruleRefExpr{ - pos: position{line: 358, col: 18, offset: 7356}, - name: "SeparatorToken", - }, - &ruleRefExpr{ - pos: position{line: 358, col: 33, offset: 7371}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 358, col: 35, offset: 7373}, - label: "e", - expr: &ruleRefExpr{ - pos: position{line: 358, col: 37, offset: 7375}, - name: "Expr", - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - { - name: "MultiExprWithDefault", - pos: position{line: 361, col: 1, offset: 7433}, - expr: &actionExpr{ - pos: position{line: 362, col: 4, offset: 7457}, - run: (*parser).callonMultiExprWithDefault1, - expr: &seqExpr{ - pos: position{line: 362, col: 4, offset: 7457}, - exprs: []interface{}{ - &labeledExpr{ - pos: position{line: 362, col: 4, offset: 7457}, - label: "x", - expr: &ruleRefExpr{ - pos: position{line: 362, col: 6, offset: 7459}, - name: "ExprWithDefault", - }, - }, - &labeledExpr{ - pos: position{line: 362, col: 22, offset: 7475}, - label: "xs", - expr: &zeroOrMoreExpr{ - pos: position{line: 362, col: 25, offset: 7478}, - expr: &actionExpr{ - pos: position{line: 362, col: 27, offset: 7480}, - run: (*parser).callonMultiExprWithDefault7, - expr: &seqExpr{ - pos: position{line: 362, col: 27, offset: 7480}, - exprs: []interface{}{ - &ruleRefExpr{ - pos: position{line: 362, col: 27, offset: 7480}, - name: "_", - }, - &ruleRefExpr{ - pos: position{line: 362, col: 29, offset: 7482}, - name: "SeparatorToken", - }, - &ruleRefExpr{ - pos: position{line: 362, col: 44, offset: 7497}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 362, col: 46, offset: 7499}, - label: "e", - expr: &ruleRefExpr{ - pos: position{line: 362, col: 48, offset: 7501}, - name: "ExprWithDefault", - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - { - name: "Operand", - pos: position{line: 365, col: 1, offset: 7570}, - expr: &choiceExpr{ - pos: position{line: 366, col: 4, offset: 7581}, - alternatives: []interface{}{ - &actionExpr{ - pos: position{line: 366, col: 4, offset: 7581}, - run: (*parser).callonOperand2, - expr: &seqExpr{ - pos: position{line: 366, col: 4, offset: 7581}, - exprs: []interface{}{ - &labeledExpr{ - pos: position{line: 366, col: 4, offset: 7581}, - label: "op", - expr: &ruleRefExpr{ - pos: position{line: 366, col: 7, offset: 7584}, - name: "UnaryOperator", - }, - }, - &ruleRefExpr{ - pos: position{line: 366, col: 21, offset: 7598}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 366, col: 23, offset: 7600}, - label: "s", - expr: &ruleRefExpr{ - pos: position{line: 366, col: 25, offset: 7602}, - name: "Operand", - }, - }, - }, - }, - }, - &actionExpr{ - pos: position{line: 367, col: 4, offset: 7648}, - run: (*parser).callonOperand9, - expr: &seqExpr{ - pos: position{line: 367, col: 4, offset: 7648}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 367, col: 4, offset: 7648}, - val: "(", - ignoreCase: false, - }, - &ruleRefExpr{ - pos: position{line: 367, col: 8, offset: 7652}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 367, col: 10, offset: 7654}, - label: "e", - expr: &ruleRefExpr{ - pos: position{line: 367, col: 12, offset: 7656}, - name: "Expr", - }, - }, - &ruleRefExpr{ - pos: position{line: 367, col: 17, offset: 7661}, - name: "_", - }, - &litMatcher{ - pos: position{line: 367, col: 19, offset: 7663}, - val: ")", - ignoreCase: false, - }, - }, - }, - }, - &actionExpr{ - pos: position{line: 368, col: 4, offset: 7688}, - run: (*parser).callonOperand17, - expr: &seqExpr{ - pos: position{line: 368, col: 4, offset: 7688}, - exprs: []interface{}{ - &andExpr{ - pos: position{line: 368, col: 4, offset: 7688}, - expr: &ruleRefExpr{ - pos: position{line: 368, col: 6, offset: 7690}, - name: "CastToken", - }, - }, - &labeledExpr{ - pos: position{line: 368, col: 17, offset: 7701}, - label: "t", - expr: &ruleRefExpr{ - pos: position{line: 368, col: 19, offset: 7703}, - name: "TypeCast", - }, - }, - }, - }, - }, - &ruleRefExpr{ - pos: position{line: 369, col: 4, offset: 7733}, - name: "FunctionCall", - }, - &ruleRefExpr{ - pos: position{line: 370, col: 4, offset: 7749}, - name: "Value", - }, - &ruleRefExpr{ - pos: position{line: 371, col: 4, offset: 7758}, - name: "Identifier", - }, - }, - }, - }, - { - name: "TypeCast", - pos: position{line: 373, col: 1, offset: 7770}, - expr: &actionExpr{ - pos: position{line: 374, col: 4, offset: 7782}, - run: (*parser).callonTypeCast1, - expr: &seqExpr{ - pos: position{line: 374, col: 4, offset: 7782}, - exprs: []interface{}{ - &ruleRefExpr{ - pos: position{line: 374, col: 4, offset: 7782}, - name: "CastToken", - }, - &ruleRefExpr{ - pos: position{line: 374, col: 14, offset: 7792}, - name: "_", - }, - &litMatcher{ - pos: position{line: 374, col: 16, offset: 7794}, - val: "(", - ignoreCase: false, - }, - &ruleRefExpr{ - pos: position{line: 374, col: 20, offset: 7798}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 374, col: 22, offset: 7800}, - label: "o", - expr: &ruleRefExpr{ - pos: position{line: 374, col: 24, offset: 7802}, - name: "Expr", - }, - }, - &ruleRefExpr{ - pos: position{line: 374, col: 29, offset: 7807}, - name: "_", - }, - &ruleRefExpr{ - pos: position{line: 374, col: 31, offset: 7809}, - name: "AsToken", - }, - &ruleRefExpr{ - pos: position{line: 374, col: 39, offset: 7817}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 374, col: 41, offset: 7819}, - label: "s", - expr: &ruleRefExpr{ - pos: position{line: 374, col: 43, offset: 7821}, - name: "DataType", - }, - }, - &ruleRefExpr{ - pos: position{line: 374, col: 52, offset: 7830}, - name: "_", - }, - &litMatcher{ - pos: position{line: 374, col: 54, offset: 7832}, - val: ")", - ignoreCase: false, - }, - }, - }, - }, - }, - { - name: "FunctionCall", - pos: position{line: 377, col: 1, offset: 7906}, - expr: &actionExpr{ - pos: position{line: 378, col: 4, offset: 7922}, - run: (*parser).callonFunctionCall1, - expr: &seqExpr{ - pos: position{line: 378, col: 4, offset: 7922}, - exprs: []interface{}{ - &labeledExpr{ - pos: position{line: 378, col: 4, offset: 7922}, - label: "i", - expr: &ruleRefExpr{ - pos: position{line: 378, col: 6, offset: 7924}, - name: "Identifier", - }, - }, - &ruleRefExpr{ - pos: position{line: 378, col: 17, offset: 7935}, - name: "_", - }, - &litMatcher{ - pos: position{line: 378, col: 19, offset: 7937}, - val: "(", - ignoreCase: false, - }, - &ruleRefExpr{ - pos: position{line: 378, col: 23, offset: 7941}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 378, col: 25, offset: 7943}, - label: "r", - expr: &zeroOrOneExpr{ - pos: position{line: 378, col: 27, offset: 7945}, - expr: &ruleRefExpr{ - pos: position{line: 378, col: 27, offset: 7945}, - name: "FunctionArgs", - }, - }, - }, - &ruleRefExpr{ - pos: position{line: 378, col: 41, offset: 7959}, - name: "_", - }, - &litMatcher{ - pos: position{line: 378, col: 43, offset: 7961}, - val: ")", - ignoreCase: false, - }, - }, - }, - }, - }, - { - name: "FunctionArgs", - pos: position{line: 381, col: 1, offset: 8039}, - expr: &choiceExpr{ - pos: position{line: 382, col: 4, offset: 8055}, - alternatives: []interface{}{ - &actionExpr{ - pos: position{line: 382, col: 4, offset: 8055}, - run: (*parser).callonFunctionArgs2, - expr: &labeledExpr{ - pos: position{line: 382, col: 4, offset: 8055}, - label: "a", - expr: &ruleRefExpr{ - pos: position{line: 382, col: 6, offset: 8057}, - name: "AnyLiteral", - }, - }, - }, - &ruleRefExpr{ - pos: position{line: 383, col: 4, offset: 8104}, - name: "MultiExpr", - }, - }, - }, - }, - { - name: "Assignment", - pos: position{line: 385, col: 1, offset: 8115}, - expr: &actionExpr{ - pos: position{line: 386, col: 4, offset: 8129}, - run: (*parser).callonAssignment1, - expr: &seqExpr{ - pos: position{line: 386, col: 4, offset: 8129}, - exprs: []interface{}{ - &labeledExpr{ - pos: position{line: 386, col: 4, offset: 8129}, - label: "i", - expr: &ruleRefExpr{ - pos: position{line: 386, col: 6, offset: 8131}, - name: "Identifier", - }, - }, - &ruleRefExpr{ - pos: position{line: 386, col: 17, offset: 8142}, - name: "_", - }, - &litMatcher{ - pos: position{line: 386, col: 19, offset: 8144}, - val: "=", - ignoreCase: false, - }, - &ruleRefExpr{ - pos: position{line: 386, col: 23, offset: 8148}, - name: "_", - }, - &labeledExpr{ - pos: position{line: 386, col: 25, offset: 8150}, - label: "e", - expr: &ruleRefExpr{ - pos: position{line: 386, col: 27, offset: 8152}, - name: "ExprWithDefault", - }, - }, - }, - }, - }, - }, - { - name: "UnaryOperator", - pos: position{line: 390, col: 1, offset: 8255}, - expr: &ruleRefExpr{ - pos: position{line: 391, col: 4, offset: 8272}, - name: "SignOperator", - }, - }, - { - name: "SignOperator", - pos: position{line: 393, col: 1, offset: 8286}, - expr: &actionExpr{ - pos: position{line: 394, col: 4, offset: 8302}, - run: (*parser).callonSignOperator1, - expr: &ruleRefExpr{ - pos: position{line: 394, col: 4, offset: 8302}, - name: "Sign", - }, - }, - }, - { - name: "NotOperator", - pos: position{line: 405, col: 1, offset: 8468}, - expr: &actionExpr{ - pos: position{line: 406, col: 4, offset: 8483}, - run: (*parser).callonNotOperator1, - expr: &ruleRefExpr{ - pos: position{line: 406, col: 4, offset: 8483}, - name: "NotToken", - }, - }, - }, - { - name: "AndOperator", - pos: position{line: 409, col: 1, offset: 8528}, - expr: &actionExpr{ - pos: position{line: 410, col: 4, offset: 8543}, - run: (*parser).callonAndOperator1, - expr: &ruleRefExpr{ - pos: position{line: 410, col: 4, offset: 8543}, - name: "AndToken", - }, - }, - }, - { - name: "OrOperator", - pos: position{line: 413, col: 1, offset: 8588}, - expr: &actionExpr{ - pos: position{line: 414, col: 4, offset: 8602}, - run: (*parser).callonOrOperator1, - expr: &ruleRefExpr{ - pos: position{line: 414, col: 4, offset: 8602}, - name: "OrToken", - }, - }, - }, - { - name: "CmpOperator", - pos: position{line: 417, col: 1, offset: 8645}, - expr: &actionExpr{ - pos: position{line: 418, col: 4, offset: 8660}, - run: (*parser).callonCmpOperator1, - expr: &choiceExpr{ - pos: position{line: 418, col: 6, offset: 8662}, - alternatives: []interface{}{ - &litMatcher{ - pos: position{line: 418, col: 6, offset: 8662}, - val: "<=", - ignoreCase: false, - }, - &litMatcher{ - pos: position{line: 418, col: 13, offset: 8669}, - val: ">=", - ignoreCase: false, - }, - &litMatcher{ - pos: position{line: 418, col: 20, offset: 8676}, - val: "<>", - ignoreCase: false, - }, - &litMatcher{ - pos: position{line: 418, col: 27, offset: 8683}, - val: "!=", - ignoreCase: false, - }, - &charClassMatcher{ - pos: position{line: 418, col: 34, offset: 8690}, - val: "[<>=]", - chars: []rune{'<', '>', '='}, - ignoreCase: false, - inverted: false, - }, - }, - }, - }, - }, - { - name: "ConcatOperator", - pos: position{line: 439, col: 1, offset: 9118}, - expr: &actionExpr{ - pos: position{line: 440, col: 4, offset: 9136}, - run: (*parser).callonConcatOperator1, - expr: &litMatcher{ - pos: position{line: 440, col: 4, offset: 9136}, - val: "||", - ignoreCase: false, - }, - }, - }, - { - name: "AddSubOperator", - pos: position{line: 443, col: 1, offset: 9180}, - expr: &actionExpr{ - pos: position{line: 444, col: 4, offset: 9198}, - run: (*parser).callonAddSubOperator1, - expr: &charClassMatcher{ - pos: position{line: 444, col: 4, offset: 9198}, - val: "[+-]", - chars: []rune{'+', '-'}, - ignoreCase: false, - inverted: false, - }, - }, - }, - { - name: "MulDivModOperator", - pos: position{line: 455, col: 1, offset: 9367}, - expr: &actionExpr{ - pos: position{line: 456, col: 4, offset: 9388}, - run: (*parser).callonMulDivModOperator1, - expr: &charClassMatcher{ - pos: position{line: 456, col: 4, offset: 9388}, - val: "[*/%]", - chars: []rune{'*', '/', '%'}, - ignoreCase: false, - inverted: false, - }, - }, - }, - { - name: "DataType", - pos: position{line: 470, col: 1, offset: 9617}, - expr: &choiceExpr{ - pos: position{line: 471, col: 4, offset: 9629}, - alternatives: []interface{}{ - &ruleRefExpr{ - pos: position{line: 471, col: 4, offset: 9629}, - name: "UIntType", - }, - &ruleRefExpr{ - pos: position{line: 472, col: 4, offset: 9641}, - name: "IntType", - }, - &ruleRefExpr{ - pos: position{line: 473, col: 4, offset: 9652}, - name: "UFixedType", - }, - &ruleRefExpr{ - pos: position{line: 474, col: 4, offset: 9666}, - name: "FixedType", - }, - &ruleRefExpr{ - pos: position{line: 475, col: 4, offset: 9679}, - name: "FixedBytesType", - }, - &ruleRefExpr{ - pos: position{line: 476, col: 4, offset: 9697}, - name: "DynamicBytesType", - }, - &ruleRefExpr{ - pos: position{line: 477, col: 4, offset: 9717}, - name: "BoolType", - }, - &ruleRefExpr{ - pos: position{line: 478, col: 4, offset: 9729}, - name: "AddressType", - }, - }, - }, - }, - { - name: "UIntType", - pos: position{line: 480, col: 1, offset: 9742}, - expr: &actionExpr{ - pos: position{line: 481, col: 4, offset: 9754}, - run: (*parser).callonUIntType1, - expr: &seqExpr{ - pos: position{line: 481, col: 4, offset: 9754}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 481, col: 4, offset: 9754}, - val: "uint", - ignoreCase: true, - }, - &labeledExpr{ - pos: position{line: 481, col: 12, offset: 9762}, - label: "s", - expr: &ruleRefExpr{ - pos: position{line: 481, col: 14, offset: 9764}, - name: "NonZeroLeadingInteger", - }, - }, - ¬Expr{ - pos: position{line: 481, col: 36, offset: 9786}, - expr: &ruleRefExpr{ - pos: position{line: 481, col: 37, offset: 9787}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - }, - }, - { - name: "IntType", - pos: position{line: 484, col: 1, offset: 9878}, - expr: &actionExpr{ - pos: position{line: 485, col: 4, offset: 9889}, - run: (*parser).callonIntType1, - expr: &seqExpr{ - pos: position{line: 485, col: 4, offset: 9889}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 485, col: 4, offset: 9889}, - val: "int", - ignoreCase: true, - }, - &labeledExpr{ - pos: position{line: 485, col: 11, offset: 9896}, - label: "s", - expr: &ruleRefExpr{ - pos: position{line: 485, col: 13, offset: 9898}, - name: "NonZeroLeadingInteger", - }, - }, - ¬Expr{ - pos: position{line: 485, col: 35, offset: 9920}, - expr: &ruleRefExpr{ - pos: position{line: 485, col: 36, offset: 9921}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - }, - }, - { - name: "UFixedType", - pos: position{line: 488, col: 1, offset: 9996}, - expr: &actionExpr{ - pos: position{line: 489, col: 4, offset: 10010}, - run: (*parser).callonUFixedType1, - expr: &seqExpr{ - pos: position{line: 489, col: 4, offset: 10010}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 489, col: 4, offset: 10010}, - val: "ufixed", - ignoreCase: true, - }, - &labeledExpr{ - pos: position{line: 489, col: 14, offset: 10020}, - label: "s", - expr: &ruleRefExpr{ - pos: position{line: 489, col: 16, offset: 10022}, - name: "NonZeroLeadingInteger", - }, - }, - &litMatcher{ - pos: position{line: 489, col: 38, offset: 10044}, - val: "x", - ignoreCase: true, - }, - &labeledExpr{ - pos: position{line: 489, col: 43, offset: 10049}, - label: "t", - expr: &ruleRefExpr{ - pos: position{line: 489, col: 45, offset: 10051}, - name: "NonZeroLeadingInteger", - }, - }, - ¬Expr{ - pos: position{line: 489, col: 67, offset: 10073}, - expr: &ruleRefExpr{ - pos: position{line: 489, col: 68, offset: 10074}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - }, - }, - { - name: "FixedType", - pos: position{line: 498, col: 1, offset: 10229}, - expr: &actionExpr{ - pos: position{line: 499, col: 4, offset: 10242}, - run: (*parser).callonFixedType1, - expr: &seqExpr{ - pos: position{line: 499, col: 4, offset: 10242}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 499, col: 4, offset: 10242}, - val: "fixed", - ignoreCase: true, - }, - &labeledExpr{ - pos: position{line: 499, col: 13, offset: 10251}, - label: "s", - expr: &ruleRefExpr{ - pos: position{line: 499, col: 15, offset: 10253}, - name: "NonZeroLeadingInteger", - }, - }, - &litMatcher{ - pos: position{line: 499, col: 37, offset: 10275}, - val: "x", - ignoreCase: true, - }, - &labeledExpr{ - pos: position{line: 499, col: 42, offset: 10280}, - label: "t", - expr: &ruleRefExpr{ - pos: position{line: 499, col: 44, offset: 10282}, - name: "NonZeroLeadingInteger", - }, - }, - ¬Expr{ - pos: position{line: 499, col: 66, offset: 10304}, - expr: &ruleRefExpr{ - pos: position{line: 499, col: 67, offset: 10305}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - }, - }, - { - name: "FixedBytesType", - pos: position{line: 507, col: 1, offset: 10436}, - expr: &choiceExpr{ - pos: position{line: 508, col: 4, offset: 10454}, - alternatives: []interface{}{ - &actionExpr{ - pos: position{line: 508, col: 4, offset: 10454}, - run: (*parser).callonFixedBytesType2, - expr: &seqExpr{ - pos: position{line: 508, col: 4, offset: 10454}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 508, col: 4, offset: 10454}, - val: "bytes", - ignoreCase: true, - }, - &labeledExpr{ - pos: position{line: 508, col: 13, offset: 10463}, - label: "s", - expr: &ruleRefExpr{ - pos: position{line: 508, col: 15, offset: 10465}, - name: "NonZeroLeadingInteger", - }, - }, - ¬Expr{ - pos: position{line: 508, col: 37, offset: 10487}, - expr: &ruleRefExpr{ - pos: position{line: 508, col: 38, offset: 10488}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - }, - &actionExpr{ - pos: position{line: 510, col: 4, offset: 10572}, - run: (*parser).callonFixedBytesType9, - expr: &seqExpr{ - pos: position{line: 510, col: 4, offset: 10572}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 510, col: 4, offset: 10572}, - val: "byte", - ignoreCase: true, - }, - ¬Expr{ - pos: position{line: 510, col: 12, offset: 10580}, - expr: &ruleRefExpr{ - pos: position{line: 510, col: 13, offset: 10581}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - }, - }, - }, - }, - { - name: "DynamicBytesType", - pos: position{line: 513, col: 1, offset: 10647}, - expr: &actionExpr{ - pos: position{line: 514, col: 4, offset: 10667}, - run: (*parser).callonDynamicBytesType1, - expr: &choiceExpr{ - pos: position{line: 514, col: 6, offset: 10669}, - alternatives: []interface{}{ - &seqExpr{ - pos: position{line: 514, col: 6, offset: 10669}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 514, col: 6, offset: 10669}, - val: "bytes", - ignoreCase: true, - }, - ¬Expr{ - pos: position{line: 514, col: 15, offset: 10678}, - expr: &ruleRefExpr{ - pos: position{line: 514, col: 16, offset: 10679}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - &seqExpr{ - pos: position{line: 515, col: 5, offset: 10704}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 515, col: 5, offset: 10704}, - val: "string", - ignoreCase: true, - }, - ¬Expr{ - pos: position{line: 515, col: 15, offset: 10714}, - expr: &ruleRefExpr{ - pos: position{line: 515, col: 16, offset: 10715}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - &seqExpr{ - pos: position{line: 516, col: 5, offset: 10740}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 516, col: 5, offset: 10740}, - val: "text", - ignoreCase: true, - }, - ¬Expr{ - pos: position{line: 516, col: 13, offset: 10748}, - expr: &ruleRefExpr{ - pos: position{line: 516, col: 14, offset: 10749}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - }, - }, - }, - }, - { - name: "AddressType", - pos: position{line: 520, col: 1, offset: 10813}, - expr: &actionExpr{ - pos: position{line: 521, col: 4, offset: 10828}, - run: (*parser).callonAddressType1, - expr: &seqExpr{ - pos: position{line: 521, col: 4, offset: 10828}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 521, col: 4, offset: 10828}, - val: "address", - ignoreCase: true, - }, - ¬Expr{ - pos: position{line: 521, col: 15, offset: 10839}, - expr: &ruleRefExpr{ - pos: position{line: 521, col: 16, offset: 10840}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - }, - }, - { - name: "BoolType", - pos: position{line: 524, col: 1, offset: 10896}, - expr: &actionExpr{ - pos: position{line: 525, col: 4, offset: 10908}, - run: (*parser).callonBoolType1, - expr: &choiceExpr{ - pos: position{line: 525, col: 6, offset: 10910}, - alternatives: []interface{}{ - &seqExpr{ - pos: position{line: 525, col: 6, offset: 10910}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 525, col: 6, offset: 10910}, - val: "bool", - ignoreCase: true, - }, - ¬Expr{ - pos: position{line: 525, col: 14, offset: 10918}, - expr: &ruleRefExpr{ - pos: position{line: 525, col: 15, offset: 10919}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - &seqExpr{ - pos: position{line: 526, col: 5, offset: 10944}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 526, col: 5, offset: 10944}, - val: "boolean", - ignoreCase: true, - }, - ¬Expr{ - pos: position{line: 526, col: 16, offset: 10955}, - expr: &ruleRefExpr{ - pos: position{line: 526, col: 17, offset: 10956}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - }, - }, - }, - }, - { - name: "Value", - pos: position{line: 531, col: 1, offset: 11024}, - expr: &choiceExpr{ - pos: position{line: 532, col: 4, offset: 11033}, - alternatives: []interface{}{ - &ruleRefExpr{ - pos: position{line: 532, col: 4, offset: 11033}, - name: "NumberLiteral", - }, - &ruleRefExpr{ - pos: position{line: 533, col: 4, offset: 11050}, - name: "StringLiteral", - }, - &ruleRefExpr{ - pos: position{line: 534, col: 4, offset: 11067}, - name: "BoolLiteral", - }, - &ruleRefExpr{ - pos: position{line: 535, col: 4, offset: 11082}, - name: "NullLiteral", - }, - }, - }, - }, - { - name: "AnyLiteral", - pos: position{line: 537, col: 1, offset: 11095}, - expr: &actionExpr{ - pos: position{line: 538, col: 4, offset: 11109}, - run: (*parser).callonAnyLiteral1, - expr: &ruleRefExpr{ - pos: position{line: 538, col: 4, offset: 11109}, - name: "AnyToken", - }, - }, - }, - { - name: "DefaultLiteral", - pos: position{line: 541, col: 1, offset: 11150}, - expr: &actionExpr{ - pos: position{line: 542, col: 4, offset: 11168}, - run: (*parser).callonDefaultLiteral1, - expr: &ruleRefExpr{ - pos: position{line: 542, col: 4, offset: 11168}, - name: "DefaultToken", - }, - }, - }, - { - name: "BoolLiteral", - pos: position{line: 545, col: 1, offset: 11217}, - expr: &actionExpr{ - pos: position{line: 546, col: 4, offset: 11232}, - run: (*parser).callonBoolLiteral1, - expr: &labeledExpr{ - pos: position{line: 546, col: 4, offset: 11232}, - label: "b", - expr: &choiceExpr{ - pos: position{line: 546, col: 8, offset: 11236}, - alternatives: []interface{}{ - &ruleRefExpr{ - pos: position{line: 546, col: 8, offset: 11236}, - name: "TrueToken", - }, - &ruleRefExpr{ - pos: position{line: 546, col: 20, offset: 11248}, - name: "FalseToken", - }, - }, - }, - }, - }, - }, - { - name: "NullLiteral", - pos: position{line: 549, col: 1, offset: 11322}, - expr: &actionExpr{ - pos: position{line: 550, col: 4, offset: 11337}, - run: (*parser).callonNullLiteral1, - expr: &ruleRefExpr{ - pos: position{line: 550, col: 4, offset: 11337}, - name: "NullToken", - }, - }, - }, - { - name: "NumberLiteral", - pos: position{line: 553, col: 1, offset: 11380}, - expr: &choiceExpr{ - pos: position{line: 554, col: 4, offset: 11397}, - alternatives: []interface{}{ - &actionExpr{ - pos: position{line: 554, col: 4, offset: 11397}, - run: (*parser).callonNumberLiteral2, - expr: &seqExpr{ - pos: position{line: 554, col: 4, offset: 11397}, - exprs: []interface{}{ - &andExpr{ - pos: position{line: 554, col: 4, offset: 11397}, - expr: &seqExpr{ - pos: position{line: 554, col: 6, offset: 11399}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 554, col: 6, offset: 11399}, - val: "0", - ignoreCase: false, - }, - &litMatcher{ - pos: position{line: 554, col: 10, offset: 11403}, - val: "x", - ignoreCase: true, - }, - }, - }, - }, - &labeledExpr{ - pos: position{line: 554, col: 16, offset: 11409}, - label: "h", - expr: &ruleRefExpr{ - pos: position{line: 554, col: 18, offset: 11411}, - name: "Hex", - }, - }, - }, - }, - }, - &ruleRefExpr{ - pos: position{line: 555, col: 4, offset: 11436}, - name: "Decimal", - }, - }, - }, - }, - { - name: "Sign", - pos: position{line: 557, col: 1, offset: 11445}, - expr: &charClassMatcher{ - pos: position{line: 558, col: 4, offset: 11453}, - val: "[-+]", - chars: []rune{'-', '+'}, - ignoreCase: false, - inverted: false, - }, - }, - { - name: "Integer", - pos: position{line: 560, col: 1, offset: 11459}, - expr: &actionExpr{ - pos: position{line: 561, col: 4, offset: 11470}, - run: (*parser).callonInteger1, - expr: &oneOrMoreExpr{ - pos: position{line: 561, col: 4, offset: 11470}, - expr: &charClassMatcher{ - pos: position{line: 561, col: 4, offset: 11470}, - val: "[0-9]", - ranges: []rune{'0', '9'}, - ignoreCase: false, - inverted: false, - }, - }, - }, - }, - { - name: "NonZeroLeadingInteger", - pos: position{line: 564, col: 1, offset: 11533}, - expr: &actionExpr{ - pos: position{line: 565, col: 4, offset: 11558}, - run: (*parser).callonNonZeroLeadingInteger1, - expr: &choiceExpr{ - pos: position{line: 565, col: 6, offset: 11560}, - alternatives: []interface{}{ - &litMatcher{ - pos: position{line: 565, col: 6, offset: 11560}, - val: "0", - ignoreCase: false, - }, - &seqExpr{ - pos: position{line: 565, col: 12, offset: 11566}, - exprs: []interface{}{ - &charClassMatcher{ - pos: position{line: 565, col: 12, offset: 11566}, - val: "[1-9]", - ranges: []rune{'1', '9'}, - ignoreCase: false, - inverted: false, - }, - &zeroOrMoreExpr{ - pos: position{line: 565, col: 17, offset: 11571}, - expr: &charClassMatcher{ - pos: position{line: 565, col: 17, offset: 11571}, - val: "[0-9]", - ranges: []rune{'0', '9'}, - ignoreCase: false, - inverted: false, - }, - }, - }, - }, - }, - }, - }, - }, - { - name: "Fixnum", - pos: position{line: 568, col: 1, offset: 11604}, - expr: &choiceExpr{ - pos: position{line: 569, col: 4, offset: 11614}, - alternatives: []interface{}{ - &seqExpr{ - pos: position{line: 569, col: 4, offset: 11614}, - exprs: []interface{}{ - &ruleRefExpr{ - pos: position{line: 569, col: 4, offset: 11614}, - name: "Integer", - }, - &litMatcher{ - pos: position{line: 569, col: 12, offset: 11622}, - val: ".", - ignoreCase: false, - }, - &ruleRefExpr{ - pos: position{line: 569, col: 16, offset: 11626}, - name: "Integer", - }, - }, - }, - &seqExpr{ - pos: position{line: 570, col: 4, offset: 11637}, - exprs: []interface{}{ - &ruleRefExpr{ - pos: position{line: 570, col: 4, offset: 11637}, - name: "Integer", - }, - &zeroOrOneExpr{ - pos: position{line: 570, col: 12, offset: 11645}, - expr: &litMatcher{ - pos: position{line: 570, col: 12, offset: 11645}, - val: ".", - ignoreCase: false, - }, - }, - }, - }, - &seqExpr{ - pos: position{line: 571, col: 4, offset: 11653}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 571, col: 4, offset: 11653}, - val: ".", - ignoreCase: false, - }, - &ruleRefExpr{ - pos: position{line: 571, col: 8, offset: 11657}, - name: "Integer", - }, - }, - }, - }, - }, - }, - { - name: "Decimal", - pos: position{line: 573, col: 1, offset: 11666}, - expr: &actionExpr{ - pos: position{line: 574, col: 4, offset: 11677}, - run: (*parser).callonDecimal1, - expr: &seqExpr{ - pos: position{line: 574, col: 4, offset: 11677}, - exprs: []interface{}{ - &ruleRefExpr{ - pos: position{line: 574, col: 4, offset: 11677}, - name: "Fixnum", - }, - &zeroOrOneExpr{ - pos: position{line: 574, col: 11, offset: 11684}, - expr: &seqExpr{ - pos: position{line: 574, col: 13, offset: 11686}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 574, col: 13, offset: 11686}, - val: "e", - ignoreCase: true, - }, - &zeroOrOneExpr{ - pos: position{line: 574, col: 18, offset: 11691}, - expr: &ruleRefExpr{ - pos: position{line: 574, col: 18, offset: 11691}, - name: "Sign", - }, - }, - &ruleRefExpr{ - pos: position{line: 574, col: 24, offset: 11697}, - name: "Integer", - }, - }, - }, - }, - }, - }, - }, - }, - { - name: "Hex", - pos: position{line: 577, col: 1, offset: 11761}, - expr: &actionExpr{ - pos: position{line: 578, col: 4, offset: 11768}, - run: (*parser).callonHex1, - expr: &seqExpr{ - pos: position{line: 578, col: 4, offset: 11768}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 578, col: 4, offset: 11768}, - val: "0", - ignoreCase: false, - }, - &litMatcher{ - pos: position{line: 578, col: 8, offset: 11772}, - val: "x", - ignoreCase: true, - }, - &labeledExpr{ - pos: position{line: 578, col: 13, offset: 11777}, - label: "s", - expr: &oneOrMoreExpr{ - pos: position{line: 578, col: 15, offset: 11779}, - expr: &charClassMatcher{ - pos: position{line: 578, col: 17, offset: 11781}, - val: "[0-9A-Fa-f]", - ranges: []rune{'0', '9', 'A', 'F', 'a', 'f'}, - ignoreCase: false, - inverted: false, - }, - }, - }, - ¬Expr{ - pos: position{line: 578, col: 32, offset: 11796}, - expr: &ruleRefExpr{ - pos: position{line: 578, col: 33, offset: 11797}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - }, - }, - { - name: "StringLiteral", - pos: position{line: 581, col: 1, offset: 11862}, - expr: &choiceExpr{ - pos: position{line: 582, col: 4, offset: 11879}, - alternatives: []interface{}{ - &ruleRefExpr{ - pos: position{line: 582, col: 4, offset: 11879}, - name: "HexString", - }, - &ruleRefExpr{ - pos: position{line: 583, col: 4, offset: 11892}, - name: "NormalString", - }, - }, - }, - }, - { - name: "HexString", - pos: position{line: 585, col: 1, offset: 11906}, - expr: &actionExpr{ - pos: position{line: 586, col: 4, offset: 11919}, - run: (*parser).callonHexString1, - expr: &seqExpr{ - pos: position{line: 586, col: 4, offset: 11919}, - exprs: []interface{}{ - &choiceExpr{ - pos: position{line: 586, col: 6, offset: 11921}, - alternatives: []interface{}{ - &litMatcher{ - pos: position{line: 586, col: 6, offset: 11921}, - val: "hex", - ignoreCase: true, - }, - &litMatcher{ - pos: position{line: 586, col: 15, offset: 11930}, - val: "x", - ignoreCase: true, - }, - }, - }, - &litMatcher{ - pos: position{line: 586, col: 22, offset: 11937}, - val: "'", - ignoreCase: false, - }, - &labeledExpr{ - pos: position{line: 586, col: 26, offset: 11941}, - label: "s", - expr: &zeroOrMoreExpr{ - pos: position{line: 586, col: 28, offset: 11943}, - expr: &actionExpr{ - pos: position{line: 586, col: 29, offset: 11944}, - run: (*parser).callonHexString9, - expr: &seqExpr{ - pos: position{line: 586, col: 29, offset: 11944}, - exprs: []interface{}{ - &charClassMatcher{ - pos: position{line: 586, col: 29, offset: 11944}, - val: "[0-9a-fA-F]", - ranges: []rune{'0', '9', 'a', 'f', 'A', 'F'}, - ignoreCase: false, - inverted: false, - }, - &charClassMatcher{ - pos: position{line: 586, col: 40, offset: 11955}, - val: "[0-9a-fA-F]", - ranges: []rune{'0', '9', 'a', 'f', 'A', 'F'}, - ignoreCase: false, - inverted: false, - }, - }, - }, - }, - }, - }, - &litMatcher{ - pos: position{line: 586, col: 78, offset: 11993}, - val: "'", - ignoreCase: false, - }, - }, - }, - }, - }, - { - name: "NormalString", - pos: position{line: 589, col: 1, offset: 12055}, - expr: &actionExpr{ - pos: position{line: 590, col: 4, offset: 12071}, - run: (*parser).callonNormalString1, - expr: &seqExpr{ - pos: position{line: 590, col: 4, offset: 12071}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 590, col: 4, offset: 12071}, - val: "'", - ignoreCase: false, - }, - &labeledExpr{ - pos: position{line: 590, col: 8, offset: 12075}, - label: "s", - expr: &zeroOrMoreExpr{ - pos: position{line: 590, col: 10, offset: 12077}, - expr: &actionExpr{ - pos: position{line: 590, col: 12, offset: 12079}, - run: (*parser).callonNormalString6, - expr: &choiceExpr{ - pos: position{line: 590, col: 14, offset: 12081}, - alternatives: []interface{}{ - &charClassMatcher{ - pos: position{line: 590, col: 14, offset: 12081}, - val: "[^'\\r\\n\\\\]", - chars: []rune{'\'', '\r', '\n', '\\'}, - ignoreCase: false, - inverted: true, - }, - &seqExpr{ - pos: position{line: 590, col: 27, offset: 12094}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 590, col: 27, offset: 12094}, - val: "\\", - ignoreCase: false, - }, - &anyMatcher{ - line: 590, col: 32, offset: 12099, - }, - }, - }, - }, - }, - }, - }, - }, - &litMatcher{ - pos: position{line: 590, col: 62, offset: 12129}, - val: "'", - ignoreCase: false, - }, - }, - }, - }, - }, - { - name: "SelectToken", - pos: position{line: 594, col: 1, offset: 12206}, - expr: &seqExpr{ - pos: position{line: 595, col: 4, offset: 12221}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 595, col: 4, offset: 12221}, - val: "select", - ignoreCase: true, - }, - ¬Expr{ - pos: position{line: 595, col: 14, offset: 12231}, - expr: &ruleRefExpr{ - pos: position{line: 595, col: 15, offset: 12232}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - }, - { - name: "FromToken", - pos: position{line: 597, col: 1, offset: 12254}, - expr: &seqExpr{ - pos: position{line: 598, col: 4, offset: 12267}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 598, col: 4, offset: 12267}, - val: "from", - ignoreCase: true, - }, - ¬Expr{ - pos: position{line: 598, col: 12, offset: 12275}, - expr: &ruleRefExpr{ - pos: position{line: 598, col: 13, offset: 12276}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - }, - { - name: "WhereToken", - pos: position{line: 600, col: 1, offset: 12298}, - expr: &seqExpr{ - pos: position{line: 601, col: 4, offset: 12312}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 601, col: 4, offset: 12312}, - val: "where", - ignoreCase: true, - }, - ¬Expr{ - pos: position{line: 601, col: 13, offset: 12321}, - expr: &ruleRefExpr{ - pos: position{line: 601, col: 14, offset: 12322}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - }, - { - name: "OrderToken", - pos: position{line: 603, col: 1, offset: 12344}, - expr: &seqExpr{ - pos: position{line: 604, col: 4, offset: 12358}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 604, col: 4, offset: 12358}, - val: "order", - ignoreCase: true, - }, - ¬Expr{ - pos: position{line: 604, col: 13, offset: 12367}, - expr: &ruleRefExpr{ - pos: position{line: 604, col: 14, offset: 12368}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - }, - { - name: "ByToken", - pos: position{line: 606, col: 1, offset: 12390}, - expr: &seqExpr{ - pos: position{line: 607, col: 4, offset: 12401}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 607, col: 4, offset: 12401}, - val: "by", - ignoreCase: true, - }, - ¬Expr{ - pos: position{line: 607, col: 10, offset: 12407}, - expr: &ruleRefExpr{ - pos: position{line: 607, col: 11, offset: 12408}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - }, - { - name: "GroupToken", - pos: position{line: 609, col: 1, offset: 12430}, - expr: &seqExpr{ - pos: position{line: 610, col: 4, offset: 12444}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 610, col: 4, offset: 12444}, - val: "group", - ignoreCase: true, - }, - ¬Expr{ - pos: position{line: 610, col: 13, offset: 12453}, - expr: &ruleRefExpr{ - pos: position{line: 610, col: 14, offset: 12454}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - }, - { - name: "LimitToken", - pos: position{line: 612, col: 1, offset: 12476}, - expr: &seqExpr{ - pos: position{line: 613, col: 4, offset: 12490}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 613, col: 4, offset: 12490}, - val: "limit", - ignoreCase: true, - }, - ¬Expr{ - pos: position{line: 613, col: 13, offset: 12499}, - expr: &ruleRefExpr{ - pos: position{line: 613, col: 14, offset: 12500}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - }, - { - name: "OffsetToken", - pos: position{line: 615, col: 1, offset: 12522}, - expr: &seqExpr{ - pos: position{line: 616, col: 4, offset: 12537}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 616, col: 4, offset: 12537}, - val: "offset", - ignoreCase: true, - }, - ¬Expr{ - pos: position{line: 616, col: 14, offset: 12547}, - expr: &ruleRefExpr{ - pos: position{line: 616, col: 15, offset: 12548}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - }, - { - name: "UpdateToken", - pos: position{line: 618, col: 1, offset: 12570}, - expr: &seqExpr{ - pos: position{line: 619, col: 4, offset: 12585}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 619, col: 4, offset: 12585}, - val: "update", - ignoreCase: true, - }, - ¬Expr{ - pos: position{line: 619, col: 14, offset: 12595}, - expr: &ruleRefExpr{ - pos: position{line: 619, col: 15, offset: 12596}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - }, - { - name: "SetToken", - pos: position{line: 621, col: 1, offset: 12618}, - expr: &seqExpr{ - pos: position{line: 622, col: 4, offset: 12630}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 622, col: 4, offset: 12630}, - val: "set", - ignoreCase: true, - }, - ¬Expr{ - pos: position{line: 622, col: 11, offset: 12637}, - expr: &ruleRefExpr{ - pos: position{line: 622, col: 12, offset: 12638}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - }, - { - name: "DeleteToken", - pos: position{line: 624, col: 1, offset: 12660}, - expr: &seqExpr{ - pos: position{line: 625, col: 4, offset: 12675}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 625, col: 4, offset: 12675}, - val: "delete", - ignoreCase: true, - }, - ¬Expr{ - pos: position{line: 625, col: 14, offset: 12685}, - expr: &ruleRefExpr{ - pos: position{line: 625, col: 15, offset: 12686}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - }, - { - name: "InsertToken", - pos: position{line: 627, col: 1, offset: 12708}, - expr: &seqExpr{ - pos: position{line: 628, col: 4, offset: 12723}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 628, col: 4, offset: 12723}, - val: "insert", - ignoreCase: true, - }, - ¬Expr{ - pos: position{line: 628, col: 14, offset: 12733}, - expr: &ruleRefExpr{ - pos: position{line: 628, col: 15, offset: 12734}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - }, - { - name: "IntoToken", - pos: position{line: 630, col: 1, offset: 12756}, - expr: &seqExpr{ - pos: position{line: 631, col: 4, offset: 12769}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 631, col: 4, offset: 12769}, - val: "into", - ignoreCase: true, - }, - ¬Expr{ - pos: position{line: 631, col: 12, offset: 12777}, - expr: &ruleRefExpr{ - pos: position{line: 631, col: 13, offset: 12778}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - }, - { - name: "ValuesToken", - pos: position{line: 633, col: 1, offset: 12800}, - expr: &seqExpr{ - pos: position{line: 634, col: 4, offset: 12815}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 634, col: 4, offset: 12815}, - val: "values", - ignoreCase: true, - }, - ¬Expr{ - pos: position{line: 634, col: 14, offset: 12825}, - expr: &ruleRefExpr{ - pos: position{line: 634, col: 15, offset: 12826}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - }, - { - name: "CreateToken", - pos: position{line: 636, col: 1, offset: 12848}, - expr: &seqExpr{ - pos: position{line: 637, col: 4, offset: 12863}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 637, col: 4, offset: 12863}, - val: "create", - ignoreCase: true, - }, - ¬Expr{ - pos: position{line: 637, col: 14, offset: 12873}, - expr: &ruleRefExpr{ - pos: position{line: 637, col: 15, offset: 12874}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - }, - { - name: "TableToken", - pos: position{line: 639, col: 1, offset: 12896}, - expr: &seqExpr{ - pos: position{line: 640, col: 4, offset: 12910}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 640, col: 4, offset: 12910}, - val: "table", - ignoreCase: true, - }, - ¬Expr{ - pos: position{line: 640, col: 13, offset: 12919}, - expr: &ruleRefExpr{ - pos: position{line: 640, col: 14, offset: 12920}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - }, - { - name: "IndexToken", - pos: position{line: 642, col: 1, offset: 12942}, - expr: &seqExpr{ - pos: position{line: 643, col: 4, offset: 12956}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 643, col: 4, offset: 12956}, - val: "index", - ignoreCase: true, - }, - ¬Expr{ - pos: position{line: 643, col: 13, offset: 12965}, - expr: &ruleRefExpr{ - pos: position{line: 643, col: 14, offset: 12966}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - }, - { - name: "UniqueToken", - pos: position{line: 645, col: 1, offset: 12988}, - expr: &seqExpr{ - pos: position{line: 646, col: 4, offset: 13003}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 646, col: 4, offset: 13003}, - val: "unique", - ignoreCase: true, - }, - ¬Expr{ - pos: position{line: 646, col: 14, offset: 13013}, - expr: &ruleRefExpr{ - pos: position{line: 646, col: 15, offset: 13014}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - }, - { - name: "DefaultToken", - pos: position{line: 648, col: 1, offset: 13036}, - expr: &seqExpr{ - pos: position{line: 649, col: 4, offset: 13052}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 649, col: 4, offset: 13052}, - val: "default", - ignoreCase: true, - }, - ¬Expr{ - pos: position{line: 649, col: 15, offset: 13063}, - expr: &ruleRefExpr{ - pos: position{line: 649, col: 16, offset: 13064}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - }, - { - name: "PrimaryToken", - pos: position{line: 651, col: 1, offset: 13086}, - expr: &seqExpr{ - pos: position{line: 652, col: 4, offset: 13102}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 652, col: 4, offset: 13102}, - val: "primary", - ignoreCase: true, - }, - ¬Expr{ - pos: position{line: 652, col: 15, offset: 13113}, - expr: &ruleRefExpr{ - pos: position{line: 652, col: 16, offset: 13114}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - }, - { - name: "KeyToken", - pos: position{line: 654, col: 1, offset: 13136}, - expr: &seqExpr{ - pos: position{line: 655, col: 4, offset: 13148}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 655, col: 4, offset: 13148}, - val: "key", - ignoreCase: true, - }, - ¬Expr{ - pos: position{line: 655, col: 11, offset: 13155}, - expr: &ruleRefExpr{ - pos: position{line: 655, col: 12, offset: 13156}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - }, - { - name: "ReferencesToken", - pos: position{line: 657, col: 1, offset: 13178}, - expr: &seqExpr{ - pos: position{line: 658, col: 4, offset: 13197}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 658, col: 4, offset: 13197}, - val: "references", - ignoreCase: true, - }, - ¬Expr{ - pos: position{line: 658, col: 18, offset: 13211}, - expr: &ruleRefExpr{ - pos: position{line: 658, col: 19, offset: 13212}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - }, - { - name: "AutoincrementToken", - pos: position{line: 660, col: 1, offset: 13234}, - expr: &seqExpr{ - pos: position{line: 661, col: 4, offset: 13256}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 661, col: 4, offset: 13256}, - val: "autoincrement", - ignoreCase: true, - }, - ¬Expr{ - pos: position{line: 661, col: 21, offset: 13273}, - expr: &ruleRefExpr{ - pos: position{line: 661, col: 22, offset: 13274}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - }, - { - name: "OnToken", - pos: position{line: 663, col: 1, offset: 13296}, - expr: &seqExpr{ - pos: position{line: 664, col: 4, offset: 13307}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 664, col: 4, offset: 13307}, - val: "on", - ignoreCase: true, - }, - ¬Expr{ - pos: position{line: 664, col: 10, offset: 13313}, - expr: &ruleRefExpr{ - pos: position{line: 664, col: 11, offset: 13314}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - }, - { - name: "TrueToken", - pos: position{line: 666, col: 1, offset: 13336}, - expr: &actionExpr{ - pos: position{line: 667, col: 4, offset: 13349}, - run: (*parser).callonTrueToken1, - expr: &seqExpr{ - pos: position{line: 667, col: 4, offset: 13349}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 667, col: 4, offset: 13349}, - val: "true", - ignoreCase: true, - }, - ¬Expr{ - pos: position{line: 667, col: 12, offset: 13357}, - expr: &ruleRefExpr{ - pos: position{line: 667, col: 13, offset: 13358}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - }, - }, - { - name: "FalseToken", - pos: position{line: 670, col: 1, offset: 13412}, - expr: &actionExpr{ - pos: position{line: 671, col: 4, offset: 13426}, - run: (*parser).callonFalseToken1, - expr: &seqExpr{ - pos: position{line: 671, col: 4, offset: 13426}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 671, col: 4, offset: 13426}, - val: "false", - ignoreCase: true, - }, - ¬Expr{ - pos: position{line: 671, col: 13, offset: 13435}, - expr: &ruleRefExpr{ - pos: position{line: 671, col: 14, offset: 13436}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - }, - }, - { - name: "NullToken", - pos: position{line: 674, col: 1, offset: 13490}, - expr: &seqExpr{ - pos: position{line: 675, col: 4, offset: 13503}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 675, col: 4, offset: 13503}, - val: "null", - ignoreCase: true, - }, - ¬Expr{ - pos: position{line: 675, col: 12, offset: 13511}, - expr: &ruleRefExpr{ - pos: position{line: 675, col: 13, offset: 13512}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - }, - { - name: "IsToken", - pos: position{line: 677, col: 1, offset: 13534}, - expr: &seqExpr{ - pos: position{line: 678, col: 4, offset: 13545}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 678, col: 4, offset: 13545}, - val: "is", - ignoreCase: true, - }, - ¬Expr{ - pos: position{line: 678, col: 10, offset: 13551}, - expr: &ruleRefExpr{ - pos: position{line: 678, col: 11, offset: 13552}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - }, - { - name: "NullsToken", - pos: position{line: 680, col: 1, offset: 13574}, - expr: &seqExpr{ - pos: position{line: 681, col: 4, offset: 13588}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 681, col: 4, offset: 13588}, - val: "nulls", - ignoreCase: true, - }, - ¬Expr{ - pos: position{line: 681, col: 13, offset: 13597}, - expr: &ruleRefExpr{ - pos: position{line: 681, col: 14, offset: 13598}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - }, - { - name: "LastToken", - pos: position{line: 683, col: 1, offset: 13620}, - expr: &actionExpr{ - pos: position{line: 684, col: 4, offset: 13633}, - run: (*parser).callonLastToken1, - expr: &seqExpr{ - pos: position{line: 684, col: 4, offset: 13633}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 684, col: 4, offset: 13633}, - val: "last", - ignoreCase: true, - }, - ¬Expr{ - pos: position{line: 684, col: 12, offset: 13641}, - expr: &ruleRefExpr{ - pos: position{line: 684, col: 13, offset: 13642}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - }, - }, - { - name: "FirstToken", - pos: position{line: 687, col: 1, offset: 13696}, - expr: &actionExpr{ - pos: position{line: 688, col: 4, offset: 13710}, - run: (*parser).callonFirstToken1, - expr: &seqExpr{ - pos: position{line: 688, col: 4, offset: 13710}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 688, col: 4, offset: 13710}, - val: "first", - ignoreCase: true, - }, - ¬Expr{ - pos: position{line: 688, col: 13, offset: 13719}, - expr: &ruleRefExpr{ - pos: position{line: 688, col: 14, offset: 13720}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - }, - }, - { - name: "AndToken", - pos: position{line: 691, col: 1, offset: 13774}, - expr: &seqExpr{ - pos: position{line: 692, col: 4, offset: 13786}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 692, col: 4, offset: 13786}, - val: "and", - ignoreCase: true, - }, - ¬Expr{ - pos: position{line: 692, col: 11, offset: 13793}, - expr: &ruleRefExpr{ - pos: position{line: 692, col: 12, offset: 13794}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - }, - { - name: "OrToken", - pos: position{line: 694, col: 1, offset: 13816}, - expr: &seqExpr{ - pos: position{line: 695, col: 4, offset: 13827}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 695, col: 4, offset: 13827}, - val: "or", - ignoreCase: true, - }, - ¬Expr{ - pos: position{line: 695, col: 10, offset: 13833}, - expr: &ruleRefExpr{ - pos: position{line: 695, col: 11, offset: 13834}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - }, - { - name: "NotToken", - pos: position{line: 697, col: 1, offset: 13856}, - expr: &seqExpr{ - pos: position{line: 698, col: 4, offset: 13868}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 698, col: 4, offset: 13868}, - val: "not", - ignoreCase: true, - }, - ¬Expr{ - pos: position{line: 698, col: 11, offset: 13875}, - expr: &ruleRefExpr{ - pos: position{line: 698, col: 12, offset: 13876}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - }, - { - name: "InToken", - pos: position{line: 700, col: 1, offset: 13898}, - expr: &seqExpr{ - pos: position{line: 701, col: 4, offset: 13909}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 701, col: 4, offset: 13909}, - val: "in", - ignoreCase: true, - }, - ¬Expr{ - pos: position{line: 701, col: 10, offset: 13915}, - expr: &ruleRefExpr{ - pos: position{line: 701, col: 11, offset: 13916}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - }, - { - name: "LikeToken", - pos: position{line: 703, col: 1, offset: 13938}, - expr: &seqExpr{ - pos: position{line: 704, col: 4, offset: 13951}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 704, col: 4, offset: 13951}, - val: "like", - ignoreCase: true, - }, - ¬Expr{ - pos: position{line: 704, col: 12, offset: 13959}, - expr: &ruleRefExpr{ - pos: position{line: 704, col: 13, offset: 13960}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - }, - { - name: "AscToken", - pos: position{line: 706, col: 1, offset: 13982}, - expr: &actionExpr{ - pos: position{line: 707, col: 4, offset: 13994}, - run: (*parser).callonAscToken1, - expr: &seqExpr{ - pos: position{line: 707, col: 4, offset: 13994}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 707, col: 4, offset: 13994}, - val: "asc", - ignoreCase: true, - }, - ¬Expr{ - pos: position{line: 707, col: 11, offset: 14001}, - expr: &ruleRefExpr{ - pos: position{line: 707, col: 12, offset: 14002}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - }, - }, - { - name: "DescToken", - pos: position{line: 710, col: 1, offset: 14056}, - expr: &actionExpr{ - pos: position{line: 711, col: 4, offset: 14069}, - run: (*parser).callonDescToken1, - expr: &seqExpr{ - pos: position{line: 711, col: 4, offset: 14069}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 711, col: 4, offset: 14069}, - val: "desc", - ignoreCase: true, - }, - ¬Expr{ - pos: position{line: 711, col: 12, offset: 14077}, - expr: &ruleRefExpr{ - pos: position{line: 711, col: 13, offset: 14078}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - }, - }, - { - name: "CastToken", - pos: position{line: 714, col: 1, offset: 14132}, - expr: &seqExpr{ - pos: position{line: 715, col: 4, offset: 14145}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 715, col: 4, offset: 14145}, - val: "cast", - ignoreCase: true, - }, - ¬Expr{ - pos: position{line: 715, col: 12, offset: 14153}, - expr: &ruleRefExpr{ - pos: position{line: 715, col: 13, offset: 14154}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - }, - { - name: "AsToken", - pos: position{line: 717, col: 1, offset: 14176}, - expr: &seqExpr{ - pos: position{line: 718, col: 4, offset: 14187}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 718, col: 4, offset: 14187}, - val: "as", - ignoreCase: true, - }, - ¬Expr{ - pos: position{line: 718, col: 10, offset: 14193}, - expr: &ruleRefExpr{ - pos: position{line: 718, col: 11, offset: 14194}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - }, - { - name: "SeparatorToken", - pos: position{line: 720, col: 1, offset: 14216}, - expr: &litMatcher{ - pos: position{line: 721, col: 4, offset: 14234}, - val: ",", - ignoreCase: false, - }, - }, - { - name: "AnyToken", - pos: position{line: 723, col: 1, offset: 14239}, - expr: &litMatcher{ - pos: position{line: 724, col: 4, offset: 14251}, - val: "*", - ignoreCase: false, - }, - }, - { - name: "Identifier", - pos: position{line: 727, col: 1, offset: 14273}, - expr: &choiceExpr{ - pos: position{line: 728, col: 4, offset: 14287}, - alternatives: []interface{}{ - &ruleRefExpr{ - pos: position{line: 728, col: 4, offset: 14287}, - name: "NormalIdentifier", - }, - &ruleRefExpr{ - pos: position{line: 729, col: 4, offset: 14307}, - name: "StringIdentifier", - }, - }, - }, - }, - { - name: "NormalIdentifier", - pos: position{line: 731, col: 1, offset: 14325}, - expr: &actionExpr{ - pos: position{line: 732, col: 4, offset: 14345}, - run: (*parser).callonNormalIdentifier1, - expr: &seqExpr{ - pos: position{line: 732, col: 4, offset: 14345}, - exprs: []interface{}{ - &ruleRefExpr{ - pos: position{line: 732, col: 4, offset: 14345}, - name: "NormalIdentifierStart", - }, - &zeroOrMoreExpr{ - pos: position{line: 732, col: 26, offset: 14367}, - expr: &ruleRefExpr{ - pos: position{line: 732, col: 26, offset: 14367}, - name: "NormalIdentifierRest", - }, - }, - }, - }, - }, - }, - { - name: "NormalIdentifierStart", - pos: position{line: 735, col: 1, offset: 14429}, - expr: &charClassMatcher{ - pos: position{line: 736, col: 4, offset: 14454}, - val: "[a-zA-Z@#_\\u0080-\\uffff]", - chars: []rune{'@', '#', '_'}, - ranges: []rune{'a', 'z', 'A', 'Z', '\u0080', '\uffff'}, - ignoreCase: false, - inverted: false, - }, - }, - { - name: "NormalIdentifierRest", - pos: position{line: 738, col: 1, offset: 14480}, - expr: &charClassMatcher{ - pos: position{line: 739, col: 4, offset: 14504}, - val: "[a-zA-Z0-9@#$_\\u0080-\\uffff]", - chars: []rune{'@', '#', '$', '_'}, - ranges: []rune{'a', 'z', 'A', 'Z', '0', '9', '\u0080', '\uffff'}, - ignoreCase: false, - inverted: false, - }, - }, - { - name: "StringIdentifier", - pos: position{line: 741, col: 1, offset: 14534}, - expr: &actionExpr{ - pos: position{line: 742, col: 4, offset: 14554}, - run: (*parser).callonStringIdentifier1, - expr: &seqExpr{ - pos: position{line: 742, col: 4, offset: 14554}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 742, col: 4, offset: 14554}, - val: "\"", - ignoreCase: false, - }, - &labeledExpr{ - pos: position{line: 742, col: 9, offset: 14559}, - label: "s", - expr: &zeroOrMoreExpr{ - pos: position{line: 742, col: 11, offset: 14561}, - expr: &actionExpr{ - pos: position{line: 742, col: 13, offset: 14563}, - run: (*parser).callonStringIdentifier6, - expr: &choiceExpr{ - pos: position{line: 742, col: 15, offset: 14565}, - alternatives: []interface{}{ - &charClassMatcher{ - pos: position{line: 742, col: 15, offset: 14565}, - val: "[^\"\\r\\n\\\\]", - chars: []rune{'"', '\r', '\n', '\\'}, - ignoreCase: false, - inverted: true, - }, - &seqExpr{ - pos: position{line: 742, col: 28, offset: 14578}, - exprs: []interface{}{ - &litMatcher{ - pos: position{line: 742, col: 28, offset: 14578}, - val: "\\", - ignoreCase: false, - }, - &anyMatcher{ - line: 742, col: 33, offset: 14583, - }, - }, - }, - }, - }, - }, - }, - }, - &litMatcher{ - pos: position{line: 742, col: 63, offset: 14613}, - val: "\"", - ignoreCase: false, - }, - }, - }, - }, - }, - { - name: "_", - pos: position{line: 748, col: 1, offset: 14691}, - expr: &zeroOrMoreExpr{ - pos: position{line: 749, col: 4, offset: 14696}, - expr: &choiceExpr{ - pos: position{line: 749, col: 6, offset: 14698}, - alternatives: []interface{}{ - &ruleRefExpr{ - pos: position{line: 749, col: 6, offset: 14698}, - name: "Whitespace", - }, - &ruleRefExpr{ - pos: position{line: 749, col: 19, offset: 14711}, - name: "Newline", - }, - }, - }, - }, - }, - { - name: "Newline", - pos: position{line: 751, col: 1, offset: 14723}, - expr: &choiceExpr{ - pos: position{line: 752, col: 4, offset: 14734}, - alternatives: []interface{}{ - &litMatcher{ - pos: position{line: 752, col: 4, offset: 14734}, - val: "\r\n", - ignoreCase: false, - }, - &litMatcher{ - pos: position{line: 753, col: 4, offset: 14744}, - val: "\r", - ignoreCase: false, - }, - &litMatcher{ - pos: position{line: 754, col: 4, offset: 14752}, - val: "\n", - ignoreCase: false, - }, - }, - }, - }, - { - name: "Whitespace", - pos: position{line: 756, col: 1, offset: 14758}, - expr: &choiceExpr{ - pos: position{line: 757, col: 4, offset: 14772}, - alternatives: []interface{}{ - &litMatcher{ - pos: position{line: 757, col: 4, offset: 14772}, - val: " ", - ignoreCase: false, - }, - &litMatcher{ - pos: position{line: 758, col: 4, offset: 14779}, - val: "\t", - ignoreCase: false, - }, - &litMatcher{ - pos: position{line: 759, col: 4, offset: 14787}, - val: "\v", - ignoreCase: false, - }, - &litMatcher{ - pos: position{line: 760, col: 4, offset: 14795}, - val: "\f", - ignoreCase: false, - }, - }, - }, - }, - { - name: "EOF", - pos: position{line: 762, col: 1, offset: 14801}, - expr: ¬Expr{ - pos: position{line: 763, col: 4, offset: 14808}, - expr: &anyMatcher{ - line: 763, col: 5, offset: 14809, - }, - }, - }, - }, -} - -func (c *current) onS10(s interface{}) (interface{}, error) { - return s, nil -} - -func (p *parser) callonS10() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onS10(stack["s"]) -} - -func (c *current) onS1(x, xs interface{}) (interface{}, error) { - return prepend(x, xs), nil -} - -func (p *parser) callonS1() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onS1(stack["x"], stack["xs"]) -} - -func (c *current) onSelectStmt9(s interface{}) (interface{}, error) { - return s, nil -} - -func (p *parser) callonSelectStmt9() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onSelectStmt9(stack["s"]) -} - -func (c *current) onSelectStmt18(i interface{}) (interface{}, error) { - return i, nil -} - -func (p *parser) callonSelectStmt18() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onSelectStmt18(stack["i"]) -} - -func (c *current) onSelectStmt27(w interface{}) (interface{}, error) { - return w, nil -} - -func (p *parser) callonSelectStmt27() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onSelectStmt27(stack["w"]) -} - -func (c *current) onSelectStmt34(g interface{}) (interface{}, error) { - return g, nil -} - -func (p *parser) callonSelectStmt34() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onSelectStmt34(stack["g"]) -} - -func (c *current) onSelectStmt41(or interface{}) (interface{}, error) { - return or, nil -} - -func (p *parser) callonSelectStmt41() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onSelectStmt41(stack["or"]) -} - -func (c *current) onSelectStmt48(l interface{}) (interface{}, error) { - return l, nil -} - -func (p *parser) callonSelectStmt48() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onSelectStmt48(stack["l"]) -} - -func (c *current) onSelectStmt55(of interface{}) (interface{}, error) { - return of, nil -} - -func (p *parser) callonSelectStmt55() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onSelectStmt55(stack["of"]) -} - -func (c *current) onSelectStmt1(f, fs, table, where, group, order, limit, offset interface{}) (interface{}, error) { - var ( - tableNode *identifierNode - whereNode *whereOptionNode - limitNode *limitOptionNode - offsetNode *offsetOptionNode - ) - if table != nil { - t := table.(identifierNode) - tableNode = &t - } - if where != nil { - w := where.(whereOptionNode) - whereNode = &w - } - if limit != nil { - l := limit.(limitOptionNode) - limitNode = &l - } - if offset != nil { - of := offset.(offsetOptionNode) - offsetNode = &of - } - return selectStmtNode{ - column: prepend(f, fs), - table: tableNode, - where: whereNode, - group: toSlice(group), - order: toSlice(order), - limit: limitNode, - offset: offsetNode, - }, nil -} - -func (p *parser) callonSelectStmt1() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onSelectStmt1(stack["f"], stack["fs"], stack["table"], stack["where"], stack["group"], stack["order"], stack["limit"], stack["offset"]) -} - -func (c *current) onUpdateStmt14(s interface{}) (interface{}, error) { - return s, nil -} - -func (p *parser) callonUpdateStmt14() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onUpdateStmt14(stack["s"]) -} - -func (c *current) onUpdateStmt23(w interface{}) (interface{}, error) { - return w, nil -} - -func (p *parser) callonUpdateStmt23() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onUpdateStmt23(stack["w"]) -} - -func (c *current) onUpdateStmt1(table, a, as, where interface{}) (interface{}, error) { - var ( - whereNode *whereOptionNode - ) - if where != nil { - w := where.(whereOptionNode) - whereNode = &w - } - return updateStmtNode{ - table: table.(identifierNode), - assignment: prepend(a, as), - where: whereNode, - }, nil -} - -func (p *parser) callonUpdateStmt1() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onUpdateStmt1(stack["table"], stack["a"], stack["as"], stack["where"]) -} - -func (c *current) onDeleteStmt11(w interface{}) (interface{}, error) { - return w, nil -} - -func (p *parser) callonDeleteStmt11() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onDeleteStmt11(stack["w"]) -} - -func (c *current) onDeleteStmt1(table, where interface{}) (interface{}, error) { - var ( - whereNode *whereOptionNode - ) - if where != nil { - w := where.(whereOptionNode) - whereNode = &w - } - return deleteStmtNode{ - table: table.(identifierNode), - where: whereNode, - }, nil -} - -func (p *parser) callonDeleteStmt1() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onDeleteStmt1(stack["table"], stack["where"]) -} - -func (c *current) onInsertStmt1(table, insert interface{}) (interface{}, error) { - return insertStmtNode{ - table: table.(identifierNode), - insert: insert, - }, nil -} - -func (p *parser) callonInsertStmt1() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onInsertStmt1(stack["table"], stack["insert"]) -} - -func (c *current) onInsertValue1(e interface{}) (interface{}, error) { - return e, nil -} - -func (p *parser) callonInsertValue1() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onInsertValue1(stack["e"]) -} - -func (c *current) onCreateTableStmt20(t interface{}) (interface{}, error) { - return t, nil -} - -func (p *parser) callonCreateTableStmt20() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onCreateTableStmt20(stack["t"]) -} - -func (c *current) onCreateTableStmt14(s, ss interface{}) (interface{}, error) { - return prepend(s, ss), nil -} - -func (p *parser) callonCreateTableStmt14() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onCreateTableStmt14(stack["s"], stack["ss"]) -} - -func (c *current) onCreateTableStmt1(table, column interface{}) (interface{}, error) { - return createTableStmtNode{ - table: table.(identifierNode), - column: toSlice(column), - }, nil -} - -func (p *parser) callonCreateTableStmt1() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onCreateTableStmt1(stack["table"], stack["column"]) -} - -func (c *current) onColumnSchema10(s interface{}) (interface{}, error) { - return s, nil -} - -func (p *parser) callonColumnSchema10() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onColumnSchema10(stack["s"]) -} - -func (c *current) onColumnSchema1(i, t, cs interface{}) (interface{}, error) { - return columnSchemaNode{ - column: i.(identifierNode), - dataType: t, - constraint: toSlice(cs), - }, nil -} - -func (p *parser) callonColumnSchema1() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onColumnSchema1(stack["i"], stack["t"], stack["cs"]) -} - -func (c *current) onCreateIndexStmt6(u interface{}) (interface{}, error) { - return u, nil -} - -func (p *parser) callonCreateIndexStmt6() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onCreateIndexStmt6(stack["u"]) -} - -func (c *current) onCreateIndexStmt28(x interface{}) (interface{}, error) { - return x, nil -} - -func (p *parser) callonCreateIndexStmt28() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onCreateIndexStmt28(stack["x"]) -} - -func (c *current) onCreateIndexStmt1(unique, index, table, i, is interface{}) (interface{}, error) { - var ( - uniqueNode *uniqueOptionNode - ) - if unique != nil { - u := unique.(uniqueOptionNode) - uniqueNode = &u - } - return createIndexStmtNode{ - index: index.(identifierNode), - table: table.(identifierNode), - column: prepend(i, is), - unique: uniqueNode, - }, nil -} - -func (p *parser) callonCreateIndexStmt1() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onCreateIndexStmt1(stack["unique"], stack["index"], stack["table"], stack["i"], stack["is"]) -} - -func (c *current) onWhereClause1(e interface{}) (interface{}, error) { - return whereOptionNode{condition: e}, nil -} - -func (p *parser) callonWhereClause1() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onWhereClause1(stack["e"]) -} - -func (c *current) onOrderByClause11(s interface{}) (interface{}, error) { - return s, nil -} - -func (p *parser) callonOrderByClause11() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onOrderByClause11(stack["s"]) -} - -func (c *current) onOrderByClause1(f, fs interface{}) (interface{}, error) { - return prepend(f, fs), nil -} - -func (p *parser) callonOrderByClause1() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onOrderByClause1(stack["f"], stack["fs"]) -} - -func (c *current) onOrderColumn7(t interface{}) (interface{}, error) { - return t, nil -} - -func (p *parser) callonOrderColumn7() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onOrderColumn7(stack["t"]) -} - -func (c *current) onOrderColumn16(l interface{}) (interface{}, error) { - return l, nil -} - -func (p *parser) callonOrderColumn16() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onOrderColumn16(stack["l"]) -} - -func (c *current) onOrderColumn1(i, s, n interface{}) (interface{}, error) { - return orderOptionNode{ - expr: i, - desc: s != nil && string(s.([]byte)) == "desc", - nullfirst: n != nil && string(n.([]byte)) == "first", - }, nil -} - -func (p *parser) callonOrderColumn1() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onOrderColumn1(stack["i"], stack["s"], stack["n"]) -} - -func (c *current) onGroupByClause11(s interface{}) (interface{}, error) { - return groupOptionNode{expr: s}, nil -} - -func (p *parser) callonGroupByClause11() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onGroupByClause11(stack["s"]) -} - -func (c *current) onGroupByClause1(i, is interface{}) (interface{}, error) { - return prepend(groupOptionNode{expr: i}, is), nil -} - -func (p *parser) callonGroupByClause1() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onGroupByClause1(stack["i"], stack["is"]) -} - -func (c *current) onOffsetClause1(i interface{}) (interface{}, error) { - return offsetOptionNode{value: i.(integerValueNode)}, nil -} - -func (p *parser) callonOffsetClause1() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onOffsetClause1(stack["i"]) -} - -func (c *current) onLimitClause1(i interface{}) (interface{}, error) { - return limitOptionNode{value: i.(integerValueNode)}, nil -} - -func (p *parser) callonLimitClause1() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onLimitClause1(stack["i"]) -} - -func (c *current) onInsertWithColumnClause13(x interface{}) (interface{}, error) { - return x, nil -} - -func (p *parser) callonInsertWithColumnClause13() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onInsertWithColumnClause13(stack["x"]) -} - -func (c *current) onInsertWithColumnClause5(f, fs interface{}) (interface{}, error) { - return prepend(f, fs), nil -} - -func (p *parser) callonInsertWithColumnClause5() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onInsertWithColumnClause5(stack["f"], stack["fs"]) -} - -func (c *current) onInsertWithColumnClause29(y interface{}) (interface{}, error) { - return y, nil -} - -func (p *parser) callonInsertWithColumnClause29() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onInsertWithColumnClause29(stack["y"]) -} - -func (c *current) onInsertWithColumnClause1(cs, v, vs interface{}) (interface{}, error) { - return insertWithColumnOptionNode{ - column: toSlice(cs), - value: prepend(v, vs), - }, nil -} - -func (p *parser) callonInsertWithColumnClause1() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onInsertWithColumnClause1(stack["cs"], stack["v"], stack["vs"]) -} - -func (c *current) onInsertWithDefaultClause1() (interface{}, error) { - return insertWithDefaultOptionNode{}, nil -} - -func (p *parser) callonInsertWithDefaultClause1() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onInsertWithDefaultClause1() -} - -func (c *current) onPrimaryKeyClause1() (interface{}, error) { - return primaryOptionNode{}, nil -} - -func (p *parser) callonPrimaryKeyClause1() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onPrimaryKeyClause1() -} - -func (c *current) onNotNullClause1() (interface{}, error) { - return notNullOptionNode{}, nil -} - -func (p *parser) callonNotNullClause1() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onNotNullClause1() -} - -func (c *current) onUniqueClause1() (interface{}, error) { - return uniqueOptionNode{}, nil -} - -func (p *parser) callonUniqueClause1() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onUniqueClause1() -} - -func (c *current) onDefaultClause1(e interface{}) (interface{}, error) { - return defaultOptionNode{value: e}, nil -} - -func (p *parser) callonDefaultClause1() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onDefaultClause1(stack["e"]) -} - -func (c *current) onForeignClause1(t, f interface{}) (interface{}, error) { - return foreignOptionNode{ - table: t.(identifierNode), - column: f.(identifierNode), - }, nil -} - -func (p *parser) callonForeignClause1() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onForeignClause1(stack["t"], stack["f"]) -} - -func (c *current) onAutoincrementClause1() (interface{}, error) { - return autoincrementOptionNode{}, nil -} - -func (p *parser) callonAutoincrementClause1() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onAutoincrementClause1() -} - -func (c *current) onExprWithDefault2(d interface{}) (interface{}, error) { - return d, nil -} - -func (p *parser) callonExprWithDefault2() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onExprWithDefault2(stack["d"]) -} - -func (c *current) onLogicExpr47(op, s interface{}) (interface{}, error) { - return opSetSubject(op, s), nil -} - -func (p *parser) callonLogicExpr47() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onLogicExpr47(stack["op"], stack["s"]) -} - -func (c *current) onLogicExpr41(o, os interface{}) (interface{}, error) { - return rightJoinOperators(o, os), nil -} - -func (p *parser) callonLogicExpr41() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onLogicExpr41(stack["o"], stack["os"]) -} - -func (c *current) onLogicExpr37(op, s interface{}) (interface{}, error) { - return opSetSubject(op, s), nil -} - -func (p *parser) callonLogicExpr37() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onLogicExpr37(stack["op"], stack["s"]) -} - -func (c *current) onLogicExpr31(o, os interface{}) (interface{}, error) { - return rightJoinOperators(o, os), nil -} - -func (p *parser) callonLogicExpr31() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onLogicExpr31(stack["o"], stack["os"]) -} - -func (c *current) onLogicExpr22(op, s interface{}) (interface{}, error) { - return opSetTarget(op, s), nil -} - -func (p *parser) callonLogicExpr22() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onLogicExpr22(stack["op"], stack["s"]) -} - -func (c *current) onLogicExpr17(l interface{}) (interface{}, error) { - return l, nil -} - -func (p *parser) callonLogicExpr17() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onLogicExpr17(stack["l"]) -} - -func (c *current) onLogicExpr11(o, os interface{}) (interface{}, error) { - return rightJoinOperators(o, os), nil -} - -func (p *parser) callonLogicExpr11() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onLogicExpr11(stack["o"], stack["os"]) -} - -func (c *current) onLogicExpr1In5(t interface{}) (interface{}, error) { - return t, nil -} - -func (p *parser) callonLogicExpr1In5() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onLogicExpr1In5(stack["t"]) -} - -func (c *current) onLogicExpr1In1(n, s interface{}) (interface{}, error) { - op := opSetSubject(&inOperatorNode{}, s) - if n != nil { - return opSetTarget(n, op), nil - } - return op, nil -} - -func (p *parser) callonLogicExpr1In1() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onLogicExpr1In1(stack["n"], stack["s"]) -} - -func (c *current) onLogicExpr1Null6(t interface{}) (interface{}, error) { - return t, nil -} - -func (p *parser) callonLogicExpr1Null6() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onLogicExpr1Null6(stack["t"]) -} - -func (c *current) onLogicExpr1Null1(n interface{}) (interface{}, error) { - op := opSetSubject(&isOperatorNode{}, nullValueNode{}) - if n != nil { - return opSetTarget(n, op), nil - } - return op, nil -} - -func (p *parser) callonLogicExpr1Null1() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onLogicExpr1Null1(stack["n"]) -} - -func (c *current) onLogicExpr1Like5(t interface{}) (interface{}, error) { - return t, nil -} - -func (p *parser) callonLogicExpr1Like5() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onLogicExpr1Like5(stack["t"]) -} - -func (c *current) onLogicExpr1Like1(n, s interface{}) (interface{}, error) { - op := opSetSubject(&likeOperatorNode{}, s) - if n != nil { - return opSetTarget(n, op), nil - } - return op, nil -} - -func (p *parser) callonLogicExpr1Like1() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onLogicExpr1Like1(stack["n"], stack["s"]) -} - -func (c *current) onLogicExpr1Cmp1(op, s interface{}) (interface{}, error) { - return opSetSubject(op, s), nil -} - -func (p *parser) callonLogicExpr1Cmp1() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onLogicExpr1Cmp1(stack["op"], stack["s"]) -} - -func (c *current) onArithmeticExpr37(op, s interface{}) (interface{}, error) { - return opSetSubject(op, s), nil -} - -func (p *parser) callonArithmeticExpr37() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onArithmeticExpr37(stack["op"], stack["s"]) -} - -func (c *current) onArithmeticExpr31(o, os interface{}) (interface{}, error) { - return rightJoinOperators(o, os), nil -} - -func (p *parser) callonArithmeticExpr31() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onArithmeticExpr31(stack["o"], stack["os"]) -} - -func (c *current) onArithmeticExpr27(op, s interface{}) (interface{}, error) { - return opSetSubject(op, s), nil -} - -func (p *parser) callonArithmeticExpr27() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onArithmeticExpr27(stack["op"], stack["s"]) -} - -func (c *current) onArithmeticExpr21(o, os interface{}) (interface{}, error) { - return rightJoinOperators(o, os), nil -} - -func (p *parser) callonArithmeticExpr21() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onArithmeticExpr21(stack["o"], stack["os"]) -} - -func (c *current) onArithmeticExpr17(op, s interface{}) (interface{}, error) { - return opSetSubject(op, s), nil -} - -func (p *parser) callonArithmeticExpr17() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onArithmeticExpr17(stack["op"], stack["s"]) -} - -func (c *current) onArithmeticExpr11(o, os interface{}) (interface{}, error) { - return rightJoinOperators(o, os), nil -} - -func (p *parser) callonArithmeticExpr11() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onArithmeticExpr11(stack["o"], stack["os"]) -} - -func (c *current) onMultiExpr7(e interface{}) (interface{}, error) { - return e, nil -} - -func (p *parser) callonMultiExpr7() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onMultiExpr7(stack["e"]) -} - -func (c *current) onMultiExpr1(x, xs interface{}) (interface{}, error) { - return prepend(x, xs), nil -} - -func (p *parser) callonMultiExpr1() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onMultiExpr1(stack["x"], stack["xs"]) -} - -func (c *current) onMultiExprWithDefault7(e interface{}) (interface{}, error) { - return e, nil -} - -func (p *parser) callonMultiExprWithDefault7() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onMultiExprWithDefault7(stack["e"]) -} - -func (c *current) onMultiExprWithDefault1(x, xs interface{}) (interface{}, error) { - return prepend(x, xs), nil -} - -func (p *parser) callonMultiExprWithDefault1() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onMultiExprWithDefault1(stack["x"], stack["xs"]) -} - -func (c *current) onOperand2(op, s interface{}) (interface{}, error) { - return opSetTarget(op, s), nil -} - -func (p *parser) callonOperand2() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onOperand2(stack["op"], stack["s"]) -} - -func (c *current) onOperand9(e interface{}) (interface{}, error) { - return e, nil -} - -func (p *parser) callonOperand9() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onOperand9(stack["e"]) -} - -func (c *current) onOperand17(t interface{}) (interface{}, error) { - return t, nil -} - -func (p *parser) callonOperand17() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onOperand17(stack["t"]) -} - -func (c *current) onTypeCast1(o, s interface{}) (interface{}, error) { - return opSetSubject(opSetObject(&castOperatorNode{}, o), s), nil -} - -func (p *parser) callonTypeCast1() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onTypeCast1(stack["o"], stack["s"]) -} - -func (c *current) onFunctionCall1(i, r interface{}) (interface{}, error) { - return opSetSubject(opSetObject(&functionOperatorNode{}, i), r), nil -} - -func (p *parser) callonFunctionCall1() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onFunctionCall1(stack["i"], stack["r"]) -} - -func (c *current) onFunctionArgs2(a interface{}) (interface{}, error) { - return []interface{}{a}, nil -} - -func (p *parser) callonFunctionArgs2() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onFunctionArgs2(stack["a"]) -} - -func (c *current) onAssignment1(i, e interface{}) (interface{}, error) { - return opSetSubject(opSetObject(&assignOperatorNode{}, i), e), nil -} - -func (p *parser) callonAssignment1() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onAssignment1(stack["i"], stack["e"]) -} - -func (c *current) onSignOperator1() (interface{}, error) { - switch string(c.text) { - case "+": - return &posOperatorNode{}, nil - case "-": - return &negOperatorNode{}, nil - } - return nil, errors.New("unknown sign") -} - -func (p *parser) callonSignOperator1() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onSignOperator1() -} - -func (c *current) onNotOperator1() (interface{}, error) { - return ¬OperatorNode{}, nil -} - -func (p *parser) callonNotOperator1() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onNotOperator1() -} - -func (c *current) onAndOperator1() (interface{}, error) { - return &andOperatorNode{}, nil -} - -func (p *parser) callonAndOperator1() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onAndOperator1() -} - -func (c *current) onOrOperator1() (interface{}, error) { - return &orOperatorNode{}, nil -} - -func (p *parser) callonOrOperator1() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onOrOperator1() -} - -func (c *current) onCmpOperator1() (interface{}, error) { - switch string(c.text) { - case "<=": - return &lessOrEqualOperatorNode{}, nil - case ">=": - return &greaterOrEqualOperatorNode{}, nil - case "<>": - return ¬EqualOperatorNode{}, nil - case "!=": - return ¬EqualOperatorNode{}, nil - case "<": - return &lessOperatorNode{}, nil - case ">": - return &greaterOperatorNode{}, nil - case "=": - return &equalOperatorNode{}, nil - } - return nil, errors.New("unknown cmp") -} - -func (p *parser) callonCmpOperator1() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onCmpOperator1() -} - -func (c *current) onConcatOperator1() (interface{}, error) { - return &concatOperatorNode{}, nil -} - -func (p *parser) callonConcatOperator1() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onConcatOperator1() -} - -func (c *current) onAddSubOperator1() (interface{}, error) { - switch string(c.text) { - case "+": - return &addOperatorNode{}, nil - case "-": - return &subOperatorNode{}, nil - } - return nil, errors.New("unknown add sub") -} - -func (p *parser) callonAddSubOperator1() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onAddSubOperator1() -} - -func (c *current) onMulDivModOperator1() (interface{}, error) { - switch string(c.text) { - case "*": - return &mulOperatorNode{}, nil - case "/": - return &divOperatorNode{}, nil - case "%": - return &modOperatorNode{}, nil - } - return nil, errors.New("unknown mul div mod") -} - -func (p *parser) callonMulDivModOperator1() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onMulDivModOperator1() -} - -func (c *current) onUIntType1(s interface{}) (interface{}, error) { - return intTypeNode{size: toInt(s.([]byte)), unsigned: true}, nil -} - -func (p *parser) callonUIntType1() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onUIntType1(stack["s"]) -} - -func (c *current) onIntType1(s interface{}) (interface{}, error) { - return intTypeNode{size: toInt(s.([]byte))}, nil -} - -func (p *parser) callonIntType1() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onIntType1(stack["s"]) -} - -func (c *current) onUFixedType1(s, t interface{}) (interface{}, error) { - return fixedTypeNode{ - integerSize: toInt(s.([]byte)), - fractionalSize: toInt(t.([]byte)), - unsigned: true, - }, nil -} - -func (p *parser) callonUFixedType1() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onUFixedType1(stack["s"], stack["t"]) -} - -func (c *current) onFixedType1(s, t interface{}) (interface{}, error) { - return fixedTypeNode{ - integerSize: toInt(s.([]byte)), - fractionalSize: toInt(t.([]byte)), - }, nil -} - -func (p *parser) callonFixedType1() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onFixedType1(stack["s"], stack["t"]) -} - -func (c *current) onFixedBytesType2(s interface{}) (interface{}, error) { - return fixedBytesTypeNode{size: toInt(s.([]byte))}, nil -} - -func (p *parser) callonFixedBytesType2() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onFixedBytesType2(stack["s"]) -} - -func (c *current) onFixedBytesType9() (interface{}, error) { - return fixedBytesTypeNode{size: 1}, nil -} - -func (p *parser) callonFixedBytesType9() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onFixedBytesType9() -} - -func (c *current) onDynamicBytesType1() (interface{}, error) { - return dynamicBytesTypeNode{}, nil -} - -func (p *parser) callonDynamicBytesType1() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onDynamicBytesType1() -} - -func (c *current) onAddressType1() (interface{}, error) { - return addressTypeNode{}, nil -} - -func (p *parser) callonAddressType1() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onAddressType1() -} - -func (c *current) onBoolType1() (interface{}, error) { - return boolTypeNode{}, nil -} - -func (p *parser) callonBoolType1() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onBoolType1() -} - -func (c *current) onAnyLiteral1() (interface{}, error) { - return anyValueNode{}, nil -} - -func (p *parser) callonAnyLiteral1() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onAnyLiteral1() -} - -func (c *current) onDefaultLiteral1() (interface{}, error) { - return defaultValueNode{}, nil -} - -func (p *parser) callonDefaultLiteral1() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onDefaultLiteral1() -} - -func (c *current) onBoolLiteral1(b interface{}) (interface{}, error) { - return boolValueNode(string(b.([]byte)) == "true"), nil -} - -func (p *parser) callonBoolLiteral1() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onBoolLiteral1(stack["b"]) -} - -func (c *current) onNullLiteral1() (interface{}, error) { - return nullValueNode{}, nil -} - -func (p *parser) callonNullLiteral1() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onNullLiteral1() -} - -func (c *current) onNumberLiteral2(h interface{}) (interface{}, error) { - return h, nil -} - -func (p *parser) callonNumberLiteral2() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onNumberLiteral2(stack["h"]) -} - -func (c *current) onInteger1() (interface{}, error) { - return integerValueNode{v: toDecimal(c.text)}, nil -} - -func (p *parser) callonInteger1() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onInteger1() -} - -func (c *current) onNonZeroLeadingInteger1() (interface{}, error) { - return c.text, nil -} - -func (p *parser) callonNonZeroLeadingInteger1() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onNonZeroLeadingInteger1() -} - -func (c *current) onDecimal1() (interface{}, error) { - return decimalValueNode(toDecimal(c.text)), nil -} - -func (p *parser) callonDecimal1() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onDecimal1() -} - -func (c *current) onHex1(s interface{}) (interface{}, error) { - return hexToInteger(joinBytes(s)), nil -} - -func (p *parser) callonHex1() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onHex1(stack["s"]) -} - -func (c *current) onHexString9() (interface{}, error) { - return c.text, nil -} - -func (p *parser) callonHexString9() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onHexString9() -} - -func (c *current) onHexString1(s interface{}) (interface{}, error) { - return bytesValueNode(hexToBytes(joinBytes(s))), nil -} - -func (p *parser) callonHexString1() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onHexString1(stack["s"]) -} - -func (c *current) onNormalString6() (interface{}, error) { - return c.text, nil -} - -func (p *parser) callonNormalString6() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onNormalString6() -} - -func (c *current) onNormalString1(s interface{}) (interface{}, error) { - return bytesValueNode(resolveString(joinBytes(s))), nil -} - -func (p *parser) callonNormalString1() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onNormalString1(stack["s"]) -} - -func (c *current) onTrueToken1() (interface{}, error) { - return toLower(c.text), nil -} - -func (p *parser) callonTrueToken1() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onTrueToken1() -} - -func (c *current) onFalseToken1() (interface{}, error) { - return toLower(c.text), nil -} - -func (p *parser) callonFalseToken1() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onFalseToken1() -} - -func (c *current) onLastToken1() (interface{}, error) { - return toLower(c.text), nil -} - -func (p *parser) callonLastToken1() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onLastToken1() -} - -func (c *current) onFirstToken1() (interface{}, error) { - return toLower(c.text), nil -} - -func (p *parser) callonFirstToken1() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onFirstToken1() -} - -func (c *current) onAscToken1() (interface{}, error) { - return toLower(c.text), nil -} - -func (p *parser) callonAscToken1() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onAscToken1() -} - -func (c *current) onDescToken1() (interface{}, error) { - return toLower(c.text), nil -} - -func (p *parser) callonDescToken1() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onDescToken1() -} - -func (c *current) onNormalIdentifier1() (interface{}, error) { - return identifierNode(c.text), nil -} - -func (p *parser) callonNormalIdentifier1() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onNormalIdentifier1() -} - -func (c *current) onStringIdentifier6() (interface{}, error) { - return c.text, nil -} - -func (p *parser) callonStringIdentifier6() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onStringIdentifier6() -} - -func (c *current) onStringIdentifier1(s interface{}) (interface{}, error) { - return identifierNode(resolveString(joinBytes(s))), nil -} - -func (p *parser) callonStringIdentifier1() (interface{}, error) { - stack := p.vstack[len(p.vstack)-1] - _ = stack - return p.cur.onStringIdentifier1(stack["s"]) -} - -var ( - // errNoRule is returned when the grammar to parse has no rule. - errNoRule = errors.New("grammar has no rule") - - // errInvalidEntrypoint is returned when the specified entrypoint rule - // does not exit. - errInvalidEntrypoint = errors.New("invalid entrypoint") - - // errInvalidEncoding is returned when the source is not properly - // utf8-encoded. - errInvalidEncoding = errors.New("invalid encoding") - - // errMaxExprCnt is used to signal that the maximum number of - // expressions have been parsed. - errMaxExprCnt = errors.New("max number of expresssions parsed") -) - -// Option is a function that can set an option on the parser. It returns -// the previous setting as an Option. -type Option func(*parser) Option - -// MaxExpressions creates an Option to stop parsing after the provided -// number of expressions have been parsed, if the value is 0 then the parser will -// parse for as many steps as needed (possibly an infinite number). -// -// The default for maxExprCnt is 0. -func MaxExpressions(maxExprCnt uint64) Option { - return func(p *parser) Option { - oldMaxExprCnt := p.maxExprCnt - p.maxExprCnt = maxExprCnt - return MaxExpressions(oldMaxExprCnt) - } -} - -// Entrypoint creates an Option to set the rule name to use as entrypoint. -// The rule name must have been specified in the -alternate-entrypoints -// if generating the parser with the -optimize-grammar flag, otherwise -// it may have been optimized out. Passing an empty string sets the -// entrypoint to the first rule in the grammar. -// -// The default is to start parsing at the first rule in the grammar. -func Entrypoint(ruleName string) Option { - return func(p *parser) Option { - oldEntrypoint := p.entrypoint - p.entrypoint = ruleName - if ruleName == "" { - p.entrypoint = g.rules[0].name - } - return Entrypoint(oldEntrypoint) - } -} - -// Statistics adds a user provided Stats struct to the parser to allow -// the user to process the results after the parsing has finished. -// Also the key for the "no match" counter is set. -// -// Example usage: -// -// input := "input" -// stats := Stats{} -// _, err := Parse("input-file", []byte(input), Statistics(&stats, "no match")) -// if err != nil { -// log.Panicln(err) -// } -// b, err := json.MarshalIndent(stats.ChoiceAltCnt, "", " ") -// if err != nil { -// log.Panicln(err) -// } -// fmt.Println(string(b)) -// -func Statistics(stats *Stats, choiceNoMatch string) Option { - return func(p *parser) Option { - oldStats := p.Stats - p.Stats = stats - oldChoiceNoMatch := p.choiceNoMatch - p.choiceNoMatch = choiceNoMatch - if p.Stats.ChoiceAltCnt == nil { - p.Stats.ChoiceAltCnt = make(map[string]map[string]int) - } - return Statistics(oldStats, oldChoiceNoMatch) - } -} - -// Debug creates an Option to set the debug flag to b. When set to true, -// debugging information is printed to stdout while parsing. -// -// The default is false. -func Debug(b bool) Option { - return func(p *parser) Option { - old := p.debug - p.debug = b - return Debug(old) - } -} - -// Memoize creates an Option to set the memoize flag to b. When set to true, -// the parser will cache all results so each expression is evaluated only -// once. This guarantees linear parsing time even for pathological cases, -// at the expense of more memory and slower times for typical cases. -// -// The default is false. -func Memoize(b bool) Option { - return func(p *parser) Option { - old := p.memoize - p.memoize = b - return Memoize(old) - } -} - -// AllowInvalidUTF8 creates an Option to allow invalid UTF-8 bytes. -// Every invalid UTF-8 byte is treated as a utf8.RuneError (U+FFFD) -// by character class matchers and is matched by the any matcher. -// The returned matched value, c.text and c.offset are NOT affected. -// -// The default is false. -func AllowInvalidUTF8(b bool) Option { - return func(p *parser) Option { - old := p.allowInvalidUTF8 - p.allowInvalidUTF8 = b - return AllowInvalidUTF8(old) - } -} - -// Recover creates an Option to set the recover flag to b. When set to -// true, this causes the parser to recover from panics and convert it -// to an error. Setting it to false can be useful while debugging to -// access the full stack trace. -// -// The default is true. -func Recover(b bool) Option { - return func(p *parser) Option { - old := p.recover - p.recover = b - return Recover(old) - } -} - -// GlobalStore creates an Option to set a key to a certain value in -// the globalStore. -func GlobalStore(key string, value interface{}) Option { - return func(p *parser) Option { - old := p.cur.globalStore[key] - p.cur.globalStore[key] = value - return GlobalStore(key, old) - } -} - -// InitState creates an Option to set a key to a certain value in -// the global "state" store. -func InitState(key string, value interface{}) Option { - return func(p *parser) Option { - old := p.cur.state[key] - p.cur.state[key] = value - return InitState(key, old) - } -} - -// ParseFile parses the file identified by filename. -func ParseFile(filename string, opts ...Option) (i interface{}, err error) { - f, err := os.Open(filename) - if err != nil { - return nil, err - } - defer func() { - if closeErr := f.Close(); closeErr != nil { - err = closeErr - } - }() - return ParseReader(filename, f, opts...) -} - -// ParseReader parses the data from r using filename as information in the -// error messages. -func ParseReader(filename string, r io.Reader, opts ...Option) (interface{}, error) { - b, err := ioutil.ReadAll(r) - if err != nil { - return nil, err - } - - return Parse(filename, b, opts...) -} - -// Parse parses the data from b using filename as information in the -// error messages. -func Parse(filename string, b []byte, opts ...Option) (interface{}, error) { - return newParser(filename, b, opts...).parse(g) -} - -// position records a position in the text. -type position struct { - line, col, offset int -} - -func (p position) String() string { - return fmt.Sprintf("%d:%d [%d]", p.line, p.col, p.offset) -} - -// savepoint stores all state required to go back to this point in the -// parser. -type savepoint struct { - position - rn rune - w int -} - -type current struct { - pos position // start position of the match - text []byte // raw text of the match - - // state is a store for arbitrary key,value pairs that the user wants to be - // tied to the backtracking of the parser. - // This is always rolled back if a parsing rule fails. - state storeDict - - // globalStore is a general store for the user to store arbitrary key-value - // pairs that they need to manage and that they do not want tied to the - // backtracking of the parser. This is only modified by the user and never - // rolled back by the parser. It is always up to the user to keep this in a - // consistent state. - globalStore storeDict -} - -type storeDict map[string]interface{} - -// the AST types... - -type grammar struct { - pos position - rules []*rule -} - -type rule struct { - pos position - name string - displayName string - expr interface{} -} - -type choiceExpr struct { - pos position - alternatives []interface{} -} - -type actionExpr struct { - pos position - expr interface{} - run func(*parser) (interface{}, error) -} - -type recoveryExpr struct { - pos position - expr interface{} - recoverExpr interface{} - failureLabel []string -} - -type seqExpr struct { - pos position - exprs []interface{} -} - -type throwExpr struct { - pos position - label string -} - -type labeledExpr struct { - pos position - label string - expr interface{} -} - -type expr struct { - pos position - expr interface{} -} - -type andExpr expr -type notExpr expr -type zeroOrOneExpr expr -type zeroOrMoreExpr expr -type oneOrMoreExpr expr - -type ruleRefExpr struct { - pos position - name string -} - -type stateCodeExpr struct { - pos position - run func(*parser) error -} - -type andCodeExpr struct { - pos position - run func(*parser) (bool, error) -} - -type notCodeExpr struct { - pos position - run func(*parser) (bool, error) -} - -type litMatcher struct { - pos position - val string - ignoreCase bool -} - -type charClassMatcher struct { - pos position - val string - basicLatinChars [128]bool - chars []rune - ranges []rune - classes []*unicode.RangeTable - ignoreCase bool - inverted bool -} - -type anyMatcher position - -// errList cumulates the errors found by the parser. -type errList []error - -func (e *errList) add(err error) { - *e = append(*e, err) -} - -func (e errList) err() error { - if len(e) == 0 { - return nil - } - e.dedupe() - return e -} - -func (e *errList) dedupe() { - var cleaned []error - set := make(map[string]bool) - for _, err := range *e { - if msg := err.Error(); !set[msg] { - set[msg] = true - cleaned = append(cleaned, err) - } - } - *e = cleaned -} - -func (e errList) Error() string { - switch len(e) { - case 0: - return "" - case 1: - return e[0].Error() - default: - var buf bytes.Buffer - - for i, err := range e { - if i > 0 { - buf.WriteRune('\n') - } - buf.WriteString(err.Error()) - } - return buf.String() - } -} - -// parserError wraps an error with a prefix indicating the rule in which -// the error occurred. The original error is stored in the Inner field. -type parserError struct { - Inner error - pos position - prefix string - expected []string -} - -// Error returns the error message. -func (p *parserError) Error() string { - return p.prefix + ": " + p.Inner.Error() -} - -// newParser creates a parser with the specified input source and options. -func newParser(filename string, b []byte, opts ...Option) *parser { - stats := Stats{ - ChoiceAltCnt: make(map[string]map[string]int), - } - - p := &parser{ - filename: filename, - errs: new(errList), - data: b, - pt: savepoint{position: position{line: 1}}, - recover: true, - cur: current{ - state: make(storeDict), - globalStore: make(storeDict), - }, - maxFailPos: position{col: 1, line: 1}, - maxFailExpected: make([]string, 0, 20), - Stats: &stats, - // start rule is rule [0] unless an alternate entrypoint is specified - entrypoint: g.rules[0].name, - } - p.setOptions(opts) - - if p.maxExprCnt == 0 { - p.maxExprCnt = math.MaxUint64 - } - - return p -} - -// setOptions applies the options to the parser. -func (p *parser) setOptions(opts []Option) { - for _, opt := range opts { - opt(p) - } -} - -type resultTuple struct { - v interface{} - b bool - end savepoint -} - -const choiceNoMatch = -1 - -// Stats stores some statistics, gathered during parsing -type Stats struct { - // ExprCnt counts the number of expressions processed during parsing - // This value is compared to the maximum number of expressions allowed - // (set by the MaxExpressions option). - ExprCnt uint64 - - // ChoiceAltCnt is used to count for each ordered choice expression, - // which alternative is used how may times. - // These numbers allow to optimize the order of the ordered choice expression - // to increase the performance of the parser - // - // The outer key of ChoiceAltCnt is composed of the name of the rule as well - // as the line and the column of the ordered choice. - // The inner key of ChoiceAltCnt is the number (one-based) of the matching alternative. - // For each alternative the number of matches are counted. If an ordered choice does not - // match, a special counter is incremented. The name of this counter is set with - // the parser option Statistics. - // For an alternative to be included in ChoiceAltCnt, it has to match at least once. - ChoiceAltCnt map[string]map[string]int -} - -type parser struct { - filename string - pt savepoint - cur current - - data []byte - errs *errList - - depth int - recover bool - debug bool - - memoize bool - // memoization table for the packrat algorithm: - // map[offset in source] map[expression or rule] {value, match} - memo map[int]map[interface{}]resultTuple - - // rules table, maps the rule identifier to the rule node - rules map[string]*rule - // variables stack, map of label to value - vstack []map[string]interface{} - // rule stack, allows identification of the current rule in errors - rstack []*rule - - // parse fail - maxFailPos position - maxFailExpected []string - maxFailInvertExpected bool - - // max number of expressions to be parsed - maxExprCnt uint64 - // entrypoint for the parser - entrypoint string - - allowInvalidUTF8 bool - - *Stats - - choiceNoMatch string - // recovery expression stack, keeps track of the currently available recovery expression, these are traversed in reverse - recoveryStack []map[string]interface{} -} - -// push a variable set on the vstack. -func (p *parser) pushV() { - if cap(p.vstack) == len(p.vstack) { - // create new empty slot in the stack - p.vstack = append(p.vstack, nil) - } else { - // slice to 1 more - p.vstack = p.vstack[:len(p.vstack)+1] - } - - // get the last args set - m := p.vstack[len(p.vstack)-1] - if m != nil && len(m) == 0 { - // empty map, all good - return - } - - m = make(map[string]interface{}) - p.vstack[len(p.vstack)-1] = m -} - -// pop a variable set from the vstack. -func (p *parser) popV() { - // if the map is not empty, clear it - m := p.vstack[len(p.vstack)-1] - if len(m) > 0 { - // GC that map - p.vstack[len(p.vstack)-1] = nil - } - p.vstack = p.vstack[:len(p.vstack)-1] -} - -// push a recovery expression with its labels to the recoveryStack -func (p *parser) pushRecovery(labels []string, expr interface{}) { - if cap(p.recoveryStack) == len(p.recoveryStack) { - // create new empty slot in the stack - p.recoveryStack = append(p.recoveryStack, nil) - } else { - // slice to 1 more - p.recoveryStack = p.recoveryStack[:len(p.recoveryStack)+1] - } - - m := make(map[string]interface{}, len(labels)) - for _, fl := range labels { - m[fl] = expr - } - p.recoveryStack[len(p.recoveryStack)-1] = m -} - -// pop a recovery expression from the recoveryStack -func (p *parser) popRecovery() { - // GC that map - p.recoveryStack[len(p.recoveryStack)-1] = nil - - p.recoveryStack = p.recoveryStack[:len(p.recoveryStack)-1] -} - -func (p *parser) print(prefix, s string) string { - if !p.debug { - return s - } - - fmt.Printf("%s %d:%d:%d: %s [%#U]\n", - prefix, p.pt.line, p.pt.col, p.pt.offset, s, p.pt.rn) - return s -} - -func (p *parser) in(s string) string { - p.depth++ - return p.print(strings.Repeat(" ", p.depth)+">", s) -} - -func (p *parser) out(s string) string { - p.depth-- - return p.print(strings.Repeat(" ", p.depth)+"<", s) -} - -func (p *parser) addErr(err error) { - p.addErrAt(err, p.pt.position, []string{}) -} - -func (p *parser) addErrAt(err error, pos position, expected []string) { - var buf bytes.Buffer - if p.filename != "" { - buf.WriteString(p.filename) - } - if buf.Len() > 0 { - buf.WriteString(":") - } - buf.WriteString(fmt.Sprintf("%d:%d (%d)", pos.line, pos.col, pos.offset)) - if len(p.rstack) > 0 { - if buf.Len() > 0 { - buf.WriteString(": ") - } - rule := p.rstack[len(p.rstack)-1] - if rule.displayName != "" { - buf.WriteString("rule " + rule.displayName) - } else { - buf.WriteString("rule " + rule.name) - } - } - pe := &parserError{Inner: err, pos: pos, prefix: buf.String(), expected: expected} - p.errs.add(pe) -} - -func (p *parser) failAt(fail bool, pos position, want string) { - // process fail if parsing fails and not inverted or parsing succeeds and invert is set - if fail == p.maxFailInvertExpected { - if pos.offset < p.maxFailPos.offset { - return - } - - if pos.offset > p.maxFailPos.offset { - p.maxFailPos = pos - p.maxFailExpected = p.maxFailExpected[:0] - } - - if p.maxFailInvertExpected { - want = "!" + want - } - p.maxFailExpected = append(p.maxFailExpected, want) - } -} - -// read advances the parser to the next rune. -func (p *parser) read() { - p.pt.offset += p.pt.w - rn, n := utf8.DecodeRune(p.data[p.pt.offset:]) - p.pt.rn = rn - p.pt.w = n - p.pt.col++ - if rn == '\n' { - p.pt.line++ - p.pt.col = 0 - } - - if rn == utf8.RuneError && n == 1 { // see utf8.DecodeRune - if !p.allowInvalidUTF8 { - p.addErr(errInvalidEncoding) - } - } -} - -// restore parser position to the savepoint pt. -func (p *parser) restore(pt savepoint) { - if p.debug { - defer p.out(p.in("restore")) - } - if pt.offset == p.pt.offset { - return - } - p.pt = pt -} - -// Cloner is implemented by any value that has a Clone method, which returns a -// copy of the value. This is mainly used for types which are not passed by -// value (e.g map, slice, chan) or structs that contain such types. -// -// This is used in conjunction with the global state feature to create proper -// copies of the state to allow the parser to properly restore the state in -// the case of backtracking. -type Cloner interface { - Clone() interface{} -} - -// clone and return parser current state. -func (p *parser) cloneState() storeDict { - if p.debug { - defer p.out(p.in("cloneState")) - } - - state := make(storeDict, len(p.cur.state)) - for k, v := range p.cur.state { - if c, ok := v.(Cloner); ok { - state[k] = c.Clone() - } else { - state[k] = v - } - } - return state -} - -// restore parser current state to the state storeDict. -// every restoreState should applied only one time for every cloned state -func (p *parser) restoreState(state storeDict) { - if p.debug { - defer p.out(p.in("restoreState")) - } - p.cur.state = state -} - -// get the slice of bytes from the savepoint start to the current position. -func (p *parser) sliceFrom(start savepoint) []byte { - return p.data[start.position.offset:p.pt.position.offset] -} - -func (p *parser) getMemoized(node interface{}) (resultTuple, bool) { - if len(p.memo) == 0 { - return resultTuple{}, false - } - m := p.memo[p.pt.offset] - if len(m) == 0 { - return resultTuple{}, false - } - res, ok := m[node] - return res, ok -} - -func (p *parser) setMemoized(pt savepoint, node interface{}, tuple resultTuple) { - if p.memo == nil { - p.memo = make(map[int]map[interface{}]resultTuple) - } - m := p.memo[pt.offset] - if m == nil { - m = make(map[interface{}]resultTuple) - p.memo[pt.offset] = m - } - m[node] = tuple -} - -func (p *parser) buildRulesTable(g *grammar) { - p.rules = make(map[string]*rule, len(g.rules)) - for _, r := range g.rules { - p.rules[r.name] = r - } -} - -func (p *parser) parse(g *grammar) (val interface{}, err error) { - if len(g.rules) == 0 { - p.addErr(errNoRule) - return nil, p.errs.err() - } - - // TODO : not super critical but this could be generated - p.buildRulesTable(g) - - if p.recover { - // panic can be used in action code to stop parsing immediately - // and return the panic as an error. - defer func() { - if e := recover(); e != nil { - if p.debug { - defer p.out(p.in("panic handler")) - } - val = nil - switch e := e.(type) { - case error: - p.addErr(e) - default: - p.addErr(fmt.Errorf("%v", e)) - } - err = p.errs.err() - } - }() - } - - startRule, ok := p.rules[p.entrypoint] - if !ok { - p.addErr(errInvalidEntrypoint) - return nil, p.errs.err() - } - - p.read() // advance to first rune - val, ok = p.parseRule(startRule) - if !ok { - if len(*p.errs) == 0 { - // If parsing fails, but no errors have been recorded, the expected values - // for the farthest parser position are returned as error. - maxFailExpectedMap := make(map[string]struct{}, len(p.maxFailExpected)) - for _, v := range p.maxFailExpected { - maxFailExpectedMap[v] = struct{}{} - } - expected := make([]string, 0, len(maxFailExpectedMap)) - eof := false - if _, ok := maxFailExpectedMap["!."]; ok { - delete(maxFailExpectedMap, "!.") - eof = true - } - for k := range maxFailExpectedMap { - expected = append(expected, k) - } - sort.Strings(expected) - if eof { - expected = append(expected, "EOF") - } - p.addErrAt(errors.New("no match found, expected: "+listJoin(expected, ", ", "or")), p.maxFailPos, expected) - } - - return nil, p.errs.err() - } - return val, p.errs.err() -} - -func listJoin(list []string, sep string, lastSep string) string { - switch len(list) { - case 0: - return "" - case 1: - return list[0] - default: - return fmt.Sprintf("%s %s %s", strings.Join(list[:len(list)-1], sep), lastSep, list[len(list)-1]) - } -} - -func (p *parser) parseRule(rule *rule) (interface{}, bool) { - if p.debug { - defer p.out(p.in("parseRule " + rule.name)) - } - - if p.memoize { - res, ok := p.getMemoized(rule) - if ok { - p.restore(res.end) - return res.v, res.b - } - } - - start := p.pt - p.rstack = append(p.rstack, rule) - p.pushV() - val, ok := p.parseExpr(rule.expr) - p.popV() - p.rstack = p.rstack[:len(p.rstack)-1] - if ok && p.debug { - p.print(strings.Repeat(" ", p.depth)+"MATCH", string(p.sliceFrom(start))) - } - - if p.memoize { - p.setMemoized(start, rule, resultTuple{val, ok, p.pt}) - } - return val, ok -} - -func (p *parser) parseExpr(expr interface{}) (interface{}, bool) { - var pt savepoint - - if p.memoize { - res, ok := p.getMemoized(expr) - if ok { - p.restore(res.end) - return res.v, res.b - } - pt = p.pt - } - - p.ExprCnt++ - if p.ExprCnt > p.maxExprCnt { - panic(errMaxExprCnt) - } - - var val interface{} - var ok bool - switch expr := expr.(type) { - case *actionExpr: - val, ok = p.parseActionExpr(expr) - case *andCodeExpr: - val, ok = p.parseAndCodeExpr(expr) - case *andExpr: - val, ok = p.parseAndExpr(expr) - case *anyMatcher: - val, ok = p.parseAnyMatcher(expr) - case *charClassMatcher: - val, ok = p.parseCharClassMatcher(expr) - case *choiceExpr: - val, ok = p.parseChoiceExpr(expr) - case *labeledExpr: - val, ok = p.parseLabeledExpr(expr) - case *litMatcher: - val, ok = p.parseLitMatcher(expr) - case *notCodeExpr: - val, ok = p.parseNotCodeExpr(expr) - case *notExpr: - val, ok = p.parseNotExpr(expr) - case *oneOrMoreExpr: - val, ok = p.parseOneOrMoreExpr(expr) - case *recoveryExpr: - val, ok = p.parseRecoveryExpr(expr) - case *ruleRefExpr: - val, ok = p.parseRuleRefExpr(expr) - case *seqExpr: - val, ok = p.parseSeqExpr(expr) - case *stateCodeExpr: - val, ok = p.parseStateCodeExpr(expr) - case *throwExpr: - val, ok = p.parseThrowExpr(expr) - case *zeroOrMoreExpr: - val, ok = p.parseZeroOrMoreExpr(expr) - case *zeroOrOneExpr: - val, ok = p.parseZeroOrOneExpr(expr) - default: - panic(fmt.Sprintf("unknown expression type %T", expr)) - } - if p.memoize { - p.setMemoized(pt, expr, resultTuple{val, ok, p.pt}) - } - return val, ok -} - -func (p *parser) parseActionExpr(act *actionExpr) (interface{}, bool) { - if p.debug { - defer p.out(p.in("parseActionExpr")) - } - - start := p.pt - val, ok := p.parseExpr(act.expr) - if ok { - p.cur.pos = start.position - p.cur.text = p.sliceFrom(start) - state := p.cloneState() - actVal, err := act.run(p) - if err != nil { - p.addErrAt(err, start.position, []string{}) - } - p.restoreState(state) - - val = actVal - } - if ok && p.debug { - p.print(strings.Repeat(" ", p.depth)+"MATCH", string(p.sliceFrom(start))) - } - return val, ok -} - -func (p *parser) parseAndCodeExpr(and *andCodeExpr) (interface{}, bool) { - if p.debug { - defer p.out(p.in("parseAndCodeExpr")) - } - - state := p.cloneState() - - ok, err := and.run(p) - if err != nil { - p.addErr(err) - } - p.restoreState(state) - - return nil, ok -} - -func (p *parser) parseAndExpr(and *andExpr) (interface{}, bool) { - if p.debug { - defer p.out(p.in("parseAndExpr")) - } - - pt := p.pt - state := p.cloneState() - p.pushV() - _, ok := p.parseExpr(and.expr) - p.popV() - p.restoreState(state) - p.restore(pt) - - return nil, ok -} - -func (p *parser) parseAnyMatcher(any *anyMatcher) (interface{}, bool) { - if p.debug { - defer p.out(p.in("parseAnyMatcher")) - } - - if p.pt.rn == utf8.RuneError && p.pt.w == 0 { - // EOF - see utf8.DecodeRune - p.failAt(false, p.pt.position, ".") - return nil, false - } - start := p.pt - p.read() - p.failAt(true, start.position, ".") - return p.sliceFrom(start), true -} - -func (p *parser) parseCharClassMatcher(chr *charClassMatcher) (interface{}, bool) { - if p.debug { - defer p.out(p.in("parseCharClassMatcher")) - } - - cur := p.pt.rn - start := p.pt - - // can't match EOF - if cur == utf8.RuneError && p.pt.w == 0 { // see utf8.DecodeRune - p.failAt(false, start.position, chr.val) - return nil, false - } - - if chr.ignoreCase { - cur = unicode.ToLower(cur) - } - - // try to match in the list of available chars - for _, rn := range chr.chars { - if rn == cur { - if chr.inverted { - p.failAt(false, start.position, chr.val) - return nil, false - } - p.read() - p.failAt(true, start.position, chr.val) - return p.sliceFrom(start), true - } - } - - // try to match in the list of ranges - for i := 0; i < len(chr.ranges); i += 2 { - if cur >= chr.ranges[i] && cur <= chr.ranges[i+1] { - if chr.inverted { - p.failAt(false, start.position, chr.val) - return nil, false - } - p.read() - p.failAt(true, start.position, chr.val) - return p.sliceFrom(start), true - } - } - - // try to match in the list of Unicode classes - for _, cl := range chr.classes { - if unicode.Is(cl, cur) { - if chr.inverted { - p.failAt(false, start.position, chr.val) - return nil, false - } - p.read() - p.failAt(true, start.position, chr.val) - return p.sliceFrom(start), true - } - } - - if chr.inverted { - p.read() - p.failAt(true, start.position, chr.val) - return p.sliceFrom(start), true - } - p.failAt(false, start.position, chr.val) - return nil, false -} - -func (p *parser) incChoiceAltCnt(ch *choiceExpr, altI int) { - choiceIdent := fmt.Sprintf("%s %d:%d", p.rstack[len(p.rstack)-1].name, ch.pos.line, ch.pos.col) - m := p.ChoiceAltCnt[choiceIdent] - if m == nil { - m = make(map[string]int) - p.ChoiceAltCnt[choiceIdent] = m - } - // We increment altI by 1, so the keys do not start at 0 - alt := strconv.Itoa(altI + 1) - if altI == choiceNoMatch { - alt = p.choiceNoMatch - } - m[alt]++ -} - -func (p *parser) parseChoiceExpr(ch *choiceExpr) (interface{}, bool) { - if p.debug { - defer p.out(p.in("parseChoiceExpr")) - } - - for altI, alt := range ch.alternatives { - // dummy assignment to prevent compile error if optimized - _ = altI - - state := p.cloneState() - - p.pushV() - val, ok := p.parseExpr(alt) - p.popV() - if ok { - p.incChoiceAltCnt(ch, altI) - return val, ok - } - p.restoreState(state) - } - p.incChoiceAltCnt(ch, choiceNoMatch) - return nil, false -} - -func (p *parser) parseLabeledExpr(lab *labeledExpr) (interface{}, bool) { - if p.debug { - defer p.out(p.in("parseLabeledExpr")) - } - - p.pushV() - val, ok := p.parseExpr(lab.expr) - p.popV() - if ok && lab.label != "" { - m := p.vstack[len(p.vstack)-1] - m[lab.label] = val - } - return val, ok -} - -func (p *parser) parseLitMatcher(lit *litMatcher) (interface{}, bool) { - if p.debug { - defer p.out(p.in("parseLitMatcher")) - } - - ignoreCase := "" - if lit.ignoreCase { - ignoreCase = "i" - } - val := fmt.Sprintf("%q%s", lit.val, ignoreCase) - start := p.pt - for _, want := range lit.val { - cur := p.pt.rn - if lit.ignoreCase { - cur = unicode.ToLower(cur) - } - if cur != want { - p.failAt(false, start.position, val) - p.restore(start) - return nil, false - } - p.read() - } - p.failAt(true, start.position, val) - return p.sliceFrom(start), true -} - -func (p *parser) parseNotCodeExpr(not *notCodeExpr) (interface{}, bool) { - if p.debug { - defer p.out(p.in("parseNotCodeExpr")) - } - - state := p.cloneState() - - ok, err := not.run(p) - if err != nil { - p.addErr(err) - } - p.restoreState(state) - - return nil, !ok -} - -func (p *parser) parseNotExpr(not *notExpr) (interface{}, bool) { - if p.debug { - defer p.out(p.in("parseNotExpr")) - } - - pt := p.pt - state := p.cloneState() - p.pushV() - p.maxFailInvertExpected = !p.maxFailInvertExpected - _, ok := p.parseExpr(not.expr) - p.maxFailInvertExpected = !p.maxFailInvertExpected - p.popV() - p.restoreState(state) - p.restore(pt) - - return nil, !ok -} - -func (p *parser) parseOneOrMoreExpr(expr *oneOrMoreExpr) (interface{}, bool) { - if p.debug { - defer p.out(p.in("parseOneOrMoreExpr")) - } - - var vals []interface{} - - for { - p.pushV() - val, ok := p.parseExpr(expr.expr) - p.popV() - if !ok { - if len(vals) == 0 { - // did not match once, no match - return nil, false - } - return vals, true - } - vals = append(vals, val) - } -} - -func (p *parser) parseRecoveryExpr(recover *recoveryExpr) (interface{}, bool) { - if p.debug { - defer p.out(p.in("parseRecoveryExpr (" + strings.Join(recover.failureLabel, ",") + ")")) - } - - p.pushRecovery(recover.failureLabel, recover.recoverExpr) - val, ok := p.parseExpr(recover.expr) - p.popRecovery() - - return val, ok -} - -func (p *parser) parseRuleRefExpr(ref *ruleRefExpr) (interface{}, bool) { - if p.debug { - defer p.out(p.in("parseRuleRefExpr " + ref.name)) - } - - if ref.name == "" { - panic(fmt.Sprintf("%s: invalid rule: missing name", ref.pos)) - } - - rule := p.rules[ref.name] - if rule == nil { - p.addErr(fmt.Errorf("undefined rule: %s", ref.name)) - return nil, false - } - return p.parseRule(rule) -} - -func (p *parser) parseSeqExpr(seq *seqExpr) (interface{}, bool) { - if p.debug { - defer p.out(p.in("parseSeqExpr")) - } - - vals := make([]interface{}, 0, len(seq.exprs)) - - pt := p.pt - state := p.cloneState() - for _, expr := range seq.exprs { - val, ok := p.parseExpr(expr) - if !ok { - p.restoreState(state) - p.restore(pt) - return nil, false - } - vals = append(vals, val) - } - return vals, true -} - -func (p *parser) parseStateCodeExpr(state *stateCodeExpr) (interface{}, bool) { - if p.debug { - defer p.out(p.in("parseStateCodeExpr")) - } - - err := state.run(p) - if err != nil { - p.addErr(err) - } - return nil, true -} - -func (p *parser) parseThrowExpr(expr *throwExpr) (interface{}, bool) { - if p.debug { - defer p.out(p.in("parseThrowExpr")) - } - - for i := len(p.recoveryStack) - 1; i >= 0; i-- { - if recoverExpr, ok := p.recoveryStack[i][expr.label]; ok { - if val, ok := p.parseExpr(recoverExpr); ok { - return val, ok - } - } - } - - return nil, false -} - -func (p *parser) parseZeroOrMoreExpr(expr *zeroOrMoreExpr) (interface{}, bool) { - if p.debug { - defer p.out(p.in("parseZeroOrMoreExpr")) - } - - var vals []interface{} - - for { - p.pushV() - val, ok := p.parseExpr(expr.expr) - p.popV() - if !ok { - return vals, true - } - vals = append(vals, val) - } -} - -func (p *parser) parseZeroOrOneExpr(expr *zeroOrOneExpr) (interface{}, bool) { - if p.debug { - defer p.out(p.in("parseZeroOrOneExpr")) - } - - p.pushV() - val, _ := p.parseExpr(expr.expr) - p.popV() - // whether it matched or not, consider it a match - return val, true -} diff --git a/core/vm/sqlvm/grammar.peg b/core/vm/sqlvm/grammar.peg deleted file mode 100644 index ac2f8928c..000000000 --- a/core/vm/sqlvm/grammar.peg +++ /dev/null @@ -1,763 +0,0 @@ -{ -package sqlvm -} - -S - <- _ x:Stmt? _ xs:( ';' _ s:Stmt? _ { return s, nil } )* EOF -{ return prepend(x, xs), nil } - -/* statement */ -Stmt - = SelectStmt - / UpdateStmt - / DeleteStmt - / InsertStmt - / CreateTableStmt - / CreateIndexStmt - -SelectStmt - = SelectToken - _ f:SelectColumn fs:( _ SeparatorToken _ s:SelectColumn { return s, nil } )* - table:( _ FromToken _ i:Identifier { return i, nil } )? - where:( _ w:WhereClause { return w, nil } )? - group:( _ g:GroupByClause { return g, nil } )? - order:( _ or:OrderByClause { return or, nil } )? - limit:( _ l:LimitClause { return l, nil } )? - offset:( _ of:OffsetClause { return of, nil } )? -{ - var ( - tableNode *identifierNode - whereNode *whereOptionNode - limitNode *limitOptionNode - offsetNode *offsetOptionNode - ) - if table != nil { - t := table.(identifierNode) - tableNode = &t - } - if where != nil { - w := where.(whereOptionNode) - whereNode = &w - } - if limit != nil { - l := limit.(limitOptionNode) - limitNode = &l - } - if offset != nil { - of := offset.(offsetOptionNode) - offsetNode = &of - } - return selectStmtNode{ - column: prepend(f, fs), - table: tableNode, - where: whereNode, - group: toSlice(group), - order: toSlice(order), - limit: limitNode, - offset: offsetNode, - }, nil -} - -SelectColumn - = AnyLiteral - / Expr - -UpdateStmt - = UpdateToken - _ table:Identifier - _ SetToken - _ a:Assignment as:( _ SeparatorToken _ s:Assignment { return s, nil } )* - where:( _ w:WhereClause { return w, nil } )? -{ - var ( - whereNode *whereOptionNode - ) - if where != nil { - w := where.(whereOptionNode) - whereNode = &w - } - return updateStmtNode{ - table: table.(identifierNode), - assignment: prepend(a, as), - where: whereNode, - }, nil -} - -DeleteStmt - = DeleteToken - _ FromToken - _ table:Identifier - where:( _ w:WhereClause { return w, nil } )? -{ - var ( - whereNode *whereOptionNode - ) - if where != nil { - w := where.(whereOptionNode) - whereNode = &w - } - return deleteStmtNode{ - table: table.(identifierNode), - where: whereNode, - }, nil -} - -InsertStmt - = InsertToken - _ IntoToken - _ table:Identifier - _ insert:( InsertWithColumnClause / InsertWithDefaultClause ) -{ - return insertStmtNode{ - table: table.(identifierNode), - insert: insert, - }, nil -} - -InsertValue - = '(' _ e:MultiExprWithDefault _ ')' -{ return e, nil } - -CreateTableStmt - = CreateToken - _ TableToken - _ table:Identifier - _ '(' - _ column:( - s:ColumnSchema - ss:( _ SeparatorToken _ t:ColumnSchema { return t, nil } )* - { return prepend(s, ss), nil } - )? - _ ')' -{ - return createTableStmtNode{ - table: table.(identifierNode), - column: toSlice(column), - }, nil -} - -ColumnSchema - = i:Identifier - _ t:DataType - cs:( _ s:ColumnConstraint { return s, nil } )* -{ - return columnSchemaNode{ - column: i.(identifierNode), - dataType: t, - constraint: toSlice(cs), - }, nil -} - -ColumnConstraint - = PrimaryKeyClause - / NotNullClause - / UniqueClause - / DefaultClause - / ForeignClause - / AutoincrementClause - -CreateIndexStmt - = CreateToken - unique:( _ u:UniqueClause { return u, nil } )? - _ IndexToken - _ index:Identifier - _ OnToken - _ table:Identifier - _ '(' _ i:Identifier is:( _ SeparatorToken _ x:Identifier { return x, nil } )* _ ')' -{ - var ( - uniqueNode *uniqueOptionNode - ) - if unique != nil { - u := unique.(uniqueOptionNode) - uniqueNode = &u - } - return createIndexStmtNode{ - index: index.(identifierNode), - table: table.(identifierNode), - column: prepend(i, is), - unique: uniqueNode, - }, nil -} - -/* clause */ -WhereClause - = WhereToken _ e:Expr -{ return whereOptionNode{condition: e}, nil } - -OrderByClause - = OrderToken - _ ByToken - _ f:OrderColumn - fs:( _ SeparatorToken _ s:OrderColumn { return s, nil } )* -{ return prepend(f, fs), nil } - -OrderColumn - = i:Expr - s:( _ t:( AscToken / DescToken ) { return t, nil } )? - n:( _ NullsToken _ l:( LastToken / FirstToken ) { return l, nil } )? -{ - return orderOptionNode{ - expr: i, - desc: s != nil && string(s.([]byte)) == "desc", - nullfirst: n != nil && string(n.([]byte)) == "first", - }, nil -} - -GroupByClause - = GroupToken - _ ByToken - _ i:Expr - is:( _ SeparatorToken _ s:Expr { return groupOptionNode{expr: s}, nil } )* -{ return prepend(groupOptionNode{expr: i}, is), nil } - -OffsetClause - = OffsetToken _ i:Integer -{ return offsetOptionNode{value: i.(integerValueNode)}, nil } - -LimitClause - = LimitToken _ i:Integer -{ return limitOptionNode{value: i.(integerValueNode)}, nil } - -InsertWithColumnClause - = cs:( '(' - _ f:Identifier - fs:( _ SeparatorToken _ x:Identifier { return x, nil } )* - _ ')' - _ { return prepend(f, fs), nil } - )? - ValuesToken - _ v:InsertValue - vs:( _ SeparatorToken _ y:InsertValue { return y, nil } )* -{ - return insertWithColumnOptionNode{ - column: toSlice(cs), - value: prepend(v, vs), - }, nil -} - -InsertWithDefaultClause - = DefaultToken _ ValuesToken -{ return insertWithDefaultOptionNode{}, nil } - -PrimaryKeyClause - = PrimaryToken _ KeyToken -{ return primaryOptionNode{}, nil } - -NotNullClause - = NotToken _ NullToken -{ return notNullOptionNode{}, nil } - -UniqueClause - = UniqueToken -{ return uniqueOptionNode{}, nil } - -DefaultClause - = DefaultToken _ e:Expr -{ return defaultOptionNode{value: e}, nil } - -ForeignClause - = ReferencesToken _ t:Identifier _ '(' _ f:Identifier _ ')' -{ - return foreignOptionNode{ - table: t.(identifierNode), - column: f.(identifierNode), - }, nil -} - -AutoincrementClause - = AutoincrementToken -{ return autoincrementOptionNode{}, nil } - -/* expression */ -Expr - = LogicExpr - -ExprWithDefault - = &(DefaultLiteral) d:DefaultLiteral { return d, nil } - / Expr - -LogicExpr - = LogicExpr4 - -LogicExpr4 - = o:LogicExpr3 - os:( _ op:OrOperator _ s:LogicExpr3 { return opSetSubject(op, s), nil } )* -{ return rightJoinOperators(o, os), nil } - -LogicExpr3 - = o:LogicExpr2 - os:( _ op:AndOperator _ s:LogicExpr2 { return opSetSubject(op, s), nil } )* -{ return rightJoinOperators(o, os), nil } - -LogicExpr2 - = op:NotOperator _ s:LogicExpr2 - { return opSetTarget(op, s), nil } - / LogicExpr1 - -LogicExpr1 - = o:ArithmeticExpr os:( _ l:LogicExpr1Op { return l, nil } )* -{ return rightJoinOperators(o, os), nil } - -LogicExpr1Op - = LogicExpr1In - / LogicExpr1Null - / LogicExpr1Like - / LogicExpr1Cmp - -LogicExpr1In - = n:( t:NotOperator _ { return t, nil } )? InToken _ '(' _ s:MultiExpr _ ')' -{ - op := opSetSubject(&inOperatorNode{}, s) - if n != nil { - return opSetTarget(n, op), nil - } - return op, nil -} - -LogicExpr1Null - = IsToken n:( _ t:NotOperator { return t, nil } )? _ NullToken -{ - op := opSetSubject(&isOperatorNode{}, nullValueNode{}) - if n != nil { - return opSetTarget(n, op), nil - } - return op, nil -} - -LogicExpr1Like - = n:( t:NotOperator _ { return t, nil } )? LikeToken _ s:Expr -{ - op := opSetSubject(&likeOperatorNode{}, s) - if n != nil { - return opSetTarget(n, op), nil - } - return op, nil -} - -LogicExpr1Cmp - = op:CmpOperator _ s:ArithmeticExpr -{ return opSetSubject(op, s), nil } - -ArithmeticExpr - = ArithmeticExpr3 - -ArithmeticExpr3 - = o:ArithmeticExpr2 os:( _ op:ConcatOperator _ s:ArithmeticExpr2 { return opSetSubject(op, s), nil } )* -{ return rightJoinOperators(o, os), nil } - -ArithmeticExpr2 - = o:ArithmeticExpr1 os:( _ op:AddSubOperator _ s:ArithmeticExpr1 { return opSetSubject(op, s), nil } )* -{ return rightJoinOperators(o, os), nil } - -ArithmeticExpr1 - = o:Operand os:( _ op:MulDivModOperator _ s:Operand { return opSetSubject(op, s), nil } )* -{ return rightJoinOperators(o, os), nil } - -MultiExpr - = x:Expr xs:( _ SeparatorToken _ e:Expr { return e, nil } )* -{ return prepend(x, xs), nil } - -MultiExprWithDefault - = x:ExprWithDefault xs:( _ SeparatorToken _ e:ExprWithDefault { return e, nil } )* -{ return prepend(x, xs), nil } - -Operand - = op:UnaryOperator _ s:Operand { return opSetTarget(op, s), nil } - / '(' _ e:Expr _ ')' { return e, nil } - / &(CastToken) t:TypeCast { return t, nil } - / FunctionCall - / Value - / Identifier - -TypeCast - = CastToken _ '(' _ o:Expr _ AsToken _ s:DataType _ ')' -{ return opSetSubject(opSetObject(&castOperatorNode{}, o), s), nil } - -FunctionCall - = i:Identifier _ '(' _ r:FunctionArgs? _ ')' -{ return opSetSubject(opSetObject(&functionOperatorNode{}, i), r), nil } - -FunctionArgs - = a:AnyLiteral { return []interface{}{a}, nil } - / MultiExpr - -Assignment - = i:Identifier _ '=' _ e:ExprWithDefault -{ return opSetSubject(opSetObject(&assignOperatorNode{}, i), e), nil } - -/* operator */ -UnaryOperator - = SignOperator - -SignOperator - = Sign -{ - switch string(c.text) { - case "+": - return &posOperatorNode{}, nil - case "-": - return &negOperatorNode{}, nil - } - return nil, errors.New("unknown sign") -} - -NotOperator - = NotToken -{ return ¬OperatorNode{}, nil } - -AndOperator - = AndToken -{ return &andOperatorNode{}, nil } - -OrOperator - = OrToken -{ return &orOperatorNode{}, nil } - -CmpOperator - = ( "<=" / ">=" / "<>" / "!=" / [<>=] ) -{ - switch string(c.text) { - case "<=": - return &lessOrEqualOperatorNode{}, nil - case ">=": - return &greaterOrEqualOperatorNode{}, nil - case "<>": - return ¬EqualOperatorNode{}, nil - case "!=": - return ¬EqualOperatorNode{}, nil - case "<": - return &lessOperatorNode{}, nil - case ">": - return &greaterOperatorNode{}, nil - case "=": - return &equalOperatorNode{}, nil - } - return nil, errors.New("unknown cmp") -} - -ConcatOperator - = "||" -{ return &concatOperatorNode{}, nil } - -AddSubOperator - = [+-] -{ - switch string(c.text) { - case "+": - return &addOperatorNode{}, nil - case "-": - return &subOperatorNode{}, nil - } - return nil, errors.New("unknown add sub") -} - -MulDivModOperator - = [*/%] -{ - switch string(c.text) { - case "*": - return &mulOperatorNode{}, nil - case "/": - return &divOperatorNode{}, nil - case "%": - return &modOperatorNode{}, nil - } - return nil, errors.New("unknown mul div mod") -} - -/* type */ -DataType - = UIntType - / IntType - / UFixedType - / FixedType - / FixedBytesType - / DynamicBytesType - / BoolType - / AddressType - -UIntType - = "UINT"i s:NonZeroLeadingInteger !NormalIdentifierRest -{ return intTypeNode{size: toInt(s.([]byte)), unsigned: true}, nil } - -IntType - = "INT"i s:NonZeroLeadingInteger !NormalIdentifierRest -{ return intTypeNode{size: toInt(s.([]byte))}, nil } - -UFixedType - = "UFIXED"i s:NonZeroLeadingInteger "X"i t:NonZeroLeadingInteger !NormalIdentifierRest -{ - return fixedTypeNode{ - integerSize: toInt(s.([]byte)), - fractionalSize: toInt(t.([]byte)), - unsigned: true, - }, nil -} - -FixedType - = "FIXED"i s:NonZeroLeadingInteger "X"i t:NonZeroLeadingInteger !NormalIdentifierRest -{ - return fixedTypeNode{ - integerSize: toInt(s.([]byte)), - fractionalSize: toInt(t.([]byte)), - }, nil -} - -FixedBytesType - = "BYTES"i s:NonZeroLeadingInteger !NormalIdentifierRest -{ return fixedBytesTypeNode{size: toInt(s.([]byte))}, nil } - / "BYTE"i !NormalIdentifierRest -{ return fixedBytesTypeNode{size: 1}, nil } - -DynamicBytesType - = ( "BYTES"i !NormalIdentifierRest - / "STRING"i !NormalIdentifierRest - / "TEXT"i !NormalIdentifierRest - ) -{ return dynamicBytesTypeNode{}, nil } - -AddressType - = "ADDRESS"i !NormalIdentifierRest -{ return addressTypeNode{}, nil } - -BoolType - = ( "BOOL"i !NormalIdentifierRest - / "BOOLEAN"i !NormalIdentifierRest - ) -{ return boolTypeNode{}, nil } - -/* value */ -Value - = NumberLiteral - / StringLiteral - / BoolLiteral - / NullLiteral - -AnyLiteral - = AnyToken -{ return anyValueNode{}, nil } - -DefaultLiteral - = DefaultToken -{ return defaultValueNode{}, nil } - -BoolLiteral - = b:( TrueToken / FalseToken ) -{ return boolValueNode(string(b.([]byte)) == "true"), nil } - -NullLiteral - = NullToken -{ return nullValueNode{}, nil } - -NumberLiteral - = &("0" "X"i) h:Hex { return h, nil } - / Decimal - -Sign - = [-+] - -Integer - = [0-9]+ -{ return integerValueNode{v: toDecimal(c.text)}, nil } - -NonZeroLeadingInteger - = ( "0" / [1-9][0-9]* ) -{ return c.text, nil } - -Fixnum - = Integer "." Integer - / Integer "."? - / "." Integer - -Decimal - = Fixnum ( "E"i Sign? Integer )? -{ return decimalValueNode(toDecimal(c.text)), nil } - -Hex - = "0" "X"i s:( [0-9A-Fa-f] )+ !NormalIdentifierRest -{ return hexToInteger(joinBytes(s)), nil } - -StringLiteral - = HexString - / NormalString - -HexString - = ( "HEX"i / "X"i ) "'" s:([0-9a-fA-F][0-9a-fA-F] { return c.text, nil } )* "'" -{ return bytesValueNode(hexToBytes(joinBytes(s))), nil } - -NormalString - = "'" s:( ( [^'\r\n\\] / "\\" . ) { return c.text, nil } )* "'" -{ return bytesValueNode(resolveString(joinBytes(s))), nil } - -/* token */ -SelectToken - = "SELECT"i !NormalIdentifierRest - -FromToken - = "FROM"i !NormalIdentifierRest - -WhereToken - = "WHERE"i !NormalIdentifierRest - -OrderToken - = "ORDER"i !NormalIdentifierRest - -ByToken - = "BY"i !NormalIdentifierRest - -GroupToken - = "GROUP"i !NormalIdentifierRest - -LimitToken - = "LIMIT"i !NormalIdentifierRest - -OffsetToken - = "OFFSET"i !NormalIdentifierRest - -UpdateToken - = "UPDATE"i !NormalIdentifierRest - -SetToken - = "SET"i !NormalIdentifierRest - -DeleteToken - = "DELETE"i !NormalIdentifierRest - -InsertToken - = "INSERT"i !NormalIdentifierRest - -IntoToken - = "INTO"i !NormalIdentifierRest - -ValuesToken - = "VALUES"i !NormalIdentifierRest - -CreateToken - = "CREATE"i !NormalIdentifierRest - -TableToken - = "TABLE"i !NormalIdentifierRest - -IndexToken - = "INDEX"i !NormalIdentifierRest - -UniqueToken - = "UNIQUE"i !NormalIdentifierRest - -DefaultToken - = "DEFAULT"i !NormalIdentifierRest - -PrimaryToken - = "PRIMARY"i !NormalIdentifierRest - -KeyToken - = "KEY"i !NormalIdentifierRest - -ReferencesToken - = "REFERENCES"i !NormalIdentifierRest - -AutoincrementToken - = "AUTOINCREMENT"i !NormalIdentifierRest - -OnToken - = "ON"i !NormalIdentifierRest - -TrueToken - = "TRUE"i !NormalIdentifierRest -{ return toLower(c.text), nil } - -FalseToken - = "FALSE"i !NormalIdentifierRest -{ return toLower(c.text), nil } - -NullToken - = "NULL"i !NormalIdentifierRest - -IsToken - = "IS"i !NormalIdentifierRest - -NullsToken - = "NULLS"i !NormalIdentifierRest - -LastToken - = "LAST"i !NormalIdentifierRest -{ return toLower(c.text), nil } - -FirstToken - = "FIRST"i !NormalIdentifierRest -{ return toLower(c.text), nil } - -AndToken - = "AND"i !NormalIdentifierRest - -OrToken - = "OR"i !NormalIdentifierRest - -NotToken - = "NOT"i !NormalIdentifierRest - -InToken - = "IN"i !NormalIdentifierRest - -LikeToken - = "LIKE"i !NormalIdentifierRest - -AscToken - = "ASC"i !NormalIdentifierRest -{ return toLower(c.text), nil } - -DescToken - = "DESC"i !NormalIdentifierRest -{ return toLower(c.text), nil } - -CastToken - = "CAST"i !NormalIdentifierRest - -AsToken - = "AS"i !NormalIdentifierRest - -SeparatorToken - = "," - -AnyToken - = "*" - -/* identifier */ -Identifier - = NormalIdentifier - / StringIdentifier - -NormalIdentifier - = NormalIdentifierStart NormalIdentifierRest* -{ return identifierNode(c.text), nil } - -NormalIdentifierStart - = [a-zA-Z@#_\u0080-\uffff] - -NormalIdentifierRest - = [a-zA-Z0-9@#$_\u0080-\uffff] - -StringIdentifier - = "\"" s:( ( [^"\r\n\\] / "\\" . ) { return c.text, nil } )* "\"" -{ - return identifierNode(resolveString(joinBytes(s))), nil -} - -/* skip */ -_ - = ( Whitespace / Newline )* - -Newline - = "\r\n" - / "\r" - / "\n" - -Whitespace - = " " - / "\t" - / "\v" - / "\f" - -EOF - = !. diff --git a/core/vm/sqlvm/parser.go b/core/vm/sqlvm/parser.go deleted file mode 100644 index 0b284c0e3..000000000 --- a/core/vm/sqlvm/parser.go +++ /dev/null @@ -1,125 +0,0 @@ -package sqlvm - -import ( - "encoding/hex" - "strconv" - "strings" - - "github.com/shopspring/decimal" -) - -// Parser was generated with pigeon v1.0.0-99-gbb0192c. -//go:generate pigeon -no-recover -o grammar.go grammar.peg -//go:generate goimports -w grammar.go - -func prepend(x interface{}, xs interface{}) []interface{} { - return append([]interface{}{x}, toSlice(xs)...) -} - -func toSlice(x interface{}) []interface{} { - if x == nil { - return nil - } - return x.([]interface{}) -} - -// TODO(wmin0): finish it. -func isAddress(h []byte) bool { - return false -} - -func hexToInteger(h []byte) interface{} { - d := decimal.Zero - l := len(h) - base := decimal.New(16, 0) - for idx, b := range h { - i, _ := strconv.ParseInt(string([]byte{b}), 16, 32) - d = d.Add( - decimal.New(i, 0). - Mul(base.Pow(decimal.New(int64(l-idx-1), 0))), - ) - } - return integerValueNode{v: d, address: isAddress(h)} -} - -func hexToBytes(h []byte) []byte { - bs, _ := hex.DecodeString(string(h)) - return bs -} - -func toInt(b []byte) int32 { - i, _ := strconv.ParseInt(string(b), 10, 32) - return int32(i) -} - -func toDecimal(b []byte) decimal.Decimal { - return decimal.RequireFromString(string(b)) -} - -func toLower(b []byte) []byte { - return []byte(strings.ToLower(string(b))) -} - -func joinBytes(x interface{}) []byte { - xs := toSlice(x) - bs := []byte{} - for _, b := range xs { - bs = append(bs, b.([]byte)...) - } - return bs -} - -func opSetSubject(op interface{}, s interface{}) interface{} { - x := op.(binaryOperator) - x.setSubject(s) - return x -} - -func opSetObject(op interface{}, o interface{}) interface{} { - x := op.(binaryOperator) - x.setObject(o) - return x -} - -func opSetTarget(op interface{}, t interface{}) interface{} { - x := op.(unaryOperator) - x.setTarget(t) - return x -} - -func joinOperator(x interface{}, o interface{}) { - if op, ok := x.(unaryOperator); ok { - joinOperator(op.getTarget(), o) - return - } - if op, ok := x.(binaryOperator); ok { - op.setObject(o) - return - } -} - -func rightJoinOperators(o interface{}, x interface{}) interface{} { - xs := toSlice(x) - if len(xs) == 0 { - return o - } - l := len(xs) - for idx := range xs { - if idx == l-1 { - break - } - joinOperator(xs[idx+1], xs[idx]) - } - joinOperator(xs[0], o) - return xs[l-1] -} - -// TODO(wmin0): finish it. -func resolveString(s []byte) []byte { - return s -} - -// ParseString parses input string to AST. -func ParseString(s string) (interface{}, error) { - return ParseReader("parser", strings.NewReader(s)) -} diff --git a/core/vm/sqlvm/parser/grammar.go b/core/vm/sqlvm/parser/grammar.go new file mode 100644 index 000000000..7dae2c977 --- /dev/null +++ b/core/vm/sqlvm/parser/grammar.go @@ -0,0 +1,7514 @@ +// Code generated by pigeon; DO NOT EDIT. + +package parser + +import ( + "bytes" + "errors" + "fmt" + "io" + "io/ioutil" + "math" + "os" + "sort" + "strconv" + "strings" + "unicode" + "unicode/utf8" + + "github.com/dexon-foundation/dexon/core/vm/sqlvm/ast" +) + +var g = &grammar{ + rules: []*rule{ + { + name: "S", + pos: position{line: 5, col: 1, offset: 20}, + expr: &actionExpr{ + pos: position{line: 6, col: 5, offset: 26}, + run: (*parser).callonS1, + expr: &seqExpr{ + pos: position{line: 6, col: 5, offset: 26}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 6, col: 5, offset: 26}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 6, col: 7, offset: 28}, + label: "x", + expr: &zeroOrOneExpr{ + pos: position{line: 6, col: 9, offset: 30}, + expr: &ruleRefExpr{ + pos: position{line: 6, col: 9, offset: 30}, + name: "Stmt", + }, + }, + }, + &ruleRefExpr{ + pos: position{line: 6, col: 15, offset: 36}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 6, col: 17, offset: 38}, + label: "xs", + expr: &zeroOrMoreExpr{ + pos: position{line: 6, col: 20, offset: 41}, + expr: &actionExpr{ + pos: position{line: 6, col: 22, offset: 43}, + run: (*parser).callonS10, + expr: &seqExpr{ + pos: position{line: 6, col: 22, offset: 43}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 6, col: 22, offset: 43}, + val: ";", + ignoreCase: false, + }, + &ruleRefExpr{ + pos: position{line: 6, col: 26, offset: 47}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 6, col: 28, offset: 49}, + label: "s", + expr: &zeroOrOneExpr{ + pos: position{line: 6, col: 30, offset: 51}, + expr: &ruleRefExpr{ + pos: position{line: 6, col: 30, offset: 51}, + name: "Stmt", + }, + }, + }, + &ruleRefExpr{ + pos: position{line: 6, col: 36, offset: 57}, + name: "_", + }, + }, + }, + }, + }, + }, + &ruleRefExpr{ + pos: position{line: 6, col: 59, offset: 80}, + name: "EOF", + }, + }, + }, + }, + }, + { + name: "Stmt", + pos: position{line: 10, col: 1, offset: 133}, + expr: &choiceExpr{ + pos: position{line: 11, col: 4, offset: 141}, + alternatives: []interface{}{ + &ruleRefExpr{ + pos: position{line: 11, col: 4, offset: 141}, + name: "SelectStmt", + }, + &ruleRefExpr{ + pos: position{line: 12, col: 4, offset: 155}, + name: "UpdateStmt", + }, + &ruleRefExpr{ + pos: position{line: 13, col: 4, offset: 169}, + name: "DeleteStmt", + }, + &ruleRefExpr{ + pos: position{line: 14, col: 4, offset: 183}, + name: "InsertStmt", + }, + &ruleRefExpr{ + pos: position{line: 15, col: 4, offset: 197}, + name: "CreateTableStmt", + }, + &ruleRefExpr{ + pos: position{line: 16, col: 4, offset: 216}, + name: "CreateIndexStmt", + }, + }, + }, + }, + { + name: "SelectStmt", + pos: position{line: 18, col: 1, offset: 233}, + expr: &actionExpr{ + pos: position{line: 19, col: 4, offset: 247}, + run: (*parser).callonSelectStmt1, + expr: &seqExpr{ + pos: position{line: 19, col: 4, offset: 247}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 19, col: 4, offset: 247}, + name: "SelectToken", + }, + &ruleRefExpr{ + pos: position{line: 20, col: 2, offset: 260}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 20, col: 4, offset: 262}, + label: "f", + expr: &ruleRefExpr{ + pos: position{line: 20, col: 6, offset: 264}, + name: "SelectColumn", + }, + }, + &labeledExpr{ + pos: position{line: 20, col: 19, offset: 277}, + label: "fs", + expr: &zeroOrMoreExpr{ + pos: position{line: 20, col: 22, offset: 280}, + expr: &actionExpr{ + pos: position{line: 20, col: 24, offset: 282}, + run: (*parser).callonSelectStmt9, + expr: &seqExpr{ + pos: position{line: 20, col: 24, offset: 282}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 20, col: 24, offset: 282}, + name: "_", + }, + &ruleRefExpr{ + pos: position{line: 20, col: 26, offset: 284}, + name: "SeparatorToken", + }, + &ruleRefExpr{ + pos: position{line: 20, col: 41, offset: 299}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 20, col: 43, offset: 301}, + label: "s", + expr: &ruleRefExpr{ + pos: position{line: 20, col: 45, offset: 303}, + name: "SelectColumn", + }, + }, + }, + }, + }, + }, + }, + &labeledExpr{ + pos: position{line: 21, col: 2, offset: 338}, + label: "table", + expr: &zeroOrOneExpr{ + pos: position{line: 21, col: 8, offset: 344}, + expr: &actionExpr{ + pos: position{line: 21, col: 10, offset: 346}, + run: (*parser).callonSelectStmt18, + expr: &seqExpr{ + pos: position{line: 21, col: 10, offset: 346}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 21, col: 10, offset: 346}, + name: "_", + }, + &ruleRefExpr{ + pos: position{line: 21, col: 12, offset: 348}, + name: "FromToken", + }, + &ruleRefExpr{ + pos: position{line: 21, col: 22, offset: 358}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 21, col: 24, offset: 360}, + label: "i", + expr: &ruleRefExpr{ + pos: position{line: 21, col: 26, offset: 362}, + name: "Identifier", + }, + }, + }, + }, + }, + }, + }, + &labeledExpr{ + pos: position{line: 22, col: 2, offset: 395}, + label: "where", + expr: &zeroOrOneExpr{ + pos: position{line: 22, col: 8, offset: 401}, + expr: &actionExpr{ + pos: position{line: 22, col: 10, offset: 403}, + run: (*parser).callonSelectStmt27, + expr: &seqExpr{ + pos: position{line: 22, col: 10, offset: 403}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 22, col: 10, offset: 403}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 22, col: 12, offset: 405}, + label: "w", + expr: &ruleRefExpr{ + pos: position{line: 22, col: 14, offset: 407}, + name: "WhereClause", + }, + }, + }, + }, + }, + }, + }, + &labeledExpr{ + pos: position{line: 23, col: 2, offset: 441}, + label: "group", + expr: &zeroOrOneExpr{ + pos: position{line: 23, col: 8, offset: 447}, + expr: &actionExpr{ + pos: position{line: 23, col: 10, offset: 449}, + run: (*parser).callonSelectStmt34, + expr: &seqExpr{ + pos: position{line: 23, col: 10, offset: 449}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 23, col: 10, offset: 449}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 23, col: 12, offset: 451}, + label: "g", + expr: &ruleRefExpr{ + pos: position{line: 23, col: 14, offset: 453}, + name: "GroupByClause", + }, + }, + }, + }, + }, + }, + }, + &labeledExpr{ + pos: position{line: 24, col: 2, offset: 489}, + label: "order", + expr: &zeroOrOneExpr{ + pos: position{line: 24, col: 8, offset: 495}, + expr: &actionExpr{ + pos: position{line: 24, col: 10, offset: 497}, + run: (*parser).callonSelectStmt41, + expr: &seqExpr{ + pos: position{line: 24, col: 10, offset: 497}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 24, col: 10, offset: 497}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 24, col: 12, offset: 499}, + label: "or", + expr: &ruleRefExpr{ + pos: position{line: 24, col: 15, offset: 502}, + name: "OrderByClause", + }, + }, + }, + }, + }, + }, + }, + &labeledExpr{ + pos: position{line: 25, col: 2, offset: 539}, + label: "limit", + expr: &zeroOrOneExpr{ + pos: position{line: 25, col: 8, offset: 545}, + expr: &actionExpr{ + pos: position{line: 25, col: 10, offset: 547}, + run: (*parser).callonSelectStmt48, + expr: &seqExpr{ + pos: position{line: 25, col: 10, offset: 547}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 25, col: 10, offset: 547}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 25, col: 12, offset: 549}, + label: "l", + expr: &ruleRefExpr{ + pos: position{line: 25, col: 14, offset: 551}, + name: "LimitClause", + }, + }, + }, + }, + }, + }, + }, + &labeledExpr{ + pos: position{line: 26, col: 2, offset: 585}, + label: "offset", + expr: &zeroOrOneExpr{ + pos: position{line: 26, col: 9, offset: 592}, + expr: &actionExpr{ + pos: position{line: 26, col: 11, offset: 594}, + run: (*parser).callonSelectStmt55, + expr: &seqExpr{ + pos: position{line: 26, col: 11, offset: 594}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 26, col: 11, offset: 594}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 26, col: 13, offset: 596}, + label: "of", + expr: &ruleRefExpr{ + pos: position{line: 26, col: 16, offset: 599}, + name: "OffsetClause", + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + { + name: "SelectColumn", + pos: position{line: 61, col: 1, offset: 1283}, + expr: &choiceExpr{ + pos: position{line: 62, col: 4, offset: 1299}, + alternatives: []interface{}{ + &ruleRefExpr{ + pos: position{line: 62, col: 4, offset: 1299}, + name: "AnyLiteral", + }, + &ruleRefExpr{ + pos: position{line: 63, col: 4, offset: 1313}, + name: "Expr", + }, + }, + }, + }, + { + name: "UpdateStmt", + pos: position{line: 65, col: 1, offset: 1319}, + expr: &actionExpr{ + pos: position{line: 66, col: 4, offset: 1333}, + run: (*parser).callonUpdateStmt1, + expr: &seqExpr{ + pos: position{line: 66, col: 4, offset: 1333}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 66, col: 4, offset: 1333}, + name: "UpdateToken", + }, + &ruleRefExpr{ + pos: position{line: 67, col: 2, offset: 1346}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 67, col: 4, offset: 1348}, + label: "table", + expr: &ruleRefExpr{ + pos: position{line: 67, col: 10, offset: 1354}, + name: "Identifier", + }, + }, + &ruleRefExpr{ + pos: position{line: 68, col: 2, offset: 1366}, + name: "_", + }, + &ruleRefExpr{ + pos: position{line: 68, col: 4, offset: 1368}, + name: "SetToken", + }, + &ruleRefExpr{ + pos: position{line: 69, col: 2, offset: 1378}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 69, col: 4, offset: 1380}, + label: "a", + expr: &ruleRefExpr{ + pos: position{line: 69, col: 6, offset: 1382}, + name: "Assignment", + }, + }, + &labeledExpr{ + pos: position{line: 69, col: 17, offset: 1393}, + label: "as", + expr: &zeroOrMoreExpr{ + pos: position{line: 69, col: 20, offset: 1396}, + expr: &actionExpr{ + pos: position{line: 69, col: 22, offset: 1398}, + run: (*parser).callonUpdateStmt14, + expr: &seqExpr{ + pos: position{line: 69, col: 22, offset: 1398}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 69, col: 22, offset: 1398}, + name: "_", + }, + &ruleRefExpr{ + pos: position{line: 69, col: 24, offset: 1400}, + name: "SeparatorToken", + }, + &ruleRefExpr{ + pos: position{line: 69, col: 39, offset: 1415}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 69, col: 41, offset: 1417}, + label: "s", + expr: &ruleRefExpr{ + pos: position{line: 69, col: 43, offset: 1419}, + name: "Assignment", + }, + }, + }, + }, + }, + }, + }, + &labeledExpr{ + pos: position{line: 70, col: 2, offset: 1452}, + label: "where", + expr: &zeroOrOneExpr{ + pos: position{line: 70, col: 8, offset: 1458}, + expr: &actionExpr{ + pos: position{line: 70, col: 10, offset: 1460}, + run: (*parser).callonUpdateStmt23, + expr: &seqExpr{ + pos: position{line: 70, col: 10, offset: 1460}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 70, col: 10, offset: 1460}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 70, col: 12, offset: 1462}, + label: "w", + expr: &ruleRefExpr{ + pos: position{line: 70, col: 14, offset: 1464}, + name: "WhereClause", + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + { + name: "DeleteStmt", + pos: position{line: 86, col: 1, offset: 1752}, + expr: &actionExpr{ + pos: position{line: 87, col: 4, offset: 1766}, + run: (*parser).callonDeleteStmt1, + expr: &seqExpr{ + pos: position{line: 87, col: 4, offset: 1766}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 87, col: 4, offset: 1766}, + name: "DeleteToken", + }, + &ruleRefExpr{ + pos: position{line: 88, col: 2, offset: 1779}, + name: "_", + }, + &ruleRefExpr{ + pos: position{line: 88, col: 4, offset: 1781}, + name: "FromToken", + }, + &ruleRefExpr{ + pos: position{line: 89, col: 2, offset: 1792}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 89, col: 4, offset: 1794}, + label: "table", + expr: &ruleRefExpr{ + pos: position{line: 89, col: 10, offset: 1800}, + name: "Identifier", + }, + }, + &labeledExpr{ + pos: position{line: 90, col: 2, offset: 1812}, + label: "where", + expr: &zeroOrOneExpr{ + pos: position{line: 90, col: 8, offset: 1818}, + expr: &actionExpr{ + pos: position{line: 90, col: 10, offset: 1820}, + run: (*parser).callonDeleteStmt11, + expr: &seqExpr{ + pos: position{line: 90, col: 10, offset: 1820}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 90, col: 10, offset: 1820}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 90, col: 12, offset: 1822}, + label: "w", + expr: &ruleRefExpr{ + pos: position{line: 90, col: 14, offset: 1824}, + name: "WhereClause", + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + { + name: "InsertStmt", + pos: position{line: 105, col: 1, offset: 2072}, + expr: &actionExpr{ + pos: position{line: 106, col: 4, offset: 2086}, + run: (*parser).callonInsertStmt1, + expr: &seqExpr{ + pos: position{line: 106, col: 4, offset: 2086}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 106, col: 4, offset: 2086}, + name: "InsertToken", + }, + &ruleRefExpr{ + pos: position{line: 107, col: 2, offset: 2099}, + name: "_", + }, + &ruleRefExpr{ + pos: position{line: 107, col: 4, offset: 2101}, + name: "IntoToken", + }, + &ruleRefExpr{ + pos: position{line: 108, col: 2, offset: 2112}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 108, col: 4, offset: 2114}, + label: "table", + expr: &ruleRefExpr{ + pos: position{line: 108, col: 10, offset: 2120}, + name: "Identifier", + }, + }, + &ruleRefExpr{ + pos: position{line: 109, col: 2, offset: 2132}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 109, col: 4, offset: 2134}, + label: "insert", + expr: &choiceExpr{ + pos: position{line: 109, col: 13, offset: 2143}, + alternatives: []interface{}{ + &ruleRefExpr{ + pos: position{line: 109, col: 13, offset: 2143}, + name: "InsertWithColumnClause", + }, + &ruleRefExpr{ + pos: position{line: 109, col: 38, offset: 2168}, + name: "InsertWithDefaultClause", + }, + }, + }, + }, + }, + }, + }, + }, + { + name: "InsertValue", + pos: position{line: 117, col: 1, offset: 2291}, + expr: &actionExpr{ + pos: position{line: 118, col: 4, offset: 2306}, + run: (*parser).callonInsertValue1, + expr: &seqExpr{ + pos: position{line: 118, col: 4, offset: 2306}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 118, col: 4, offset: 2306}, + val: "(", + ignoreCase: false, + }, + &ruleRefExpr{ + pos: position{line: 118, col: 8, offset: 2310}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 118, col: 10, offset: 2312}, + label: "e", + expr: &ruleRefExpr{ + pos: position{line: 118, col: 12, offset: 2314}, + name: "MultiExprWithDefault", + }, + }, + &ruleRefExpr{ + pos: position{line: 118, col: 33, offset: 2335}, + name: "_", + }, + &litMatcher{ + pos: position{line: 118, col: 35, offset: 2337}, + val: ")", + ignoreCase: false, + }, + }, + }, + }, + }, + { + name: "CreateTableStmt", + pos: position{line: 121, col: 1, offset: 2360}, + expr: &actionExpr{ + pos: position{line: 122, col: 4, offset: 2379}, + run: (*parser).callonCreateTableStmt1, + expr: &seqExpr{ + pos: position{line: 122, col: 4, offset: 2379}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 122, col: 4, offset: 2379}, + name: "CreateToken", + }, + &ruleRefExpr{ + pos: position{line: 123, col: 2, offset: 2392}, + name: "_", + }, + &ruleRefExpr{ + pos: position{line: 123, col: 4, offset: 2394}, + name: "TableToken", + }, + &ruleRefExpr{ + pos: position{line: 124, col: 2, offset: 2406}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 124, col: 4, offset: 2408}, + label: "table", + expr: &ruleRefExpr{ + pos: position{line: 124, col: 10, offset: 2414}, + name: "Identifier", + }, + }, + &ruleRefExpr{ + pos: position{line: 125, col: 2, offset: 2426}, + name: "_", + }, + &litMatcher{ + pos: position{line: 125, col: 4, offset: 2428}, + val: "(", + ignoreCase: false, + }, + &ruleRefExpr{ + pos: position{line: 126, col: 2, offset: 2433}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 126, col: 4, offset: 2435}, + label: "column", + expr: &zeroOrOneExpr{ + pos: position{line: 126, col: 11, offset: 2442}, + expr: &actionExpr{ + pos: position{line: 127, col: 3, offset: 2446}, + run: (*parser).callonCreateTableStmt14, + expr: &seqExpr{ + pos: position{line: 127, col: 3, offset: 2446}, + exprs: []interface{}{ + &labeledExpr{ + pos: position{line: 127, col: 3, offset: 2446}, + label: "s", + expr: &ruleRefExpr{ + pos: position{line: 127, col: 5, offset: 2448}, + name: "ColumnSchema", + }, + }, + &labeledExpr{ + pos: position{line: 128, col: 3, offset: 2463}, + label: "ss", + expr: &zeroOrMoreExpr{ + pos: position{line: 128, col: 6, offset: 2466}, + expr: &actionExpr{ + pos: position{line: 128, col: 8, offset: 2468}, + run: (*parser).callonCreateTableStmt20, + expr: &seqExpr{ + pos: position{line: 128, col: 8, offset: 2468}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 128, col: 8, offset: 2468}, + name: "_", + }, + &ruleRefExpr{ + pos: position{line: 128, col: 10, offset: 2470}, + name: "SeparatorToken", + }, + &ruleRefExpr{ + pos: position{line: 128, col: 25, offset: 2485}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 128, col: 27, offset: 2487}, + label: "t", + expr: &ruleRefExpr{ + pos: position{line: 128, col: 29, offset: 2489}, + name: "ColumnSchema", + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + &ruleRefExpr{ + pos: position{line: 131, col: 2, offset: 2561}, + name: "_", + }, + &litMatcher{ + pos: position{line: 131, col: 4, offset: 2563}, + val: ")", + ignoreCase: false, + }, + }, + }, + }, + }, + { + name: "ColumnSchema", + pos: position{line: 139, col: 1, offset: 2678}, + expr: &actionExpr{ + pos: position{line: 140, col: 4, offset: 2694}, + run: (*parser).callonColumnSchema1, + expr: &seqExpr{ + pos: position{line: 140, col: 4, offset: 2694}, + exprs: []interface{}{ + &labeledExpr{ + pos: position{line: 140, col: 4, offset: 2694}, + label: "i", + expr: &ruleRefExpr{ + pos: position{line: 140, col: 6, offset: 2696}, + name: "Identifier", + }, + }, + &ruleRefExpr{ + pos: position{line: 141, col: 2, offset: 2708}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 141, col: 4, offset: 2710}, + label: "t", + expr: &ruleRefExpr{ + pos: position{line: 141, col: 6, offset: 2712}, + name: "DataType", + }, + }, + &labeledExpr{ + pos: position{line: 142, col: 2, offset: 2722}, + label: "cs", + expr: &zeroOrMoreExpr{ + pos: position{line: 142, col: 5, offset: 2725}, + expr: &actionExpr{ + pos: position{line: 142, col: 7, offset: 2727}, + run: (*parser).callonColumnSchema10, + expr: &seqExpr{ + pos: position{line: 142, col: 7, offset: 2727}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 142, col: 7, offset: 2727}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 142, col: 9, offset: 2729}, + label: "s", + expr: &ruleRefExpr{ + pos: position{line: 142, col: 11, offset: 2731}, + name: "ColumnConstraint", + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + { + name: "ColumnConstraint", + pos: position{line: 151, col: 1, offset: 2894}, + expr: &choiceExpr{ + pos: position{line: 152, col: 4, offset: 2914}, + alternatives: []interface{}{ + &ruleRefExpr{ + pos: position{line: 152, col: 4, offset: 2914}, + name: "PrimaryKeyClause", + }, + &ruleRefExpr{ + pos: position{line: 153, col: 4, offset: 2934}, + name: "NotNullClause", + }, + &ruleRefExpr{ + pos: position{line: 154, col: 4, offset: 2951}, + name: "UniqueClause", + }, + &ruleRefExpr{ + pos: position{line: 155, col: 4, offset: 2967}, + name: "DefaultClause", + }, + &ruleRefExpr{ + pos: position{line: 156, col: 4, offset: 2984}, + name: "ForeignClause", + }, + &ruleRefExpr{ + pos: position{line: 157, col: 4, offset: 3001}, + name: "AutoincrementClause", + }, + }, + }, + }, + { + name: "CreateIndexStmt", + pos: position{line: 159, col: 1, offset: 3022}, + expr: &actionExpr{ + pos: position{line: 160, col: 4, offset: 3041}, + run: (*parser).callonCreateIndexStmt1, + expr: &seqExpr{ + pos: position{line: 160, col: 4, offset: 3041}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 160, col: 4, offset: 3041}, + name: "CreateToken", + }, + &labeledExpr{ + pos: position{line: 161, col: 2, offset: 3054}, + label: "unique", + expr: &zeroOrOneExpr{ + pos: position{line: 161, col: 9, offset: 3061}, + expr: &actionExpr{ + pos: position{line: 161, col: 11, offset: 3063}, + run: (*parser).callonCreateIndexStmt6, + expr: &seqExpr{ + pos: position{line: 161, col: 11, offset: 3063}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 161, col: 11, offset: 3063}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 161, col: 13, offset: 3065}, + label: "u", + expr: &ruleRefExpr{ + pos: position{line: 161, col: 15, offset: 3067}, + name: "UniqueClause", + }, + }, + }, + }, + }, + }, + }, + &ruleRefExpr{ + pos: position{line: 162, col: 2, offset: 3102}, + name: "_", + }, + &ruleRefExpr{ + pos: position{line: 162, col: 4, offset: 3104}, + name: "IndexToken", + }, + &ruleRefExpr{ + pos: position{line: 163, col: 2, offset: 3116}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 163, col: 4, offset: 3118}, + label: "index", + expr: &ruleRefExpr{ + pos: position{line: 163, col: 10, offset: 3124}, + name: "Identifier", + }, + }, + &ruleRefExpr{ + pos: position{line: 164, col: 2, offset: 3136}, + name: "_", + }, + &ruleRefExpr{ + pos: position{line: 164, col: 4, offset: 3138}, + name: "OnToken", + }, + &ruleRefExpr{ + pos: position{line: 165, col: 2, offset: 3147}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 165, col: 4, offset: 3149}, + label: "table", + expr: &ruleRefExpr{ + pos: position{line: 165, col: 10, offset: 3155}, + name: "Identifier", + }, + }, + &ruleRefExpr{ + pos: position{line: 166, col: 2, offset: 3167}, + name: "_", + }, + &litMatcher{ + pos: position{line: 166, col: 4, offset: 3169}, + val: "(", + ignoreCase: false, + }, + &ruleRefExpr{ + pos: position{line: 166, col: 8, offset: 3173}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 166, col: 10, offset: 3175}, + label: "i", + expr: &ruleRefExpr{ + pos: position{line: 166, col: 12, offset: 3177}, + name: "Identifier", + }, + }, + &labeledExpr{ + pos: position{line: 166, col: 23, offset: 3188}, + label: "is", + expr: &zeroOrMoreExpr{ + pos: position{line: 166, col: 26, offset: 3191}, + expr: &actionExpr{ + pos: position{line: 166, col: 28, offset: 3193}, + run: (*parser).callonCreateIndexStmt28, + expr: &seqExpr{ + pos: position{line: 166, col: 28, offset: 3193}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 166, col: 28, offset: 3193}, + name: "_", + }, + &ruleRefExpr{ + pos: position{line: 166, col: 30, offset: 3195}, + name: "SeparatorToken", + }, + &ruleRefExpr{ + pos: position{line: 166, col: 45, offset: 3210}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 166, col: 47, offset: 3212}, + label: "x", + expr: &ruleRefExpr{ + pos: position{line: 166, col: 49, offset: 3214}, + name: "Identifier", + }, + }, + }, + }, + }, + }, + }, + &ruleRefExpr{ + pos: position{line: 166, col: 81, offset: 3246}, + name: "_", + }, + &litMatcher{ + pos: position{line: 166, col: 83, offset: 3248}, + val: ")", + ignoreCase: false, + }, + }, + }, + }, + }, + { + name: "WhereClause", + pos: position{line: 184, col: 1, offset: 3559}, + expr: &actionExpr{ + pos: position{line: 185, col: 4, offset: 3574}, + run: (*parser).callonWhereClause1, + expr: &seqExpr{ + pos: position{line: 185, col: 4, offset: 3574}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 185, col: 4, offset: 3574}, + name: "WhereToken", + }, + &ruleRefExpr{ + pos: position{line: 185, col: 15, offset: 3585}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 185, col: 17, offset: 3587}, + label: "e", + expr: &ruleRefExpr{ + pos: position{line: 185, col: 19, offset: 3589}, + name: "Expr", + }, + }, + }, + }, + }, + }, + { + name: "OrderByClause", + pos: position{line: 188, col: 1, offset: 3645}, + expr: &actionExpr{ + pos: position{line: 189, col: 4, offset: 3662}, + run: (*parser).callonOrderByClause1, + expr: &seqExpr{ + pos: position{line: 189, col: 4, offset: 3662}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 189, col: 4, offset: 3662}, + name: "OrderToken", + }, + &ruleRefExpr{ + pos: position{line: 190, col: 2, offset: 3674}, + name: "_", + }, + &ruleRefExpr{ + pos: position{line: 190, col: 4, offset: 3676}, + name: "ByToken", + }, + &ruleRefExpr{ + pos: position{line: 191, col: 2, offset: 3685}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 191, col: 4, offset: 3687}, + label: "f", + expr: &ruleRefExpr{ + pos: position{line: 191, col: 6, offset: 3689}, + name: "OrderColumn", + }, + }, + &labeledExpr{ + pos: position{line: 192, col: 2, offset: 3702}, + label: "fs", + expr: &zeroOrMoreExpr{ + pos: position{line: 192, col: 5, offset: 3705}, + expr: &actionExpr{ + pos: position{line: 192, col: 7, offset: 3707}, + run: (*parser).callonOrderByClause11, + expr: &seqExpr{ + pos: position{line: 192, col: 7, offset: 3707}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 192, col: 7, offset: 3707}, + name: "_", + }, + &ruleRefExpr{ + pos: position{line: 192, col: 9, offset: 3709}, + name: "SeparatorToken", + }, + &ruleRefExpr{ + pos: position{line: 192, col: 24, offset: 3724}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 192, col: 26, offset: 3726}, + label: "s", + expr: &ruleRefExpr{ + pos: position{line: 192, col: 28, offset: 3728}, + name: "OrderColumn", + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + { + name: "OrderColumn", + pos: position{line: 195, col: 1, offset: 3793}, + expr: &actionExpr{ + pos: position{line: 196, col: 4, offset: 3808}, + run: (*parser).callonOrderColumn1, + expr: &seqExpr{ + pos: position{line: 196, col: 4, offset: 3808}, + exprs: []interface{}{ + &labeledExpr{ + pos: position{line: 196, col: 4, offset: 3808}, + label: "i", + expr: &ruleRefExpr{ + pos: position{line: 196, col: 6, offset: 3810}, + name: "Expr", + }, + }, + &labeledExpr{ + pos: position{line: 197, col: 2, offset: 3816}, + label: "s", + expr: &zeroOrOneExpr{ + pos: position{line: 197, col: 4, offset: 3818}, + expr: &actionExpr{ + pos: position{line: 197, col: 6, offset: 3820}, + run: (*parser).callonOrderColumn7, + expr: &seqExpr{ + pos: position{line: 197, col: 6, offset: 3820}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 197, col: 6, offset: 3820}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 197, col: 8, offset: 3822}, + label: "t", + expr: &choiceExpr{ + pos: position{line: 197, col: 12, offset: 3826}, + alternatives: []interface{}{ + &ruleRefExpr{ + pos: position{line: 197, col: 12, offset: 3826}, + name: "AscToken", + }, + &ruleRefExpr{ + pos: position{line: 197, col: 23, offset: 3837}, + name: "DescToken", + }, + }, + }, + }, + }, + }, + }, + }, + }, + &labeledExpr{ + pos: position{line: 198, col: 2, offset: 3871}, + label: "n", + expr: &zeroOrOneExpr{ + pos: position{line: 198, col: 4, offset: 3873}, + expr: &actionExpr{ + pos: position{line: 198, col: 6, offset: 3875}, + run: (*parser).callonOrderColumn16, + expr: &seqExpr{ + pos: position{line: 198, col: 6, offset: 3875}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 198, col: 6, offset: 3875}, + name: "_", + }, + &ruleRefExpr{ + pos: position{line: 198, col: 8, offset: 3877}, + name: "NullsToken", + }, + &ruleRefExpr{ + pos: position{line: 198, col: 19, offset: 3888}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 198, col: 21, offset: 3890}, + label: "l", + expr: &choiceExpr{ + pos: position{line: 198, col: 25, offset: 3894}, + alternatives: []interface{}{ + &ruleRefExpr{ + pos: position{line: 198, col: 25, offset: 3894}, + name: "LastToken", + }, + &ruleRefExpr{ + pos: position{line: 198, col: 37, offset: 3906}, + name: "FirstToken", + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + { + name: "GroupByClause", + pos: position{line: 207, col: 1, offset: 4112}, + expr: &actionExpr{ + pos: position{line: 208, col: 4, offset: 4129}, + run: (*parser).callonGroupByClause1, + expr: &seqExpr{ + pos: position{line: 208, col: 4, offset: 4129}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 208, col: 4, offset: 4129}, + name: "GroupToken", + }, + &ruleRefExpr{ + pos: position{line: 209, col: 2, offset: 4141}, + name: "_", + }, + &ruleRefExpr{ + pos: position{line: 209, col: 4, offset: 4143}, + name: "ByToken", + }, + &ruleRefExpr{ + pos: position{line: 210, col: 2, offset: 4152}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 210, col: 4, offset: 4154}, + label: "i", + expr: &ruleRefExpr{ + pos: position{line: 210, col: 6, offset: 4156}, + name: "Expr", + }, + }, + &labeledExpr{ + pos: position{line: 211, col: 2, offset: 4162}, + label: "is", + expr: &zeroOrMoreExpr{ + pos: position{line: 211, col: 5, offset: 4165}, + expr: &actionExpr{ + pos: position{line: 211, col: 7, offset: 4167}, + run: (*parser).callonGroupByClause11, + expr: &seqExpr{ + pos: position{line: 211, col: 7, offset: 4167}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 211, col: 7, offset: 4167}, + name: "_", + }, + &ruleRefExpr{ + pos: position{line: 211, col: 9, offset: 4169}, + name: "SeparatorToken", + }, + &ruleRefExpr{ + pos: position{line: 211, col: 24, offset: 4184}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 211, col: 26, offset: 4186}, + label: "s", + expr: &ruleRefExpr{ + pos: position{line: 211, col: 28, offset: 4188}, + name: "Expr", + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + { + name: "OffsetClause", + pos: position{line: 214, col: 1, offset: 4300}, + expr: &actionExpr{ + pos: position{line: 215, col: 4, offset: 4316}, + run: (*parser).callonOffsetClause1, + expr: &seqExpr{ + pos: position{line: 215, col: 4, offset: 4316}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 215, col: 4, offset: 4316}, + name: "OffsetToken", + }, + &ruleRefExpr{ + pos: position{line: 215, col: 16, offset: 4328}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 215, col: 18, offset: 4330}, + label: "i", + expr: &ruleRefExpr{ + pos: position{line: 215, col: 20, offset: 4332}, + name: "Integer", + }, + }, + }, + }, + }, + }, + { + name: "LimitClause", + pos: position{line: 218, col: 1, offset: 4411}, + expr: &actionExpr{ + pos: position{line: 219, col: 4, offset: 4426}, + run: (*parser).callonLimitClause1, + expr: &seqExpr{ + pos: position{line: 219, col: 4, offset: 4426}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 219, col: 4, offset: 4426}, + name: "LimitToken", + }, + &ruleRefExpr{ + pos: position{line: 219, col: 15, offset: 4437}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 219, col: 17, offset: 4439}, + label: "i", + expr: &ruleRefExpr{ + pos: position{line: 219, col: 19, offset: 4441}, + name: "Integer", + }, + }, + }, + }, + }, + }, + { + name: "InsertWithColumnClause", + pos: position{line: 222, col: 1, offset: 4519}, + expr: &actionExpr{ + pos: position{line: 223, col: 4, offset: 4545}, + run: (*parser).callonInsertWithColumnClause1, + expr: &seqExpr{ + pos: position{line: 223, col: 4, offset: 4545}, + exprs: []interface{}{ + &labeledExpr{ + pos: position{line: 223, col: 4, offset: 4545}, + label: "cs", + expr: &zeroOrOneExpr{ + pos: position{line: 223, col: 7, offset: 4548}, + expr: &actionExpr{ + pos: position{line: 223, col: 9, offset: 4550}, + run: (*parser).callonInsertWithColumnClause5, + expr: &seqExpr{ + pos: position{line: 223, col: 9, offset: 4550}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 223, col: 9, offset: 4550}, + val: "(", + ignoreCase: false, + }, + &ruleRefExpr{ + pos: position{line: 224, col: 4, offset: 4557}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 224, col: 6, offset: 4559}, + label: "f", + expr: &ruleRefExpr{ + pos: position{line: 224, col: 8, offset: 4561}, + name: "Identifier", + }, + }, + &labeledExpr{ + pos: position{line: 225, col: 4, offset: 4575}, + label: "fs", + expr: &zeroOrMoreExpr{ + pos: position{line: 225, col: 7, offset: 4578}, + expr: &actionExpr{ + pos: position{line: 225, col: 9, offset: 4580}, + run: (*parser).callonInsertWithColumnClause13, + expr: &seqExpr{ + pos: position{line: 225, col: 9, offset: 4580}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 225, col: 9, offset: 4580}, + name: "_", + }, + &ruleRefExpr{ + pos: position{line: 225, col: 11, offset: 4582}, + name: "SeparatorToken", + }, + &ruleRefExpr{ + pos: position{line: 225, col: 26, offset: 4597}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 225, col: 28, offset: 4599}, + label: "x", + expr: &ruleRefExpr{ + pos: position{line: 225, col: 30, offset: 4601}, + name: "Identifier", + }, + }, + }, + }, + }, + }, + }, + &ruleRefExpr{ + pos: position{line: 226, col: 4, offset: 4636}, + name: "_", + }, + &litMatcher{ + pos: position{line: 226, col: 6, offset: 4638}, + val: ")", + ignoreCase: false, + }, + &ruleRefExpr{ + pos: position{line: 227, col: 4, offset: 4645}, + name: "_", + }, + }, + }, + }, + }, + }, + &ruleRefExpr{ + pos: position{line: 229, col: 3, offset: 4685}, + name: "ValuesToken", + }, + &ruleRefExpr{ + pos: position{line: 230, col: 2, offset: 4698}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 230, col: 4, offset: 4700}, + label: "v", + expr: &ruleRefExpr{ + pos: position{line: 230, col: 6, offset: 4702}, + name: "InsertValue", + }, + }, + &labeledExpr{ + pos: position{line: 231, col: 2, offset: 4715}, + label: "vs", + expr: &zeroOrMoreExpr{ + pos: position{line: 231, col: 5, offset: 4718}, + expr: &actionExpr{ + pos: position{line: 231, col: 7, offset: 4720}, + run: (*parser).callonInsertWithColumnClause29, + expr: &seqExpr{ + pos: position{line: 231, col: 7, offset: 4720}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 231, col: 7, offset: 4720}, + name: "_", + }, + &ruleRefExpr{ + pos: position{line: 231, col: 9, offset: 4722}, + name: "SeparatorToken", + }, + &ruleRefExpr{ + pos: position{line: 231, col: 24, offset: 4737}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 231, col: 26, offset: 4739}, + label: "y", + expr: &ruleRefExpr{ + pos: position{line: 231, col: 28, offset: 4741}, + name: "InsertValue", + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + { + name: "InsertWithDefaultClause", + pos: position{line: 239, col: 1, offset: 4876}, + expr: &actionExpr{ + pos: position{line: 240, col: 4, offset: 4903}, + run: (*parser).callonInsertWithDefaultClause1, + expr: &seqExpr{ + pos: position{line: 240, col: 4, offset: 4903}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 240, col: 4, offset: 4903}, + name: "DefaultToken", + }, + &ruleRefExpr{ + pos: position{line: 240, col: 17, offset: 4916}, + name: "_", + }, + &ruleRefExpr{ + pos: position{line: 240, col: 19, offset: 4918}, + name: "ValuesToken", + }, + }, + }, + }, + }, + { + name: "PrimaryKeyClause", + pos: position{line: 243, col: 1, offset: 4981}, + expr: &actionExpr{ + pos: position{line: 244, col: 4, offset: 5001}, + run: (*parser).callonPrimaryKeyClause1, + expr: &seqExpr{ + pos: position{line: 244, col: 4, offset: 5001}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 244, col: 4, offset: 5001}, + name: "PrimaryToken", + }, + &ruleRefExpr{ + pos: position{line: 244, col: 17, offset: 5014}, + name: "_", + }, + &ruleRefExpr{ + pos: position{line: 244, col: 19, offset: 5016}, + name: "KeyToken", + }, + }, + }, + }, + }, + { + name: "NotNullClause", + pos: position{line: 247, col: 1, offset: 5066}, + expr: &actionExpr{ + pos: position{line: 248, col: 4, offset: 5083}, + run: (*parser).callonNotNullClause1, + expr: &seqExpr{ + pos: position{line: 248, col: 4, offset: 5083}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 248, col: 4, offset: 5083}, + name: "NotToken", + }, + &ruleRefExpr{ + pos: position{line: 248, col: 13, offset: 5092}, + name: "_", + }, + &ruleRefExpr{ + pos: position{line: 248, col: 15, offset: 5094}, + name: "NullToken", + }, + }, + }, + }, + }, + { + name: "UniqueClause", + pos: position{line: 251, col: 1, offset: 5145}, + expr: &actionExpr{ + pos: position{line: 252, col: 4, offset: 5161}, + run: (*parser).callonUniqueClause1, + expr: &ruleRefExpr{ + pos: position{line: 252, col: 4, offset: 5161}, + name: "UniqueToken", + }, + }, + }, + { + name: "DefaultClause", + pos: position{line: 255, col: 1, offset: 5213}, + expr: &actionExpr{ + pos: position{line: 256, col: 4, offset: 5230}, + run: (*parser).callonDefaultClause1, + expr: &seqExpr{ + pos: position{line: 256, col: 4, offset: 5230}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 256, col: 4, offset: 5230}, + name: "DefaultToken", + }, + &ruleRefExpr{ + pos: position{line: 256, col: 17, offset: 5243}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 256, col: 19, offset: 5245}, + label: "e", + expr: &ruleRefExpr{ + pos: position{line: 256, col: 21, offset: 5247}, + name: "Expr", + }, + }, + }, + }, + }, + }, + { + name: "ForeignClause", + pos: position{line: 259, col: 1, offset: 5301}, + expr: &actionExpr{ + pos: position{line: 260, col: 4, offset: 5318}, + run: (*parser).callonForeignClause1, + expr: &seqExpr{ + pos: position{line: 260, col: 4, offset: 5318}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 260, col: 4, offset: 5318}, + name: "ReferencesToken", + }, + &ruleRefExpr{ + pos: position{line: 260, col: 20, offset: 5334}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 260, col: 22, offset: 5336}, + label: "t", + expr: &ruleRefExpr{ + pos: position{line: 260, col: 24, offset: 5338}, + name: "Identifier", + }, + }, + &ruleRefExpr{ + pos: position{line: 260, col: 35, offset: 5349}, + name: "_", + }, + &litMatcher{ + pos: position{line: 260, col: 37, offset: 5351}, + val: "(", + ignoreCase: false, + }, + &ruleRefExpr{ + pos: position{line: 260, col: 41, offset: 5355}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 260, col: 43, offset: 5357}, + label: "f", + expr: &ruleRefExpr{ + pos: position{line: 260, col: 45, offset: 5359}, + name: "Identifier", + }, + }, + &ruleRefExpr{ + pos: position{line: 260, col: 56, offset: 5370}, + name: "_", + }, + &litMatcher{ + pos: position{line: 260, col: 58, offset: 5372}, + val: ")", + ignoreCase: false, + }, + }, + }, + }, + }, + { + name: "AutoincrementClause", + pos: position{line: 268, col: 1, offset: 5488}, + expr: &actionExpr{ + pos: position{line: 269, col: 4, offset: 5511}, + run: (*parser).callonAutoincrementClause1, + expr: &ruleRefExpr{ + pos: position{line: 269, col: 4, offset: 5511}, + name: "AutoincrementToken", + }, + }, + }, + { + name: "Expr", + pos: position{line: 273, col: 1, offset: 5595}, + expr: &ruleRefExpr{ + pos: position{line: 274, col: 4, offset: 5603}, + name: "LogicExpr", + }, + }, + { + name: "ExprWithDefault", + pos: position{line: 276, col: 1, offset: 5614}, + expr: &choiceExpr{ + pos: position{line: 277, col: 4, offset: 5633}, + alternatives: []interface{}{ + &actionExpr{ + pos: position{line: 277, col: 4, offset: 5633}, + run: (*parser).callonExprWithDefault2, + expr: &seqExpr{ + pos: position{line: 277, col: 4, offset: 5633}, + exprs: []interface{}{ + &andExpr{ + pos: position{line: 277, col: 4, offset: 5633}, + expr: &ruleRefExpr{ + pos: position{line: 277, col: 6, offset: 5635}, + name: "DefaultLiteral", + }, + }, + &labeledExpr{ + pos: position{line: 277, col: 22, offset: 5651}, + label: "d", + expr: &ruleRefExpr{ + pos: position{line: 277, col: 24, offset: 5653}, + name: "DefaultLiteral", + }, + }, + }, + }, + }, + &ruleRefExpr{ + pos: position{line: 278, col: 4, offset: 5689}, + name: "Expr", + }, + }, + }, + }, + { + name: "LogicExpr", + pos: position{line: 280, col: 1, offset: 5695}, + expr: &ruleRefExpr{ + pos: position{line: 281, col: 4, offset: 5708}, + name: "LogicExpr4", + }, + }, + { + name: "LogicExpr4", + pos: position{line: 283, col: 1, offset: 5720}, + expr: &actionExpr{ + pos: position{line: 284, col: 4, offset: 5734}, + run: (*parser).callonLogicExpr41, + expr: &seqExpr{ + pos: position{line: 284, col: 4, offset: 5734}, + exprs: []interface{}{ + &labeledExpr{ + pos: position{line: 284, col: 4, offset: 5734}, + label: "o", + expr: &ruleRefExpr{ + pos: position{line: 284, col: 6, offset: 5736}, + name: "LogicExpr3", + }, + }, + &labeledExpr{ + pos: position{line: 285, col: 3, offset: 5749}, + label: "os", + expr: &zeroOrMoreExpr{ + pos: position{line: 285, col: 6, offset: 5752}, + expr: &actionExpr{ + pos: position{line: 285, col: 8, offset: 5754}, + run: (*parser).callonLogicExpr47, + expr: &seqExpr{ + pos: position{line: 285, col: 8, offset: 5754}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 285, col: 8, offset: 5754}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 285, col: 10, offset: 5756}, + label: "op", + expr: &ruleRefExpr{ + pos: position{line: 285, col: 13, offset: 5759}, + name: "OrOperator", + }, + }, + &ruleRefExpr{ + pos: position{line: 285, col: 24, offset: 5770}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 285, col: 26, offset: 5772}, + label: "s", + expr: &ruleRefExpr{ + pos: position{line: 285, col: 28, offset: 5774}, + name: "LogicExpr3", + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + { + name: "LogicExpr3", + pos: position{line: 288, col: 1, offset: 5867}, + expr: &actionExpr{ + pos: position{line: 289, col: 4, offset: 5881}, + run: (*parser).callonLogicExpr31, + expr: &seqExpr{ + pos: position{line: 289, col: 4, offset: 5881}, + exprs: []interface{}{ + &labeledExpr{ + pos: position{line: 289, col: 4, offset: 5881}, + label: "o", + expr: &ruleRefExpr{ + pos: position{line: 289, col: 6, offset: 5883}, + name: "LogicExpr2", + }, + }, + &labeledExpr{ + pos: position{line: 290, col: 3, offset: 5896}, + label: "os", + expr: &zeroOrMoreExpr{ + pos: position{line: 290, col: 6, offset: 5899}, + expr: &actionExpr{ + pos: position{line: 290, col: 8, offset: 5901}, + run: (*parser).callonLogicExpr37, + expr: &seqExpr{ + pos: position{line: 290, col: 8, offset: 5901}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 290, col: 8, offset: 5901}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 290, col: 10, offset: 5903}, + label: "op", + expr: &ruleRefExpr{ + pos: position{line: 290, col: 13, offset: 5906}, + name: "AndOperator", + }, + }, + &ruleRefExpr{ + pos: position{line: 290, col: 25, offset: 5918}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 290, col: 27, offset: 5920}, + label: "s", + expr: &ruleRefExpr{ + pos: position{line: 290, col: 29, offset: 5922}, + name: "LogicExpr2", + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + { + name: "LogicExpr2", + pos: position{line: 293, col: 1, offset: 6015}, + expr: &choiceExpr{ + pos: position{line: 294, col: 4, offset: 6029}, + alternatives: []interface{}{ + &actionExpr{ + pos: position{line: 294, col: 4, offset: 6029}, + run: (*parser).callonLogicExpr22, + expr: &seqExpr{ + pos: position{line: 294, col: 4, offset: 6029}, + exprs: []interface{}{ + &labeledExpr{ + pos: position{line: 294, col: 4, offset: 6029}, + label: "op", + expr: &ruleRefExpr{ + pos: position{line: 294, col: 7, offset: 6032}, + name: "NotOperator", + }, + }, + &ruleRefExpr{ + pos: position{line: 294, col: 19, offset: 6044}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 294, col: 21, offset: 6046}, + label: "s", + expr: &ruleRefExpr{ + pos: position{line: 294, col: 23, offset: 6048}, + name: "LogicExpr2", + }, + }, + }, + }, + }, + &ruleRefExpr{ + pos: position{line: 296, col: 4, offset: 6098}, + name: "LogicExpr1", + }, + }, + }, + }, + { + name: "LogicExpr1", + pos: position{line: 298, col: 1, offset: 6110}, + expr: &actionExpr{ + pos: position{line: 299, col: 4, offset: 6124}, + run: (*parser).callonLogicExpr11, + expr: &seqExpr{ + pos: position{line: 299, col: 4, offset: 6124}, + exprs: []interface{}{ + &labeledExpr{ + pos: position{line: 299, col: 4, offset: 6124}, + label: "o", + expr: &ruleRefExpr{ + pos: position{line: 299, col: 6, offset: 6126}, + name: "ArithmeticExpr", + }, + }, + &labeledExpr{ + pos: position{line: 299, col: 21, offset: 6141}, + label: "os", + expr: &zeroOrMoreExpr{ + pos: position{line: 299, col: 24, offset: 6144}, + expr: &actionExpr{ + pos: position{line: 299, col: 26, offset: 6146}, + run: (*parser).callonLogicExpr17, + expr: &seqExpr{ + pos: position{line: 299, col: 26, offset: 6146}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 299, col: 26, offset: 6146}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 299, col: 28, offset: 6148}, + label: "l", + expr: &ruleRefExpr{ + pos: position{line: 299, col: 30, offset: 6150}, + name: "LogicExpr1Op", + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + { + name: "LogicExpr1Op", + pos: position{line: 302, col: 1, offset: 6227}, + expr: &choiceExpr{ + pos: position{line: 303, col: 4, offset: 6243}, + alternatives: []interface{}{ + &ruleRefExpr{ + pos: position{line: 303, col: 4, offset: 6243}, + name: "LogicExpr1In", + }, + &ruleRefExpr{ + pos: position{line: 304, col: 4, offset: 6259}, + name: "LogicExpr1Null", + }, + &ruleRefExpr{ + pos: position{line: 305, col: 4, offset: 6277}, + name: "LogicExpr1Like", + }, + &ruleRefExpr{ + pos: position{line: 306, col: 4, offset: 6295}, + name: "LogicExpr1Cmp", + }, + }, + }, + }, + { + name: "LogicExpr1In", + pos: position{line: 308, col: 1, offset: 6310}, + expr: &actionExpr{ + pos: position{line: 309, col: 4, offset: 6326}, + run: (*parser).callonLogicExpr1In1, + expr: &seqExpr{ + pos: position{line: 309, col: 4, offset: 6326}, + exprs: []interface{}{ + &labeledExpr{ + pos: position{line: 309, col: 4, offset: 6326}, + label: "n", + expr: &zeroOrOneExpr{ + pos: position{line: 309, col: 6, offset: 6328}, + expr: &actionExpr{ + pos: position{line: 309, col: 8, offset: 6330}, + run: (*parser).callonLogicExpr1In5, + expr: &seqExpr{ + pos: position{line: 309, col: 8, offset: 6330}, + exprs: []interface{}{ + &labeledExpr{ + pos: position{line: 309, col: 8, offset: 6330}, + label: "t", + expr: &ruleRefExpr{ + pos: position{line: 309, col: 10, offset: 6332}, + name: "NotOperator", + }, + }, + &ruleRefExpr{ + pos: position{line: 309, col: 22, offset: 6344}, + name: "_", + }, + }, + }, + }, + }, + }, + &ruleRefExpr{ + pos: position{line: 309, col: 45, offset: 6367}, + name: "InToken", + }, + &ruleRefExpr{ + pos: position{line: 309, col: 53, offset: 6375}, + name: "_", + }, + &litMatcher{ + pos: position{line: 309, col: 55, offset: 6377}, + val: "(", + ignoreCase: false, + }, + &ruleRefExpr{ + pos: position{line: 309, col: 59, offset: 6381}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 309, col: 61, offset: 6383}, + label: "s", + expr: &ruleRefExpr{ + pos: position{line: 309, col: 63, offset: 6385}, + name: "MultiExpr", + }, + }, + &ruleRefExpr{ + pos: position{line: 309, col: 73, offset: 6395}, + name: "_", + }, + &litMatcher{ + pos: position{line: 309, col: 75, offset: 6397}, + val: ")", + ignoreCase: false, + }, + }, + }, + }, + }, + { + name: "LogicExpr1Null", + pos: position{line: 318, col: 1, offset: 6519}, + expr: &actionExpr{ + pos: position{line: 319, col: 4, offset: 6537}, + run: (*parser).callonLogicExpr1Null1, + expr: &seqExpr{ + pos: position{line: 319, col: 4, offset: 6537}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 319, col: 4, offset: 6537}, + name: "IsToken", + }, + &labeledExpr{ + pos: position{line: 319, col: 12, offset: 6545}, + label: "n", + expr: &zeroOrOneExpr{ + pos: position{line: 319, col: 14, offset: 6547}, + expr: &actionExpr{ + pos: position{line: 319, col: 16, offset: 6549}, + run: (*parser).callonLogicExpr1Null6, + expr: &seqExpr{ + pos: position{line: 319, col: 16, offset: 6549}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 319, col: 16, offset: 6549}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 319, col: 18, offset: 6551}, + label: "t", + expr: &ruleRefExpr{ + pos: position{line: 319, col: 20, offset: 6553}, + name: "NotOperator", + }, + }, + }, + }, + }, + }, + }, + &ruleRefExpr{ + pos: position{line: 319, col: 53, offset: 6586}, + name: "_", + }, + &ruleRefExpr{ + pos: position{line: 319, col: 55, offset: 6588}, + name: "NullToken", + }, + }, + }, + }, + }, + { + name: "LogicExpr1Like", + pos: position{line: 328, col: 1, offset: 6734}, + expr: &actionExpr{ + pos: position{line: 329, col: 4, offset: 6752}, + run: (*parser).callonLogicExpr1Like1, + expr: &seqExpr{ + pos: position{line: 329, col: 4, offset: 6752}, + exprs: []interface{}{ + &labeledExpr{ + pos: position{line: 329, col: 4, offset: 6752}, + label: "n", + expr: &zeroOrOneExpr{ + pos: position{line: 329, col: 6, offset: 6754}, + expr: &actionExpr{ + pos: position{line: 329, col: 8, offset: 6756}, + run: (*parser).callonLogicExpr1Like5, + expr: &seqExpr{ + pos: position{line: 329, col: 8, offset: 6756}, + exprs: []interface{}{ + &labeledExpr{ + pos: position{line: 329, col: 8, offset: 6756}, + label: "t", + expr: &ruleRefExpr{ + pos: position{line: 329, col: 10, offset: 6758}, + name: "NotOperator", + }, + }, + &ruleRefExpr{ + pos: position{line: 329, col: 22, offset: 6770}, + name: "_", + }, + }, + }, + }, + }, + }, + &ruleRefExpr{ + pos: position{line: 329, col: 45, offset: 6793}, + name: "LikeToken", + }, + &ruleRefExpr{ + pos: position{line: 329, col: 55, offset: 6803}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 329, col: 57, offset: 6805}, + label: "s", + expr: &ruleRefExpr{ + pos: position{line: 329, col: 59, offset: 6807}, + name: "Expr", + }, + }, + }, + }, + }, + }, + { + name: "LogicExpr1Cmp", + pos: position{line: 338, col: 1, offset: 6932}, + expr: &actionExpr{ + pos: position{line: 339, col: 4, offset: 6949}, + run: (*parser).callonLogicExpr1Cmp1, + expr: &seqExpr{ + pos: position{line: 339, col: 4, offset: 6949}, + exprs: []interface{}{ + &labeledExpr{ + pos: position{line: 339, col: 4, offset: 6949}, + label: "op", + expr: &ruleRefExpr{ + pos: position{line: 339, col: 7, offset: 6952}, + name: "CmpOperator", + }, + }, + &ruleRefExpr{ + pos: position{line: 339, col: 19, offset: 6964}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 339, col: 21, offset: 6966}, + label: "s", + expr: &ruleRefExpr{ + pos: position{line: 339, col: 23, offset: 6968}, + name: "ArithmeticExpr", + }, + }, + }, + }, + }, + }, + { + name: "ArithmeticExpr", + pos: position{line: 342, col: 1, offset: 7020}, + expr: &ruleRefExpr{ + pos: position{line: 343, col: 4, offset: 7038}, + name: "ArithmeticExpr3", + }, + }, + { + name: "ArithmeticExpr3", + pos: position{line: 345, col: 1, offset: 7055}, + expr: &actionExpr{ + pos: position{line: 346, col: 4, offset: 7074}, + run: (*parser).callonArithmeticExpr31, + expr: &seqExpr{ + pos: position{line: 346, col: 4, offset: 7074}, + exprs: []interface{}{ + &labeledExpr{ + pos: position{line: 346, col: 4, offset: 7074}, + label: "o", + expr: &ruleRefExpr{ + pos: position{line: 346, col: 6, offset: 7076}, + name: "ArithmeticExpr2", + }, + }, + &labeledExpr{ + pos: position{line: 346, col: 22, offset: 7092}, + label: "os", + expr: &zeroOrMoreExpr{ + pos: position{line: 346, col: 25, offset: 7095}, + expr: &actionExpr{ + pos: position{line: 346, col: 27, offset: 7097}, + run: (*parser).callonArithmeticExpr37, + expr: &seqExpr{ + pos: position{line: 346, col: 27, offset: 7097}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 346, col: 27, offset: 7097}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 346, col: 29, offset: 7099}, + label: "op", + expr: &ruleRefExpr{ + pos: position{line: 346, col: 32, offset: 7102}, + name: "ConcatOperator", + }, + }, + &ruleRefExpr{ + pos: position{line: 346, col: 47, offset: 7117}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 346, col: 49, offset: 7119}, + label: "s", + expr: &ruleRefExpr{ + pos: position{line: 346, col: 51, offset: 7121}, + name: "ArithmeticExpr2", + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + { + name: "ArithmeticExpr2", + pos: position{line: 349, col: 1, offset: 7219}, + expr: &actionExpr{ + pos: position{line: 350, col: 4, offset: 7238}, + run: (*parser).callonArithmeticExpr21, + expr: &seqExpr{ + pos: position{line: 350, col: 4, offset: 7238}, + exprs: []interface{}{ + &labeledExpr{ + pos: position{line: 350, col: 4, offset: 7238}, + label: "o", + expr: &ruleRefExpr{ + pos: position{line: 350, col: 6, offset: 7240}, + name: "ArithmeticExpr1", + }, + }, + &labeledExpr{ + pos: position{line: 350, col: 22, offset: 7256}, + label: "os", + expr: &zeroOrMoreExpr{ + pos: position{line: 350, col: 25, offset: 7259}, + expr: &actionExpr{ + pos: position{line: 350, col: 27, offset: 7261}, + run: (*parser).callonArithmeticExpr27, + expr: &seqExpr{ + pos: position{line: 350, col: 27, offset: 7261}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 350, col: 27, offset: 7261}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 350, col: 29, offset: 7263}, + label: "op", + expr: &ruleRefExpr{ + pos: position{line: 350, col: 32, offset: 7266}, + name: "AddSubOperator", + }, + }, + &ruleRefExpr{ + pos: position{line: 350, col: 47, offset: 7281}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 350, col: 49, offset: 7283}, + label: "s", + expr: &ruleRefExpr{ + pos: position{line: 350, col: 51, offset: 7285}, + name: "ArithmeticExpr1", + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + { + name: "ArithmeticExpr1", + pos: position{line: 353, col: 1, offset: 7383}, + expr: &actionExpr{ + pos: position{line: 354, col: 4, offset: 7402}, + run: (*parser).callonArithmeticExpr11, + expr: &seqExpr{ + pos: position{line: 354, col: 4, offset: 7402}, + exprs: []interface{}{ + &labeledExpr{ + pos: position{line: 354, col: 4, offset: 7402}, + label: "o", + expr: &ruleRefExpr{ + pos: position{line: 354, col: 6, offset: 7404}, + name: "Operand", + }, + }, + &labeledExpr{ + pos: position{line: 354, col: 14, offset: 7412}, + label: "os", + expr: &zeroOrMoreExpr{ + pos: position{line: 354, col: 17, offset: 7415}, + expr: &actionExpr{ + pos: position{line: 354, col: 19, offset: 7417}, + run: (*parser).callonArithmeticExpr17, + expr: &seqExpr{ + pos: position{line: 354, col: 19, offset: 7417}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 354, col: 19, offset: 7417}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 354, col: 21, offset: 7419}, + label: "op", + expr: &ruleRefExpr{ + pos: position{line: 354, col: 24, offset: 7422}, + name: "MulDivModOperator", + }, + }, + &ruleRefExpr{ + pos: position{line: 354, col: 42, offset: 7440}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 354, col: 44, offset: 7442}, + label: "s", + expr: &ruleRefExpr{ + pos: position{line: 354, col: 46, offset: 7444}, + name: "Operand", + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + { + name: "MultiExpr", + pos: position{line: 357, col: 1, offset: 7534}, + expr: &actionExpr{ + pos: position{line: 358, col: 4, offset: 7547}, + run: (*parser).callonMultiExpr1, + expr: &seqExpr{ + pos: position{line: 358, col: 4, offset: 7547}, + exprs: []interface{}{ + &labeledExpr{ + pos: position{line: 358, col: 4, offset: 7547}, + label: "x", + expr: &ruleRefExpr{ + pos: position{line: 358, col: 6, offset: 7549}, + name: "Expr", + }, + }, + &labeledExpr{ + pos: position{line: 358, col: 11, offset: 7554}, + label: "xs", + expr: &zeroOrMoreExpr{ + pos: position{line: 358, col: 14, offset: 7557}, + expr: &actionExpr{ + pos: position{line: 358, col: 16, offset: 7559}, + run: (*parser).callonMultiExpr7, + expr: &seqExpr{ + pos: position{line: 358, col: 16, offset: 7559}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 358, col: 16, offset: 7559}, + name: "_", + }, + &ruleRefExpr{ + pos: position{line: 358, col: 18, offset: 7561}, + name: "SeparatorToken", + }, + &ruleRefExpr{ + pos: position{line: 358, col: 33, offset: 7576}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 358, col: 35, offset: 7578}, + label: "e", + expr: &ruleRefExpr{ + pos: position{line: 358, col: 37, offset: 7580}, + name: "Expr", + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + { + name: "MultiExprWithDefault", + pos: position{line: 361, col: 1, offset: 7638}, + expr: &actionExpr{ + pos: position{line: 362, col: 4, offset: 7662}, + run: (*parser).callonMultiExprWithDefault1, + expr: &seqExpr{ + pos: position{line: 362, col: 4, offset: 7662}, + exprs: []interface{}{ + &labeledExpr{ + pos: position{line: 362, col: 4, offset: 7662}, + label: "x", + expr: &ruleRefExpr{ + pos: position{line: 362, col: 6, offset: 7664}, + name: "ExprWithDefault", + }, + }, + &labeledExpr{ + pos: position{line: 362, col: 22, offset: 7680}, + label: "xs", + expr: &zeroOrMoreExpr{ + pos: position{line: 362, col: 25, offset: 7683}, + expr: &actionExpr{ + pos: position{line: 362, col: 27, offset: 7685}, + run: (*parser).callonMultiExprWithDefault7, + expr: &seqExpr{ + pos: position{line: 362, col: 27, offset: 7685}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 362, col: 27, offset: 7685}, + name: "_", + }, + &ruleRefExpr{ + pos: position{line: 362, col: 29, offset: 7687}, + name: "SeparatorToken", + }, + &ruleRefExpr{ + pos: position{line: 362, col: 44, offset: 7702}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 362, col: 46, offset: 7704}, + label: "e", + expr: &ruleRefExpr{ + pos: position{line: 362, col: 48, offset: 7706}, + name: "ExprWithDefault", + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + { + name: "Operand", + pos: position{line: 365, col: 1, offset: 7775}, + expr: &choiceExpr{ + pos: position{line: 366, col: 4, offset: 7786}, + alternatives: []interface{}{ + &actionExpr{ + pos: position{line: 366, col: 4, offset: 7786}, + run: (*parser).callonOperand2, + expr: &seqExpr{ + pos: position{line: 366, col: 4, offset: 7786}, + exprs: []interface{}{ + &labeledExpr{ + pos: position{line: 366, col: 4, offset: 7786}, + label: "op", + expr: &ruleRefExpr{ + pos: position{line: 366, col: 7, offset: 7789}, + name: "UnaryOperator", + }, + }, + &ruleRefExpr{ + pos: position{line: 366, col: 21, offset: 7803}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 366, col: 23, offset: 7805}, + label: "s", + expr: &ruleRefExpr{ + pos: position{line: 366, col: 25, offset: 7807}, + name: "Operand", + }, + }, + }, + }, + }, + &actionExpr{ + pos: position{line: 367, col: 4, offset: 7853}, + run: (*parser).callonOperand9, + expr: &seqExpr{ + pos: position{line: 367, col: 4, offset: 7853}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 367, col: 4, offset: 7853}, + val: "(", + ignoreCase: false, + }, + &ruleRefExpr{ + pos: position{line: 367, col: 8, offset: 7857}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 367, col: 10, offset: 7859}, + label: "e", + expr: &ruleRefExpr{ + pos: position{line: 367, col: 12, offset: 7861}, + name: "Expr", + }, + }, + &ruleRefExpr{ + pos: position{line: 367, col: 17, offset: 7866}, + name: "_", + }, + &litMatcher{ + pos: position{line: 367, col: 19, offset: 7868}, + val: ")", + ignoreCase: false, + }, + }, + }, + }, + &actionExpr{ + pos: position{line: 368, col: 4, offset: 7893}, + run: (*parser).callonOperand17, + expr: &seqExpr{ + pos: position{line: 368, col: 4, offset: 7893}, + exprs: []interface{}{ + &andExpr{ + pos: position{line: 368, col: 4, offset: 7893}, + expr: &ruleRefExpr{ + pos: position{line: 368, col: 6, offset: 7895}, + name: "CastToken", + }, + }, + &labeledExpr{ + pos: position{line: 368, col: 17, offset: 7906}, + label: "t", + expr: &ruleRefExpr{ + pos: position{line: 368, col: 19, offset: 7908}, + name: "TypeCast", + }, + }, + }, + }, + }, + &ruleRefExpr{ + pos: position{line: 369, col: 4, offset: 7938}, + name: "FunctionCall", + }, + &ruleRefExpr{ + pos: position{line: 370, col: 4, offset: 7954}, + name: "Value", + }, + &ruleRefExpr{ + pos: position{line: 371, col: 4, offset: 7963}, + name: "Identifier", + }, + }, + }, + }, + { + name: "TypeCast", + pos: position{line: 373, col: 1, offset: 7975}, + expr: &actionExpr{ + pos: position{line: 374, col: 4, offset: 7987}, + run: (*parser).callonTypeCast1, + expr: &seqExpr{ + pos: position{line: 374, col: 4, offset: 7987}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 374, col: 4, offset: 7987}, + name: "CastToken", + }, + &ruleRefExpr{ + pos: position{line: 374, col: 14, offset: 7997}, + name: "_", + }, + &litMatcher{ + pos: position{line: 374, col: 16, offset: 7999}, + val: "(", + ignoreCase: false, + }, + &ruleRefExpr{ + pos: position{line: 374, col: 20, offset: 8003}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 374, col: 22, offset: 8005}, + label: "o", + expr: &ruleRefExpr{ + pos: position{line: 374, col: 24, offset: 8007}, + name: "Expr", + }, + }, + &ruleRefExpr{ + pos: position{line: 374, col: 29, offset: 8012}, + name: "_", + }, + &ruleRefExpr{ + pos: position{line: 374, col: 31, offset: 8014}, + name: "AsToken", + }, + &ruleRefExpr{ + pos: position{line: 374, col: 39, offset: 8022}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 374, col: 41, offset: 8024}, + label: "s", + expr: &ruleRefExpr{ + pos: position{line: 374, col: 43, offset: 8026}, + name: "DataType", + }, + }, + &ruleRefExpr{ + pos: position{line: 374, col: 52, offset: 8035}, + name: "_", + }, + &litMatcher{ + pos: position{line: 374, col: 54, offset: 8037}, + val: ")", + ignoreCase: false, + }, + }, + }, + }, + }, + { + name: "FunctionCall", + pos: position{line: 377, col: 1, offset: 8115}, + expr: &actionExpr{ + pos: position{line: 378, col: 4, offset: 8131}, + run: (*parser).callonFunctionCall1, + expr: &seqExpr{ + pos: position{line: 378, col: 4, offset: 8131}, + exprs: []interface{}{ + &labeledExpr{ + pos: position{line: 378, col: 4, offset: 8131}, + label: "i", + expr: &ruleRefExpr{ + pos: position{line: 378, col: 6, offset: 8133}, + name: "Identifier", + }, + }, + &ruleRefExpr{ + pos: position{line: 378, col: 17, offset: 8144}, + name: "_", + }, + &litMatcher{ + pos: position{line: 378, col: 19, offset: 8146}, + val: "(", + ignoreCase: false, + }, + &ruleRefExpr{ + pos: position{line: 378, col: 23, offset: 8150}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 378, col: 25, offset: 8152}, + label: "r", + expr: &zeroOrOneExpr{ + pos: position{line: 378, col: 27, offset: 8154}, + expr: &ruleRefExpr{ + pos: position{line: 378, col: 27, offset: 8154}, + name: "FunctionArgs", + }, + }, + }, + &ruleRefExpr{ + pos: position{line: 378, col: 41, offset: 8168}, + name: "_", + }, + &litMatcher{ + pos: position{line: 378, col: 43, offset: 8170}, + val: ")", + ignoreCase: false, + }, + }, + }, + }, + }, + { + name: "FunctionArgs", + pos: position{line: 381, col: 1, offset: 8252}, + expr: &choiceExpr{ + pos: position{line: 382, col: 4, offset: 8268}, + alternatives: []interface{}{ + &actionExpr{ + pos: position{line: 382, col: 4, offset: 8268}, + run: (*parser).callonFunctionArgs2, + expr: &labeledExpr{ + pos: position{line: 382, col: 4, offset: 8268}, + label: "a", + expr: &ruleRefExpr{ + pos: position{line: 382, col: 6, offset: 8270}, + name: "AnyLiteral", + }, + }, + }, + &ruleRefExpr{ + pos: position{line: 383, col: 4, offset: 8317}, + name: "MultiExpr", + }, + }, + }, + }, + { + name: "Assignment", + pos: position{line: 385, col: 1, offset: 8328}, + expr: &actionExpr{ + pos: position{line: 386, col: 4, offset: 8342}, + run: (*parser).callonAssignment1, + expr: &seqExpr{ + pos: position{line: 386, col: 4, offset: 8342}, + exprs: []interface{}{ + &labeledExpr{ + pos: position{line: 386, col: 4, offset: 8342}, + label: "i", + expr: &ruleRefExpr{ + pos: position{line: 386, col: 6, offset: 8344}, + name: "Identifier", + }, + }, + &ruleRefExpr{ + pos: position{line: 386, col: 17, offset: 8355}, + name: "_", + }, + &litMatcher{ + pos: position{line: 386, col: 19, offset: 8357}, + val: "=", + ignoreCase: false, + }, + &ruleRefExpr{ + pos: position{line: 386, col: 23, offset: 8361}, + name: "_", + }, + &labeledExpr{ + pos: position{line: 386, col: 25, offset: 8363}, + label: "e", + expr: &ruleRefExpr{ + pos: position{line: 386, col: 27, offset: 8365}, + name: "ExprWithDefault", + }, + }, + }, + }, + }, + }, + { + name: "UnaryOperator", + pos: position{line: 390, col: 1, offset: 8473}, + expr: &ruleRefExpr{ + pos: position{line: 391, col: 4, offset: 8490}, + name: "SignOperator", + }, + }, + { + name: "SignOperator", + pos: position{line: 393, col: 1, offset: 8504}, + expr: &actionExpr{ + pos: position{line: 394, col: 4, offset: 8520}, + run: (*parser).callonSignOperator1, + expr: &ruleRefExpr{ + pos: position{line: 394, col: 4, offset: 8520}, + name: "Sign", + }, + }, + }, + { + name: "NotOperator", + pos: position{line: 405, col: 1, offset: 8694}, + expr: &actionExpr{ + pos: position{line: 406, col: 4, offset: 8709}, + run: (*parser).callonNotOperator1, + expr: &ruleRefExpr{ + pos: position{line: 406, col: 4, offset: 8709}, + name: "NotToken", + }, + }, + }, + { + name: "AndOperator", + pos: position{line: 409, col: 1, offset: 8758}, + expr: &actionExpr{ + pos: position{line: 410, col: 4, offset: 8773}, + run: (*parser).callonAndOperator1, + expr: &ruleRefExpr{ + pos: position{line: 410, col: 4, offset: 8773}, + name: "AndToken", + }, + }, + }, + { + name: "OrOperator", + pos: position{line: 413, col: 1, offset: 8822}, + expr: &actionExpr{ + pos: position{line: 414, col: 4, offset: 8836}, + run: (*parser).callonOrOperator1, + expr: &ruleRefExpr{ + pos: position{line: 414, col: 4, offset: 8836}, + name: "OrToken", + }, + }, + }, + { + name: "CmpOperator", + pos: position{line: 417, col: 1, offset: 8883}, + expr: &actionExpr{ + pos: position{line: 418, col: 4, offset: 8898}, + run: (*parser).callonCmpOperator1, + expr: &choiceExpr{ + pos: position{line: 418, col: 6, offset: 8900}, + alternatives: []interface{}{ + &litMatcher{ + pos: position{line: 418, col: 6, offset: 8900}, + val: "<=", + ignoreCase: false, + }, + &litMatcher{ + pos: position{line: 418, col: 13, offset: 8907}, + val: ">=", + ignoreCase: false, + }, + &litMatcher{ + pos: position{line: 418, col: 20, offset: 8914}, + val: "<>", + ignoreCase: false, + }, + &litMatcher{ + pos: position{line: 418, col: 27, offset: 8921}, + val: "!=", + ignoreCase: false, + }, + &charClassMatcher{ + pos: position{line: 418, col: 34, offset: 8928}, + val: "[<>=]", + chars: []rune{'<', '>', '='}, + ignoreCase: false, + inverted: false, + }, + }, + }, + }, + }, + { + name: "ConcatOperator", + pos: position{line: 439, col: 1, offset: 9384}, + expr: &actionExpr{ + pos: position{line: 440, col: 4, offset: 9402}, + run: (*parser).callonConcatOperator1, + expr: &litMatcher{ + pos: position{line: 440, col: 4, offset: 9402}, + val: "||", + ignoreCase: false, + }, + }, + }, + { + name: "AddSubOperator", + pos: position{line: 443, col: 1, offset: 9450}, + expr: &actionExpr{ + pos: position{line: 444, col: 4, offset: 9468}, + run: (*parser).callonAddSubOperator1, + expr: &charClassMatcher{ + pos: position{line: 444, col: 4, offset: 9468}, + val: "[+-]", + chars: []rune{'+', '-'}, + ignoreCase: false, + inverted: false, + }, + }, + }, + { + name: "MulDivModOperator", + pos: position{line: 455, col: 1, offset: 9645}, + expr: &actionExpr{ + pos: position{line: 456, col: 4, offset: 9666}, + run: (*parser).callonMulDivModOperator1, + expr: &charClassMatcher{ + pos: position{line: 456, col: 4, offset: 9666}, + val: "[*/%]", + chars: []rune{'*', '/', '%'}, + ignoreCase: false, + inverted: false, + }, + }, + }, + { + name: "DataType", + pos: position{line: 470, col: 1, offset: 9908}, + expr: &choiceExpr{ + pos: position{line: 471, col: 4, offset: 9920}, + alternatives: []interface{}{ + &ruleRefExpr{ + pos: position{line: 471, col: 4, offset: 9920}, + name: "UIntType", + }, + &ruleRefExpr{ + pos: position{line: 472, col: 4, offset: 9932}, + name: "IntType", + }, + &ruleRefExpr{ + pos: position{line: 473, col: 4, offset: 9943}, + name: "UFixedType", + }, + &ruleRefExpr{ + pos: position{line: 474, col: 4, offset: 9957}, + name: "FixedType", + }, + &ruleRefExpr{ + pos: position{line: 475, col: 4, offset: 9970}, + name: "FixedBytesType", + }, + &ruleRefExpr{ + pos: position{line: 476, col: 4, offset: 9988}, + name: "DynamicBytesType", + }, + &ruleRefExpr{ + pos: position{line: 477, col: 4, offset: 10008}, + name: "BoolType", + }, + &ruleRefExpr{ + pos: position{line: 478, col: 4, offset: 10020}, + name: "AddressType", + }, + }, + }, + }, + { + name: "UIntType", + pos: position{line: 480, col: 1, offset: 10033}, + expr: &actionExpr{ + pos: position{line: 481, col: 4, offset: 10045}, + run: (*parser).callonUIntType1, + expr: &seqExpr{ + pos: position{line: 481, col: 4, offset: 10045}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 481, col: 4, offset: 10045}, + val: "uint", + ignoreCase: true, + }, + &labeledExpr{ + pos: position{line: 481, col: 12, offset: 10053}, + label: "s", + expr: &ruleRefExpr{ + pos: position{line: 481, col: 14, offset: 10055}, + name: "NonZeroLeadingInteger", + }, + }, + ¬Expr{ + pos: position{line: 481, col: 36, offset: 10077}, + expr: &ruleRefExpr{ + pos: position{line: 481, col: 37, offset: 10078}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + }, + }, + { + name: "IntType", + pos: position{line: 489, col: 1, offset: 10187}, + expr: &actionExpr{ + pos: position{line: 490, col: 4, offset: 10198}, + run: (*parser).callonIntType1, + expr: &seqExpr{ + pos: position{line: 490, col: 4, offset: 10198}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 490, col: 4, offset: 10198}, + val: "int", + ignoreCase: true, + }, + &labeledExpr{ + pos: position{line: 490, col: 11, offset: 10205}, + label: "s", + expr: &ruleRefExpr{ + pos: position{line: 490, col: 13, offset: 10207}, + name: "NonZeroLeadingInteger", + }, + }, + ¬Expr{ + pos: position{line: 490, col: 35, offset: 10229}, + expr: &ruleRefExpr{ + pos: position{line: 490, col: 36, offset: 10230}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + }, + }, + { + name: "UFixedType", + pos: position{line: 498, col: 1, offset: 10340}, + expr: &actionExpr{ + pos: position{line: 499, col: 4, offset: 10354}, + run: (*parser).callonUFixedType1, + expr: &seqExpr{ + pos: position{line: 499, col: 4, offset: 10354}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 499, col: 4, offset: 10354}, + val: "ufixed", + ignoreCase: true, + }, + &labeledExpr{ + pos: position{line: 499, col: 14, offset: 10364}, + label: "s", + expr: &ruleRefExpr{ + pos: position{line: 499, col: 16, offset: 10366}, + name: "NonZeroLeadingInteger", + }, + }, + &litMatcher{ + pos: position{line: 499, col: 38, offset: 10388}, + val: "x", + ignoreCase: true, + }, + &labeledExpr{ + pos: position{line: 499, col: 43, offset: 10393}, + label: "t", + expr: &ruleRefExpr{ + pos: position{line: 499, col: 45, offset: 10395}, + name: "NonZeroLeadingInteger", + }, + }, + ¬Expr{ + pos: position{line: 499, col: 67, offset: 10417}, + expr: &ruleRefExpr{ + pos: position{line: 499, col: 68, offset: 10418}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + }, + }, + { + name: "FixedType", + pos: position{line: 508, col: 1, offset: 10585}, + expr: &actionExpr{ + pos: position{line: 509, col: 4, offset: 10598}, + run: (*parser).callonFixedType1, + expr: &seqExpr{ + pos: position{line: 509, col: 4, offset: 10598}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 509, col: 4, offset: 10598}, + val: "fixed", + ignoreCase: true, + }, + &labeledExpr{ + pos: position{line: 509, col: 13, offset: 10607}, + label: "s", + expr: &ruleRefExpr{ + pos: position{line: 509, col: 15, offset: 10609}, + name: "NonZeroLeadingInteger", + }, + }, + &litMatcher{ + pos: position{line: 509, col: 37, offset: 10631}, + val: "x", + ignoreCase: true, + }, + &labeledExpr{ + pos: position{line: 509, col: 42, offset: 10636}, + label: "t", + expr: &ruleRefExpr{ + pos: position{line: 509, col: 44, offset: 10638}, + name: "NonZeroLeadingInteger", + }, + }, + ¬Expr{ + pos: position{line: 509, col: 66, offset: 10660}, + expr: &ruleRefExpr{ + pos: position{line: 509, col: 67, offset: 10661}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + }, + }, + { + name: "FixedBytesType", + pos: position{line: 518, col: 1, offset: 10829}, + expr: &choiceExpr{ + pos: position{line: 519, col: 4, offset: 10847}, + alternatives: []interface{}{ + &actionExpr{ + pos: position{line: 519, col: 4, offset: 10847}, + run: (*parser).callonFixedBytesType2, + expr: &seqExpr{ + pos: position{line: 519, col: 4, offset: 10847}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 519, col: 4, offset: 10847}, + val: "bytes", + ignoreCase: true, + }, + &labeledExpr{ + pos: position{line: 519, col: 13, offset: 10856}, + label: "s", + expr: &ruleRefExpr{ + pos: position{line: 519, col: 15, offset: 10858}, + name: "NonZeroLeadingInteger", + }, + }, + ¬Expr{ + pos: position{line: 519, col: 37, offset: 10880}, + expr: &ruleRefExpr{ + pos: position{line: 519, col: 38, offset: 10881}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + }, + &actionExpr{ + pos: position{line: 521, col: 4, offset: 10970}, + run: (*parser).callonFixedBytesType9, + expr: &seqExpr{ + pos: position{line: 521, col: 4, offset: 10970}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 521, col: 4, offset: 10970}, + val: "byte", + ignoreCase: true, + }, + ¬Expr{ + pos: position{line: 521, col: 12, offset: 10978}, + expr: &ruleRefExpr{ + pos: position{line: 521, col: 13, offset: 10979}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + }, + }, + }, + }, + { + name: "DynamicBytesType", + pos: position{line: 524, col: 1, offset: 11049}, + expr: &actionExpr{ + pos: position{line: 525, col: 4, offset: 11069}, + run: (*parser).callonDynamicBytesType1, + expr: &choiceExpr{ + pos: position{line: 525, col: 6, offset: 11071}, + alternatives: []interface{}{ + &seqExpr{ + pos: position{line: 525, col: 6, offset: 11071}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 525, col: 6, offset: 11071}, + val: "bytes", + ignoreCase: true, + }, + ¬Expr{ + pos: position{line: 525, col: 15, offset: 11080}, + expr: &ruleRefExpr{ + pos: position{line: 525, col: 16, offset: 11081}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + &seqExpr{ + pos: position{line: 526, col: 5, offset: 11106}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 526, col: 5, offset: 11106}, + val: "string", + ignoreCase: true, + }, + ¬Expr{ + pos: position{line: 526, col: 15, offset: 11116}, + expr: &ruleRefExpr{ + pos: position{line: 526, col: 16, offset: 11117}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + &seqExpr{ + pos: position{line: 527, col: 5, offset: 11142}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 527, col: 5, offset: 11142}, + val: "text", + ignoreCase: true, + }, + ¬Expr{ + pos: position{line: 527, col: 13, offset: 11150}, + expr: &ruleRefExpr{ + pos: position{line: 527, col: 14, offset: 11151}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + }, + }, + }, + }, + { + name: "AddressType", + pos: position{line: 531, col: 1, offset: 11219}, + expr: &actionExpr{ + pos: position{line: 532, col: 4, offset: 11234}, + run: (*parser).callonAddressType1, + expr: &seqExpr{ + pos: position{line: 532, col: 4, offset: 11234}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 532, col: 4, offset: 11234}, + val: "address", + ignoreCase: true, + }, + ¬Expr{ + pos: position{line: 532, col: 15, offset: 11245}, + expr: &ruleRefExpr{ + pos: position{line: 532, col: 16, offset: 11246}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + }, + }, + { + name: "BoolType", + pos: position{line: 535, col: 1, offset: 11306}, + expr: &actionExpr{ + pos: position{line: 536, col: 4, offset: 11318}, + run: (*parser).callonBoolType1, + expr: &choiceExpr{ + pos: position{line: 536, col: 6, offset: 11320}, + alternatives: []interface{}{ + &seqExpr{ + pos: position{line: 536, col: 6, offset: 11320}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 536, col: 6, offset: 11320}, + val: "bool", + ignoreCase: true, + }, + ¬Expr{ + pos: position{line: 536, col: 14, offset: 11328}, + expr: &ruleRefExpr{ + pos: position{line: 536, col: 15, offset: 11329}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + &seqExpr{ + pos: position{line: 537, col: 5, offset: 11354}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 537, col: 5, offset: 11354}, + val: "boolean", + ignoreCase: true, + }, + ¬Expr{ + pos: position{line: 537, col: 16, offset: 11365}, + expr: &ruleRefExpr{ + pos: position{line: 537, col: 17, offset: 11366}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + }, + }, + }, + }, + { + name: "Value", + pos: position{line: 542, col: 1, offset: 11439}, + expr: &choiceExpr{ + pos: position{line: 543, col: 4, offset: 11448}, + alternatives: []interface{}{ + &ruleRefExpr{ + pos: position{line: 543, col: 4, offset: 11448}, + name: "NumberLiteral", + }, + &ruleRefExpr{ + pos: position{line: 544, col: 4, offset: 11465}, + name: "StringLiteral", + }, + &ruleRefExpr{ + pos: position{line: 545, col: 4, offset: 11482}, + name: "BoolLiteral", + }, + &ruleRefExpr{ + pos: position{line: 546, col: 4, offset: 11497}, + name: "NullLiteral", + }, + }, + }, + }, + { + name: "AnyLiteral", + pos: position{line: 548, col: 1, offset: 11510}, + expr: &actionExpr{ + pos: position{line: 549, col: 4, offset: 11524}, + run: (*parser).callonAnyLiteral1, + expr: &ruleRefExpr{ + pos: position{line: 549, col: 4, offset: 11524}, + name: "AnyToken", + }, + }, + }, + { + name: "DefaultLiteral", + pos: position{line: 552, col: 1, offset: 11569}, + expr: &actionExpr{ + pos: position{line: 553, col: 4, offset: 11587}, + run: (*parser).callonDefaultLiteral1, + expr: &ruleRefExpr{ + pos: position{line: 553, col: 4, offset: 11587}, + name: "DefaultToken", + }, + }, + }, + { + name: "BoolLiteral", + pos: position{line: 556, col: 1, offset: 11640}, + expr: &actionExpr{ + pos: position{line: 557, col: 4, offset: 11655}, + run: (*parser).callonBoolLiteral1, + expr: &labeledExpr{ + pos: position{line: 557, col: 4, offset: 11655}, + label: "b", + expr: &choiceExpr{ + pos: position{line: 557, col: 8, offset: 11659}, + alternatives: []interface{}{ + &ruleRefExpr{ + pos: position{line: 557, col: 8, offset: 11659}, + name: "TrueToken", + }, + &ruleRefExpr{ + pos: position{line: 557, col: 20, offset: 11671}, + name: "FalseToken", + }, + }, + }, + }, + }, + }, + { + name: "NullLiteral", + pos: position{line: 560, col: 1, offset: 11752}, + expr: &actionExpr{ + pos: position{line: 561, col: 4, offset: 11767}, + run: (*parser).callonNullLiteral1, + expr: &ruleRefExpr{ + pos: position{line: 561, col: 4, offset: 11767}, + name: "NullToken", + }, + }, + }, + { + name: "NumberLiteral", + pos: position{line: 564, col: 1, offset: 11814}, + expr: &choiceExpr{ + pos: position{line: 565, col: 4, offset: 11831}, + alternatives: []interface{}{ + &actionExpr{ + pos: position{line: 565, col: 4, offset: 11831}, + run: (*parser).callonNumberLiteral2, + expr: &seqExpr{ + pos: position{line: 565, col: 4, offset: 11831}, + exprs: []interface{}{ + &andExpr{ + pos: position{line: 565, col: 4, offset: 11831}, + expr: &seqExpr{ + pos: position{line: 565, col: 6, offset: 11833}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 565, col: 6, offset: 11833}, + val: "0", + ignoreCase: false, + }, + &litMatcher{ + pos: position{line: 565, col: 10, offset: 11837}, + val: "x", + ignoreCase: true, + }, + }, + }, + }, + &labeledExpr{ + pos: position{line: 565, col: 16, offset: 11843}, + label: "h", + expr: &ruleRefExpr{ + pos: position{line: 565, col: 18, offset: 11845}, + name: "Hex", + }, + }, + }, + }, + }, + &ruleRefExpr{ + pos: position{line: 566, col: 4, offset: 11870}, + name: "Decimal", + }, + }, + }, + }, + { + name: "Sign", + pos: position{line: 568, col: 1, offset: 11879}, + expr: &charClassMatcher{ + pos: position{line: 569, col: 4, offset: 11887}, + val: "[-+]", + chars: []rune{'-', '+'}, + ignoreCase: false, + inverted: false, + }, + }, + { + name: "Integer", + pos: position{line: 571, col: 1, offset: 11893}, + expr: &actionExpr{ + pos: position{line: 572, col: 4, offset: 11904}, + run: (*parser).callonInteger1, + expr: &oneOrMoreExpr{ + pos: position{line: 572, col: 4, offset: 11904}, + expr: &charClassMatcher{ + pos: position{line: 572, col: 4, offset: 11904}, + val: "[0-9]", + ranges: []rune{'0', '9'}, + ignoreCase: false, + inverted: false, + }, + }, + }, + }, + { + name: "NonZeroLeadingInteger", + pos: position{line: 575, col: 1, offset: 11971}, + expr: &actionExpr{ + pos: position{line: 576, col: 4, offset: 11996}, + run: (*parser).callonNonZeroLeadingInteger1, + expr: &choiceExpr{ + pos: position{line: 576, col: 6, offset: 11998}, + alternatives: []interface{}{ + &litMatcher{ + pos: position{line: 576, col: 6, offset: 11998}, + val: "0", + ignoreCase: false, + }, + &seqExpr{ + pos: position{line: 576, col: 12, offset: 12004}, + exprs: []interface{}{ + &charClassMatcher{ + pos: position{line: 576, col: 12, offset: 12004}, + val: "[1-9]", + ranges: []rune{'1', '9'}, + ignoreCase: false, + inverted: false, + }, + &zeroOrMoreExpr{ + pos: position{line: 576, col: 17, offset: 12009}, + expr: &charClassMatcher{ + pos: position{line: 576, col: 17, offset: 12009}, + val: "[0-9]", + ranges: []rune{'0', '9'}, + ignoreCase: false, + inverted: false, + }, + }, + }, + }, + }, + }, + }, + }, + { + name: "Fixnum", + pos: position{line: 579, col: 1, offset: 12042}, + expr: &choiceExpr{ + pos: position{line: 580, col: 4, offset: 12052}, + alternatives: []interface{}{ + &seqExpr{ + pos: position{line: 580, col: 4, offset: 12052}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 580, col: 4, offset: 12052}, + name: "Integer", + }, + &litMatcher{ + pos: position{line: 580, col: 12, offset: 12060}, + val: ".", + ignoreCase: false, + }, + &ruleRefExpr{ + pos: position{line: 580, col: 16, offset: 12064}, + name: "Integer", + }, + }, + }, + &seqExpr{ + pos: position{line: 581, col: 4, offset: 12075}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 581, col: 4, offset: 12075}, + name: "Integer", + }, + &zeroOrOneExpr{ + pos: position{line: 581, col: 12, offset: 12083}, + expr: &litMatcher{ + pos: position{line: 581, col: 12, offset: 12083}, + val: ".", + ignoreCase: false, + }, + }, + }, + }, + &seqExpr{ + pos: position{line: 582, col: 4, offset: 12091}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 582, col: 4, offset: 12091}, + val: ".", + ignoreCase: false, + }, + &ruleRefExpr{ + pos: position{line: 582, col: 8, offset: 12095}, + name: "Integer", + }, + }, + }, + }, + }, + }, + { + name: "Decimal", + pos: position{line: 584, col: 1, offset: 12104}, + expr: &actionExpr{ + pos: position{line: 585, col: 4, offset: 12115}, + run: (*parser).callonDecimal1, + expr: &seqExpr{ + pos: position{line: 585, col: 4, offset: 12115}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 585, col: 4, offset: 12115}, + name: "Fixnum", + }, + &zeroOrOneExpr{ + pos: position{line: 585, col: 11, offset: 12122}, + expr: &seqExpr{ + pos: position{line: 585, col: 13, offset: 12124}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 585, col: 13, offset: 12124}, + val: "e", + ignoreCase: true, + }, + &zeroOrOneExpr{ + pos: position{line: 585, col: 18, offset: 12129}, + expr: &ruleRefExpr{ + pos: position{line: 585, col: 18, offset: 12129}, + name: "Sign", + }, + }, + &ruleRefExpr{ + pos: position{line: 585, col: 24, offset: 12135}, + name: "Integer", + }, + }, + }, + }, + }, + }, + }, + }, + { + name: "Hex", + pos: position{line: 588, col: 1, offset: 12206}, + expr: &actionExpr{ + pos: position{line: 589, col: 4, offset: 12213}, + run: (*parser).callonHex1, + expr: &seqExpr{ + pos: position{line: 589, col: 4, offset: 12213}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 589, col: 4, offset: 12213}, + val: "0", + ignoreCase: false, + }, + &litMatcher{ + pos: position{line: 589, col: 8, offset: 12217}, + val: "x", + ignoreCase: true, + }, + &labeledExpr{ + pos: position{line: 589, col: 13, offset: 12222}, + label: "s", + expr: &oneOrMoreExpr{ + pos: position{line: 589, col: 15, offset: 12224}, + expr: &charClassMatcher{ + pos: position{line: 589, col: 17, offset: 12226}, + val: "[0-9A-Fa-f]", + ranges: []rune{'0', '9', 'A', 'F', 'a', 'f'}, + ignoreCase: false, + inverted: false, + }, + }, + }, + ¬Expr{ + pos: position{line: 589, col: 32, offset: 12241}, + expr: &ruleRefExpr{ + pos: position{line: 589, col: 33, offset: 12242}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + }, + }, + { + name: "StringLiteral", + pos: position{line: 592, col: 1, offset: 12307}, + expr: &choiceExpr{ + pos: position{line: 593, col: 4, offset: 12324}, + alternatives: []interface{}{ + &ruleRefExpr{ + pos: position{line: 593, col: 4, offset: 12324}, + name: "HexString", + }, + &ruleRefExpr{ + pos: position{line: 594, col: 4, offset: 12337}, + name: "NormalString", + }, + }, + }, + }, + { + name: "HexString", + pos: position{line: 596, col: 1, offset: 12351}, + expr: &actionExpr{ + pos: position{line: 597, col: 4, offset: 12364}, + run: (*parser).callonHexString1, + expr: &seqExpr{ + pos: position{line: 597, col: 4, offset: 12364}, + exprs: []interface{}{ + &choiceExpr{ + pos: position{line: 597, col: 6, offset: 12366}, + alternatives: []interface{}{ + &litMatcher{ + pos: position{line: 597, col: 6, offset: 12366}, + val: "hex", + ignoreCase: true, + }, + &litMatcher{ + pos: position{line: 597, col: 15, offset: 12375}, + val: "x", + ignoreCase: true, + }, + }, + }, + &litMatcher{ + pos: position{line: 597, col: 22, offset: 12382}, + val: "'", + ignoreCase: false, + }, + &labeledExpr{ + pos: position{line: 597, col: 26, offset: 12386}, + label: "s", + expr: &zeroOrMoreExpr{ + pos: position{line: 597, col: 28, offset: 12388}, + expr: &actionExpr{ + pos: position{line: 597, col: 29, offset: 12389}, + run: (*parser).callonHexString9, + expr: &seqExpr{ + pos: position{line: 597, col: 29, offset: 12389}, + exprs: []interface{}{ + &charClassMatcher{ + pos: position{line: 597, col: 29, offset: 12389}, + val: "[0-9a-fA-F]", + ranges: []rune{'0', '9', 'a', 'f', 'A', 'F'}, + ignoreCase: false, + inverted: false, + }, + &charClassMatcher{ + pos: position{line: 597, col: 40, offset: 12400}, + val: "[0-9a-fA-F]", + ranges: []rune{'0', '9', 'a', 'f', 'A', 'F'}, + ignoreCase: false, + inverted: false, + }, + }, + }, + }, + }, + }, + &litMatcher{ + pos: position{line: 597, col: 78, offset: 12438}, + val: "'", + ignoreCase: false, + }, + }, + }, + }, + }, + { + name: "NormalString", + pos: position{line: 600, col: 1, offset: 12507}, + expr: &actionExpr{ + pos: position{line: 601, col: 4, offset: 12523}, + run: (*parser).callonNormalString1, + expr: &seqExpr{ + pos: position{line: 601, col: 4, offset: 12523}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 601, col: 4, offset: 12523}, + val: "'", + ignoreCase: false, + }, + &labeledExpr{ + pos: position{line: 601, col: 8, offset: 12527}, + label: "s", + expr: &zeroOrMoreExpr{ + pos: position{line: 601, col: 10, offset: 12529}, + expr: &actionExpr{ + pos: position{line: 601, col: 12, offset: 12531}, + run: (*parser).callonNormalString6, + expr: &choiceExpr{ + pos: position{line: 601, col: 14, offset: 12533}, + alternatives: []interface{}{ + &charClassMatcher{ + pos: position{line: 601, col: 14, offset: 12533}, + val: "[^'\\r\\n\\\\]", + chars: []rune{'\'', '\r', '\n', '\\'}, + ignoreCase: false, + inverted: true, + }, + &seqExpr{ + pos: position{line: 601, col: 27, offset: 12546}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 601, col: 27, offset: 12546}, + val: "\\", + ignoreCase: false, + }, + &anyMatcher{ + line: 601, col: 32, offset: 12551, + }, + }, + }, + }, + }, + }, + }, + }, + &litMatcher{ + pos: position{line: 601, col: 62, offset: 12581}, + val: "'", + ignoreCase: false, + }, + }, + }, + }, + }, + { + name: "SelectToken", + pos: position{line: 605, col: 1, offset: 12666}, + expr: &seqExpr{ + pos: position{line: 606, col: 4, offset: 12681}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 606, col: 4, offset: 12681}, + val: "select", + ignoreCase: true, + }, + ¬Expr{ + pos: position{line: 606, col: 14, offset: 12691}, + expr: &ruleRefExpr{ + pos: position{line: 606, col: 15, offset: 12692}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + }, + { + name: "FromToken", + pos: position{line: 608, col: 1, offset: 12714}, + expr: &seqExpr{ + pos: position{line: 609, col: 4, offset: 12727}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 609, col: 4, offset: 12727}, + val: "from", + ignoreCase: true, + }, + ¬Expr{ + pos: position{line: 609, col: 12, offset: 12735}, + expr: &ruleRefExpr{ + pos: position{line: 609, col: 13, offset: 12736}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + }, + { + name: "WhereToken", + pos: position{line: 611, col: 1, offset: 12758}, + expr: &seqExpr{ + pos: position{line: 612, col: 4, offset: 12772}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 612, col: 4, offset: 12772}, + val: "where", + ignoreCase: true, + }, + ¬Expr{ + pos: position{line: 612, col: 13, offset: 12781}, + expr: &ruleRefExpr{ + pos: position{line: 612, col: 14, offset: 12782}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + }, + { + name: "OrderToken", + pos: position{line: 614, col: 1, offset: 12804}, + expr: &seqExpr{ + pos: position{line: 615, col: 4, offset: 12818}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 615, col: 4, offset: 12818}, + val: "order", + ignoreCase: true, + }, + ¬Expr{ + pos: position{line: 615, col: 13, offset: 12827}, + expr: &ruleRefExpr{ + pos: position{line: 615, col: 14, offset: 12828}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + }, + { + name: "ByToken", + pos: position{line: 617, col: 1, offset: 12850}, + expr: &seqExpr{ + pos: position{line: 618, col: 4, offset: 12861}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 618, col: 4, offset: 12861}, + val: "by", + ignoreCase: true, + }, + ¬Expr{ + pos: position{line: 618, col: 10, offset: 12867}, + expr: &ruleRefExpr{ + pos: position{line: 618, col: 11, offset: 12868}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + }, + { + name: "GroupToken", + pos: position{line: 620, col: 1, offset: 12890}, + expr: &seqExpr{ + pos: position{line: 621, col: 4, offset: 12904}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 621, col: 4, offset: 12904}, + val: "group", + ignoreCase: true, + }, + ¬Expr{ + pos: position{line: 621, col: 13, offset: 12913}, + expr: &ruleRefExpr{ + pos: position{line: 621, col: 14, offset: 12914}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + }, + { + name: "LimitToken", + pos: position{line: 623, col: 1, offset: 12936}, + expr: &seqExpr{ + pos: position{line: 624, col: 4, offset: 12950}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 624, col: 4, offset: 12950}, + val: "limit", + ignoreCase: true, + }, + ¬Expr{ + pos: position{line: 624, col: 13, offset: 12959}, + expr: &ruleRefExpr{ + pos: position{line: 624, col: 14, offset: 12960}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + }, + { + name: "OffsetToken", + pos: position{line: 626, col: 1, offset: 12982}, + expr: &seqExpr{ + pos: position{line: 627, col: 4, offset: 12997}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 627, col: 4, offset: 12997}, + val: "offset", + ignoreCase: true, + }, + ¬Expr{ + pos: position{line: 627, col: 14, offset: 13007}, + expr: &ruleRefExpr{ + pos: position{line: 627, col: 15, offset: 13008}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + }, + { + name: "UpdateToken", + pos: position{line: 629, col: 1, offset: 13030}, + expr: &seqExpr{ + pos: position{line: 630, col: 4, offset: 13045}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 630, col: 4, offset: 13045}, + val: "update", + ignoreCase: true, + }, + ¬Expr{ + pos: position{line: 630, col: 14, offset: 13055}, + expr: &ruleRefExpr{ + pos: position{line: 630, col: 15, offset: 13056}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + }, + { + name: "SetToken", + pos: position{line: 632, col: 1, offset: 13078}, + expr: &seqExpr{ + pos: position{line: 633, col: 4, offset: 13090}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 633, col: 4, offset: 13090}, + val: "set", + ignoreCase: true, + }, + ¬Expr{ + pos: position{line: 633, col: 11, offset: 13097}, + expr: &ruleRefExpr{ + pos: position{line: 633, col: 12, offset: 13098}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + }, + { + name: "DeleteToken", + pos: position{line: 635, col: 1, offset: 13120}, + expr: &seqExpr{ + pos: position{line: 636, col: 4, offset: 13135}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 636, col: 4, offset: 13135}, + val: "delete", + ignoreCase: true, + }, + ¬Expr{ + pos: position{line: 636, col: 14, offset: 13145}, + expr: &ruleRefExpr{ + pos: position{line: 636, col: 15, offset: 13146}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + }, + { + name: "InsertToken", + pos: position{line: 638, col: 1, offset: 13168}, + expr: &seqExpr{ + pos: position{line: 639, col: 4, offset: 13183}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 639, col: 4, offset: 13183}, + val: "insert", + ignoreCase: true, + }, + ¬Expr{ + pos: position{line: 639, col: 14, offset: 13193}, + expr: &ruleRefExpr{ + pos: position{line: 639, col: 15, offset: 13194}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + }, + { + name: "IntoToken", + pos: position{line: 641, col: 1, offset: 13216}, + expr: &seqExpr{ + pos: position{line: 642, col: 4, offset: 13229}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 642, col: 4, offset: 13229}, + val: "into", + ignoreCase: true, + }, + ¬Expr{ + pos: position{line: 642, col: 12, offset: 13237}, + expr: &ruleRefExpr{ + pos: position{line: 642, col: 13, offset: 13238}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + }, + { + name: "ValuesToken", + pos: position{line: 644, col: 1, offset: 13260}, + expr: &seqExpr{ + pos: position{line: 645, col: 4, offset: 13275}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 645, col: 4, offset: 13275}, + val: "values", + ignoreCase: true, + }, + ¬Expr{ + pos: position{line: 645, col: 14, offset: 13285}, + expr: &ruleRefExpr{ + pos: position{line: 645, col: 15, offset: 13286}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + }, + { + name: "CreateToken", + pos: position{line: 647, col: 1, offset: 13308}, + expr: &seqExpr{ + pos: position{line: 648, col: 4, offset: 13323}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 648, col: 4, offset: 13323}, + val: "create", + ignoreCase: true, + }, + ¬Expr{ + pos: position{line: 648, col: 14, offset: 13333}, + expr: &ruleRefExpr{ + pos: position{line: 648, col: 15, offset: 13334}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + }, + { + name: "TableToken", + pos: position{line: 650, col: 1, offset: 13356}, + expr: &seqExpr{ + pos: position{line: 651, col: 4, offset: 13370}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 651, col: 4, offset: 13370}, + val: "table", + ignoreCase: true, + }, + ¬Expr{ + pos: position{line: 651, col: 13, offset: 13379}, + expr: &ruleRefExpr{ + pos: position{line: 651, col: 14, offset: 13380}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + }, + { + name: "IndexToken", + pos: position{line: 653, col: 1, offset: 13402}, + expr: &seqExpr{ + pos: position{line: 654, col: 4, offset: 13416}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 654, col: 4, offset: 13416}, + val: "index", + ignoreCase: true, + }, + ¬Expr{ + pos: position{line: 654, col: 13, offset: 13425}, + expr: &ruleRefExpr{ + pos: position{line: 654, col: 14, offset: 13426}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + }, + { + name: "UniqueToken", + pos: position{line: 656, col: 1, offset: 13448}, + expr: &seqExpr{ + pos: position{line: 657, col: 4, offset: 13463}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 657, col: 4, offset: 13463}, + val: "unique", + ignoreCase: true, + }, + ¬Expr{ + pos: position{line: 657, col: 14, offset: 13473}, + expr: &ruleRefExpr{ + pos: position{line: 657, col: 15, offset: 13474}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + }, + { + name: "DefaultToken", + pos: position{line: 659, col: 1, offset: 13496}, + expr: &seqExpr{ + pos: position{line: 660, col: 4, offset: 13512}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 660, col: 4, offset: 13512}, + val: "default", + ignoreCase: true, + }, + ¬Expr{ + pos: position{line: 660, col: 15, offset: 13523}, + expr: &ruleRefExpr{ + pos: position{line: 660, col: 16, offset: 13524}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + }, + { + name: "PrimaryToken", + pos: position{line: 662, col: 1, offset: 13546}, + expr: &seqExpr{ + pos: position{line: 663, col: 4, offset: 13562}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 663, col: 4, offset: 13562}, + val: "primary", + ignoreCase: true, + }, + ¬Expr{ + pos: position{line: 663, col: 15, offset: 13573}, + expr: &ruleRefExpr{ + pos: position{line: 663, col: 16, offset: 13574}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + }, + { + name: "KeyToken", + pos: position{line: 665, col: 1, offset: 13596}, + expr: &seqExpr{ + pos: position{line: 666, col: 4, offset: 13608}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 666, col: 4, offset: 13608}, + val: "key", + ignoreCase: true, + }, + ¬Expr{ + pos: position{line: 666, col: 11, offset: 13615}, + expr: &ruleRefExpr{ + pos: position{line: 666, col: 12, offset: 13616}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + }, + { + name: "ReferencesToken", + pos: position{line: 668, col: 1, offset: 13638}, + expr: &seqExpr{ + pos: position{line: 669, col: 4, offset: 13657}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 669, col: 4, offset: 13657}, + val: "references", + ignoreCase: true, + }, + ¬Expr{ + pos: position{line: 669, col: 18, offset: 13671}, + expr: &ruleRefExpr{ + pos: position{line: 669, col: 19, offset: 13672}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + }, + { + name: "AutoincrementToken", + pos: position{line: 671, col: 1, offset: 13694}, + expr: &seqExpr{ + pos: position{line: 672, col: 4, offset: 13716}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 672, col: 4, offset: 13716}, + val: "autoincrement", + ignoreCase: true, + }, + ¬Expr{ + pos: position{line: 672, col: 21, offset: 13733}, + expr: &ruleRefExpr{ + pos: position{line: 672, col: 22, offset: 13734}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + }, + { + name: "OnToken", + pos: position{line: 674, col: 1, offset: 13756}, + expr: &seqExpr{ + pos: position{line: 675, col: 4, offset: 13767}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 675, col: 4, offset: 13767}, + val: "on", + ignoreCase: true, + }, + ¬Expr{ + pos: position{line: 675, col: 10, offset: 13773}, + expr: &ruleRefExpr{ + pos: position{line: 675, col: 11, offset: 13774}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + }, + { + name: "TrueToken", + pos: position{line: 677, col: 1, offset: 13796}, + expr: &actionExpr{ + pos: position{line: 678, col: 4, offset: 13809}, + run: (*parser).callonTrueToken1, + expr: &seqExpr{ + pos: position{line: 678, col: 4, offset: 13809}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 678, col: 4, offset: 13809}, + val: "true", + ignoreCase: true, + }, + ¬Expr{ + pos: position{line: 678, col: 12, offset: 13817}, + expr: &ruleRefExpr{ + pos: position{line: 678, col: 13, offset: 13818}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + }, + }, + { + name: "FalseToken", + pos: position{line: 681, col: 1, offset: 13872}, + expr: &actionExpr{ + pos: position{line: 682, col: 4, offset: 13886}, + run: (*parser).callonFalseToken1, + expr: &seqExpr{ + pos: position{line: 682, col: 4, offset: 13886}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 682, col: 4, offset: 13886}, + val: "false", + ignoreCase: true, + }, + ¬Expr{ + pos: position{line: 682, col: 13, offset: 13895}, + expr: &ruleRefExpr{ + pos: position{line: 682, col: 14, offset: 13896}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + }, + }, + { + name: "NullToken", + pos: position{line: 685, col: 1, offset: 13950}, + expr: &seqExpr{ + pos: position{line: 686, col: 4, offset: 13963}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 686, col: 4, offset: 13963}, + val: "null", + ignoreCase: true, + }, + ¬Expr{ + pos: position{line: 686, col: 12, offset: 13971}, + expr: &ruleRefExpr{ + pos: position{line: 686, col: 13, offset: 13972}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + }, + { + name: "IsToken", + pos: position{line: 688, col: 1, offset: 13994}, + expr: &seqExpr{ + pos: position{line: 689, col: 4, offset: 14005}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 689, col: 4, offset: 14005}, + val: "is", + ignoreCase: true, + }, + ¬Expr{ + pos: position{line: 689, col: 10, offset: 14011}, + expr: &ruleRefExpr{ + pos: position{line: 689, col: 11, offset: 14012}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + }, + { + name: "NullsToken", + pos: position{line: 691, col: 1, offset: 14034}, + expr: &seqExpr{ + pos: position{line: 692, col: 4, offset: 14048}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 692, col: 4, offset: 14048}, + val: "nulls", + ignoreCase: true, + }, + ¬Expr{ + pos: position{line: 692, col: 13, offset: 14057}, + expr: &ruleRefExpr{ + pos: position{line: 692, col: 14, offset: 14058}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + }, + { + name: "LastToken", + pos: position{line: 694, col: 1, offset: 14080}, + expr: &actionExpr{ + pos: position{line: 695, col: 4, offset: 14093}, + run: (*parser).callonLastToken1, + expr: &seqExpr{ + pos: position{line: 695, col: 4, offset: 14093}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 695, col: 4, offset: 14093}, + val: "last", + ignoreCase: true, + }, + ¬Expr{ + pos: position{line: 695, col: 12, offset: 14101}, + expr: &ruleRefExpr{ + pos: position{line: 695, col: 13, offset: 14102}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + }, + }, + { + name: "FirstToken", + pos: position{line: 698, col: 1, offset: 14156}, + expr: &actionExpr{ + pos: position{line: 699, col: 4, offset: 14170}, + run: (*parser).callonFirstToken1, + expr: &seqExpr{ + pos: position{line: 699, col: 4, offset: 14170}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 699, col: 4, offset: 14170}, + val: "first", + ignoreCase: true, + }, + ¬Expr{ + pos: position{line: 699, col: 13, offset: 14179}, + expr: &ruleRefExpr{ + pos: position{line: 699, col: 14, offset: 14180}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + }, + }, + { + name: "AndToken", + pos: position{line: 702, col: 1, offset: 14234}, + expr: &seqExpr{ + pos: position{line: 703, col: 4, offset: 14246}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 703, col: 4, offset: 14246}, + val: "and", + ignoreCase: true, + }, + ¬Expr{ + pos: position{line: 703, col: 11, offset: 14253}, + expr: &ruleRefExpr{ + pos: position{line: 703, col: 12, offset: 14254}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + }, + { + name: "OrToken", + pos: position{line: 705, col: 1, offset: 14276}, + expr: &seqExpr{ + pos: position{line: 706, col: 4, offset: 14287}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 706, col: 4, offset: 14287}, + val: "or", + ignoreCase: true, + }, + ¬Expr{ + pos: position{line: 706, col: 10, offset: 14293}, + expr: &ruleRefExpr{ + pos: position{line: 706, col: 11, offset: 14294}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + }, + { + name: "NotToken", + pos: position{line: 708, col: 1, offset: 14316}, + expr: &seqExpr{ + pos: position{line: 709, col: 4, offset: 14328}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 709, col: 4, offset: 14328}, + val: "not", + ignoreCase: true, + }, + ¬Expr{ + pos: position{line: 709, col: 11, offset: 14335}, + expr: &ruleRefExpr{ + pos: position{line: 709, col: 12, offset: 14336}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + }, + { + name: "InToken", + pos: position{line: 711, col: 1, offset: 14358}, + expr: &seqExpr{ + pos: position{line: 712, col: 4, offset: 14369}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 712, col: 4, offset: 14369}, + val: "in", + ignoreCase: true, + }, + ¬Expr{ + pos: position{line: 712, col: 10, offset: 14375}, + expr: &ruleRefExpr{ + pos: position{line: 712, col: 11, offset: 14376}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + }, + { + name: "LikeToken", + pos: position{line: 714, col: 1, offset: 14398}, + expr: &seqExpr{ + pos: position{line: 715, col: 4, offset: 14411}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 715, col: 4, offset: 14411}, + val: "like", + ignoreCase: true, + }, + ¬Expr{ + pos: position{line: 715, col: 12, offset: 14419}, + expr: &ruleRefExpr{ + pos: position{line: 715, col: 13, offset: 14420}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + }, + { + name: "AscToken", + pos: position{line: 717, col: 1, offset: 14442}, + expr: &actionExpr{ + pos: position{line: 718, col: 4, offset: 14454}, + run: (*parser).callonAscToken1, + expr: &seqExpr{ + pos: position{line: 718, col: 4, offset: 14454}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 718, col: 4, offset: 14454}, + val: "asc", + ignoreCase: true, + }, + ¬Expr{ + pos: position{line: 718, col: 11, offset: 14461}, + expr: &ruleRefExpr{ + pos: position{line: 718, col: 12, offset: 14462}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + }, + }, + { + name: "DescToken", + pos: position{line: 721, col: 1, offset: 14516}, + expr: &actionExpr{ + pos: position{line: 722, col: 4, offset: 14529}, + run: (*parser).callonDescToken1, + expr: &seqExpr{ + pos: position{line: 722, col: 4, offset: 14529}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 722, col: 4, offset: 14529}, + val: "desc", + ignoreCase: true, + }, + ¬Expr{ + pos: position{line: 722, col: 12, offset: 14537}, + expr: &ruleRefExpr{ + pos: position{line: 722, col: 13, offset: 14538}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + }, + }, + { + name: "CastToken", + pos: position{line: 725, col: 1, offset: 14592}, + expr: &seqExpr{ + pos: position{line: 726, col: 4, offset: 14605}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 726, col: 4, offset: 14605}, + val: "cast", + ignoreCase: true, + }, + ¬Expr{ + pos: position{line: 726, col: 12, offset: 14613}, + expr: &ruleRefExpr{ + pos: position{line: 726, col: 13, offset: 14614}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + }, + { + name: "AsToken", + pos: position{line: 728, col: 1, offset: 14636}, + expr: &seqExpr{ + pos: position{line: 729, col: 4, offset: 14647}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 729, col: 4, offset: 14647}, + val: "as", + ignoreCase: true, + }, + ¬Expr{ + pos: position{line: 729, col: 10, offset: 14653}, + expr: &ruleRefExpr{ + pos: position{line: 729, col: 11, offset: 14654}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + }, + { + name: "SeparatorToken", + pos: position{line: 731, col: 1, offset: 14676}, + expr: &litMatcher{ + pos: position{line: 732, col: 4, offset: 14694}, + val: ",", + ignoreCase: false, + }, + }, + { + name: "AnyToken", + pos: position{line: 734, col: 1, offset: 14699}, + expr: &litMatcher{ + pos: position{line: 735, col: 4, offset: 14711}, + val: "*", + ignoreCase: false, + }, + }, + { + name: "Identifier", + pos: position{line: 738, col: 1, offset: 14734}, + expr: &choiceExpr{ + pos: position{line: 739, col: 4, offset: 14748}, + alternatives: []interface{}{ + &ruleRefExpr{ + pos: position{line: 739, col: 4, offset: 14748}, + name: "NormalIdentifier", + }, + &ruleRefExpr{ + pos: position{line: 740, col: 4, offset: 14768}, + name: "StringIdentifier", + }, + }, + }, + }, + { + name: "NormalIdentifier", + pos: position{line: 742, col: 1, offset: 14786}, + expr: &actionExpr{ + pos: position{line: 743, col: 4, offset: 14806}, + run: (*parser).callonNormalIdentifier1, + expr: &seqExpr{ + pos: position{line: 743, col: 4, offset: 14806}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 743, col: 4, offset: 14806}, + name: "NormalIdentifierStart", + }, + &zeroOrMoreExpr{ + pos: position{line: 743, col: 26, offset: 14828}, + expr: &ruleRefExpr{ + pos: position{line: 743, col: 26, offset: 14828}, + name: "NormalIdentifierRest", + }, + }, + }, + }, + }, + }, + { + name: "NormalIdentifierStart", + pos: position{line: 746, col: 1, offset: 14900}, + expr: &charClassMatcher{ + pos: position{line: 747, col: 4, offset: 14925}, + val: "[a-zA-Z@#_\\u0080-\\uffff]", + chars: []rune{'@', '#', '_'}, + ranges: []rune{'a', 'z', 'A', 'Z', '\u0080', '\uffff'}, + ignoreCase: false, + inverted: false, + }, + }, + { + name: "NormalIdentifierRest", + pos: position{line: 749, col: 1, offset: 14951}, + expr: &charClassMatcher{ + pos: position{line: 750, col: 4, offset: 14975}, + val: "[a-zA-Z0-9@#$_\\u0080-\\uffff]", + chars: []rune{'@', '#', '$', '_'}, + ranges: []rune{'a', 'z', 'A', 'Z', '0', '9', '\u0080', '\uffff'}, + ignoreCase: false, + inverted: false, + }, + }, + { + name: "StringIdentifier", + pos: position{line: 752, col: 1, offset: 15005}, + expr: &actionExpr{ + pos: position{line: 753, col: 4, offset: 15025}, + run: (*parser).callonStringIdentifier1, + expr: &seqExpr{ + pos: position{line: 753, col: 4, offset: 15025}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 753, col: 4, offset: 15025}, + val: "\"", + ignoreCase: false, + }, + &labeledExpr{ + pos: position{line: 753, col: 9, offset: 15030}, + label: "s", + expr: &zeroOrMoreExpr{ + pos: position{line: 753, col: 11, offset: 15032}, + expr: &actionExpr{ + pos: position{line: 753, col: 13, offset: 15034}, + run: (*parser).callonStringIdentifier6, + expr: &choiceExpr{ + pos: position{line: 753, col: 15, offset: 15036}, + alternatives: []interface{}{ + &charClassMatcher{ + pos: position{line: 753, col: 15, offset: 15036}, + val: "[^\"\\r\\n\\\\]", + chars: []rune{'"', '\r', '\n', '\\'}, + ignoreCase: false, + inverted: true, + }, + &seqExpr{ + pos: position{line: 753, col: 28, offset: 15049}, + exprs: []interface{}{ + &litMatcher{ + pos: position{line: 753, col: 28, offset: 15049}, + val: "\\", + ignoreCase: false, + }, + &anyMatcher{ + line: 753, col: 33, offset: 15054, + }, + }, + }, + }, + }, + }, + }, + }, + &litMatcher{ + pos: position{line: 753, col: 63, offset: 15084}, + val: "\"", + ignoreCase: false, + }, + }, + }, + }, + }, + { + name: "_", + pos: position{line: 759, col: 1, offset: 15172}, + expr: &zeroOrMoreExpr{ + pos: position{line: 760, col: 4, offset: 15177}, + expr: &choiceExpr{ + pos: position{line: 760, col: 6, offset: 15179}, + alternatives: []interface{}{ + &ruleRefExpr{ + pos: position{line: 760, col: 6, offset: 15179}, + name: "Whitespace", + }, + &ruleRefExpr{ + pos: position{line: 760, col: 19, offset: 15192}, + name: "Newline", + }, + }, + }, + }, + }, + { + name: "Newline", + pos: position{line: 762, col: 1, offset: 15204}, + expr: &choiceExpr{ + pos: position{line: 763, col: 4, offset: 15215}, + alternatives: []interface{}{ + &litMatcher{ + pos: position{line: 763, col: 4, offset: 15215}, + val: "\r\n", + ignoreCase: false, + }, + &litMatcher{ + pos: position{line: 764, col: 4, offset: 15225}, + val: "\r", + ignoreCase: false, + }, + &litMatcher{ + pos: position{line: 765, col: 4, offset: 15233}, + val: "\n", + ignoreCase: false, + }, + }, + }, + }, + { + name: "Whitespace", + pos: position{line: 767, col: 1, offset: 15239}, + expr: &choiceExpr{ + pos: position{line: 768, col: 4, offset: 15253}, + alternatives: []interface{}{ + &litMatcher{ + pos: position{line: 768, col: 4, offset: 15253}, + val: " ", + ignoreCase: false, + }, + &litMatcher{ + pos: position{line: 769, col: 4, offset: 15260}, + val: "\t", + ignoreCase: false, + }, + &litMatcher{ + pos: position{line: 770, col: 4, offset: 15268}, + val: "\v", + ignoreCase: false, + }, + &litMatcher{ + pos: position{line: 771, col: 4, offset: 15276}, + val: "\f", + ignoreCase: false, + }, + }, + }, + }, + { + name: "EOF", + pos: position{line: 773, col: 1, offset: 15282}, + expr: ¬Expr{ + pos: position{line: 774, col: 4, offset: 15289}, + expr: &anyMatcher{ + line: 774, col: 5, offset: 15290, + }, + }, + }, + }, +} + +func (c *current) onS10(s interface{}) (interface{}, error) { + return s, nil +} + +func (p *parser) callonS10() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onS10(stack["s"]) +} + +func (c *current) onS1(x, xs interface{}) (interface{}, error) { + return prepend(x, xs), nil +} + +func (p *parser) callonS1() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onS1(stack["x"], stack["xs"]) +} + +func (c *current) onSelectStmt9(s interface{}) (interface{}, error) { + return s, nil +} + +func (p *parser) callonSelectStmt9() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onSelectStmt9(stack["s"]) +} + +func (c *current) onSelectStmt18(i interface{}) (interface{}, error) { + return i, nil +} + +func (p *parser) callonSelectStmt18() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onSelectStmt18(stack["i"]) +} + +func (c *current) onSelectStmt27(w interface{}) (interface{}, error) { + return w, nil +} + +func (p *parser) callonSelectStmt27() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onSelectStmt27(stack["w"]) +} + +func (c *current) onSelectStmt34(g interface{}) (interface{}, error) { + return g, nil +} + +func (p *parser) callonSelectStmt34() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onSelectStmt34(stack["g"]) +} + +func (c *current) onSelectStmt41(or interface{}) (interface{}, error) { + return or, nil +} + +func (p *parser) callonSelectStmt41() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onSelectStmt41(stack["or"]) +} + +func (c *current) onSelectStmt48(l interface{}) (interface{}, error) { + return l, nil +} + +func (p *parser) callonSelectStmt48() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onSelectStmt48(stack["l"]) +} + +func (c *current) onSelectStmt55(of interface{}) (interface{}, error) { + return of, nil +} + +func (p *parser) callonSelectStmt55() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onSelectStmt55(stack["of"]) +} + +func (c *current) onSelectStmt1(f, fs, table, where, group, order, limit, offset interface{}) (interface{}, error) { + var ( + tableNode *ast.IdentifierNode + whereNode *ast.WhereOptionNode + limitNode *ast.LimitOptionNode + offsetNode *ast.OffsetOptionNode + ) + if table != nil { + t := table.(ast.IdentifierNode) + tableNode = &t + } + if where != nil { + w := where.(ast.WhereOptionNode) + whereNode = &w + } + if limit != nil { + l := limit.(ast.LimitOptionNode) + limitNode = &l + } + if offset != nil { + o := offset.(ast.OffsetOptionNode) + offsetNode = &o + } + return ast.SelectStmtNode{ + Column: prepend(f, fs), + Table: tableNode, + Where: whereNode, + Group: toSlice(group), + Order: toSlice(order), + Limit: limitNode, + Offset: offsetNode, + }, nil +} + +func (p *parser) callonSelectStmt1() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onSelectStmt1(stack["f"], stack["fs"], stack["table"], stack["where"], stack["group"], stack["order"], stack["limit"], stack["offset"]) +} + +func (c *current) onUpdateStmt14(s interface{}) (interface{}, error) { + return s, nil +} + +func (p *parser) callonUpdateStmt14() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onUpdateStmt14(stack["s"]) +} + +func (c *current) onUpdateStmt23(w interface{}) (interface{}, error) { + return w, nil +} + +func (p *parser) callonUpdateStmt23() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onUpdateStmt23(stack["w"]) +} + +func (c *current) onUpdateStmt1(table, a, as, where interface{}) (interface{}, error) { + var ( + whereNode *ast.WhereOptionNode + ) + if where != nil { + w := where.(ast.WhereOptionNode) + whereNode = &w + } + return ast.UpdateStmtNode{ + Table: table.(ast.IdentifierNode), + Assignment: prepend(a, as), + Where: whereNode, + }, nil +} + +func (p *parser) callonUpdateStmt1() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onUpdateStmt1(stack["table"], stack["a"], stack["as"], stack["where"]) +} + +func (c *current) onDeleteStmt11(w interface{}) (interface{}, error) { + return w, nil +} + +func (p *parser) callonDeleteStmt11() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onDeleteStmt11(stack["w"]) +} + +func (c *current) onDeleteStmt1(table, where interface{}) (interface{}, error) { + var ( + whereNode *ast.WhereOptionNode + ) + if where != nil { + w := where.(ast.WhereOptionNode) + whereNode = &w + } + return ast.DeleteStmtNode{ + Table: table.(ast.IdentifierNode), + Where: whereNode, + }, nil +} + +func (p *parser) callonDeleteStmt1() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onDeleteStmt1(stack["table"], stack["where"]) +} + +func (c *current) onInsertStmt1(table, insert interface{}) (interface{}, error) { + return ast.InsertStmtNode{ + Table: table.(ast.IdentifierNode), + Insert: insert, + }, nil +} + +func (p *parser) callonInsertStmt1() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onInsertStmt1(stack["table"], stack["insert"]) +} + +func (c *current) onInsertValue1(e interface{}) (interface{}, error) { + return e, nil +} + +func (p *parser) callonInsertValue1() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onInsertValue1(stack["e"]) +} + +func (c *current) onCreateTableStmt20(t interface{}) (interface{}, error) { + return t, nil +} + +func (p *parser) callonCreateTableStmt20() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onCreateTableStmt20(stack["t"]) +} + +func (c *current) onCreateTableStmt14(s, ss interface{}) (interface{}, error) { + return prepend(s, ss), nil +} + +func (p *parser) callonCreateTableStmt14() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onCreateTableStmt14(stack["s"], stack["ss"]) +} + +func (c *current) onCreateTableStmt1(table, column interface{}) (interface{}, error) { + return ast.CreateTableStmtNode{ + Table: table.(ast.IdentifierNode), + Column: toSlice(column), + }, nil +} + +func (p *parser) callonCreateTableStmt1() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onCreateTableStmt1(stack["table"], stack["column"]) +} + +func (c *current) onColumnSchema10(s interface{}) (interface{}, error) { + return s, nil +} + +func (p *parser) callonColumnSchema10() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onColumnSchema10(stack["s"]) +} + +func (c *current) onColumnSchema1(i, t, cs interface{}) (interface{}, error) { + return ast.ColumnSchemaNode{ + Column: i.(ast.IdentifierNode), + DataType: t, + Constraint: toSlice(cs), + }, nil +} + +func (p *parser) callonColumnSchema1() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onColumnSchema1(stack["i"], stack["t"], stack["cs"]) +} + +func (c *current) onCreateIndexStmt6(u interface{}) (interface{}, error) { + return u, nil +} + +func (p *parser) callonCreateIndexStmt6() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onCreateIndexStmt6(stack["u"]) +} + +func (c *current) onCreateIndexStmt28(x interface{}) (interface{}, error) { + return x, nil +} + +func (p *parser) callonCreateIndexStmt28() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onCreateIndexStmt28(stack["x"]) +} + +func (c *current) onCreateIndexStmt1(unique, index, table, i, is interface{}) (interface{}, error) { + var ( + uniqueNode *ast.UniqueOptionNode + ) + if unique != nil { + u := unique.(ast.UniqueOptionNode) + uniqueNode = &u + } + return ast.CreateIndexStmtNode{ + Index: index.(ast.IdentifierNode), + Table: table.(ast.IdentifierNode), + Column: prepend(i, is), + Unique: uniqueNode, + }, nil +} + +func (p *parser) callonCreateIndexStmt1() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onCreateIndexStmt1(stack["unique"], stack["index"], stack["table"], stack["i"], stack["is"]) +} + +func (c *current) onWhereClause1(e interface{}) (interface{}, error) { + return ast.WhereOptionNode{Condition: e}, nil +} + +func (p *parser) callonWhereClause1() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onWhereClause1(stack["e"]) +} + +func (c *current) onOrderByClause11(s interface{}) (interface{}, error) { + return s, nil +} + +func (p *parser) callonOrderByClause11() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onOrderByClause11(stack["s"]) +} + +func (c *current) onOrderByClause1(f, fs interface{}) (interface{}, error) { + return prepend(f, fs), nil +} + +func (p *parser) callonOrderByClause1() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onOrderByClause1(stack["f"], stack["fs"]) +} + +func (c *current) onOrderColumn7(t interface{}) (interface{}, error) { + return t, nil +} + +func (p *parser) callonOrderColumn7() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onOrderColumn7(stack["t"]) +} + +func (c *current) onOrderColumn16(l interface{}) (interface{}, error) { + return l, nil +} + +func (p *parser) callonOrderColumn16() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onOrderColumn16(stack["l"]) +} + +func (c *current) onOrderColumn1(i, s, n interface{}) (interface{}, error) { + return ast.OrderOptionNode{ + Expr: i, + Desc: s != nil && string(s.([]byte)) == "desc", + NullsFirst: n != nil && string(n.([]byte)) == "first", + }, nil +} + +func (p *parser) callonOrderColumn1() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onOrderColumn1(stack["i"], stack["s"], stack["n"]) +} + +func (c *current) onGroupByClause11(s interface{}) (interface{}, error) { + return ast.GroupOptionNode{Expr: s}, nil +} + +func (p *parser) callonGroupByClause11() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onGroupByClause11(stack["s"]) +} + +func (c *current) onGroupByClause1(i, is interface{}) (interface{}, error) { + return prepend(ast.GroupOptionNode{Expr: i}, is), nil +} + +func (p *parser) callonGroupByClause1() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onGroupByClause1(stack["i"], stack["is"]) +} + +func (c *current) onOffsetClause1(i interface{}) (interface{}, error) { + return ast.OffsetOptionNode{Value: i.(ast.IntegerValueNode)}, nil +} + +func (p *parser) callonOffsetClause1() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onOffsetClause1(stack["i"]) +} + +func (c *current) onLimitClause1(i interface{}) (interface{}, error) { + return ast.LimitOptionNode{Value: i.(ast.IntegerValueNode)}, nil +} + +func (p *parser) callonLimitClause1() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onLimitClause1(stack["i"]) +} + +func (c *current) onInsertWithColumnClause13(x interface{}) (interface{}, error) { + return x, nil +} + +func (p *parser) callonInsertWithColumnClause13() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onInsertWithColumnClause13(stack["x"]) +} + +func (c *current) onInsertWithColumnClause5(f, fs interface{}) (interface{}, error) { + return prepend(f, fs), nil +} + +func (p *parser) callonInsertWithColumnClause5() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onInsertWithColumnClause5(stack["f"], stack["fs"]) +} + +func (c *current) onInsertWithColumnClause29(y interface{}) (interface{}, error) { + return y, nil +} + +func (p *parser) callonInsertWithColumnClause29() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onInsertWithColumnClause29(stack["y"]) +} + +func (c *current) onInsertWithColumnClause1(cs, v, vs interface{}) (interface{}, error) { + return ast.InsertWithColumnOptionNode{ + Column: toSlice(cs), + Value: prepend(v, vs), + }, nil +} + +func (p *parser) callonInsertWithColumnClause1() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onInsertWithColumnClause1(stack["cs"], stack["v"], stack["vs"]) +} + +func (c *current) onInsertWithDefaultClause1() (interface{}, error) { + return ast.InsertWithDefaultOptionNode{}, nil +} + +func (p *parser) callonInsertWithDefaultClause1() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onInsertWithDefaultClause1() +} + +func (c *current) onPrimaryKeyClause1() (interface{}, error) { + return ast.PrimaryOptionNode{}, nil +} + +func (p *parser) callonPrimaryKeyClause1() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onPrimaryKeyClause1() +} + +func (c *current) onNotNullClause1() (interface{}, error) { + return ast.NotNullOptionNode{}, nil +} + +func (p *parser) callonNotNullClause1() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onNotNullClause1() +} + +func (c *current) onUniqueClause1() (interface{}, error) { + return ast.UniqueOptionNode{}, nil +} + +func (p *parser) callonUniqueClause1() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onUniqueClause1() +} + +func (c *current) onDefaultClause1(e interface{}) (interface{}, error) { + return ast.DefaultOptionNode{Value: e}, nil +} + +func (p *parser) callonDefaultClause1() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onDefaultClause1(stack["e"]) +} + +func (c *current) onForeignClause1(t, f interface{}) (interface{}, error) { + return ast.ForeignOptionNode{ + Table: t.(ast.IdentifierNode), + Column: f.(ast.IdentifierNode), + }, nil +} + +func (p *parser) callonForeignClause1() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onForeignClause1(stack["t"], stack["f"]) +} + +func (c *current) onAutoincrementClause1() (interface{}, error) { + return ast.AutoIncrementOptionNode{}, nil +} + +func (p *parser) callonAutoincrementClause1() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onAutoincrementClause1() +} + +func (c *current) onExprWithDefault2(d interface{}) (interface{}, error) { + return d, nil +} + +func (p *parser) callonExprWithDefault2() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onExprWithDefault2(stack["d"]) +} + +func (c *current) onLogicExpr47(op, s interface{}) (interface{}, error) { + return opSetSubject(op, s), nil +} + +func (p *parser) callonLogicExpr47() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onLogicExpr47(stack["op"], stack["s"]) +} + +func (c *current) onLogicExpr41(o, os interface{}) (interface{}, error) { + return rightJoinOperators(o, os), nil +} + +func (p *parser) callonLogicExpr41() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onLogicExpr41(stack["o"], stack["os"]) +} + +func (c *current) onLogicExpr37(op, s interface{}) (interface{}, error) { + return opSetSubject(op, s), nil +} + +func (p *parser) callonLogicExpr37() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onLogicExpr37(stack["op"], stack["s"]) +} + +func (c *current) onLogicExpr31(o, os interface{}) (interface{}, error) { + return rightJoinOperators(o, os), nil +} + +func (p *parser) callonLogicExpr31() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onLogicExpr31(stack["o"], stack["os"]) +} + +func (c *current) onLogicExpr22(op, s interface{}) (interface{}, error) { + return opSetTarget(op, s), nil +} + +func (p *parser) callonLogicExpr22() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onLogicExpr22(stack["op"], stack["s"]) +} + +func (c *current) onLogicExpr17(l interface{}) (interface{}, error) { + return l, nil +} + +func (p *parser) callonLogicExpr17() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onLogicExpr17(stack["l"]) +} + +func (c *current) onLogicExpr11(o, os interface{}) (interface{}, error) { + return rightJoinOperators(o, os), nil +} + +func (p *parser) callonLogicExpr11() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onLogicExpr11(stack["o"], stack["os"]) +} + +func (c *current) onLogicExpr1In5(t interface{}) (interface{}, error) { + return t, nil +} + +func (p *parser) callonLogicExpr1In5() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onLogicExpr1In5(stack["t"]) +} + +func (c *current) onLogicExpr1In1(n, s interface{}) (interface{}, error) { + op := opSetSubject(&ast.InOperatorNode{}, s) + if n != nil { + return opSetTarget(n, op), nil + } + return op, nil +} + +func (p *parser) callonLogicExpr1In1() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onLogicExpr1In1(stack["n"], stack["s"]) +} + +func (c *current) onLogicExpr1Null6(t interface{}) (interface{}, error) { + return t, nil +} + +func (p *parser) callonLogicExpr1Null6() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onLogicExpr1Null6(stack["t"]) +} + +func (c *current) onLogicExpr1Null1(n interface{}) (interface{}, error) { + op := opSetSubject(&ast.IsOperatorNode{}, ast.NullValueNode{}) + if n != nil { + return opSetTarget(n, op), nil + } + return op, nil +} + +func (p *parser) callonLogicExpr1Null1() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onLogicExpr1Null1(stack["n"]) +} + +func (c *current) onLogicExpr1Like5(t interface{}) (interface{}, error) { + return t, nil +} + +func (p *parser) callonLogicExpr1Like5() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onLogicExpr1Like5(stack["t"]) +} + +func (c *current) onLogicExpr1Like1(n, s interface{}) (interface{}, error) { + op := opSetSubject(&ast.LikeOperatorNode{}, s) + if n != nil { + return opSetTarget(n, op), nil + } + return op, nil +} + +func (p *parser) callonLogicExpr1Like1() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onLogicExpr1Like1(stack["n"], stack["s"]) +} + +func (c *current) onLogicExpr1Cmp1(op, s interface{}) (interface{}, error) { + return opSetSubject(op, s), nil +} + +func (p *parser) callonLogicExpr1Cmp1() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onLogicExpr1Cmp1(stack["op"], stack["s"]) +} + +func (c *current) onArithmeticExpr37(op, s interface{}) (interface{}, error) { + return opSetSubject(op, s), nil +} + +func (p *parser) callonArithmeticExpr37() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onArithmeticExpr37(stack["op"], stack["s"]) +} + +func (c *current) onArithmeticExpr31(o, os interface{}) (interface{}, error) { + return rightJoinOperators(o, os), nil +} + +func (p *parser) callonArithmeticExpr31() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onArithmeticExpr31(stack["o"], stack["os"]) +} + +func (c *current) onArithmeticExpr27(op, s interface{}) (interface{}, error) { + return opSetSubject(op, s), nil +} + +func (p *parser) callonArithmeticExpr27() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onArithmeticExpr27(stack["op"], stack["s"]) +} + +func (c *current) onArithmeticExpr21(o, os interface{}) (interface{}, error) { + return rightJoinOperators(o, os), nil +} + +func (p *parser) callonArithmeticExpr21() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onArithmeticExpr21(stack["o"], stack["os"]) +} + +func (c *current) onArithmeticExpr17(op, s interface{}) (interface{}, error) { + return opSetSubject(op, s), nil +} + +func (p *parser) callonArithmeticExpr17() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onArithmeticExpr17(stack["op"], stack["s"]) +} + +func (c *current) onArithmeticExpr11(o, os interface{}) (interface{}, error) { + return rightJoinOperators(o, os), nil +} + +func (p *parser) callonArithmeticExpr11() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onArithmeticExpr11(stack["o"], stack["os"]) +} + +func (c *current) onMultiExpr7(e interface{}) (interface{}, error) { + return e, nil +} + +func (p *parser) callonMultiExpr7() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onMultiExpr7(stack["e"]) +} + +func (c *current) onMultiExpr1(x, xs interface{}) (interface{}, error) { + return prepend(x, xs), nil +} + +func (p *parser) callonMultiExpr1() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onMultiExpr1(stack["x"], stack["xs"]) +} + +func (c *current) onMultiExprWithDefault7(e interface{}) (interface{}, error) { + return e, nil +} + +func (p *parser) callonMultiExprWithDefault7() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onMultiExprWithDefault7(stack["e"]) +} + +func (c *current) onMultiExprWithDefault1(x, xs interface{}) (interface{}, error) { + return prepend(x, xs), nil +} + +func (p *parser) callonMultiExprWithDefault1() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onMultiExprWithDefault1(stack["x"], stack["xs"]) +} + +func (c *current) onOperand2(op, s interface{}) (interface{}, error) { + return opSetTarget(op, s), nil +} + +func (p *parser) callonOperand2() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onOperand2(stack["op"], stack["s"]) +} + +func (c *current) onOperand9(e interface{}) (interface{}, error) { + return e, nil +} + +func (p *parser) callonOperand9() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onOperand9(stack["e"]) +} + +func (c *current) onOperand17(t interface{}) (interface{}, error) { + return t, nil +} + +func (p *parser) callonOperand17() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onOperand17(stack["t"]) +} + +func (c *current) onTypeCast1(o, s interface{}) (interface{}, error) { + return opSetSubject(opSetObject(&ast.CastOperatorNode{}, o), s), nil +} + +func (p *parser) callonTypeCast1() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onTypeCast1(stack["o"], stack["s"]) +} + +func (c *current) onFunctionCall1(i, r interface{}) (interface{}, error) { + return opSetSubject(opSetObject(&ast.FunctionOperatorNode{}, i), r), nil +} + +func (p *parser) callonFunctionCall1() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onFunctionCall1(stack["i"], stack["r"]) +} + +func (c *current) onFunctionArgs2(a interface{}) (interface{}, error) { + return []interface{}{a}, nil +} + +func (p *parser) callonFunctionArgs2() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onFunctionArgs2(stack["a"]) +} + +func (c *current) onAssignment1(i, e interface{}) (interface{}, error) { + return opSetSubject(opSetObject(&ast.AssignOperatorNode{}, i), e), nil +} + +func (p *parser) callonAssignment1() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onAssignment1(stack["i"], stack["e"]) +} + +func (c *current) onSignOperator1() (interface{}, error) { + switch string(c.text) { + case "+": + return &ast.PosOperatorNode{}, nil + case "-": + return &ast.NegOperatorNode{}, nil + } + return nil, errors.New("unknown sign") +} + +func (p *parser) callonSignOperator1() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onSignOperator1() +} + +func (c *current) onNotOperator1() (interface{}, error) { + return &ast.NotOperatorNode{}, nil +} + +func (p *parser) callonNotOperator1() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onNotOperator1() +} + +func (c *current) onAndOperator1() (interface{}, error) { + return &ast.AndOperatorNode{}, nil +} + +func (p *parser) callonAndOperator1() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onAndOperator1() +} + +func (c *current) onOrOperator1() (interface{}, error) { + return &ast.OrOperatorNode{}, nil +} + +func (p *parser) callonOrOperator1() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onOrOperator1() +} + +func (c *current) onCmpOperator1() (interface{}, error) { + switch string(c.text) { + case "<=": + return &ast.LessOrEqualOperatorNode{}, nil + case ">=": + return &ast.GreaterOrEqualOperatorNode{}, nil + case "<>": + return &ast.NotEqualOperatorNode{}, nil + case "!=": + return &ast.NotEqualOperatorNode{}, nil + case "<": + return &ast.LessOperatorNode{}, nil + case ">": + return &ast.GreaterOperatorNode{}, nil + case "=": + return &ast.EqualOperatorNode{}, nil + } + return nil, errors.New("unknown cmp") +} + +func (p *parser) callonCmpOperator1() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onCmpOperator1() +} + +func (c *current) onConcatOperator1() (interface{}, error) { + return &ast.ConcatOperatorNode{}, nil +} + +func (p *parser) callonConcatOperator1() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onConcatOperator1() +} + +func (c *current) onAddSubOperator1() (interface{}, error) { + switch string(c.text) { + case "+": + return &ast.AddOperatorNode{}, nil + case "-": + return &ast.SubOperatorNode{}, nil + } + return nil, errors.New("unknown add sub") +} + +func (p *parser) callonAddSubOperator1() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onAddSubOperator1() +} + +func (c *current) onMulDivModOperator1() (interface{}, error) { + switch string(c.text) { + case "*": + return &ast.MulOperatorNode{}, nil + case "/": + return &ast.DivOperatorNode{}, nil + case "%": + return &ast.ModOperatorNode{}, nil + } + return nil, errors.New("unknown mul div mod") +} + +func (p *parser) callonMulDivModOperator1() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onMulDivModOperator1() +} + +func (c *current) onUIntType1(s interface{}) (interface{}, error) { + return ast.IntTypeNode{ + Unsigned: true, + Size: toUint(s.([]byte)), + }, nil +} + +func (p *parser) callonUIntType1() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onUIntType1(stack["s"]) +} + +func (c *current) onIntType1(s interface{}) (interface{}, error) { + return ast.IntTypeNode{ + Unsigned: false, + Size: toUint(s.([]byte)), + }, nil +} + +func (p *parser) callonIntType1() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onIntType1(stack["s"]) +} + +func (c *current) onUFixedType1(s, t interface{}) (interface{}, error) { + return ast.FixedTypeNode{ + Unsigned: true, + Size: toUint(s.([]byte)), + FractionalDigits: toUint(t.([]byte)), + }, nil +} + +func (p *parser) callonUFixedType1() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onUFixedType1(stack["s"], stack["t"]) +} + +func (c *current) onFixedType1(s, t interface{}) (interface{}, error) { + return ast.FixedTypeNode{ + Unsigned: false, + Size: toUint(s.([]byte)), + FractionalDigits: toUint(t.([]byte)), + }, nil +} + +func (p *parser) callonFixedType1() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onFixedType1(stack["s"], stack["t"]) +} + +func (c *current) onFixedBytesType2(s interface{}) (interface{}, error) { + return ast.FixedBytesTypeNode{Size: toUint(s.([]byte))}, nil +} + +func (p *parser) callonFixedBytesType2() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onFixedBytesType2(stack["s"]) +} + +func (c *current) onFixedBytesType9() (interface{}, error) { + return ast.FixedBytesTypeNode{Size: 1}, nil +} + +func (p *parser) callonFixedBytesType9() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onFixedBytesType9() +} + +func (c *current) onDynamicBytesType1() (interface{}, error) { + return ast.DynamicBytesTypeNode{}, nil +} + +func (p *parser) callonDynamicBytesType1() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onDynamicBytesType1() +} + +func (c *current) onAddressType1() (interface{}, error) { + return ast.AddressTypeNode{}, nil +} + +func (p *parser) callonAddressType1() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onAddressType1() +} + +func (c *current) onBoolType1() (interface{}, error) { + return ast.BoolTypeNode{}, nil +} + +func (p *parser) callonBoolType1() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onBoolType1() +} + +func (c *current) onAnyLiteral1() (interface{}, error) { + return ast.AnyValueNode{}, nil +} + +func (p *parser) callonAnyLiteral1() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onAnyLiteral1() +} + +func (c *current) onDefaultLiteral1() (interface{}, error) { + return ast.DefaultValueNode{}, nil +} + +func (p *parser) callonDefaultLiteral1() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onDefaultLiteral1() +} + +func (c *current) onBoolLiteral1(b interface{}) (interface{}, error) { + return ast.BoolValueNode{V: string(b.([]byte)) == "true"}, nil +} + +func (p *parser) callonBoolLiteral1() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onBoolLiteral1(stack["b"]) +} + +func (c *current) onNullLiteral1() (interface{}, error) { + return ast.NullValueNode{}, nil +} + +func (p *parser) callonNullLiteral1() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onNullLiteral1() +} + +func (c *current) onNumberLiteral2(h interface{}) (interface{}, error) { + return h, nil +} + +func (p *parser) callonNumberLiteral2() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onNumberLiteral2(stack["h"]) +} + +func (c *current) onInteger1() (interface{}, error) { + return ast.IntegerValueNode{V: toDecimal(c.text)}, nil +} + +func (p *parser) callonInteger1() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onInteger1() +} + +func (c *current) onNonZeroLeadingInteger1() (interface{}, error) { + return c.text, nil +} + +func (p *parser) callonNonZeroLeadingInteger1() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onNonZeroLeadingInteger1() +} + +func (c *current) onDecimal1() (interface{}, error) { + return ast.DecimalValueNode{V: toDecimal(c.text)}, nil +} + +func (p *parser) callonDecimal1() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onDecimal1() +} + +func (c *current) onHex1(s interface{}) (interface{}, error) { + return hexToInteger(joinBytes(s)), nil +} + +func (p *parser) callonHex1() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onHex1(stack["s"]) +} + +func (c *current) onHexString9() (interface{}, error) { + return c.text, nil +} + +func (p *parser) callonHexString9() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onHexString9() +} + +func (c *current) onHexString1(s interface{}) (interface{}, error) { + return ast.BytesValueNode{V: hexToBytes(joinBytes(s))}, nil +} + +func (p *parser) callonHexString1() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onHexString1(stack["s"]) +} + +func (c *current) onNormalString6() (interface{}, error) { + return c.text, nil +} + +func (p *parser) callonNormalString6() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onNormalString6() +} + +func (c *current) onNormalString1(s interface{}) (interface{}, error) { + return ast.BytesValueNode{V: resolveString(joinBytes(s))}, nil +} + +func (p *parser) callonNormalString1() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onNormalString1(stack["s"]) +} + +func (c *current) onTrueToken1() (interface{}, error) { + return toLower(c.text), nil +} + +func (p *parser) callonTrueToken1() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onTrueToken1() +} + +func (c *current) onFalseToken1() (interface{}, error) { + return toLower(c.text), nil +} + +func (p *parser) callonFalseToken1() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onFalseToken1() +} + +func (c *current) onLastToken1() (interface{}, error) { + return toLower(c.text), nil +} + +func (p *parser) callonLastToken1() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onLastToken1() +} + +func (c *current) onFirstToken1() (interface{}, error) { + return toLower(c.text), nil +} + +func (p *parser) callonFirstToken1() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onFirstToken1() +} + +func (c *current) onAscToken1() (interface{}, error) { + return toLower(c.text), nil +} + +func (p *parser) callonAscToken1() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onAscToken1() +} + +func (c *current) onDescToken1() (interface{}, error) { + return toLower(c.text), nil +} + +func (p *parser) callonDescToken1() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onDescToken1() +} + +func (c *current) onNormalIdentifier1() (interface{}, error) { + return ast.IdentifierNode{Name: c.text}, nil +} + +func (p *parser) callonNormalIdentifier1() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onNormalIdentifier1() +} + +func (c *current) onStringIdentifier6() (interface{}, error) { + return c.text, nil +} + +func (p *parser) callonStringIdentifier6() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onStringIdentifier6() +} + +func (c *current) onStringIdentifier1(s interface{}) (interface{}, error) { + return ast.IdentifierNode{Name: resolveString(joinBytes(s))}, nil +} + +func (p *parser) callonStringIdentifier1() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onStringIdentifier1(stack["s"]) +} + +var ( + // errNoRule is returned when the grammar to parse has no rule. + errNoRule = errors.New("grammar has no rule") + + // errInvalidEntrypoint is returned when the specified entrypoint rule + // does not exit. + errInvalidEntrypoint = errors.New("invalid entrypoint") + + // errInvalidEncoding is returned when the source is not properly + // utf8-encoded. + errInvalidEncoding = errors.New("invalid encoding") + + // errMaxExprCnt is used to signal that the maximum number of + // expressions have been parsed. + errMaxExprCnt = errors.New("max number of expresssions parsed") +) + +// Option is a function that can set an option on the parser. It returns +// the previous setting as an Option. +type Option func(*parser) Option + +// MaxExpressions creates an Option to stop parsing after the provided +// number of expressions have been parsed, if the value is 0 then the parser will +// parse for as many steps as needed (possibly an infinite number). +// +// The default for maxExprCnt is 0. +func MaxExpressions(maxExprCnt uint64) Option { + return func(p *parser) Option { + oldMaxExprCnt := p.maxExprCnt + p.maxExprCnt = maxExprCnt + return MaxExpressions(oldMaxExprCnt) + } +} + +// Entrypoint creates an Option to set the rule name to use as entrypoint. +// The rule name must have been specified in the -alternate-entrypoints +// if generating the parser with the -optimize-grammar flag, otherwise +// it may have been optimized out. Passing an empty string sets the +// entrypoint to the first rule in the grammar. +// +// The default is to start parsing at the first rule in the grammar. +func Entrypoint(ruleName string) Option { + return func(p *parser) Option { + oldEntrypoint := p.entrypoint + p.entrypoint = ruleName + if ruleName == "" { + p.entrypoint = g.rules[0].name + } + return Entrypoint(oldEntrypoint) + } +} + +// Statistics adds a user provided Stats struct to the parser to allow +// the user to process the results after the parsing has finished. +// Also the key for the "no match" counter is set. +// +// Example usage: +// +// input := "input" +// stats := Stats{} +// _, err := Parse("input-file", []byte(input), Statistics(&stats, "no match")) +// if err != nil { +// log.Panicln(err) +// } +// b, err := json.MarshalIndent(stats.ChoiceAltCnt, "", " ") +// if err != nil { +// log.Panicln(err) +// } +// fmt.Println(string(b)) +// +func Statistics(stats *Stats, choiceNoMatch string) Option { + return func(p *parser) Option { + oldStats := p.Stats + p.Stats = stats + oldChoiceNoMatch := p.choiceNoMatch + p.choiceNoMatch = choiceNoMatch + if p.Stats.ChoiceAltCnt == nil { + p.Stats.ChoiceAltCnt = make(map[string]map[string]int) + } + return Statistics(oldStats, oldChoiceNoMatch) + } +} + +// Debug creates an Option to set the debug flag to b. When set to true, +// debugging information is printed to stdout while parsing. +// +// The default is false. +func Debug(b bool) Option { + return func(p *parser) Option { + old := p.debug + p.debug = b + return Debug(old) + } +} + +// Memoize creates an Option to set the memoize flag to b. When set to true, +// the parser will cache all results so each expression is evaluated only +// once. This guarantees linear parsing time even for pathological cases, +// at the expense of more memory and slower times for typical cases. +// +// The default is false. +func Memoize(b bool) Option { + return func(p *parser) Option { + old := p.memoize + p.memoize = b + return Memoize(old) + } +} + +// AllowInvalidUTF8 creates an Option to allow invalid UTF-8 bytes. +// Every invalid UTF-8 byte is treated as a utf8.RuneError (U+FFFD) +// by character class matchers and is matched by the any matcher. +// The returned matched value, c.text and c.offset are NOT affected. +// +// The default is false. +func AllowInvalidUTF8(b bool) Option { + return func(p *parser) Option { + old := p.allowInvalidUTF8 + p.allowInvalidUTF8 = b + return AllowInvalidUTF8(old) + } +} + +// Recover creates an Option to set the recover flag to b. When set to +// true, this causes the parser to recover from panics and convert it +// to an error. Setting it to false can be useful while debugging to +// access the full stack trace. +// +// The default is true. +func Recover(b bool) Option { + return func(p *parser) Option { + old := p.recover + p.recover = b + return Recover(old) + } +} + +// GlobalStore creates an Option to set a key to a certain value in +// the globalStore. +func GlobalStore(key string, value interface{}) Option { + return func(p *parser) Option { + old := p.cur.globalStore[key] + p.cur.globalStore[key] = value + return GlobalStore(key, old) + } +} + +// InitState creates an Option to set a key to a certain value in +// the global "state" store. +func InitState(key string, value interface{}) Option { + return func(p *parser) Option { + old := p.cur.state[key] + p.cur.state[key] = value + return InitState(key, old) + } +} + +// ParseFile parses the file identified by filename. +func ParseFile(filename string, opts ...Option) (i interface{}, err error) { + f, err := os.Open(filename) + if err != nil { + return nil, err + } + defer func() { + if closeErr := f.Close(); closeErr != nil { + err = closeErr + } + }() + return ParseReader(filename, f, opts...) +} + +// ParseReader parses the data from r using filename as information in the +// error messages. +func ParseReader(filename string, r io.Reader, opts ...Option) (interface{}, error) { + b, err := ioutil.ReadAll(r) + if err != nil { + return nil, err + } + + return Parse(filename, b, opts...) +} + +// Parse parses the data from b using filename as information in the +// error messages. +func Parse(filename string, b []byte, opts ...Option) (interface{}, error) { + return newParser(filename, b, opts...).parse(g) +} + +// position records a position in the text. +type position struct { + line, col, offset int +} + +func (p position) String() string { + return fmt.Sprintf("%d:%d [%d]", p.line, p.col, p.offset) +} + +// savepoint stores all state required to go back to this point in the +// parser. +type savepoint struct { + position + rn rune + w int +} + +type current struct { + pos position // start position of the match + text []byte // raw text of the match + + // state is a store for arbitrary key,value pairs that the user wants to be + // tied to the backtracking of the parser. + // This is always rolled back if a parsing rule fails. + state storeDict + + // globalStore is a general store for the user to store arbitrary key-value + // pairs that they need to manage and that they do not want tied to the + // backtracking of the parser. This is only modified by the user and never + // rolled back by the parser. It is always up to the user to keep this in a + // consistent state. + globalStore storeDict +} + +type storeDict map[string]interface{} + +// the AST types... + +type grammar struct { + pos position + rules []*rule +} + +type rule struct { + pos position + name string + displayName string + expr interface{} +} + +type choiceExpr struct { + pos position + alternatives []interface{} +} + +type actionExpr struct { + pos position + expr interface{} + run func(*parser) (interface{}, error) +} + +type recoveryExpr struct { + pos position + expr interface{} + recoverExpr interface{} + failureLabel []string +} + +type seqExpr struct { + pos position + exprs []interface{} +} + +type throwExpr struct { + pos position + label string +} + +type labeledExpr struct { + pos position + label string + expr interface{} +} + +type expr struct { + pos position + expr interface{} +} + +type andExpr expr +type notExpr expr +type zeroOrOneExpr expr +type zeroOrMoreExpr expr +type oneOrMoreExpr expr + +type ruleRefExpr struct { + pos position + name string +} + +type stateCodeExpr struct { + pos position + run func(*parser) error +} + +type andCodeExpr struct { + pos position + run func(*parser) (bool, error) +} + +type notCodeExpr struct { + pos position + run func(*parser) (bool, error) +} + +type litMatcher struct { + pos position + val string + ignoreCase bool +} + +type charClassMatcher struct { + pos position + val string + basicLatinChars [128]bool + chars []rune + ranges []rune + classes []*unicode.RangeTable + ignoreCase bool + inverted bool +} + +type anyMatcher position + +// errList cumulates the errors found by the parser. +type errList []error + +func (e *errList) add(err error) { + *e = append(*e, err) +} + +func (e errList) err() error { + if len(e) == 0 { + return nil + } + e.dedupe() + return e +} + +func (e *errList) dedupe() { + var cleaned []error + set := make(map[string]bool) + for _, err := range *e { + if msg := err.Error(); !set[msg] { + set[msg] = true + cleaned = append(cleaned, err) + } + } + *e = cleaned +} + +func (e errList) Error() string { + switch len(e) { + case 0: + return "" + case 1: + return e[0].Error() + default: + var buf bytes.Buffer + + for i, err := range e { + if i > 0 { + buf.WriteRune('\n') + } + buf.WriteString(err.Error()) + } + return buf.String() + } +} + +// parserError wraps an error with a prefix indicating the rule in which +// the error occurred. The original error is stored in the Inner field. +type parserError struct { + Inner error + pos position + prefix string + expected []string +} + +// Error returns the error message. +func (p *parserError) Error() string { + return p.prefix + ": " + p.Inner.Error() +} + +// newParser creates a parser with the specified input source and options. +func newParser(filename string, b []byte, opts ...Option) *parser { + stats := Stats{ + ChoiceAltCnt: make(map[string]map[string]int), + } + + p := &parser{ + filename: filename, + errs: new(errList), + data: b, + pt: savepoint{position: position{line: 1}}, + recover: true, + cur: current{ + state: make(storeDict), + globalStore: make(storeDict), + }, + maxFailPos: position{col: 1, line: 1}, + maxFailExpected: make([]string, 0, 20), + Stats: &stats, + // start rule is rule [0] unless an alternate entrypoint is specified + entrypoint: g.rules[0].name, + } + p.setOptions(opts) + + if p.maxExprCnt == 0 { + p.maxExprCnt = math.MaxUint64 + } + + return p +} + +// setOptions applies the options to the parser. +func (p *parser) setOptions(opts []Option) { + for _, opt := range opts { + opt(p) + } +} + +type resultTuple struct { + v interface{} + b bool + end savepoint +} + +const choiceNoMatch = -1 + +// Stats stores some statistics, gathered during parsing +type Stats struct { + // ExprCnt counts the number of expressions processed during parsing + // This value is compared to the maximum number of expressions allowed + // (set by the MaxExpressions option). + ExprCnt uint64 + + // ChoiceAltCnt is used to count for each ordered choice expression, + // which alternative is used how may times. + // These numbers allow to optimize the order of the ordered choice expression + // to increase the performance of the parser + // + // The outer key of ChoiceAltCnt is composed of the name of the rule as well + // as the line and the column of the ordered choice. + // The inner key of ChoiceAltCnt is the number (one-based) of the matching alternative. + // For each alternative the number of matches are counted. If an ordered choice does not + // match, a special counter is incremented. The name of this counter is set with + // the parser option Statistics. + // For an alternative to be included in ChoiceAltCnt, it has to match at least once. + ChoiceAltCnt map[string]map[string]int +} + +type parser struct { + filename string + pt savepoint + cur current + + data []byte + errs *errList + + depth int + recover bool + debug bool + + memoize bool + // memoization table for the packrat algorithm: + // map[offset in source] map[expression or rule] {value, match} + memo map[int]map[interface{}]resultTuple + + // rules table, maps the rule identifier to the rule node + rules map[string]*rule + // variables stack, map of label to value + vstack []map[string]interface{} + // rule stack, allows identification of the current rule in errors + rstack []*rule + + // parse fail + maxFailPos position + maxFailExpected []string + maxFailInvertExpected bool + + // max number of expressions to be parsed + maxExprCnt uint64 + // entrypoint for the parser + entrypoint string + + allowInvalidUTF8 bool + + *Stats + + choiceNoMatch string + // recovery expression stack, keeps track of the currently available recovery expression, these are traversed in reverse + recoveryStack []map[string]interface{} +} + +// push a variable set on the vstack. +func (p *parser) pushV() { + if cap(p.vstack) == len(p.vstack) { + // create new empty slot in the stack + p.vstack = append(p.vstack, nil) + } else { + // slice to 1 more + p.vstack = p.vstack[:len(p.vstack)+1] + } + + // get the last args set + m := p.vstack[len(p.vstack)-1] + if m != nil && len(m) == 0 { + // empty map, all good + return + } + + m = make(map[string]interface{}) + p.vstack[len(p.vstack)-1] = m +} + +// pop a variable set from the vstack. +func (p *parser) popV() { + // if the map is not empty, clear it + m := p.vstack[len(p.vstack)-1] + if len(m) > 0 { + // GC that map + p.vstack[len(p.vstack)-1] = nil + } + p.vstack = p.vstack[:len(p.vstack)-1] +} + +// push a recovery expression with its labels to the recoveryStack +func (p *parser) pushRecovery(labels []string, expr interface{}) { + if cap(p.recoveryStack) == len(p.recoveryStack) { + // create new empty slot in the stack + p.recoveryStack = append(p.recoveryStack, nil) + } else { + // slice to 1 more + p.recoveryStack = p.recoveryStack[:len(p.recoveryStack)+1] + } + + m := make(map[string]interface{}, len(labels)) + for _, fl := range labels { + m[fl] = expr + } + p.recoveryStack[len(p.recoveryStack)-1] = m +} + +// pop a recovery expression from the recoveryStack +func (p *parser) popRecovery() { + // GC that map + p.recoveryStack[len(p.recoveryStack)-1] = nil + + p.recoveryStack = p.recoveryStack[:len(p.recoveryStack)-1] +} + +func (p *parser) print(prefix, s string) string { + if !p.debug { + return s + } + + fmt.Printf("%s %d:%d:%d: %s [%#U]\n", + prefix, p.pt.line, p.pt.col, p.pt.offset, s, p.pt.rn) + return s +} + +func (p *parser) in(s string) string { + p.depth++ + return p.print(strings.Repeat(" ", p.depth)+">", s) +} + +func (p *parser) out(s string) string { + p.depth-- + return p.print(strings.Repeat(" ", p.depth)+"<", s) +} + +func (p *parser) addErr(err error) { + p.addErrAt(err, p.pt.position, []string{}) +} + +func (p *parser) addErrAt(err error, pos position, expected []string) { + var buf bytes.Buffer + if p.filename != "" { + buf.WriteString(p.filename) + } + if buf.Len() > 0 { + buf.WriteString(":") + } + buf.WriteString(fmt.Sprintf("%d:%d (%d)", pos.line, pos.col, pos.offset)) + if len(p.rstack) > 0 { + if buf.Len() > 0 { + buf.WriteString(": ") + } + rule := p.rstack[len(p.rstack)-1] + if rule.displayName != "" { + buf.WriteString("rule " + rule.displayName) + } else { + buf.WriteString("rule " + rule.name) + } + } + pe := &parserError{Inner: err, pos: pos, prefix: buf.String(), expected: expected} + p.errs.add(pe) +} + +func (p *parser) failAt(fail bool, pos position, want string) { + // process fail if parsing fails and not inverted or parsing succeeds and invert is set + if fail == p.maxFailInvertExpected { + if pos.offset < p.maxFailPos.offset { + return + } + + if pos.offset > p.maxFailPos.offset { + p.maxFailPos = pos + p.maxFailExpected = p.maxFailExpected[:0] + } + + if p.maxFailInvertExpected { + want = "!" + want + } + p.maxFailExpected = append(p.maxFailExpected, want) + } +} + +// read advances the parser to the next rune. +func (p *parser) read() { + p.pt.offset += p.pt.w + rn, n := utf8.DecodeRune(p.data[p.pt.offset:]) + p.pt.rn = rn + p.pt.w = n + p.pt.col++ + if rn == '\n' { + p.pt.line++ + p.pt.col = 0 + } + + if rn == utf8.RuneError && n == 1 { // see utf8.DecodeRune + if !p.allowInvalidUTF8 { + p.addErr(errInvalidEncoding) + } + } +} + +// restore parser position to the savepoint pt. +func (p *parser) restore(pt savepoint) { + if p.debug { + defer p.out(p.in("restore")) + } + if pt.offset == p.pt.offset { + return + } + p.pt = pt +} + +// Cloner is implemented by any value that has a Clone method, which returns a +// copy of the value. This is mainly used for types which are not passed by +// value (e.g map, slice, chan) or structs that contain such types. +// +// This is used in conjunction with the global state feature to create proper +// copies of the state to allow the parser to properly restore the state in +// the case of backtracking. +type Cloner interface { + Clone() interface{} +} + +// clone and return parser current state. +func (p *parser) cloneState() storeDict { + if p.debug { + defer p.out(p.in("cloneState")) + } + + state := make(storeDict, len(p.cur.state)) + for k, v := range p.cur.state { + if c, ok := v.(Cloner); ok { + state[k] = c.Clone() + } else { + state[k] = v + } + } + return state +} + +// restore parser current state to the state storeDict. +// every restoreState should applied only one time for every cloned state +func (p *parser) restoreState(state storeDict) { + if p.debug { + defer p.out(p.in("restoreState")) + } + p.cur.state = state +} + +// get the slice of bytes from the savepoint start to the current position. +func (p *parser) sliceFrom(start savepoint) []byte { + return p.data[start.position.offset:p.pt.position.offset] +} + +func (p *parser) getMemoized(node interface{}) (resultTuple, bool) { + if len(p.memo) == 0 { + return resultTuple{}, false + } + m := p.memo[p.pt.offset] + if len(m) == 0 { + return resultTuple{}, false + } + res, ok := m[node] + return res, ok +} + +func (p *parser) setMemoized(pt savepoint, node interface{}, tuple resultTuple) { + if p.memo == nil { + p.memo = make(map[int]map[interface{}]resultTuple) + } + m := p.memo[pt.offset] + if m == nil { + m = make(map[interface{}]resultTuple) + p.memo[pt.offset] = m + } + m[node] = tuple +} + +func (p *parser) buildRulesTable(g *grammar) { + p.rules = make(map[string]*rule, len(g.rules)) + for _, r := range g.rules { + p.rules[r.name] = r + } +} + +func (p *parser) parse(g *grammar) (val interface{}, err error) { + if len(g.rules) == 0 { + p.addErr(errNoRule) + return nil, p.errs.err() + } + + // TODO : not super critical but this could be generated + p.buildRulesTable(g) + + if p.recover { + // panic can be used in action code to stop parsing immediately + // and return the panic as an error. + defer func() { + if e := recover(); e != nil { + if p.debug { + defer p.out(p.in("panic handler")) + } + val = nil + switch e := e.(type) { + case error: + p.addErr(e) + default: + p.addErr(fmt.Errorf("%v", e)) + } + err = p.errs.err() + } + }() + } + + startRule, ok := p.rules[p.entrypoint] + if !ok { + p.addErr(errInvalidEntrypoint) + return nil, p.errs.err() + } + + p.read() // advance to first rune + val, ok = p.parseRule(startRule) + if !ok { + if len(*p.errs) == 0 { + // If parsing fails, but no errors have been recorded, the expected values + // for the farthest parser position are returned as error. + maxFailExpectedMap := make(map[string]struct{}, len(p.maxFailExpected)) + for _, v := range p.maxFailExpected { + maxFailExpectedMap[v] = struct{}{} + } + expected := make([]string, 0, len(maxFailExpectedMap)) + eof := false + if _, ok := maxFailExpectedMap["!."]; ok { + delete(maxFailExpectedMap, "!.") + eof = true + } + for k := range maxFailExpectedMap { + expected = append(expected, k) + } + sort.Strings(expected) + if eof { + expected = append(expected, "EOF") + } + p.addErrAt(errors.New("no match found, expected: "+listJoin(expected, ", ", "or")), p.maxFailPos, expected) + } + + return nil, p.errs.err() + } + return val, p.errs.err() +} + +func listJoin(list []string, sep string, lastSep string) string { + switch len(list) { + case 0: + return "" + case 1: + return list[0] + default: + return fmt.Sprintf("%s %s %s", strings.Join(list[:len(list)-1], sep), lastSep, list[len(list)-1]) + } +} + +func (p *parser) parseRule(rule *rule) (interface{}, bool) { + if p.debug { + defer p.out(p.in("parseRule " + rule.name)) + } + + if p.memoize { + res, ok := p.getMemoized(rule) + if ok { + p.restore(res.end) + return res.v, res.b + } + } + + start := p.pt + p.rstack = append(p.rstack, rule) + p.pushV() + val, ok := p.parseExpr(rule.expr) + p.popV() + p.rstack = p.rstack[:len(p.rstack)-1] + if ok && p.debug { + p.print(strings.Repeat(" ", p.depth)+"MATCH", string(p.sliceFrom(start))) + } + + if p.memoize { + p.setMemoized(start, rule, resultTuple{val, ok, p.pt}) + } + return val, ok +} + +func (p *parser) parseExpr(expr interface{}) (interface{}, bool) { + var pt savepoint + + if p.memoize { + res, ok := p.getMemoized(expr) + if ok { + p.restore(res.end) + return res.v, res.b + } + pt = p.pt + } + + p.ExprCnt++ + if p.ExprCnt > p.maxExprCnt { + panic(errMaxExprCnt) + } + + var val interface{} + var ok bool + switch expr := expr.(type) { + case *actionExpr: + val, ok = p.parseActionExpr(expr) + case *andCodeExpr: + val, ok = p.parseAndCodeExpr(expr) + case *andExpr: + val, ok = p.parseAndExpr(expr) + case *anyMatcher: + val, ok = p.parseAnyMatcher(expr) + case *charClassMatcher: + val, ok = p.parseCharClassMatcher(expr) + case *choiceExpr: + val, ok = p.parseChoiceExpr(expr) + case *labeledExpr: + val, ok = p.parseLabeledExpr(expr) + case *litMatcher: + val, ok = p.parseLitMatcher(expr) + case *notCodeExpr: + val, ok = p.parseNotCodeExpr(expr) + case *notExpr: + val, ok = p.parseNotExpr(expr) + case *oneOrMoreExpr: + val, ok = p.parseOneOrMoreExpr(expr) + case *recoveryExpr: + val, ok = p.parseRecoveryExpr(expr) + case *ruleRefExpr: + val, ok = p.parseRuleRefExpr(expr) + case *seqExpr: + val, ok = p.parseSeqExpr(expr) + case *stateCodeExpr: + val, ok = p.parseStateCodeExpr(expr) + case *throwExpr: + val, ok = p.parseThrowExpr(expr) + case *zeroOrMoreExpr: + val, ok = p.parseZeroOrMoreExpr(expr) + case *zeroOrOneExpr: + val, ok = p.parseZeroOrOneExpr(expr) + default: + panic(fmt.Sprintf("unknown expression type %T", expr)) + } + if p.memoize { + p.setMemoized(pt, expr, resultTuple{val, ok, p.pt}) + } + return val, ok +} + +func (p *parser) parseActionExpr(act *actionExpr) (interface{}, bool) { + if p.debug { + defer p.out(p.in("parseActionExpr")) + } + + start := p.pt + val, ok := p.parseExpr(act.expr) + if ok { + p.cur.pos = start.position + p.cur.text = p.sliceFrom(start) + state := p.cloneState() + actVal, err := act.run(p) + if err != nil { + p.addErrAt(err, start.position, []string{}) + } + p.restoreState(state) + + val = actVal + } + if ok && p.debug { + p.print(strings.Repeat(" ", p.depth)+"MATCH", string(p.sliceFrom(start))) + } + return val, ok +} + +func (p *parser) parseAndCodeExpr(and *andCodeExpr) (interface{}, bool) { + if p.debug { + defer p.out(p.in("parseAndCodeExpr")) + } + + state := p.cloneState() + + ok, err := and.run(p) + if err != nil { + p.addErr(err) + } + p.restoreState(state) + + return nil, ok +} + +func (p *parser) parseAndExpr(and *andExpr) (interface{}, bool) { + if p.debug { + defer p.out(p.in("parseAndExpr")) + } + + pt := p.pt + state := p.cloneState() + p.pushV() + _, ok := p.parseExpr(and.expr) + p.popV() + p.restoreState(state) + p.restore(pt) + + return nil, ok +} + +func (p *parser) parseAnyMatcher(any *anyMatcher) (interface{}, bool) { + if p.debug { + defer p.out(p.in("parseAnyMatcher")) + } + + if p.pt.rn == utf8.RuneError && p.pt.w == 0 { + // EOF - see utf8.DecodeRune + p.failAt(false, p.pt.position, ".") + return nil, false + } + start := p.pt + p.read() + p.failAt(true, start.position, ".") + return p.sliceFrom(start), true +} + +func (p *parser) parseCharClassMatcher(chr *charClassMatcher) (interface{}, bool) { + if p.debug { + defer p.out(p.in("parseCharClassMatcher")) + } + + cur := p.pt.rn + start := p.pt + + // can't match EOF + if cur == utf8.RuneError && p.pt.w == 0 { // see utf8.DecodeRune + p.failAt(false, start.position, chr.val) + return nil, false + } + + if chr.ignoreCase { + cur = unicode.ToLower(cur) + } + + // try to match in the list of available chars + for _, rn := range chr.chars { + if rn == cur { + if chr.inverted { + p.failAt(false, start.position, chr.val) + return nil, false + } + p.read() + p.failAt(true, start.position, chr.val) + return p.sliceFrom(start), true + } + } + + // try to match in the list of ranges + for i := 0; i < len(chr.ranges); i += 2 { + if cur >= chr.ranges[i] && cur <= chr.ranges[i+1] { + if chr.inverted { + p.failAt(false, start.position, chr.val) + return nil, false + } + p.read() + p.failAt(true, start.position, chr.val) + return p.sliceFrom(start), true + } + } + + // try to match in the list of Unicode classes + for _, cl := range chr.classes { + if unicode.Is(cl, cur) { + if chr.inverted { + p.failAt(false, start.position, chr.val) + return nil, false + } + p.read() + p.failAt(true, start.position, chr.val) + return p.sliceFrom(start), true + } + } + + if chr.inverted { + p.read() + p.failAt(true, start.position, chr.val) + return p.sliceFrom(start), true + } + p.failAt(false, start.position, chr.val) + return nil, false +} + +func (p *parser) incChoiceAltCnt(ch *choiceExpr, altI int) { + choiceIdent := fmt.Sprintf("%s %d:%d", p.rstack[len(p.rstack)-1].name, ch.pos.line, ch.pos.col) + m := p.ChoiceAltCnt[choiceIdent] + if m == nil { + m = make(map[string]int) + p.ChoiceAltCnt[choiceIdent] = m + } + // We increment altI by 1, so the keys do not start at 0 + alt := strconv.Itoa(altI + 1) + if altI == choiceNoMatch { + alt = p.choiceNoMatch + } + m[alt]++ +} + +func (p *parser) parseChoiceExpr(ch *choiceExpr) (interface{}, bool) { + if p.debug { + defer p.out(p.in("parseChoiceExpr")) + } + + for altI, alt := range ch.alternatives { + // dummy assignment to prevent compile error if optimized + _ = altI + + state := p.cloneState() + + p.pushV() + val, ok := p.parseExpr(alt) + p.popV() + if ok { + p.incChoiceAltCnt(ch, altI) + return val, ok + } + p.restoreState(state) + } + p.incChoiceAltCnt(ch, choiceNoMatch) + return nil, false +} + +func (p *parser) parseLabeledExpr(lab *labeledExpr) (interface{}, bool) { + if p.debug { + defer p.out(p.in("parseLabeledExpr")) + } + + p.pushV() + val, ok := p.parseExpr(lab.expr) + p.popV() + if ok && lab.label != "" { + m := p.vstack[len(p.vstack)-1] + m[lab.label] = val + } + return val, ok +} + +func (p *parser) parseLitMatcher(lit *litMatcher) (interface{}, bool) { + if p.debug { + defer p.out(p.in("parseLitMatcher")) + } + + ignoreCase := "" + if lit.ignoreCase { + ignoreCase = "i" + } + val := fmt.Sprintf("%q%s", lit.val, ignoreCase) + start := p.pt + for _, want := range lit.val { + cur := p.pt.rn + if lit.ignoreCase { + cur = unicode.ToLower(cur) + } + if cur != want { + p.failAt(false, start.position, val) + p.restore(start) + return nil, false + } + p.read() + } + p.failAt(true, start.position, val) + return p.sliceFrom(start), true +} + +func (p *parser) parseNotCodeExpr(not *notCodeExpr) (interface{}, bool) { + if p.debug { + defer p.out(p.in("parseNotCodeExpr")) + } + + state := p.cloneState() + + ok, err := not.run(p) + if err != nil { + p.addErr(err) + } + p.restoreState(state) + + return nil, !ok +} + +func (p *parser) parseNotExpr(not *notExpr) (interface{}, bool) { + if p.debug { + defer p.out(p.in("parseNotExpr")) + } + + pt := p.pt + state := p.cloneState() + p.pushV() + p.maxFailInvertExpected = !p.maxFailInvertExpected + _, ok := p.parseExpr(not.expr) + p.maxFailInvertExpected = !p.maxFailInvertExpected + p.popV() + p.restoreState(state) + p.restore(pt) + + return nil, !ok +} + +func (p *parser) parseOneOrMoreExpr(expr *oneOrMoreExpr) (interface{}, bool) { + if p.debug { + defer p.out(p.in("parseOneOrMoreExpr")) + } + + var vals []interface{} + + for { + p.pushV() + val, ok := p.parseExpr(expr.expr) + p.popV() + if !ok { + if len(vals) == 0 { + // did not match once, no match + return nil, false + } + return vals, true + } + vals = append(vals, val) + } +} + +func (p *parser) parseRecoveryExpr(recover *recoveryExpr) (interface{}, bool) { + if p.debug { + defer p.out(p.in("parseRecoveryExpr (" + strings.Join(recover.failureLabel, ",") + ")")) + } + + p.pushRecovery(recover.failureLabel, recover.recoverExpr) + val, ok := p.parseExpr(recover.expr) + p.popRecovery() + + return val, ok +} + +func (p *parser) parseRuleRefExpr(ref *ruleRefExpr) (interface{}, bool) { + if p.debug { + defer p.out(p.in("parseRuleRefExpr " + ref.name)) + } + + if ref.name == "" { + panic(fmt.Sprintf("%s: invalid rule: missing name", ref.pos)) + } + + rule := p.rules[ref.name] + if rule == nil { + p.addErr(fmt.Errorf("undefined rule: %s", ref.name)) + return nil, false + } + return p.parseRule(rule) +} + +func (p *parser) parseSeqExpr(seq *seqExpr) (interface{}, bool) { + if p.debug { + defer p.out(p.in("parseSeqExpr")) + } + + vals := make([]interface{}, 0, len(seq.exprs)) + + pt := p.pt + state := p.cloneState() + for _, expr := range seq.exprs { + val, ok := p.parseExpr(expr) + if !ok { + p.restoreState(state) + p.restore(pt) + return nil, false + } + vals = append(vals, val) + } + return vals, true +} + +func (p *parser) parseStateCodeExpr(state *stateCodeExpr) (interface{}, bool) { + if p.debug { + defer p.out(p.in("parseStateCodeExpr")) + } + + err := state.run(p) + if err != nil { + p.addErr(err) + } + return nil, true +} + +func (p *parser) parseThrowExpr(expr *throwExpr) (interface{}, bool) { + if p.debug { + defer p.out(p.in("parseThrowExpr")) + } + + for i := len(p.recoveryStack) - 1; i >= 0; i-- { + if recoverExpr, ok := p.recoveryStack[i][expr.label]; ok { + if val, ok := p.parseExpr(recoverExpr); ok { + return val, ok + } + } + } + + return nil, false +} + +func (p *parser) parseZeroOrMoreExpr(expr *zeroOrMoreExpr) (interface{}, bool) { + if p.debug { + defer p.out(p.in("parseZeroOrMoreExpr")) + } + + var vals []interface{} + + for { + p.pushV() + val, ok := p.parseExpr(expr.expr) + p.popV() + if !ok { + return vals, true + } + vals = append(vals, val) + } +} + +func (p *parser) parseZeroOrOneExpr(expr *zeroOrOneExpr) (interface{}, bool) { + if p.debug { + defer p.out(p.in("parseZeroOrOneExpr")) + } + + p.pushV() + val, _ := p.parseExpr(expr.expr) + p.popV() + // whether it matched or not, consider it a match + return val, true +} diff --git a/core/vm/sqlvm/parser/grammar.peg b/core/vm/sqlvm/parser/grammar.peg new file mode 100644 index 000000000..7f847b3c1 --- /dev/null +++ b/core/vm/sqlvm/parser/grammar.peg @@ -0,0 +1,774 @@ +{ +package parser +} + +S + <- _ x:Stmt? _ xs:( ';' _ s:Stmt? _ { return s, nil } )* EOF +{ return prepend(x, 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 } )? +{ + var ( + tableNode *ast.IdentifierNode + whereNode *ast.WhereOptionNode + limitNode *ast.LimitOptionNode + offsetNode *ast.OffsetOptionNode + ) + if table != nil { + t := table.(ast.IdentifierNode) + tableNode = &t + } + if where != nil { + w := where.(ast.WhereOptionNode) + whereNode = &w + } + if limit != nil { + l := limit.(ast.LimitOptionNode) + limitNode = &l + } + if offset != nil { + o := offset.(ast.OffsetOptionNode) + offsetNode = &o + } + return ast.SelectStmtNode{ + Column: prepend(f, fs), + Table: tableNode, + Where: whereNode, + Group: toSlice(group), + Order: toSlice(order), + Limit: limitNode, + Offset: offsetNode, + }, nil +} + +SelectColumn + = AnyLiteral + / Expr + +UpdateStmt + = UpdateToken + _ table:Identifier + _ SetToken + _ a:Assignment as:( _ SeparatorToken _ s:Assignment { return s, nil } )* + where:( _ w:WhereClause { return w, nil } )? +{ + var ( + whereNode *ast.WhereOptionNode + ) + if where != nil { + w := where.(ast.WhereOptionNode) + whereNode = &w + } + return ast.UpdateStmtNode{ + Table: table.(ast.IdentifierNode), + Assignment: prepend(a, as), + Where: whereNode, + }, nil +} + +DeleteStmt + = DeleteToken + _ FromToken + _ table:Identifier + where:( _ w:WhereClause { return w, nil } )? +{ + var ( + whereNode *ast.WhereOptionNode + ) + if where != nil { + w := where.(ast.WhereOptionNode) + whereNode = &w + } + return ast.DeleteStmtNode{ + Table: table.(ast.IdentifierNode), + Where: whereNode, + }, nil +} + +InsertStmt + = InsertToken + _ IntoToken + _ table:Identifier + _ insert:( InsertWithColumnClause / InsertWithDefaultClause ) +{ + return ast.InsertStmtNode{ + Table: table.(ast.IdentifierNode), + Insert: insert, + }, nil +} + +InsertValue + = '(' _ e:MultiExprWithDefault _ ')' +{ return e, nil } + +CreateTableStmt + = CreateToken + _ TableToken + _ table:Identifier + _ '(' + _ column:( + s:ColumnSchema + ss:( _ SeparatorToken _ t:ColumnSchema { return t, nil } )* + { return prepend(s, ss), nil } + )? + _ ')' +{ + return ast.CreateTableStmtNode{ + Table: table.(ast.IdentifierNode), + Column: toSlice(column), + }, nil +} + +ColumnSchema + = i:Identifier + _ t:DataType + cs:( _ s:ColumnConstraint { return s, nil } )* +{ + return ast.ColumnSchemaNode{ + Column: i.(ast.IdentifierNode), + DataType: t, + Constraint: toSlice(cs), + }, nil +} + +ColumnConstraint + = PrimaryKeyClause + / NotNullClause + / UniqueClause + / DefaultClause + / ForeignClause + / AutoincrementClause + +CreateIndexStmt + = CreateToken + unique:( _ u:UniqueClause { return u, nil } )? + _ IndexToken + _ index:Identifier + _ OnToken + _ table:Identifier + _ '(' _ i:Identifier is:( _ SeparatorToken _ x:Identifier { return x, nil } )* _ ')' +{ + var ( + uniqueNode *ast.UniqueOptionNode + ) + if unique != nil { + u := unique.(ast.UniqueOptionNode) + uniqueNode = &u + } + return ast.CreateIndexStmtNode{ + Index: index.(ast.IdentifierNode), + Table: table.(ast.IdentifierNode), + Column: prepend(i, is), + Unique: uniqueNode, + }, nil +} + +/* Clauses */ +WhereClause + = WhereToken _ e:Expr +{ return ast.WhereOptionNode{Condition: e}, nil } + +OrderByClause + = OrderToken + _ ByToken + _ f:OrderColumn + fs:( _ SeparatorToken _ s:OrderColumn { return s, nil } )* +{ return prepend(f, fs), nil } + +OrderColumn + = i:Expr + s:( _ t:( AscToken / DescToken ) { return t, nil } )? + n:( _ NullsToken _ l:( LastToken / FirstToken ) { return l, nil } )? +{ + return ast.OrderOptionNode{ + Expr: i, + Desc: s != nil && string(s.([]byte)) == "desc", + NullsFirst: n != nil && string(n.([]byte)) == "first", + }, nil +} + +GroupByClause + = GroupToken + _ ByToken + _ i:Expr + is:( _ SeparatorToken _ s:Expr { return ast.GroupOptionNode{Expr: s}, nil } )* +{ return prepend(ast.GroupOptionNode{Expr: i}, is), nil } + +OffsetClause + = OffsetToken _ i:Integer +{ return ast.OffsetOptionNode{Value: i.(ast.IntegerValueNode)}, nil } + +LimitClause + = LimitToken _ i:Integer +{ return ast.LimitOptionNode{Value: i.(ast.IntegerValueNode)}, nil } + +InsertWithColumnClause + = cs:( '(' + _ f:Identifier + fs:( _ SeparatorToken _ x:Identifier { return x, nil } )* + _ ')' + _ { return prepend(f, fs), nil } + )? + ValuesToken + _ v:InsertValue + vs:( _ SeparatorToken _ y:InsertValue { return y, nil } )* +{ + return ast.InsertWithColumnOptionNode{ + Column: toSlice(cs), + Value: prepend(v, vs), + }, nil +} + +InsertWithDefaultClause + = DefaultToken _ ValuesToken +{ return ast.InsertWithDefaultOptionNode{}, nil } + +PrimaryKeyClause + = PrimaryToken _ KeyToken +{ return ast.PrimaryOptionNode{}, nil } + +NotNullClause + = NotToken _ NullToken +{ return ast.NotNullOptionNode{}, nil } + +UniqueClause + = UniqueToken +{ return ast.UniqueOptionNode{}, nil } + +DefaultClause + = DefaultToken _ e:Expr +{ return ast.DefaultOptionNode{Value: e}, nil } + +ForeignClause + = ReferencesToken _ t:Identifier _ '(' _ f:Identifier _ ')' +{ + return ast.ForeignOptionNode{ + Table: t.(ast.IdentifierNode), + Column: f.(ast.IdentifierNode), + }, nil +} + +AutoincrementClause + = AutoincrementToken +{ return ast.AutoIncrementOptionNode{}, 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, s), nil } )* +{ return rightJoinOperators(o, os), nil } + +LogicExpr3 + = o:LogicExpr2 + os:( _ op:AndOperator _ s:LogicExpr2 { return opSetSubject(op, s), nil } )* +{ return rightJoinOperators(o, os), nil } + +LogicExpr2 + = op:NotOperator _ s:LogicExpr2 + { return opSetTarget(op, s), nil } + / LogicExpr1 + +LogicExpr1 + = o:ArithmeticExpr os:( _ l:LogicExpr1Op { return l, nil } )* +{ return rightJoinOperators(o, os), nil } + +LogicExpr1Op + = LogicExpr1In + / LogicExpr1Null + / LogicExpr1Like + / LogicExpr1Cmp + +LogicExpr1In + = n:( t:NotOperator _ { return t, nil } )? InToken _ '(' _ s:MultiExpr _ ')' +{ + op := opSetSubject(&ast.InOperatorNode{}, s) + if n != nil { + return opSetTarget(n, op), nil + } + return op, nil +} + +LogicExpr1Null + = IsToken n:( _ t:NotOperator { return t, nil } )? _ NullToken +{ + op := opSetSubject(&ast.IsOperatorNode{}, ast.NullValueNode{}) + if n != nil { + return opSetTarget(n, op), nil + } + return op, nil +} + +LogicExpr1Like + = n:( t:NotOperator _ { return t, nil } )? LikeToken _ s:Expr +{ + op := opSetSubject(&ast.LikeOperatorNode{}, s) + if n != nil { + return opSetTarget(n, op), nil + } + return op, nil +} + +LogicExpr1Cmp + = op:CmpOperator _ s:ArithmeticExpr +{ return opSetSubject(op, s), nil } + +ArithmeticExpr + = ArithmeticExpr3 + +ArithmeticExpr3 + = o:ArithmeticExpr2 os:( _ op:ConcatOperator _ s:ArithmeticExpr2 { return opSetSubject(op, s), nil } )* +{ return rightJoinOperators(o, os), nil } + +ArithmeticExpr2 + = o:ArithmeticExpr1 os:( _ op:AddSubOperator _ s:ArithmeticExpr1 { return opSetSubject(op, s), nil } )* +{ return rightJoinOperators(o, os), nil } + +ArithmeticExpr1 + = o:Operand os:( _ op:MulDivModOperator _ s:Operand { return opSetSubject(op, s), nil } )* +{ return rightJoinOperators(o, os), nil } + +MultiExpr + = x:Expr xs:( _ SeparatorToken _ e:Expr { return e, nil } )* +{ return prepend(x, xs), nil } + +MultiExprWithDefault + = x:ExprWithDefault xs:( _ SeparatorToken _ e:ExprWithDefault { return e, nil } )* +{ return prepend(x, xs), nil } + +Operand + = op:UnaryOperator _ s:Operand { return opSetTarget(op, s), nil } + / '(' _ e:Expr _ ')' { return e, nil } + / &(CastToken) t:TypeCast { return t, nil } + / FunctionCall + / Value + / Identifier + +TypeCast + = CastToken _ '(' _ o:Expr _ AsToken _ s:DataType _ ')' +{ return opSetSubject(opSetObject(&ast.CastOperatorNode{}, o), s), nil } + +FunctionCall + = i:Identifier _ '(' _ r:FunctionArgs? _ ')' +{ return opSetSubject(opSetObject(&ast.FunctionOperatorNode{}, i), r), nil } + +FunctionArgs + = a:AnyLiteral { return []interface{}{a}, nil } + / MultiExpr + +Assignment + = i:Identifier _ '=' _ e:ExprWithDefault +{ return opSetSubject(opSetObject(&ast.AssignOperatorNode{}, i), e), nil } + +/* Operators */ +UnaryOperator + = SignOperator + +SignOperator + = Sign +{ + switch string(c.text) { + case "+": + return &ast.PosOperatorNode{}, nil + case "-": + return &ast.NegOperatorNode{}, nil + } + return nil, errors.New("unknown sign") +} + +NotOperator + = NotToken +{ return &ast.NotOperatorNode{}, nil } + +AndOperator + = AndToken +{ return &ast.AndOperatorNode{}, nil } + +OrOperator + = OrToken +{ return &ast.OrOperatorNode{}, nil } + +CmpOperator + = ( "<=" / ">=" / "<>" / "!=" / [<>=] ) +{ + switch string(c.text) { + case "<=": + return &ast.LessOrEqualOperatorNode{}, nil + case ">=": + return &ast.GreaterOrEqualOperatorNode{}, nil + case "<>": + return &ast.NotEqualOperatorNode{}, nil + case "!=": + return &ast.NotEqualOperatorNode{}, nil + case "<": + return &ast.LessOperatorNode{}, nil + case ">": + return &ast.GreaterOperatorNode{}, nil + case "=": + return &ast.EqualOperatorNode{}, nil + } + return nil, errors.New("unknown cmp") +} + +ConcatOperator + = "||" +{ return &ast.ConcatOperatorNode{}, nil } + +AddSubOperator + = [+-] +{ + switch string(c.text) { + case "+": + return &ast.AddOperatorNode{}, nil + case "-": + return &ast.SubOperatorNode{}, nil + } + return nil, errors.New("unknown add sub") +} + +MulDivModOperator + = [*/%] +{ + switch string(c.text) { + case "*": + return &ast.MulOperatorNode{}, nil + case "/": + return &ast.DivOperatorNode{}, nil + case "%": + return &ast.ModOperatorNode{}, nil + } + return nil, errors.New("unknown mul div mod") +} + +/* Types */ +DataType + = UIntType + / IntType + / UFixedType + / FixedType + / FixedBytesType + / DynamicBytesType + / BoolType + / AddressType + +UIntType + = "UINT"i s:NonZeroLeadingInteger !NormalIdentifierRest +{ + return ast.IntTypeNode{ + Unsigned: true, + Size: toUint(s.([]byte)), + }, nil +} + +IntType + = "INT"i s:NonZeroLeadingInteger !NormalIdentifierRest +{ + return ast.IntTypeNode{ + Unsigned: false, + Size: toUint(s.([]byte)), + }, nil +} + +UFixedType + = "UFIXED"i s:NonZeroLeadingInteger "X"i t:NonZeroLeadingInteger !NormalIdentifierRest +{ + return ast.FixedTypeNode{ + Unsigned: true, + Size: toUint(s.([]byte)), + FractionalDigits: toUint(t.([]byte)), + }, nil +} + +FixedType + = "FIXED"i s:NonZeroLeadingInteger "X"i t:NonZeroLeadingInteger !NormalIdentifierRest +{ + return ast.FixedTypeNode{ + Unsigned: false, + Size: toUint(s.([]byte)), + FractionalDigits: toUint(t.([]byte)), + }, nil +} + +FixedBytesType + = "BYTES"i s:NonZeroLeadingInteger !NormalIdentifierRest +{ return ast.FixedBytesTypeNode{Size: toUint(s.([]byte))}, nil } + / "BYTE"i !NormalIdentifierRest +{ return ast.FixedBytesTypeNode{Size: 1}, nil } + +DynamicBytesType + = ( "BYTES"i !NormalIdentifierRest + / "STRING"i !NormalIdentifierRest + / "TEXT"i !NormalIdentifierRest + ) +{ return ast.DynamicBytesTypeNode{}, nil } + +AddressType + = "ADDRESS"i !NormalIdentifierRest +{ return ast.AddressTypeNode{}, nil } + +BoolType + = ( "BOOL"i !NormalIdentifierRest + / "BOOLEAN"i !NormalIdentifierRest + ) +{ return ast.BoolTypeNode{}, nil } + +/* Values */ +Value + = NumberLiteral + / StringLiteral + / BoolLiteral + / NullLiteral + +AnyLiteral + = AnyToken +{ return ast.AnyValueNode{}, nil } + +DefaultLiteral + = DefaultToken +{ return ast.DefaultValueNode{}, nil } + +BoolLiteral + = b:( TrueToken / FalseToken ) +{ return ast.BoolValueNode{V: string(b.([]byte)) == "true"}, nil } + +NullLiteral + = NullToken +{ return ast.NullValueNode{}, nil } + +NumberLiteral + = &("0" "X"i) h:Hex { return h, nil } + / Decimal + +Sign + = [-+] + +Integer + = [0-9]+ +{ return ast.IntegerValueNode{V: toDecimal(c.text)}, nil } + +NonZeroLeadingInteger + = ( "0" / [1-9][0-9]* ) +{ return c.text, nil } + +Fixnum + = Integer "." Integer + / Integer "."? + / "." Integer + +Decimal + = Fixnum ( "E"i Sign? Integer )? +{ return ast.DecimalValueNode{V: toDecimal(c.text)}, nil } + +Hex + = "0" "X"i s:( [0-9A-Fa-f] )+ !NormalIdentifierRest +{ return hexToInteger(joinBytes(s)), nil } + +StringLiteral + = HexString + / NormalString + +HexString + = ( "HEX"i / "X"i ) "'" s:([0-9a-fA-F][0-9a-fA-F] { return c.text, nil } )* "'" +{ return ast.BytesValueNode{V: hexToBytes(joinBytes(s))}, nil } + +NormalString + = "'" s:( ( [^'\r\n\\] / "\\" . ) { return c.text, nil } )* "'" +{ return ast.BytesValueNode{V: resolveString(joinBytes(s))}, 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* +{ return ast.IdentifierNode{Name: c.text}, nil } + +NormalIdentifierStart + = [a-zA-Z@#_\u0080-\uffff] + +NormalIdentifierRest + = [a-zA-Z0-9@#$_\u0080-\uffff] + +StringIdentifier + = "\"" s:( ( [^"\r\n\\] / "\\" . ) { return c.text, nil } )* "\"" +{ + return ast.IdentifierNode{Name: resolveString(joinBytes(s))}, nil +} + +/* Skip */ +_ + = ( Whitespace / Newline )* + +Newline + = "\r\n" + / "\r" + / "\n" + +Whitespace + = " " + / "\t" + / "\v" + / "\f" + +EOF + = !. diff --git a/core/vm/sqlvm/parser/parser.go b/core/vm/sqlvm/parser/parser.go new file mode 100644 index 000000000..19d5e7477 --- /dev/null +++ b/core/vm/sqlvm/parser/parser.go @@ -0,0 +1,126 @@ +package parser + +import ( + "encoding/hex" + "strconv" + "strings" + + "github.com/dexon-foundation/dexon/core/vm/sqlvm/ast" + "github.com/shopspring/decimal" +) + +// Parser was generated with pigeon v1.0.0-99-gbb0192c. +//go:generate pigeon -no-recover -o grammar.go grammar.peg +//go:generate goimports -w grammar.go + +func prepend(x interface{}, xs interface{}) []interface{} { + return append([]interface{}{x}, toSlice(xs)...) +} + +func toSlice(x interface{}) []interface{} { + if x == nil { + return nil + } + return x.([]interface{}) +} + +// TODO(wmin0): finish it. +func isAddress(h []byte) bool { + return false +} + +func hexToInteger(h []byte) interface{} { + d := decimal.Zero + l := len(h) + base := decimal.New(16, 0) + for idx, b := range h { + i, _ := strconv.ParseInt(string([]byte{b}), 16, 32) + d = d.Add( + decimal.New(i, 0). + Mul(base.Pow(decimal.New(int64(l-idx-1), 0))), + ) + } + return ast.IntegerValueNode{V: d, IsAddress: isAddress(h)} +} + +func hexToBytes(h []byte) []byte { + bs, _ := hex.DecodeString(string(h)) + return bs +} + +func toUint(b []byte) uint32 { + i, _ := strconv.ParseUint(string(b), 10, 32) + return uint32(i) +} + +func toDecimal(b []byte) decimal.Decimal { + return decimal.RequireFromString(string(b)) +} + +func toLower(b []byte) []byte { + return []byte(strings.ToLower(string(b))) +} + +func joinBytes(x interface{}) []byte { + xs := toSlice(x) + bs := []byte{} + for _, b := range xs { + bs = append(bs, b.([]byte)...) + } + return bs +} + +func opSetSubject(op interface{}, s interface{}) interface{} { + x := op.(ast.BinaryOperator) + x.SetSubject(s) + return x +} + +func opSetObject(op interface{}, o interface{}) interface{} { + x := op.(ast.BinaryOperator) + x.SetObject(o) + return x +} + +func opSetTarget(op interface{}, t interface{}) interface{} { + x := op.(ast.UnaryOperator) + x.SetTarget(t) + return x +} + +func joinOperator(x interface{}, o interface{}) { + if op, ok := x.(ast.UnaryOperator); ok { + joinOperator(op.GetTarget(), o) + return + } + if op, ok := x.(ast.BinaryOperator); ok { + op.SetObject(o) + return + } +} + +func rightJoinOperators(o interface{}, x interface{}) interface{} { + xs := toSlice(x) + if len(xs) == 0 { + return o + } + l := len(xs) + for idx := range xs { + if idx == l-1 { + break + } + joinOperator(xs[idx+1], xs[idx]) + } + joinOperator(xs[0], o) + return xs[l-1] +} + +// TODO(wmin0): finish it. +func resolveString(s []byte) []byte { + return s +} + +// ParseString parses input string to AST. +func ParseString(s string) (interface{}, error) { + return ParseReader("parser", strings.NewReader(s)) +} diff --git a/core/vm/sqlvm/parser/parser_test.go b/core/vm/sqlvm/parser/parser_test.go new file mode 100644 index 000000000..a81b1d22d --- /dev/null +++ b/core/vm/sqlvm/parser/parser_test.go @@ -0,0 +1,82 @@ +package parser + +import ( + "testing" + + "github.com/stretchr/testify/suite" +) + +type ParserTestSuite struct{ suite.Suite } + +func (s *ParserTestSuite) requireParseNoError(sql string) { + _, err := ParseString(sql) + s.Require().NoError(err) +} + +func (s *ParserTestSuite) TestParse() { + // Test stmt. + s.requireParseNoError(``) + s.requireParseNoError(`;`) + s.requireParseNoError(`;;;select 1;;;;`) + + // Test expr. + s.requireParseNoError(`select 1 + 2 * 3`) + s.requireParseNoError(`select a(1 + 1)`) + s.requireParseNoError(`select hEx'12'`) + s.requireParseNoError(`select x'12'`) + s.requireParseNoError(`select 0xABC`) + s.requireParseNoError(`select true and false or true and false or true`) + s.requireParseNoError(`SeLeCT '1' NoT LiKe '1';`) + s.requireParseNoError(`select a in (1,2) is not null not in (true)`) + s.requireParseNoError(`select count(*)`) + s.requireParseNoError(`select cast(a as fixed65535X1)`) + s.requireParseNoError(`select "now!" ( not a + b, aa( + 3 + .1 + 1. ) + - .3e-9 + 1.e-10, 'a' || 'b' and true )`) + + // Test where. + s.requireParseNoError(`select * from abc where abc is null`) + s.requireParseNoError(`select * from abc where abc is not null`) + s.requireParseNoError(`select * from abc where abc in (1, 1)`) + s.requireParseNoError(`select * from abc where abc not in (1, 1)`) + s.requireParseNoError(`select * from abc where not true`) + s.requireParseNoError(`select * from abc where a like a + 1`) + + // Test some logic expr and no from. + s.requireParseNoError(`select 1 where a is not null = b`) + s.requireParseNoError(`select 1 where null = null is null and true`) + s.requireParseNoError(`select 1 where null is null = null`) + s.requireParseNoError(`SELECT 1 + 2 WHERE 3 <> 4`) + + // Test order by. + s.requireParseNoError(`select a=b+1 from a order by a desc`) + s.requireParseNoError(`select 1 from a order by b + 1 desc`) + s.requireParseNoError(`select 1 from a order by b + 1 nulls first`) + s.requireParseNoError(`select 1 from a order by b + 1 desc nulls last`) + + // Test group by. + s.requireParseNoError(`select 1 from a group by b + 1`) + + // Test insert. + s.requireParseNoError(`insert into "abc"(a) values (f(a, b),g(a),h())`) + s.requireParseNoError(`insert into "abc"(a) values (1,2,3), (f(a, b),g(a),h())`) + s.requireParseNoError(`insert into a default values`) + s.requireParseNoError(`insert into a values (default)`) + + // Test update. + s.requireParseNoError(`update "~!@#$%^&*()" set b = default where a is null;`) + s.requireParseNoError(`update "~!@#$%^&*()" set b = default, a = 123 where a is null;`) + + // Test delete. + s.requireParseNoError(`delete from a where b is null`) + + // Test create table. + s.requireParseNoError(`create table a (a int32 not null unique primary key default 0)`) + s.requireParseNoError(`create table "~!@#$%^&*()" ( a int32 references b ( a ) , b string primary key, c address not null default 1 + 1 )`) + + // Test create index. + s.requireParseNoError(`create unique index a on a (a)`) + s.requireParseNoError(`create index "~!@#$%^&*()" on ㄅ ( a , b )`) +} + +func TestParser(t *testing.T) { + suite.Run(t, new(ParserTestSuite)) +} diff --git a/core/vm/sqlvm/parser_test.go b/core/vm/sqlvm/parser_test.go deleted file mode 100644 index e7dc18e95..000000000 --- a/core/vm/sqlvm/parser_test.go +++ /dev/null @@ -1,82 +0,0 @@ -package sqlvm - -import ( - "testing" - - "github.com/stretchr/testify/suite" -) - -type ParserTestSuite struct{ suite.Suite } - -func (s *ParserTestSuite) requireParseNoError(sql string) { - _, err := ParseString(sql) - s.Require().NoError(err) -} - -func (s *ParserTestSuite) TestParse() { - // Test stmt. - s.requireParseNoError(``) - s.requireParseNoError(`;`) - s.requireParseNoError(`;;;select 1;;;;`) - - // Test expr. - s.requireParseNoError(`select 1 + 2 * 3`) - s.requireParseNoError(`select a(1 + 1)`) - s.requireParseNoError(`select hEx'12'`) - s.requireParseNoError(`select x'12'`) - s.requireParseNoError(`select 0xABC`) - s.requireParseNoError(`select true and false or true and false or true`) - s.requireParseNoError(`SeLeCT '1' NoT LiKe '1';`) - s.requireParseNoError(`select a in (1,2) is not null not in (true)`) - s.requireParseNoError(`select count(*)`) - s.requireParseNoError(`select cast(a as fixed65535X1)`) - s.requireParseNoError(`select "now!" ( not a + b, aa( + 3 + .1 + 1. ) + - .3e-9 + 1.e-10, 'a' || 'b' and true )`) - - // Test where. - s.requireParseNoError(`select * from abc where abc is null`) - s.requireParseNoError(`select * from abc where abc is not null`) - s.requireParseNoError(`select * from abc where abc in (1, 1)`) - s.requireParseNoError(`select * from abc where abc not in (1, 1)`) - s.requireParseNoError(`select * from abc where not true`) - s.requireParseNoError(`select * from abc where a like a + 1`) - - // Test some logic expr and no from. - s.requireParseNoError(`select 1 where a is not null = b`) - s.requireParseNoError(`select 1 where null = null is null and true`) - s.requireParseNoError(`select 1 where null is null = null`) - s.requireParseNoError(`SELECT 1 + 2 WHERE 3 <> 4`) - - // Test order by. - s.requireParseNoError(`select a=b+1 from a order by a desc`) - s.requireParseNoError(`select 1 from a order by b + 1 desc`) - s.requireParseNoError(`select 1 from a order by b + 1 nulls first`) - s.requireParseNoError(`select 1 from a order by b + 1 desc nulls last`) - - // Test group by. - s.requireParseNoError(`select 1 from a group by b + 1`) - - // Test insert. - s.requireParseNoError(`insert into "abc"(a) values (f(a, b),g(a),h())`) - s.requireParseNoError(`insert into "abc"(a) values (1,2,3), (f(a, b),g(a),h())`) - s.requireParseNoError(`insert into a default values`) - s.requireParseNoError(`insert into a values (default)`) - - // Test update. - s.requireParseNoError(`update "~!@#$%^&*()" set b = default where a is null;`) - s.requireParseNoError(`update "~!@#$%^&*()" set b = default, a = 123 where a is null;`) - - // Test delete. - s.requireParseNoError(`delete from a where b is null`) - - // Test create table. - s.requireParseNoError(`create table a (a int32 not null unique primary key default 0)`) - s.requireParseNoError(`create table "~!@#$%^&*()" ( a int32 references b ( a ) , b string primary key, c address not null default 1 + 1 )`) - - // Test create index. - s.requireParseNoError(`create unique index a on a (a)`) - s.requireParseNoError(`create index "~!@#$%^&*()" on ㄅ ( a , b )`) -} - -func TestParser(t *testing.T) { - suite.Run(t, new(ParserTestSuite)) -} diff --git a/core/vm/sqlvm/type.go b/core/vm/sqlvm/type.go deleted file mode 100644 index 890b5e6ee..000000000 --- a/core/vm/sqlvm/type.go +++ /dev/null @@ -1,408 +0,0 @@ -package sqlvm - -import ( - "fmt" - "reflect" - - "github.com/shopspring/decimal" -) - -type identifierNode string - -type valuer interface { - value() interface{} -} - -type boolValueNode bool - -func (n boolValueNode) value() interface{} { return bool(n) } - -type integerValueNode struct { - v decimal.Decimal - address bool -} - -func (n integerValueNode) value() interface{} { return n.v } -func (n integerValueNode) String() string { return n.v.String() } - -type decimalValueNode decimal.Decimal - -func (n decimalValueNode) value() interface{} { return decimal.Decimal(n) } -func (n decimalValueNode) String() string { return decimal.Decimal(n).String() } - -type bytesValueNode []byte - -func (n bytesValueNode) value() interface{} { return []byte(n) } -func (n bytesValueNode) String() string { return string(n) } - -type anyValueNode struct{} - -func (n anyValueNode) value() interface{} { return n } - -type defaultValueNode struct{} - -func (n defaultValueNode) value() interface{} { return n } - -type nullValueNode struct{} - -func (n nullValueNode) value() interface{} { return n } - -type intTypeNode struct { - size int32 - unsigned bool -} - -type fixedTypeNode struct { - integerSize int32 - fractionalSize int32 - unsigned bool -} - -type dynamicBytesTypeNode struct{} - -type fixedBytesTypeNode struct { - size int32 -} - -type addressTypeNode struct{} -type boolTypeNode struct{} - -type unaryOperator interface { - getTarget() interface{} - setTarget(interface{}) -} - -type binaryOperator interface { - getObject() interface{} - getSubject() interface{} - setObject(interface{}) - setSubject(interface{}) -} - -type unaryOperatorNode struct { - target interface{} -} - -func (n unaryOperatorNode) getTarget() interface{} { - return n.target -} - -func (n *unaryOperatorNode) setTarget(t interface{}) { - n.target = t -} - -type binaryOperatorNode struct { - object interface{} - subject interface{} -} - -func (n binaryOperatorNode) getObject() interface{} { - return n.object -} - -func (n binaryOperatorNode) getSubject() interface{} { - return n.subject -} - -func (n *binaryOperatorNode) setObject(o interface{}) { - n.object = o -} - -func (n *binaryOperatorNode) setSubject(s interface{}) { - n.subject = s -} - -type posOperatorNode struct{ unaryOperatorNode } -type negOperatorNode struct{ unaryOperatorNode } -type notOperatorNode struct{ unaryOperatorNode } -type andOperatorNode struct{ binaryOperatorNode } -type orOperatorNode struct{ binaryOperatorNode } - -type greaterOrEqualOperatorNode struct{ binaryOperatorNode } -type lessOrEqualOperatorNode struct{ binaryOperatorNode } -type notEqualOperatorNode struct{ binaryOperatorNode } -type equalOperatorNode struct{ binaryOperatorNode } -type greaterOperatorNode struct{ binaryOperatorNode } -type lessOperatorNode struct{ binaryOperatorNode } - -type concatOperatorNode struct{ binaryOperatorNode } -type addOperatorNode struct{ binaryOperatorNode } -type subOperatorNode struct{ binaryOperatorNode } -type mulOperatorNode struct{ binaryOperatorNode } -type divOperatorNode struct{ binaryOperatorNode } -type modOperatorNode struct{ binaryOperatorNode } - -type inOperatorNode struct{ binaryOperatorNode } -type isOperatorNode struct{ binaryOperatorNode } -type likeOperatorNode struct{ binaryOperatorNode } - -type castOperatorNode struct{ binaryOperatorNode } -type assignOperatorNode struct{ binaryOperatorNode } -type functionOperatorNode struct{ binaryOperatorNode } - -type optional interface { - getOption() map[string]interface{} -} - -type nilOptionNode struct{} - -func (n nilOptionNode) getOption() map[string]interface{} { return nil } - -type whereOptionNode struct { - condition interface{} -} - -func (n whereOptionNode) getOption() map[string]interface{} { - return map[string]interface{}{ - "condition": n.condition, - } -} - -type orderOptionNode struct { - expr interface{} - desc bool - nullfirst bool -} - -func (n orderOptionNode) getOption() map[string]interface{} { - return map[string]interface{}{ - "expr": n.expr, - "desc": n.desc, - "nullfirst": n.nullfirst, - } -} - -type groupOptionNode struct { - expr interface{} -} - -func (n groupOptionNode) getOption() map[string]interface{} { - return map[string]interface{}{ - "expr": n.expr, - } -} - -type offsetOptionNode struct { - value integerValueNode -} - -func (n offsetOptionNode) getOption() map[string]interface{} { - return map[string]interface{}{ - "value": n.value, - } -} - -type limitOptionNode struct { - value integerValueNode -} - -func (n limitOptionNode) getOption() map[string]interface{} { - return map[string]interface{}{ - "value": n.value, - } -} - -type insertWithColumnOptionNode struct { - column []interface{} - value []interface{} -} - -func (n insertWithColumnOptionNode) getOption() map[string]interface{} { - return map[string]interface{}{ - "column": n.column, - "value": n.value, - } -} - -type insertWithDefaultOptionNode struct{ nilOptionNode } -type primaryOptionNode struct{ nilOptionNode } -type notNullOptionNode struct{ nilOptionNode } -type uniqueOptionNode struct{ nilOptionNode } -type autoincrementOptionNode struct{ nilOptionNode } - -type defaultOptionNode struct { - value interface{} -} - -func (n defaultOptionNode) getOption() map[string]interface{} { - return map[string]interface{}{ - "value": n.value, - } -} - -type foreignOptionNode struct { - table identifierNode - column identifierNode -} - -func (n foreignOptionNode) getOption() map[string]interface{} { - return map[string]interface{}{ - "table": n.table, - "column": n.column, - } -} - -type selectStmtNode struct { - column []interface{} - table *identifierNode - where *whereOptionNode - group []interface{} - order []interface{} - limit *limitOptionNode - offset *offsetOptionNode -} - -func (n selectStmtNode) getOption() map[string]interface{} { - return map[string]interface{}{ - "column": n.column, - "table": n.table, - "where": n.where, - "group": n.group, - "order": n.order, - "limit": n.limit, - "offset": n.offset, - } -} - -type updateStmtNode struct { - table identifierNode - assignment []interface{} - where *whereOptionNode -} - -func (n updateStmtNode) getOption() map[string]interface{} { - return map[string]interface{}{ - "table": n.table, - "assignment": n.assignment, - "where": n.where, - } -} - -type deleteStmtNode struct { - table identifierNode - where *whereOptionNode -} - -func (n deleteStmtNode) getOption() map[string]interface{} { - return map[string]interface{}{ - "table": n.table, - "where": n.where, - } -} - -type insertStmtNode struct { - table identifierNode - insert interface{} -} - -func (n insertStmtNode) getOption() map[string]interface{} { - return map[string]interface{}{ - "table": n.table, - "insert": n.insert, - } -} - -type createTableStmtNode struct { - table identifierNode - column []interface{} -} - -func (n createTableStmtNode) getOption() map[string]interface{} { - return map[string]interface{}{ - "table": n.table, - "column": n.column, - } -} - -type columnSchemaNode struct { - column identifierNode - dataType interface{} - constraint []interface{} -} - -func (n columnSchemaNode) getOption() map[string]interface{} { - return map[string]interface{}{ - "column": n.column, - "data_type": n.dataType, - "constraint": n.constraint, - } -} - -type createIndexStmtNode struct { - index identifierNode - table identifierNode - column []interface{} - unique *uniqueOptionNode -} - -func (n createIndexStmtNode) getOption() map[string]interface{} { - return map[string]interface{}{ - "index": n.index, - "table": n.table, - "column": n.column, - "unique": n.unique, - } -} - -// PrintAST prints ast to stdout. -func PrintAST(n interface{}, indent string) { - if n == nil { - fmt.Printf("%snil\n", indent) - return - } - typeOf := reflect.TypeOf(n) - valueOf := reflect.ValueOf(n) - name := "" - if typeOf.Kind() == reflect.Ptr { - if valueOf.IsNil() { - fmt.Printf("%snil\n", indent) - return - } - name = "*" - valueOf = valueOf.Elem() - typeOf = typeOf.Elem() - } - name = name + typeOf.Name() - - if op, ok := n.(optional); ok { - fmt.Printf("%s%s", indent, name) - m := op.getOption() - if m == nil { - fmt.Printf("\n") - return - } - fmt.Printf(":\n") - for k := range m { - fmt.Printf("%s %s:\n", indent, k) - PrintAST(m[k], indent+" ") - } - return - } - if op, ok := n.(unaryOperator); ok { - fmt.Printf("%s%s:\n", indent, name) - fmt.Printf("%s target:\n", indent) - PrintAST(op.getTarget(), indent+" ") - return - } - if op, ok := n.(binaryOperator); ok { - fmt.Printf("%s%s:\n", indent, name) - fmt.Printf("%s object:\n", indent) - PrintAST(op.getObject(), indent+" ") - fmt.Printf("%s subject:\n", indent) - PrintAST(op.getSubject(), indent+" ") - return - } - if arr, ok := n.([]interface{}); ok { - fmt.Printf("%s[\n", indent) - for idx := range arr { - PrintAST(arr[idx], indent+" ") - } - fmt.Printf("%s]\n", indent) - return - } - if stringer, ok := n.(fmt.Stringer); ok { - fmt.Printf("%s%s: %s\n", indent, name, stringer.String()) - return - } - fmt.Printf("%s%s: %+v\n", indent, name, valueOf.Interface()) -} -- cgit v1.2.3