// Code generated by pigeon; DO NOT EDIT. package ast import ( "bytes" "errors" "fmt" "io" "io/ioutil" "math" "os" "sort" "strconv" "strings" "unicode" "unicode/utf8" ) var g = &grammar{ rules: []*rule{ { name: "Program", pos: position{line: 5, col: 1, offset: 17}, expr: &actionExpr{ pos: position{line: 5, col: 12, offset: 28}, run: (*parser).callonProgram1, expr: &seqExpr{ pos: position{line: 5, col: 12, offset: 28}, exprs: []interface{}{ &ruleRefExpr{ pos: position{line: 5, col: 12, offset: 28}, name: "_", }, &labeledExpr{ pos: position{line: 5, col: 14, offset: 30}, label: "vals", expr: &zeroOrOneExpr{ pos: position{line: 5, col: 19, offset: 35}, expr: &seqExpr{ pos: position{line: 5, col: 20, offset: 36}, exprs: []interface{}{ &ruleRefExpr{ pos: position{line: 5, col: 20, offset: 36}, name: "Stmt", }, &zeroOrMoreExpr{ pos: position{line: 5, col: 25, offset: 41}, expr: &seqExpr{ pos: position{line: 5, col: 26, offset: 42}, exprs: []interface{}{ &ruleRefExpr{ pos: position{line: 5, col: 26, offset: 42}, name: "ws", }, &ruleRefExpr{ pos: position{line: 5, col: 29, offset: 45}, name: "Stmt", }, }, }, }, }, }, }, }, &ruleRefExpr{ pos: position{line: 5, col: 38, offset: 54}, name: "_", }, &ruleRefExpr{ pos: position{line: 5, col: 40, offset: 56}, name: "EOF", }, }, }, }, }, { name: "Stmt", pos: position{line: 9, col: 1, offset: 97}, expr: &actionExpr{ pos: position{line: 9, col: 9, offset: 105}, run: (*parser).callonStmt1, expr: &labeledExpr{ pos: position{line: 9, col: 9, offset: 105}, label: "val", expr: &choiceExpr{ pos: position{line: 9, col: 14, offset: 110}, alternatives: []interface{}{ &ruleRefExpr{ pos: position{line: 9, col: 14, offset: 110}, name: "Package", }, &ruleRefExpr{ pos: position{line: 9, col: 24, offset: 120}, name: "Import", }, &ruleRefExpr{ pos: position{line: 9, col: 33, offset: 129}, name: "Rules", }, &ruleRefExpr{ pos: position{line: 9, col: 41, offset: 137}, name: "Body", }, &ruleRefExpr{ pos: position{line: 9, col: 48, offset: 144}, name: "Comment", }, }, }, }, }, }, { name: "Package", pos: position{line: 13, col: 1, offset: 178}, expr: &actionExpr{ pos: position{line: 13, col: 12, offset: 189}, run: (*parser).callonPackage1, expr: &seqExpr{ pos: position{line: 13, col: 12, offset: 189}, exprs: []interface{}{ &litMatcher{ pos: position{line: 13, col: 12, offset: 189}, val: "package", ignoreCase: false, }, &ruleRefExpr{ pos: position{line: 13, col: 22, offset: 199}, name: "ws", }, &labeledExpr{ pos: position{line: 13, col: 25, offset: 202}, label: "val", expr: &choiceExpr{ pos: position{line: 13, col: 30, offset: 207}, alternatives: []interface{}{ &ruleRefExpr{ pos: position{line: 13, col: 30, offset: 207}, name: "Ref", }, &ruleRefExpr{ pos: position{line: 13, col: 36, offset: 213}, name: "Var", }, }, }, }, }, }, }, }, { name: "Import", pos: position{line: 17, col: 1, offset: 271}, expr: &actionExpr{ pos: position{line: 17, col: 11, offset: 281}, run: (*parser).callonImport1, expr: &seqExpr{ pos: position{line: 17, col: 11, offset: 281}, exprs: []interface{}{ &litMatcher{ pos: position{line: 17, col: 11, offset: 281}, val: "import", ignoreCase: false, }, &ruleRefExpr{ pos: position{line: 17, col: 20, offset: 290}, name: "ws", }, &labeledExpr{ pos: position{line: 17, col: 23, offset: 293}, label: "path", expr: &choiceExpr{ pos: position{line: 17, col: 29, offset: 299}, alternatives: []interface{}{ &ruleRefExpr{ pos: position{line: 17, col: 29, offset: 299}, name: "Ref", }, &ruleRefExpr{ pos: position{line: 17, col: 35, offset: 305}, name: "Var", }, }, }, }, &labeledExpr{ pos: position{line: 17, col: 40, offset: 310}, label: "alias", expr: &zeroOrOneExpr{ pos: position{line: 17, col: 46, offset: 316}, expr: &seqExpr{ pos: position{line: 17, col: 47, offset: 317}, exprs: []interface{}{ &ruleRefExpr{ pos: position{line: 17, col: 47, offset: 317}, name: "ws", }, &litMatcher{ pos: position{line: 17, col: 50, offset: 320}, val: "as", ignoreCase: false, }, &ruleRefExpr{ pos: position{line: 17, col: 55, offset: 325}, name: "ws", }, &ruleRefExpr{ pos: position{line: 17, col: 58, offset: 328}, name: "Var", }, }, }, }, }, }, }, }, }, { name: "Rules", pos: position{line: 21, col: 1, offset: 394}, expr: &choiceExpr{ pos: position{line: 21, col: 10, offset: 403}, alternatives: []interface{}{ &ruleRefExpr{ pos: position{line: 21, col: 10, offset: 403}, name: "DefaultRules", }, &ruleRefExpr{ pos: position{line: 21, col: 25, offset: 418}, name: "NormalRules", }, }, }, }, { name: "DefaultRules", pos: position{line: 23, col: 1, offset: 431}, expr: &actionExpr{ pos: position{line: 23, col: 17, offset: 447}, run: (*parser).callonDefaultRules1, expr: &seqExpr{ pos: position{line: 23, col: 17, offset: 447}, exprs: []interface{}{ &litMatcher{ pos: position{line: 23, col: 17, offset: 447}, val: "default", ignoreCase: false, }, &ruleRefExpr{ pos: position{line: 23, col: 27, offset: 457}, name: "ws", }, &labeledExpr{ pos: position{line: 23, col: 30, offset: 460}, label: "name", expr: &ruleRefExpr{ pos: position{line: 23, col: 35, offset: 465}, name: "Var", }, }, &ruleRefExpr{ pos: position{line: 23, col: 39, offset: 469}, name: "_", }, &labeledExpr{ pos: position{line: 23, col: 41, offset: 471}, label: "operator", expr: &choiceExpr{ pos: position{line: 23, col: 52, offset: 482}, alternatives: []interface{}{ &litMatcher{ pos: position{line: 23, col: 52, offset: 482}, val: ":=", ignoreCase: false, }, &litMatcher{ pos: position{line: 23, col: 59, offset: 489}, val: "=", ignoreCase: false, }, }, }, }, &ruleRefExpr{ pos: position{line: 23, col: 65, offset: 495}, name: "_", }, &labeledExpr{ pos: position{line: 23, col: 67, offset: 497}, label: "value", expr: &ruleRefExpr{ pos: position{line: 23, col: 73, offset: 503}, name: "Term", }, }, }, }, }, }, { name: "NormalRules", pos: position{line: 27, col: 1, offset: 583}, expr: &actionExpr{ pos: position{line: 27, col: 16, offset: 598}, run: (*parser).callonNormalRules1, expr: &seqExpr{ pos: position{line: 27, col: 16, offset: 598}, exprs: []interface{}{ &labeledExpr{ pos: position{line: 27, col: 16, offset: 598}, label: "head", expr: &choiceExpr{ pos: position{line: 27, col: 22, offset: 604}, alternatives: []interface{}{ &ruleRefExpr{ pos: position{line: 27, col: 22, offset: 604}, name: "PartialRuleHead", }, &ruleRefExpr{ pos: position{line: 27, col: 40, offset: 622}, name: "RuleHead", }, }, }, }, &ruleRefExpr{ pos: position{line: 27, col: 50, offset: 632}, name: "_", }, &labeledExpr{ pos: position{line: 27, col: 52, offset: 634}, label: "rest", expr: &seqExpr{ pos: position{line: 27, col: 58, offset: 640}, exprs: []interface{}{ &ruleRefExpr{ pos: position{line: 27, col: 58, offset: 640}, name: "NonEmptyBraceEnclosedBody", }, &zeroOrMoreExpr{ pos: position{line: 27, col: 84, offset: 666}, expr: &seqExpr{ pos: position{line: 27, col: 86, offset: 668}, exprs: []interface{}{ &ruleRefExpr{ pos: position{line: 27, col: 86, offset: 668}, name: "_", }, &ruleRefExpr{ pos: position{line: 27, col: 88, offset: 670}, name: "RuleExt", }, }, }, }, }, }, }, }, }, }, }, { name: "PartialRuleHead", pos: position{line: 31, col: 1, offset: 739}, expr: &actionExpr{ pos: position{line: 31, col: 20, offset: 758}, run: (*parser).callonPartialRuleHead1, expr: &seqExpr{ pos: position{line: 31, col: 20, offset: 758}, exprs: []interface{}{ &labeledExpr{ pos: position{line: 31, col: 20, offset: 758}, label: "name", expr: &ruleRefExpr{ pos: position{line: 31, col: 25, offset: 763}, name: "Var", }, }, &labeledExpr{ pos: position{line: 31, col: 29, offset: 767}, label: "args", expr: &seqExpr{ pos: position{line: 31, col: 36, offset: 774}, exprs: []interface{}{ &ruleRefExpr{ pos: position{line: 31, col: 36, offset: 774}, name: "_", }, &litMatcher{ pos: position{line: 31, col: 38, offset: 776}, val: "(", ignoreCase: false, }, &ruleRefExpr{ pos: position{line: 31, col: 42, offset: 780}, name: "_", }, &ruleRefExpr{ pos: position{line: 31, col: 44, offset: 782}, name: "Args", }, &ruleRefExpr{ pos: position{line: 31, col: 49, offset: 787}, name: "_", }, &litMatcher{ pos: position{line: 31, col: 51, offset: 789}, val: ")", ignoreCase: false, }, &ruleRefExpr{ pos: position{line: 31, col: 55, offset: 793}, name: "_", }, }, }, }, &labeledExpr{ pos: position{line: 31, col: 59, offset: 797}, label: "value", expr: &zeroOrOneExpr{ pos: position{line: 31, col: 65, offset: 803}, expr: &seqExpr{ pos: position{line: 31, col: 67, offset: 805}, exprs: []interface{}{ &ruleRefExpr{ pos: position{line: 31, col: 67, offset: 805}, name: "_", }, &choiceExpr{ pos: position{line: 31, col: 71, offset: 809}, alternatives: []interface{}{ &litMatcher{ pos: position{line: 31, col: 71, offset: 809}, val: ":=", ignoreCase: false, }, &litMatcher{ pos: position{line: 31, col: 78, offset: 816}, val: "=", ignoreCase: false, }, }, }, &ruleRefExpr{ pos: position{line: 31, col: 84, offset: 822}, name: "_", }, &ruleRefExpr{ pos: position{line: 31, col: 86, offset: 824}, name: "ExprTerm", }, }, }, }, }, }, }, }, }, { name: "RuleHead", pos: position{line: 35, col: 1, offset: 909}, expr: &actionExpr{ pos: position{line: 35, col: 13, offset: 921}, run: (*parser).callonRuleHead1, expr: &seqExpr{ pos: position{line: 35, col: 13, offset: 921}, exprs: []interface{}{ &labeledExpr{ pos: position{line: 35, col: 13, offset: 921}, label: "name", expr: &ruleRefExpr{ pos: position{line: 35, col: 18, offset: 926}, name: "Var", }, }, &labeledExpr{ pos: position{line: 35, col: 22, offset: 930}, label: "key", expr: &zeroOrOneExpr{ pos: position{line: 35, col: 26, offset: 934}, expr: &seqExpr{ pos: position{line: 35, col: 28, offset: 936}, exprs: []interface{}{ &ruleRefExpr{ pos: position{line: 35, col: 28, offset: 936}, name: "_", }, &litMatcher{ pos: position{line: 35, col: 30, offset: 938}, val: "[", ignoreCase: false, }, &ruleRefExpr{ pos: position{line: 35, col: 34, offset: 942}, name: "_", }, &ruleRefExpr{ pos: position{line: 35, col: 36, offset: 944}, name: "ExprTerm", }, &ruleRefExpr{ pos: position{line: 35, col: 45, offset: 953}, name: "_", }, &litMatcher{ pos: position{line: 35, col: 47, offset: 955}, val: "]", ignoreCase: false, }, &ruleRefExpr{ pos: position{line: 35, col: 51, offset: 959}, name: "_", }, }, }, }, }, &labeledExpr{ pos: position{line: 35, col: 56, offset: 964}, label: "value", expr: &zeroOrOneExpr{ pos: position{line: 35, col: 62, offset: 970}, expr: &seqExpr{ pos: position{line: 35, col: 64, offset: 972}, exprs: []interface{}{ &ruleRefExpr{ pos: position{line: 35, col: 64, offset: 972}, name: "_", }, &choiceExpr{ pos: position{line: 35, col: 68, offset: 976}, alternatives: []interface{}{ &litMatcher{ pos: position{line: 35, col: 68, offset: 976}, val: ":=", ignoreCase: false, }, &litMatcher{ pos: position{line: 35, col: 75, offset: 983}, val: "=", ignoreCase: false, }, }, }, &ruleRefExpr{ pos: position{line: 35, col: 81, offset: 989}, name: "_", }, &ruleRefExpr{ pos: position{line: 35, col: 83, offset: 991}, name: "ExprTerm", }, }, }, }, }, }, }, }, }, { name: "Args", pos: position{line: 39, col: 1, offset: 1075}, expr: &actionExpr{ pos: position{line: 39, col: 9, offset: 1083}, run: (*parser).callonArgs1, expr: &labeledExpr{ pos: position{line: 39, col: 9, offset: 1083}, label: "list", expr: &ruleRefExpr{ pos: position{line: 39, col: 14, offset: 1088}, name: "ExprTermList", }, }, }, }, { name: "Else", pos: position{line: 43, col: 1, offset: 1132}, expr: &actionExpr{ pos: position{line: 43, col: 9, offset: 1140}, run: (*parser).callonElse1, expr: &seqExpr{ pos: position{line: 43, col: 9, offset: 1140}, exprs: []interface{}{ &litMatcher{ pos: position{line: 43, col: 9, offset: 1140}, val: "else", ignoreCase: false, }, &labeledExpr{ pos: position{line: 43, col: 16, offset: 1147}, label: "value", expr: &zeroOrOneExpr{ pos: position{line: 43, col: 22, offset: 1153}, expr: &seqExpr{ pos: position{line: 43, col: 24, offset: 1155}, exprs: []interface{}{ &ruleRefExpr{ pos: position{line: 43, col: 24, offset: 1155}, name: "_", }, &litMatcher{ pos: position{line: 43, col: 26, offset: 1157}, val: "=", ignoreCase: false, }, &ruleRefExpr{ pos: position{line: 43, col: 30, offset: 1161}, name: "_", }, &ruleRefExpr{ pos: position{line: 43, col: 32, offset: 1163}, name: "Term", }, }, }, }, }, &labeledExpr{ pos: position{line: 43, col: 40, offset: 1171}, label: "body", expr: &seqExpr{ pos: position{line: 43, col: 47, offset: 1178}, exprs: []interface{}{ &ruleRefExpr{ pos: position{line: 43, col: 47, offset: 1178}, name: "_", }, &ruleRefExpr{ pos: position{line: 43, col: 49, offset: 1180}, name: "NonEmptyBraceEnclosedBody", }, }, }, }, }, }, }, }, { name: "RuleDup", pos: position{line: 47, col: 1, offset: 1269}, expr: &actionExpr{ pos: position{line: 47, col: 12, offset: 1280}, run: (*parser).callonRuleDup1, expr: &labeledExpr{ pos: position{line: 47, col: 12, offset: 1280}, label: "b", expr: &ruleRefExpr{ pos: position{line: 47, col: 14, offset: 1282}, name: "NonEmptyBraceEnclosedBody", }, }, }, }, { name: "RuleExt", pos: position{line: 51, col: 1, offset: 1378}, expr: &choiceExpr{ pos: position{line: 51, col: 12, offset: 1389}, alternatives: []interface{}{ &ruleRefExpr{ pos: position{line: 51, col: 12, offset: 1389}, name: "Else", }, &ruleRefExpr{ pos: position{line: 51, col: 19, offset: 1396}, name: "RuleDup", }, }, }, }, { name: "Body", pos: position{line: 53, col: 1, offset: 1405}, expr: &choiceExpr{ pos: position{line: 53, col: 9, offset: 1413}, alternatives: []interface{}{ &ruleRefExpr{ pos: position{line: 53, col: 9, offset: 1413}, name: "NonWhitespaceBody", }, &ruleRefExpr{ pos: position{line: 53, col: 29, offset: 1433}, name: "BraceEnclosedBody", }, }, }, }, { name: "NonEmptyBraceEnclosedBody", pos: position{line: 55, col: 1, offset: 1452}, expr: &actionExpr{ pos: position{line: 55, col: 30, offset: 1481}, run: (*parser).callonNonEmptyBraceEnclosedBody1, expr: &seqExpr{ pos: position{line: 55, col: 30, offset: 1481}, exprs: []interface{}{ &litMatcher{ pos: position{line: 55, col: 30, offset: 1481}, val: "{", ignoreCase: false, }, &ruleRefExpr{ pos: position{line: 55, col: 34, offset: 1485}, name: "_", }, &labeledExpr{ pos: position{line: 55, col: 36, offset: 1487}, label: "val", expr: &zeroOrOneExpr{ pos: position{line: 55, col: 40, offset: 1491}, expr: &ruleRefExpr{ pos: position{line: 55, col: 40, offset: 1491}, name: "WhitespaceBody", }, }, }, &ruleRefExpr{ pos: position{line: 55, col: 56, offset: 1507}, name: "_", }, &litMatcher{ pos: position{line: 55, col: 58, offset: 1509}, val: "}", ignoreCase: false, }, }, }, }, }, { name: "BraceEnclosedBody", pos: position{line: 62, col: 1, offset: 1621}, expr: &actionExpr{ pos: position{line: 62, col: 22, offset: 1642}, run: (*parser).callonBraceEnclosedBody1, expr: &seqExpr{ pos: position{line: 62, col: 22, offset: 1642}, exprs: []interface{}{ &litMatcher{ pos: position{line: 62, col: 22, offset: 1642}, val: "{", ignoreCase: false, }, &ruleRefExpr{ pos: position{line: 62, col: 26, offset: 1646}, name: "_", }, &labeledExpr{ pos: position{line: 62, col: 28, offset: 1648}, label: "val", expr: &zeroOrOneExpr{ pos: position{line: 62, col: 32, offset: 1652}, expr: &ruleRefExpr{ pos: position{line: 62, col: 32, offset: 1652}, name: "WhitespaceBody", }, }, }, &ruleRefExpr{ pos: position{line: 62, col: 48, offset: 1668}, name: "_", }, &litMatcher{ pos: position{line: 62, col: 50, offset: 1670}, val: "}", ignoreCase: false, }, }, }, }, }, { name: "WhitespaceBody", pos: position{line: 66, col: 1, offset: 1737}, expr: &actionExpr{ pos: position{line: 66, col: 19, offset: 1755}, run: (*parser).callonWhitespaceBody1, expr: &seqExpr{ pos: position{line: 66, col: 19, offset: 1755}, exprs: []interface{}{ &labeledExpr{ pos: position{line: 66, col: 19, offset: 1755}, label: "head", expr: &ruleRefExpr{ pos: position{line: 66, col: 24, offset: 1760}, name: "Literal", }, }, &labeledExpr{ pos: position{line: 66, col: 32, offset: 1768}, label: "tail", expr: &zeroOrMoreExpr{ pos: position{line: 66, col: 37, offset: 1773}, expr: &seqExpr{ pos: position{line: 66, col: 38, offset: 1774}, exprs: []interface{}{ &ruleRefExpr{ pos: position{line: 66, col: 38, offset: 1774}, name: "WhitespaceLiteralSeparator", }, &ruleRefExpr{ pos: position{line: 66, col: 65, offset: 1801}, name: "_", }, &ruleRefExpr{ pos: position{line: 66, col: 67, offset: 1803}, name: "Literal", }, }, }, }, }, }, }, }, }, { name: "NonWhitespaceBody", pos: position{line: 70, col: 1, offset: 1853}, expr: &actionExpr{ pos: position{line: 70, col: 22, offset: 1874}, run: (*parser).callonNonWhitespaceBody1, expr: &seqExpr{ pos: position{line: 70, col: 22, offset: 1874}, exprs: []interface{}{ &labeledExpr{ pos: position{line: 70, col: 22, offset: 1874}, label: "head", expr: &ruleRefExpr{ pos: position{line: 70, col: 27, offset: 1879}, name: "Literal", }, }, &labeledExpr{ pos: position{line: 70, col: 35, offset: 1887}, label: "tail", expr: &zeroOrMoreExpr{ pos: position{line: 70, col: 40, offset: 1892}, expr: &seqExpr{ pos: position{line: 70, col: 42, offset: 1894}, exprs: []interface{}{ &ruleRefExpr{ pos: position{line: 70, col: 42, offset: 1894}, name: "_", }, &ruleRefExpr{ pos: position{line: 70, col: 44, offset: 1896}, name: "NonWhitespaceLiteralSeparator", }, &ruleRefExpr{ pos: position{line: 70, col: 74, offset: 1926}, name: "_", }, &ruleRefExpr{ pos: position{line: 70, col: 76, offset: 1928}, name: "Literal", }, }, }, }, }, }, }, }, }, { name: "WhitespaceLiteralSeparator", pos: position{line: 74, col: 1, offset: 1978}, expr: &seqExpr{ pos: position{line: 74, col: 31, offset: 2008}, exprs: []interface{}{ &zeroOrMoreExpr{ pos: position{line: 74, col: 31, offset: 2008}, expr: &charClassMatcher{ pos: position{line: 74, col: 31, offset: 2008}, val: "[ \\t]", chars: []rune{' ', '\t'}, ignoreCase: false, inverted: false, }, }, &choiceExpr{ pos: position{line: 74, col: 39, offset: 2016}, alternatives: []interface{}{ &seqExpr{ pos: position{line: 74, col: 40, offset: 2017}, exprs: []interface{}{ &ruleRefExpr{ pos: position{line: 74, col: 40, offset: 2017}, name: "NonWhitespaceLiteralSeparator", }, &zeroOrOneExpr{ pos: position{line: 74, col: 70, offset: 2047}, expr: &ruleRefExpr{ pos: position{line: 74, col: 70, offset: 2047}, name: "Comment", }, }, }, }, &seqExpr{ pos: position{line: 74, col: 83, offset: 2060}, exprs: []interface{}{ &zeroOrOneExpr{ pos: position{line: 74, col: 83, offset: 2060}, expr: &ruleRefExpr{ pos: position{line: 74, col: 83, offset: 2060}, name: "Comment", }, }, &charClassMatcher{ pos: position{line: 74, col: 92, offset: 2069}, val: "[\\r\\n]", chars: []rune{'\r', '\n'}, ignoreCase: false, inverted: false, }, }, }, }, }, }, }, }, { name: "NonWhitespaceLiteralSeparator", pos: position{line: 76, col: 1, offset: 2079}, expr: &litMatcher{ pos: position{line: 76, col: 34, offset: 2112}, val: ";", ignoreCase: false, }, }, { name: "Literal", pos: position{line: 78, col: 1, offset: 2117}, expr: &choiceExpr{ pos: position{line: 78, col: 12, offset: 2128}, alternatives: []interface{}{ &ruleRefExpr{ pos: position{line: 78, col: 12, offset: 2128}, name: "TermExpr", }, &ruleRefExpr{ pos: position{line: 78, col: 23, offset: 2139}, name: "SomeDecl", }, }, }, }, { name: "SomeDecl", pos: position{line: 80, col: 1, offset: 2149}, expr: &actionExpr{ pos: position{line: 80, col: 13, offset: 2161}, run: (*parser).callonSomeDecl1, expr: &seqExpr{ pos: position{line: 80, col: 13, offset: 2161}, exprs: []interface{}{ &litMatcher{ pos: position{line: 80, col: 13, offset: 2161}, val: "some", ignoreCase: false, }, &ruleRefExpr{ pos: position{line: 80, col: 20, offset: 2168}, name: "ws", }, &labeledExpr{ pos: position{line: 80, col: 23, offset: 2171}, label: "symbols", expr: &ruleRefExpr{ pos: position{line: 80, col: 31, offset: 2179}, name: "SomeDeclList", }, }, }, }, }, }, { name: "SomeDeclList", pos: position{line: 84, col: 1, offset: 2257}, expr: &actionExpr{ pos: position{line: 84, col: 17, offset: 2273}, run: (*parser).callonSomeDeclList1, expr: &seqExpr{ pos: position{line: 84, col: 17, offset: 2273}, exprs: []interface{}{ &labeledExpr{ pos: position{line: 84, col: 17, offset: 2273}, label: "head", expr: &ruleRefExpr{ pos: position{line: 84, col: 22, offset: 2278}, name: "Var", }, }, &labeledExpr{ pos: position{line: 84, col: 26, offset: 2282}, label: "rest", expr: &zeroOrMoreExpr{ pos: position{line: 84, col: 31, offset: 2287}, expr: &seqExpr{ pos: position{line: 84, col: 33, offset: 2289}, exprs: []interface{}{ &ruleRefExpr{ pos: position{line: 84, col: 33, offset: 2289}, name: "_", }, &litMatcher{ pos: position{line: 84, col: 35, offset: 2291}, val: ",", ignoreCase: false, }, &ruleRefExpr{ pos: position{line: 84, col: 39, offset: 2295}, name: "_", }, &ruleRefExpr{ pos: position{line: 84, col: 41, offset: 2297}, name: "Var", }, }, }, }, }, }, }, }, }, { name: "TermExpr", pos: position{line: 88, col: 1, offset: 2351}, expr: &actionExpr{ pos: position{line: 88, col: 13, offset: 2363}, run: (*parser).callonTermExpr1, expr: &seqExpr{ pos: position{line: 88, col: 13, offset: 2363}, exprs: []interface{}{ &labeledExpr{ pos: position{line: 88, col: 13, offset: 2363}, label: "negated", expr: &zeroOrOneExpr{ pos: position{line: 88, col: 21, offset: 2371}, expr: &ruleRefExpr{ pos: position{line: 88, col: 21, offset: 2371}, name: "NotKeyword", }, }, }, &labeledExpr{ pos: position{line: 88, col: 33, offset: 2383}, label: "value", expr: &ruleRefExpr{ pos: position{line: 88, col: 39, offset: 2389}, name: "LiteralExpr", }, }, &labeledExpr{ pos: position{line: 88, col: 51, offset: 2401}, label: "with", expr: &zeroOrOneExpr{ pos: position{line: 88, col: 56, offset: 2406}, expr: &ruleRefExpr{ pos: position{line: 88, col: 56, offset: 2406}, name: "WithKeywordList", }, }, }, }, }, }, }, { name: "LiteralExpr", pos: position{line: 92, col: 1, offset: 2473}, expr: &actionExpr{ pos: position{line: 92, col: 16, offset: 2488}, run: (*parser).callonLiteralExpr1, expr: &seqExpr{ pos: position{line: 92, col: 16, offset: 2488}, exprs: []interface{}{ &labeledExpr{ pos: position{line: 92, col: 16, offset: 2488}, label: "lhs", expr: &ruleRefExpr{ pos: position{line: 92, col: 20, offset: 2492}, name: "ExprTerm", }, }, &labeledExpr{ pos: position{line: 92, col: 29, offset: 2501}, label: "rest", expr: &zeroOrOneExpr{ pos: position{line: 92, col: 34, offset: 2506}, expr: &seqExpr{ pos: position{line: 92, col: 36, offset: 2508}, exprs: []interface{}{ &ruleRefExpr{ pos: position{line: 92, col: 36, offset: 2508}, name: "_", }, &ruleRefExpr{ pos: position{line: 92, col: 38, offset: 2510}, name: "LiteralExprOperator", }, &ruleRefExpr{ pos: position{line: 92, col: 58, offset: 2530}, name: "_", }, &ruleRefExpr{ pos: position{line: 92, col: 60, offset: 2532}, name: "ExprTerm", }, }, }, }, }, }, }, }, }, { name: "LiteralExprOperator", pos: position{line: 96, col: 1, offset: 2606}, expr: &actionExpr{ pos: position{line: 96, col: 24, offset: 2629}, run: (*parser).callonLiteralExprOperator1, expr: &labeledExpr{ pos: position{line: 96, col: 24, offset: 2629}, label: "val", expr: &choiceExpr{ pos: position{line: 96, col: 30, offset: 2635}, alternatives: []interface{}{ &litMatcher{ pos: position{line: 96, col: 30, offset: 2635}, val: ":=", ignoreCase: false, }, &litMatcher{ pos: position{line: 96, col: 37, offset: 2642}, val: "=", ignoreCase: false, }, }, }, }, }, }, { name: "NotKeyword", pos: position{line: 100, col: 1, offset: 2710}, expr: &actionExpr{ pos: position{line: 100, col: 15, offset: 2724}, run: (*parser).callonNotKeyword1, expr: &labeledExpr{ pos: position{line: 100, col: 15, offset: 2724}, label: "val", expr: &zeroOrOneExpr{ pos: position{line: 100, col: 19, offset: 2728}, expr: &seqExpr{ pos: position{line: 100, col: 20, offset: 2729}, exprs: []interface{}{ &litMatcher{ pos: position{line: 100, col: 20, offset: 2729}, val: "not", ignoreCase: false, }, &ruleRefExpr{ pos: position{line: 100, col: 26, offset: 2735}, name: "ws", }, }, }, }, }, }, }, { name: "WithKeywordList", pos: position{line: 104, col: 1, offset: 2772}, expr: &actionExpr{ pos: position{line: 104, col: 20, offset: 2791}, run: (*parser).callonWithKeywordList1, expr: &seqExpr{ pos: position{line: 104, col: 20, offset: 2791}, exprs: []interface{}{ &ruleRefExpr{ pos: position{line: 104, col: 20, offset: 2791}, name: "ws", }, &labeledExpr{ pos: position{line: 104, col: 23, offset: 2794}, label: "head", expr: &ruleRefExpr{ pos: position{line: 104, col: 28, offset: 2799}, name: "WithKeyword", }, }, &labeledExpr{ pos: position{line: 104, col: 40, offset: 2811}, label: "rest", expr: &zeroOrMoreExpr{ pos: position{line: 104, col: 45, offset: 2816}, expr: &seqExpr{ pos: position{line: 104, col: 47, offset: 2818}, exprs: []interface{}{ &ruleRefExpr{ pos: position{line: 104, col: 47, offset: 2818}, name: "ws", }, &ruleRefExpr{ pos: position{line: 104, col: 50, offset: 2821}, name: "WithKeyword", }, }, }, }, }, }, }, }, }, { name: "WithKeyword", pos: position{line: 108, col: 1, offset: 2884}, expr: &actionExpr{ pos: position{line: 108, col: 16, offset: 2899}, run: (*parser).callonWithKeyword1, expr: &seqExpr{ pos: position{line: 108, col: 16, offset: 2899}, exprs: []interface{}{ &litMatcher{ pos: position{line: 108, col: 16, offset: 2899}, val: "with", ignoreCase: false, }, &ruleRefExpr{ pos: position{line: 108, col: 23, offset: 2906}, name: "ws", }, &labeledExpr{ pos: position{line: 108, col: 26, offset: 2909}, label: "target", expr: &ruleRefExpr{ pos: position{line: 108, col: 33, offset: 2916}, name: "ExprTerm", }, }, &ruleRefExpr{ pos: position{line: 108, col: 42, offset: 2925}, name: "ws", }, &litMatcher{ pos: position{line: 108, col: 45, offset: 2928}, val: "as", ignoreCase: false, }, &ruleRefExpr{ pos: position{line: 108, col: 50, offset: 2933}, name: "ws", }, &labeledExpr{ pos: position{line: 108, col: 53, offset: 2936}, label: "value", expr: &ruleRefExpr{ pos: position{line: 108, col: 59, offset: 2942}, name: "ExprTerm", }, }, }, }, }, }, { name: "ExprTerm", pos: position{line: 112, col: 1, offset: 3018}, expr: &actionExpr{ pos: position{line: 112, col: 13, offset: 3030}, run: (*parser).callonExprTerm1, expr: &seqExpr{ pos: position{line: 112, col: 13, offset: 3030}, exprs: []interface{}{ &labeledExpr{ pos: position{line: 112, col: 13, offset: 3030}, label: "lhs", expr: &ruleRefExpr{ pos: position{line: 112, col: 17, offset: 3034}, name: "RelationExpr", }, }, &labeledExpr{ pos: position{line: 112, col: 30, offset: 3047}, label: "rest", expr: &zeroOrMoreExpr{ pos: position{line: 112, col: 35, offset: 3052}, expr: &seqExpr{ pos: position{line: 112, col: 37, offset: 3054}, exprs: []interface{}{ &ruleRefExpr{ pos: position{line: 112, col: 37, offset: 3054}, name: "_", }, &ruleRefExpr{ pos: position{line: 112, col: 39, offset: 3056}, name: "RelationOperator", }, &ruleRefExpr{ pos: position{line: 112, col: 56, offset: 3073}, name: "_", }, &ruleRefExpr{ pos: position{line: 112, col: 58, offset: 3075}, name: "RelationExpr", }, }, }, }, }, }, }, }, }, { name: "ExprTermPairList", pos: position{line: 116, col: 1, offset: 3151}, expr: &actionExpr{ pos: position{line: 116, col: 21, offset: 3171}, run: (*parser).callonExprTermPairList1, expr: &seqExpr{ pos: position{line: 116, col: 21, offset: 3171}, exprs: []interface{}{ &labeledExpr{ pos: position{line: 116, col: 21, offset: 3171}, label: "head", expr: &zeroOrOneExpr{ pos: position{line: 116, col: 26, offset: 3176}, expr: &ruleRefExpr{ pos: position{line: 116, col: 26, offset: 3176}, name: "ExprTermPair", }, }, }, &labeledExpr{ pos: position{line: 116, col: 40, offset: 3190}, label: "tail", expr: &zeroOrMoreExpr{ pos: position{line: 116, col: 45, offset: 3195}, expr: &seqExpr{ pos: position{line: 116, col: 47, offset: 3197}, exprs: []interface{}{ &ruleRefExpr{ pos: position{line: 116, col: 47, offset: 3197}, name: "_", }, &litMatcher{ pos: position{line: 116, col: 49, offset: 3199}, val: ",", ignoreCase: false, }, &ruleRefExpr{ pos: position{line: 116, col: 53, offset: 3203}, name: "_", }, &ruleRefExpr{ pos: position{line: 116, col: 55, offset: 3205}, name: "ExprTermPair", }, }, }, }, }, &ruleRefExpr{ pos: position{line: 116, col: 71, offset: 3221}, name: "_", }, &zeroOrOneExpr{ pos: position{line: 116, col: 73, offset: 3223}, expr: &litMatcher{ pos: position{line: 116, col: 73, offset: 3223}, val: ",", ignoreCase: false, }, }, }, }, }, }, { name: "ExprTermList", pos: position{line: 120, col: 1, offset: 3277}, expr: &actionExpr{ pos: position{line: 120, col: 17, offset: 3293}, run: (*parser).callonExprTermList1, expr: &seqExpr{ pos: position{line: 120, col: 17, offset: 3293}, exprs: []interface{}{ &labeledExpr{ pos: position{line: 120, col: 17, offset: 3293}, label: "head", expr: &zeroOrOneExpr{ pos: position{line: 120, col: 22, offset: 3298}, expr: &ruleRefExpr{ pos: position{line: 120, col: 22, offset: 3298}, name: "ExprTerm", }, }, }, &labeledExpr{ pos: position{line: 120, col: 32, offset: 3308}, label: "tail", expr: &zeroOrMoreExpr{ pos: position{line: 120, col: 37, offset: 3313}, expr: &seqExpr{ pos: position{line: 120, col: 39, offset: 3315}, exprs: []interface{}{ &ruleRefExpr{ pos: position{line: 120, col: 39, offset: 3315}, name: "_", }, &litMatcher{ pos: position{line: 120, col: 41, offset: 3317}, val: ",", ignoreCase: false, }, &ruleRefExpr{ pos: position{line: 120, col: 45, offset: 3321}, name: "_", }, &ruleRefExpr{ pos: position{line: 120, col: 47, offset: 3323}, name: "ExprTerm", }, }, }, }, }, &ruleRefExpr{ pos: position{line: 120, col: 59, offset: 3335}, name: "_", }, &zeroOrOneExpr{ pos: position{line: 120, col: 61, offset: 3337}, expr: &litMatcher{ pos: position{line: 120, col: 61, offset: 3337}, val: ",", ignoreCase: false, }, }, }, }, }, }, { name: "ExprTermPair", pos: position{line: 124, col: 1, offset: 3388}, expr: &actionExpr{ pos: position{line: 124, col: 17, offset: 3404}, run: (*parser).callonExprTermPair1, expr: &seqExpr{ pos: position{line: 124, col: 17, offset: 3404}, exprs: []interface{}{ &labeledExpr{ pos: position{line: 124, col: 17, offset: 3404}, label: "key", expr: &ruleRefExpr{ pos: position{line: 124, col: 21, offset: 3408}, name: "ExprTerm", }, }, &ruleRefExpr{ pos: position{line: 124, col: 30, offset: 3417}, name: "_", }, &litMatcher{ pos: position{line: 124, col: 32, offset: 3419}, val: ":", ignoreCase: false, }, &ruleRefExpr{ pos: position{line: 124, col: 36, offset: 3423}, name: "_", }, &labeledExpr{ pos: position{line: 124, col: 38, offset: 3425}, label: "value", expr: &ruleRefExpr{ pos: position{line: 124, col: 44, offset: 3431}, name: "ExprTerm", }, }, }, }, }, }, { name: "RelationOperator", pos: position{line: 128, col: 1, offset: 3485}, expr: &actionExpr{ pos: position{line: 128, col: 21, offset: 3505}, run: (*parser).callonRelationOperator1, expr: &labeledExpr{ pos: position{line: 128, col: 21, offset: 3505}, label: "val", expr: &choiceExpr{ pos: position{line: 128, col: 26, offset: 3510}, alternatives: []interface{}{ &litMatcher{ pos: position{line: 128, col: 26, offset: 3510}, val: "==", ignoreCase: false, }, &litMatcher{ pos: position{line: 128, col: 33, offset: 3517}, val: "!=", ignoreCase: false, }, &litMatcher{ pos: position{line: 128, col: 40, offset: 3524}, val: "<=", ignoreCase: false, }, &litMatcher{ pos: position{line: 128, col: 47, offset: 3531}, val: ">=", ignoreCase: false, }, &litMatcher{ pos: position{line: 128, col: 54, offset: 3538}, val: ">", ignoreCase: false, }, &litMatcher{ pos: position{line: 128, col: 60, offset: 3544}, val: "<", ignoreCase: false, }, }, }, }, }, }, { name: "RelationExpr", pos: position{line: 132, col: 1, offset: 3611}, expr: &actionExpr{ pos: position{line: 132, col: 17, offset: 3627}, run: (*parser).callonRelationExpr1, expr: &seqExpr{ pos: position{line: 132, col: 17, offset: 3627}, exprs: []interface{}{ &labeledExpr{ pos: position{line: 132, col: 17, offset: 3627}, label: "lhs", expr: &ruleRefExpr{ pos: position{line: 132, col: 21, offset: 3631}, name: "BitwiseOrExpr", }, }, &labeledExpr{ pos: position{line: 132, col: 35, offset: 3645}, label: "rest", expr: &zeroOrMoreExpr{ pos: position{line: 132, col: 40, offset: 3650}, expr: &seqExpr{ pos: position{line: 132, col: 42, offset: 3652}, exprs: []interface{}{ &ruleRefExpr{ pos: position{line: 132, col: 42, offset: 3652}, name: "_", }, &ruleRefExpr{ pos: position{line: 132, col: 44, offset: 3654}, name: "BitwiseOrOperator", }, &ruleRefExpr{ pos: position{line: 132, col: 62, offset: 3672}, name: "_", }, &ruleRefExpr{ pos: position{line: 132, col: 64, offset: 3674}, name: "BitwiseOrExpr", }, }, }, }, }, }, }, }, }, { name: "BitwiseOrOperator", pos: position{line: 136, col: 1, offset: 3750}, expr: &actionExpr{ pos: position{line: 136, col: 22, offset: 3771}, run: (*parser).callonBitwiseOrOperator1, expr: &labeledExpr{ pos: position{line: 136, col: 22, offset: 3771}, label: "val", expr: &litMatcher{ pos: position{line: 136, col: 26, offset: 3775}, val: "|", ignoreCase: false, }, }, }, }, { name: "BitwiseOrExpr", pos: position{line: 140, col: 1, offset: 3841}, expr: &actionExpr{ pos: position{line: 140, col: 18, offset: 3858}, run: (*parser).callonBitwiseOrExpr1, expr: &seqExpr{ pos: position{line: 140, col: 18, offset: 3858}, exprs: []interface{}{ &labeledExpr{ pos: position{line: 140, col: 18, offset: 3858}, label: "lhs", expr: &ruleRefExpr{ pos: position{line: 140, col: 22, offset: 3862}, name: "BitwiseAndExpr", }, }, &labeledExpr{ pos: position{line: 140, col: 37, offset: 3877}, label: "rest", expr: &zeroOrMoreExpr{ pos: position{line: 140, col: 42, offset: 3882}, expr: &seqExpr{ pos: position{line: 140, col: 44, offset: 3884}, exprs: []interface{}{ &ruleRefExpr{ pos: position{line: 140, col: 44, offset: 3884}, name: "_", }, &ruleRefExpr{ pos: position{line: 140, col: 46, offset: 3886}, name: "BitwiseAndOperator", }, &ruleRefExpr{ pos: position{line: 140, col: 65, offset: 3905}, name: "_", }, &ruleRefExpr{ pos: position{line: 140, col: 67, offset: 3907}, name: "BitwiseAndExpr", }, }, }, }, }, }, }, }, }, { name: "BitwiseAndOperator", pos: position{line: 144, col: 1, offset: 3984}, expr: &actionExpr{ pos: position{line: 144, col: 23, offset: 4006}, run: (*parser).callonBitwiseAndOperator1, expr: &labeledExpr{ pos: position{line: 144, col: 23, offset: 4006}, label: "val", expr: &litMatcher{ pos: position{line: 144, col: 27, offset: 4010}, val: "&", ignoreCase: false, }, }, }, }, { name: "BitwiseAndExpr", pos: position{line: 148, col: 1, offset: 4076}, expr: &actionExpr{ pos: position{line: 148, col: 19, offset: 4094}, run: (*parser).callonBitwiseAndExpr1, expr: &seqExpr{ pos: position{line: 148, col: 19, offset: 4094}, exprs: []interface{}{ &labeledExpr{ pos: position{line: 148, col: 19, offset: 4094}, label: "lhs", expr: &ruleRefExpr{ pos: position{line: 148, col: 23, offset: 4098}, name: "ArithExpr", }, }, &labeledExpr{ pos: position{line: 148, col: 33, offset: 4108}, label: "rest", expr: &zeroOrMoreExpr{ pos: position{line: 148, col: 38, offset: 4113}, expr: &seqExpr{ pos: position{line: 148, col: 40, offset: 4115}, exprs: []interface{}{ &ruleRefExpr{ pos: position{line: 148, col: 40, offset: 4115}, name: "_", }, &ruleRefExpr{ pos: position{line: 148, col: 42, offset: 4117}, name: "ArithOperator", }, &ruleRefExpr{ pos: position{line: 148, col: 56, offset: 4131}, name: "_", }, &ruleRefExpr{ pos: position{line: 148, col: 58, offset: 4133}, name: "ArithExpr", }, }, }, }, }, }, }, }, }, { name: "ArithOperator", pos: position{line: 152, col: 1, offset: 4205}, expr: &actionExpr{ pos: position{line: 152, col: 18, offset: 4222}, run: (*parser).callonArithOperator1, expr: &labeledExpr{ pos: position{line: 152, col: 18, offset: 4222}, label: "val", expr: &choiceExpr{ pos: position{line: 152, col: 23, offset: 4227}, alternatives: []interface{}{ &litMatcher{ pos: position{line: 152, col: 23, offset: 4227}, val: "+", ignoreCase: false, }, &litMatcher{ pos: position{line: 152, col: 29, offset: 4233}, val: "-", ignoreCase: false, }, }, }, }, }, }, { name: "ArithExpr", pos: position{line: 156, col: 1, offset: 4300}, expr: &actionExpr{ pos: position{line: 156, col: 14, offset: 4313}, run: (*parser).callonArithExpr1, expr: &seqExpr{ pos: position{line: 156, col: 14, offset: 4313}, exprs: []interface{}{ &labeledExpr{ pos: position{line: 156, col: 14, offset: 4313}, label: "lhs", expr: &ruleRefExpr{ pos: position{line: 156, col: 18, offset: 4317}, name: "FactorExpr", }, }, &labeledExpr{ pos: position{line: 156, col: 29, offset: 4328}, label: "rest", expr: &zeroOrMoreExpr{ pos: position{line: 156, col: 34, offset: 4333}, expr: &seqExpr{ pos: position{line: 156, col: 36, offset: 4335}, exprs: []interface{}{ &ruleRefExpr{ pos: position{line: 156, col: 36, offset: 4335}, name: "_", }, &ruleRefExpr{ pos: position{line: 156, col: 38, offset: 4337}, name: "FactorOperator", }, &ruleRefExpr{ pos: position{line: 156, col: 53, offset: 4352}, name: "_", }, &ruleRefExpr{ pos: position{line: 156, col: 55, offset: 4354}, name: "FactorExpr", }, }, }, }, }, }, }, }, }, { name: "FactorOperator", pos: position{line: 160, col: 1, offset: 4428}, expr: &actionExpr{ pos: position{line: 160, col: 19, offset: 4446}, run: (*parser).callonFactorOperator1, expr: &labeledExpr{ pos: position{line: 160, col: 19, offset: 4446}, label: "val", expr: &choiceExpr{ pos: position{line: 160, col: 24, offset: 4451}, alternatives: []interface{}{ &litMatcher{ pos: position{line: 160, col: 24, offset: 4451}, val: "*", ignoreCase: false, }, &litMatcher{ pos: position{line: 160, col: 30, offset: 4457}, val: "/", ignoreCase: false, }, &litMatcher{ pos: position{line: 160, col: 36, offset: 4463}, val: "%", ignoreCase: false, }, }, }, }, }, }, { name: "FactorExpr", pos: position{line: 164, col: 1, offset: 4529}, expr: &choiceExpr{ pos: position{line: 164, col: 15, offset: 4543}, alternatives: []interface{}{ &actionExpr{ pos: position{line: 164, col: 15, offset: 4543}, run: (*parser).callonFactorExpr2, expr: &seqExpr{ pos: position{line: 164, col: 17, offset: 4545}, exprs: []interface{}{ &litMatcher{ pos: position{line: 164, col: 17, offset: 4545}, val: "(", ignoreCase: false, }, &ruleRefExpr{ pos: position{line: 164, col: 21, offset: 4549}, name: "_", }, &labeledExpr{ pos: position{line: 164, col: 23, offset: 4551}, label: "expr", expr: &ruleRefExpr{ pos: position{line: 164, col: 28, offset: 4556}, name: "ExprTerm", }, }, &ruleRefExpr{ pos: position{line: 164, col: 37, offset: 4565}, name: "_", }, &litMatcher{ pos: position{line: 164, col: 39, offset: 4567}, val: ")", ignoreCase: false, }, }, }, }, &actionExpr{ pos: position{line: 166, col: 5, offset: 4600}, run: (*parser).callonFactorExpr10, expr: &labeledExpr{ pos: position{line: 166, col: 5, offset: 4600}, label: "term", expr: &ruleRefExpr{ pos: position{line: 166, col: 10, offset: 4605}, name: "Term", }, }, }, }, }, }, { name: "Call", pos: position{line: 170, col: 1, offset: 4636}, expr: &actionExpr{ pos: position{line: 170, col: 9, offset: 4644}, run: (*parser).callonCall1, expr: &seqExpr{ pos: position{line: 170, col: 9, offset: 4644}, exprs: []interface{}{ &labeledExpr{ pos: position{line: 170, col: 9, offset: 4644}, label: "operator", expr: &choiceExpr{ pos: position{line: 170, col: 19, offset: 4654}, alternatives: []interface{}{ &ruleRefExpr{ pos: position{line: 170, col: 19, offset: 4654}, name: "Ref", }, &ruleRefExpr{ pos: position{line: 170, col: 25, offset: 4660}, name: "Var", }, }, }, }, &litMatcher{ pos: position{line: 170, col: 30, offset: 4665}, val: "(", ignoreCase: false, }, &ruleRefExpr{ pos: position{line: 170, col: 34, offset: 4669}, name: "_", }, &labeledExpr{ pos: position{line: 170, col: 36, offset: 4671}, label: "args", expr: &ruleRefExpr{ pos: position{line: 170, col: 41, offset: 4676}, name: "ExprTermList", }, }, &ruleRefExpr{ pos: position{line: 170, col: 54, offset: 4689}, name: "_", }, &litMatcher{ pos: position{line: 170, col: 56, offset: 4691}, val: ")", ignoreCase: false, }, }, }, }, }, { name: "Term", pos: position{line: 174, col: 1, offset: 4756}, expr: &actionExpr{ pos: position{line: 174, col: 9, offset: 4764}, run: (*parser).callonTerm1, expr: &seqExpr{ pos: position{line: 174, col: 9, offset: 4764}, exprs: []interface{}{ &labeledExpr{ pos: position{line: 174, col: 9, offset: 4764}, label: "val", expr: &choiceExpr{ pos: position{line: 174, col: 15, offset: 4770}, alternatives: []interface{}{ &ruleRefExpr{ pos: position{line: 174, col: 15, offset: 4770}, name: "Comprehension", }, &ruleRefExpr{ pos: position{line: 174, col: 31, offset: 4786}, name: "Composite", }, &ruleRefExpr{ pos: position{line: 174, col: 43, offset: 4798}, name: "Scalar", }, &ruleRefExpr{ pos: position{line: 174, col: 52, offset: 4807}, name: "Call", }, &ruleRefExpr{ pos: position{line: 174, col: 59, offset: 4814}, name: "Var", }, }, }, }, &labeledExpr{ pos: position{line: 174, col: 65, offset: 4820}, label: "refs", expr: &zeroOrMoreExpr{ pos: position{line: 174, col: 70, offset: 4825}, expr: &ruleRefExpr{ pos: position{line: 174, col: 70, offset: 4825}, name: "RefOperand", }, }, }, }, }, }, }, { name: "TermPair", pos: position{line: 178, col: 1, offset: 4892}, expr: &actionExpr{ pos: position{line: 178, col: 13, offset: 4904}, run: (*parser).callonTermPair1, expr: &seqExpr{ pos: position{line: 178, col: 13, offset: 4904}, exprs: []interface{}{ &labeledExpr{ pos: position{line: 178, col: 13, offset: 4904}, label: "key", expr: &ruleRefExpr{ pos: position{line: 178, col: 17, offset: 4908}, name: "Term", }, }, &ruleRefExpr{ pos: position{line: 178, col: 22, offset: 4913}, name: "_", }, &litMatcher{ pos: position{line: 178, col: 24, offset: 4915}, val: ":", ignoreCase: false, }, &ruleRefExpr{ pos: position{line: 178, col: 28, offset: 4919}, name: "_", }, &labeledExpr{ pos: position{line: 178, col: 30, offset: 4921}, label: "value", expr: &ruleRefExpr{ pos: position{line: 178, col: 36, offset: 4927}, name: "Term", }, }, }, }, }, }, { name: "Comprehension", pos: position{line: 182, col: 1, offset: 4977}, expr: &choiceExpr{ pos: position{line: 182, col: 18, offset: 4994}, alternatives: []interface{}{ &ruleRefExpr{ pos: position{line: 182, col: 18, offset: 4994}, name: "ArrayComprehension", }, &ruleRefExpr{ pos: position{line: 182, col: 39, offset: 5015}, name: "ObjectComprehension", }, &ruleRefExpr{ pos: position{line: 182, col: 61, offset: 5037}, name: "SetComprehension", }, }, }, }, { name: "ArrayComprehension", pos: position{line: 184, col: 1, offset: 5055}, expr: &actionExpr{ pos: position{line: 184, col: 23, offset: 5077}, run: (*parser).callonArrayComprehension1, expr: &seqExpr{ pos: position{line: 184, col: 23, offset: 5077}, exprs: []interface{}{ &litMatcher{ pos: position{line: 184, col: 23, offset: 5077}, val: "[", ignoreCase: false, }, &ruleRefExpr{ pos: position{line: 184, col: 27, offset: 5081}, name: "_", }, &labeledExpr{ pos: position{line: 184, col: 29, offset: 5083}, label: "head", expr: &ruleRefExpr{ pos: position{line: 184, col: 34, offset: 5088}, name: "Term", }, }, &ruleRefExpr{ pos: position{line: 184, col: 39, offset: 5093}, name: "_", }, &litMatcher{ pos: position{line: 184, col: 41, offset: 5095}, val: "|", ignoreCase: false, }, &ruleRefExpr{ pos: position{line: 184, col: 45, offset: 5099}, name: "_", }, &labeledExpr{ pos: position{line: 184, col: 47, offset: 5101}, label: "body", expr: &ruleRefExpr{ pos: position{line: 184, col: 52, offset: 5106}, name: "WhitespaceBody", }, }, &ruleRefExpr{ pos: position{line: 184, col: 67, offset: 5121}, name: "_", }, &litMatcher{ pos: position{line: 184, col: 69, offset: 5123}, val: "]", ignoreCase: false, }, }, }, }, }, { name: "ObjectComprehension", pos: position{line: 188, col: 1, offset: 5198}, expr: &actionExpr{ pos: position{line: 188, col: 24, offset: 5221}, run: (*parser).callonObjectComprehension1, expr: &seqExpr{ pos: position{line: 188, col: 24, offset: 5221}, exprs: []interface{}{ &litMatcher{ pos: position{line: 188, col: 24, offset: 5221}, val: "{", ignoreCase: false, }, &ruleRefExpr{ pos: position{line: 188, col: 28, offset: 5225}, name: "_", }, &labeledExpr{ pos: position{line: 188, col: 30, offset: 5227}, label: "head", expr: &ruleRefExpr{ pos: position{line: 188, col: 35, offset: 5232}, name: "TermPair", }, }, &ruleRefExpr{ pos: position{line: 188, col: 45, offset: 5242}, name: "_", }, &litMatcher{ pos: position{line: 188, col: 47, offset: 5244}, val: "|", ignoreCase: false, }, &ruleRefExpr{ pos: position{line: 188, col: 51, offset: 5248}, name: "_", }, &labeledExpr{ pos: position{line: 188, col: 53, offset: 5250}, label: "body", expr: &ruleRefExpr{ pos: position{line: 188, col: 58, offset: 5255}, name: "WhitespaceBody", }, }, &ruleRefExpr{ pos: position{line: 188, col: 73, offset: 5270}, name: "_", }, &litMatcher{ pos: position{line: 188, col: 75, offset: 5272}, val: "}", ignoreCase: false, }, }, }, }, }, { name: "SetComprehension", pos: position{line: 192, col: 1, offset: 5348}, expr: &actionExpr{ pos: position{line: 192, col: 21, offset: 5368}, run: (*parser).callonSetComprehension1, expr: &seqExpr{ pos: position{line: 192, col: 21, offset: 5368}, exprs: []interface{}{ &litMatcher{ pos: position{line: 192, col: 21, offset: 5368}, val: "{", ignoreCase: false, }, &ruleRefExpr{ pos: position{line: 192, col: 25, offset: 5372}, name: "_", }, &labeledExpr{ pos: position{line: 192, col: 27, offset: 5374}, label: "head", expr: &ruleRefExpr{ pos: position{line: 192, col: 32, offset: 5379}, name: "Term", }, }, &ruleRefExpr{ pos: position{line: 192, col: 37, offset: 5384}, name: "_", }, &litMatcher{ pos: position{line: 192, col: 39, offset: 5386}, val: "|", ignoreCase: false, }, &ruleRefExpr{ pos: position{line: 192, col: 43, offset: 5390}, name: "_", }, &labeledExpr{ pos: position{line: 192, col: 45, offset: 5392}, label: "body", expr: &ruleRefExpr{ pos: position{line: 192, col: 50, offset: 5397}, name: "WhitespaceBody", }, }, &ruleRefExpr{ pos: position{line: 192, col: 65, offset: 5412}, name: "_", }, &litMatcher{ pos: position{line: 192, col: 67, offset: 5414}, val: "}", ignoreCase: false, }, }, }, }, }, { name: "Composite", pos: position{line: 196, col: 1, offset: 5487}, expr: &choiceExpr{ pos: position{line: 196, col: 14, offset: 5500}, alternatives: []interface{}{ &ruleRefExpr{ pos: position{line: 196, col: 14, offset: 5500}, name: "Object", }, &ruleRefExpr{ pos: position{line: 196, col: 23, offset: 5509}, name: "Array", }, &ruleRefExpr{ pos: position{line: 196, col: 31, offset: 5517}, name: "Set", }, }, }, }, { name: "Scalar", pos: position{line: 198, col: 1, offset: 5522}, expr: &choiceExpr{ pos: position{line: 198, col: 11, offset: 5532}, alternatives: []interface{}{ &ruleRefExpr{ pos: position{line: 198, col: 11, offset: 5532}, name: "Number", }, &ruleRefExpr{ pos: position{line: 198, col: 20, offset: 5541}, name: "String", }, &ruleRefExpr{ pos: position{line: 198, col: 29, offset: 5550}, name: "Bool", }, &ruleRefExpr{ pos: position{line: 198, col: 36, offset: 5557}, name: "Null", }, }, }, }, { name: "Object", pos: position{line: 200, col: 1, offset: 5563}, expr: &actionExpr{ pos: position{line: 200, col: 11, offset: 5573}, run: (*parser).callonObject1, expr: &seqExpr{ pos: position{line: 200, col: 11, offset: 5573}, exprs: []interface{}{ &litMatcher{ pos: position{line: 200, col: 11, offset: 5573}, val: "{", ignoreCase: false, }, &ruleRefExpr{ pos: position{line: 200, col: 15, offset: 5577}, name: "_", }, &labeledExpr{ pos: position{line: 200, col: 17, offset: 5579}, label: "list", expr: &ruleRefExpr{ pos: position{line: 200, col: 22, offset: 5584}, name: "ExprTermPairList", }, }, &ruleRefExpr{ pos: position{line: 200, col: 39, offset: 5601}, name: "_", }, &litMatcher{ pos: position{line: 200, col: 41, offset: 5603}, val: "}", ignoreCase: false, }, }, }, }, }, { name: "Array", pos: position{line: 204, col: 1, offset: 5660}, expr: &actionExpr{ pos: position{line: 204, col: 10, offset: 5669}, run: (*parser).callonArray1, expr: &seqExpr{ pos: position{line: 204, col: 10, offset: 5669}, exprs: []interface{}{ &litMatcher{ pos: position{line: 204, col: 10, offset: 5669}, val: "[", ignoreCase: false, }, &ruleRefExpr{ pos: position{line: 204, col: 14, offset: 5673}, name: "_", }, &labeledExpr{ pos: position{line: 204, col: 16, offset: 5675}, label: "list", expr: &ruleRefExpr{ pos: position{line: 204, col: 21, offset: 5680}, name: "ExprTermList", }, }, &ruleRefExpr{ pos: position{line: 204, col: 34, offset: 5693}, name: "_", }, &litMatcher{ pos: position{line: 204, col: 36, offset: 5695}, val: "]", ignoreCase: false, }, }, }, }, }, { name: "Set", pos: position{line: 208, col: 1, offset: 5751}, expr: &choiceExpr{ pos: position{line: 208, col: 8, offset: 5758}, alternatives: []interface{}{ &ruleRefExpr{ pos: position{line: 208, col: 8, offset: 5758}, name: "SetEmpty", }, &ruleRefExpr{ pos: position{line: 208, col: 19, offset: 5769}, name: "SetNonEmpty", }, }, }, }, { name: "SetEmpty", pos: position{line: 210, col: 1, offset: 5782}, expr: &actionExpr{ pos: position{line: 210, col: 13, offset: 5794}, run: (*parser).callonSetEmpty1, expr: &seqExpr{ pos: position{line: 210, col: 13, offset: 5794}, exprs: []interface{}{ &litMatcher{ pos: position{line: 210, col: 13, offset: 5794}, val: "set(", ignoreCase: false, }, &ruleRefExpr{ pos: position{line: 210, col: 20, offset: 5801}, name: "_", }, &litMatcher{ pos: position{line: 210, col: 22, offset: 5803}, val: ")", ignoreCase: false, }, }, }, }, }, { name: "SetNonEmpty", pos: position{line: 215, col: 1, offset: 5880}, expr: &actionExpr{ pos: position{line: 215, col: 16, offset: 5895}, run: (*parser).callonSetNonEmpty1, expr: &seqExpr{ pos: position{line: 215, col: 16, offset: 5895}, exprs: []interface{}{ &litMatcher{ pos: position{line: 215, col: 16, offset: 5895}, val: "{", ignoreCase: false, }, &ruleRefExpr{ pos: position{line: 215, col: 20, offset: 5899}, name: "_", }, &labeledExpr{ pos: position{line: 215, col: 22, offset: 5901}, label: "list", expr: &ruleRefExpr{ pos: position{line: 215, col: 27, offset: 5906}, name: "ExprTermList", }, }, &ruleRefExpr{ pos: position{line: 215, col: 40, offset: 5919}, name: "_", }, &litMatcher{ pos: position{line: 215, col: 42, offset: 5921}, val: "}", ignoreCase: false, }, }, }, }, }, { name: "Ref", pos: position{line: 219, col: 1, offset: 5975}, expr: &actionExpr{ pos: position{line: 219, col: 8, offset: 5982}, run: (*parser).callonRef1, expr: &seqExpr{ pos: position{line: 219, col: 8, offset: 5982}, exprs: []interface{}{ &labeledExpr{ pos: position{line: 219, col: 8, offset: 5982}, label: "head", expr: &choiceExpr{ pos: position{line: 219, col: 14, offset: 5988}, alternatives: []interface{}{ &ruleRefExpr{ pos: position{line: 219, col: 14, offset: 5988}, name: "Composite", }, &ruleRefExpr{ pos: position{line: 219, col: 26, offset: 6000}, name: "Var", }, }, }, }, &labeledExpr{ pos: position{line: 219, col: 31, offset: 6005}, label: "rest", expr: &oneOrMoreExpr{ pos: position{line: 219, col: 36, offset: 6010}, expr: &ruleRefExpr{ pos: position{line: 219, col: 36, offset: 6010}, name: "RefOperand", }, }, }, }, }, }, }, { name: "RefOperand", pos: position{line: 223, col: 1, offset: 6078}, expr: &choiceExpr{ pos: position{line: 223, col: 15, offset: 6092}, alternatives: []interface{}{ &ruleRefExpr{ pos: position{line: 223, col: 15, offset: 6092}, name: "RefOperandDot", }, &ruleRefExpr{ pos: position{line: 223, col: 31, offset: 6108}, name: "RefOperandCanonical", }, }, }, }, { name: "RefOperandDot", pos: position{line: 225, col: 1, offset: 6129}, expr: &actionExpr{ pos: position{line: 225, col: 18, offset: 6146}, run: (*parser).callonRefOperandDot1, expr: &seqExpr{ pos: position{line: 225, col: 18, offset: 6146}, exprs: []interface{}{ &litMatcher{ pos: position{line: 225, col: 18, offset: 6146}, val: ".", ignoreCase: false, }, &labeledExpr{ pos: position{line: 225, col: 22, offset: 6150}, label: "val", expr: &ruleRefExpr{ pos: position{line: 225, col: 26, offset: 6154}, name: "Var", }, }, }, }, }, }, { name: "RefOperandCanonical", pos: position{line: 229, col: 1, offset: 6217}, expr: &actionExpr{ pos: position{line: 229, col: 24, offset: 6240}, run: (*parser).callonRefOperandCanonical1, expr: &seqExpr{ pos: position{line: 229, col: 24, offset: 6240}, exprs: []interface{}{ &litMatcher{ pos: position{line: 229, col: 24, offset: 6240}, val: "[", ignoreCase: false, }, &labeledExpr{ pos: position{line: 229, col: 28, offset: 6244}, label: "val", expr: &ruleRefExpr{ pos: position{line: 229, col: 32, offset: 6248}, name: "ExprTerm", }, }, &litMatcher{ pos: position{line: 229, col: 41, offset: 6257}, val: "]", ignoreCase: false, }, }, }, }, }, { name: "Var", pos: position{line: 233, col: 1, offset: 6286}, expr: &actionExpr{ pos: position{line: 233, col: 8, offset: 6293}, run: (*parser).callonVar1, expr: &labeledExpr{ pos: position{line: 233, col: 8, offset: 6293}, label: "val", expr: &ruleRefExpr{ pos: position{line: 233, col: 12, offset: 6297}, name: "VarChecked", }, }, }, }, { name: "VarChecked", pos: position{line: 237, col: 1, offset: 6352}, expr: &seqExpr{ pos: position{line: 237, col: 15, offset: 6366}, exprs: []interface{}{ &labeledExpr{ pos: position{line: 237, col: 15, offset: 6366}, label: "val", expr: &ruleRefExpr{ pos: position{line: 237, col: 19, offset: 6370}, name: "VarUnchecked", }, }, ¬CodeExpr{ pos: position{line: 237, col: 32, offset: 6383}, run: (*parser).callonVarChecked4, }, }, }, }, { name: "VarUnchecked", pos: position{line: 241, col: 1, offset: 6448}, expr: &actionExpr{ pos: position{line: 241, col: 17, offset: 6464}, run: (*parser).callonVarUnchecked1, expr: &seqExpr{ pos: position{line: 241, col: 17, offset: 6464}, exprs: []interface{}{ &ruleRefExpr{ pos: position{line: 241, col: 17, offset: 6464}, name: "VarStart", }, &zeroOrMoreExpr{ pos: position{line: 241, col: 26, offset: 6473}, expr: &ruleRefExpr{ pos: position{line: 241, col: 26, offset: 6473}, name: "VarChar", }, }, }, }, }, }, { name: "Number", pos: position{line: 245, col: 1, offset: 6534}, expr: &actionExpr{ pos: position{line: 245, col: 11, offset: 6544}, run: (*parser).callonNumber1, expr: &seqExpr{ pos: position{line: 245, col: 11, offset: 6544}, exprs: []interface{}{ &zeroOrOneExpr{ pos: position{line: 245, col: 11, offset: 6544}, expr: &litMatcher{ pos: position{line: 245, col: 11, offset: 6544}, val: "-", ignoreCase: false, }, }, &choiceExpr{ pos: position{line: 245, col: 18, offset: 6551}, alternatives: []interface{}{ &ruleRefExpr{ pos: position{line: 245, col: 18, offset: 6551}, name: "Float", }, &ruleRefExpr{ pos: position{line: 245, col: 26, offset: 6559}, name: "Integer", }, }, }, }, }, }, }, { name: "Float", pos: position{line: 249, col: 1, offset: 6624}, expr: &choiceExpr{ pos: position{line: 249, col: 10, offset: 6633}, alternatives: []interface{}{ &ruleRefExpr{ pos: position{line: 249, col: 10, offset: 6633}, name: "ExponentFloat", }, &ruleRefExpr{ pos: position{line: 249, col: 26, offset: 6649}, name: "PointFloat", }, }, }, }, { name: "ExponentFloat", pos: position{line: 251, col: 1, offset: 6661}, expr: &seqExpr{ pos: position{line: 251, col: 18, offset: 6678}, exprs: []interface{}{ &choiceExpr{ pos: position{line: 251, col: 20, offset: 6680}, alternatives: []interface{}{ &ruleRefExpr{ pos: position{line: 251, col: 20, offset: 6680}, name: "PointFloat", }, &ruleRefExpr{ pos: position{line: 251, col: 33, offset: 6693}, name: "Integer", }, }, }, &ruleRefExpr{ pos: position{line: 251, col: 43, offset: 6703}, name: "Exponent", }, }, }, }, { name: "PointFloat", pos: position{line: 253, col: 1, offset: 6713}, expr: &seqExpr{ pos: position{line: 253, col: 15, offset: 6727}, exprs: []interface{}{ &zeroOrOneExpr{ pos: position{line: 253, col: 15, offset: 6727}, expr: &ruleRefExpr{ pos: position{line: 253, col: 15, offset: 6727}, name: "Integer", }, }, &ruleRefExpr{ pos: position{line: 253, col: 24, offset: 6736}, name: "Fraction", }, }, }, }, { name: "Fraction", pos: position{line: 255, col: 1, offset: 6746}, expr: &seqExpr{ pos: position{line: 255, col: 13, offset: 6758}, exprs: []interface{}{ &litMatcher{ pos: position{line: 255, col: 13, offset: 6758}, val: ".", ignoreCase: false, }, &oneOrMoreExpr{ pos: position{line: 255, col: 17, offset: 6762}, expr: &ruleRefExpr{ pos: position{line: 255, col: 17, offset: 6762}, name: "DecimalDigit", }, }, }, }, }, { name: "Exponent", pos: position{line: 257, col: 1, offset: 6777}, expr: &seqExpr{ pos: position{line: 257, col: 13, offset: 6789}, exprs: []interface{}{ &litMatcher{ pos: position{line: 257, col: 13, offset: 6789}, val: "e", ignoreCase: true, }, &zeroOrOneExpr{ pos: position{line: 257, col: 18, offset: 6794}, expr: &charClassMatcher{ pos: position{line: 257, col: 18, offset: 6794}, val: "[+-]", chars: []rune{'+', '-'}, ignoreCase: false, inverted: false, }, }, &oneOrMoreExpr{ pos: position{line: 257, col: 24, offset: 6800}, expr: &ruleRefExpr{ pos: position{line: 257, col: 24, offset: 6800}, name: "DecimalDigit", }, }, }, }, }, { name: "Integer", pos: position{line: 259, col: 1, offset: 6815}, expr: &choiceExpr{ pos: position{line: 259, col: 12, offset: 6826}, alternatives: []interface{}{ &litMatcher{ pos: position{line: 259, col: 12, offset: 6826}, val: "0", ignoreCase: false, }, &seqExpr{ pos: position{line: 259, col: 20, offset: 6834}, exprs: []interface{}{ &ruleRefExpr{ pos: position{line: 259, col: 20, offset: 6834}, name: "NonZeroDecimalDigit", }, &zeroOrMoreExpr{ pos: position{line: 259, col: 40, offset: 6854}, expr: &ruleRefExpr{ pos: position{line: 259, col: 40, offset: 6854}, name: "DecimalDigit", }, }, }, }, }, }, }, { name: "String", pos: position{line: 261, col: 1, offset: 6871}, expr: &choiceExpr{ pos: position{line: 261, col: 11, offset: 6881}, alternatives: []interface{}{ &ruleRefExpr{ pos: position{line: 261, col: 11, offset: 6881}, name: "QuotedString", }, &ruleRefExpr{ pos: position{line: 261, col: 26, offset: 6896}, name: "RawString", }, }, }, }, { name: "QuotedString", pos: position{line: 263, col: 1, offset: 6907}, expr: &choiceExpr{ pos: position{line: 263, col: 17, offset: 6923}, alternatives: []interface{}{ &actionExpr{ pos: position{line: 263, col: 17, offset: 6923}, run: (*parser).callonQuotedString2, expr: &seqExpr{ pos: position{line: 263, col: 17, offset: 6923}, exprs: []interface{}{ &litMatcher{ pos: position{line: 263, col: 17, offset: 6923}, val: "\"", ignoreCase: false, }, &zeroOrMoreExpr{ pos: position{line: 263, col: 21, offset: 6927}, expr: &ruleRefExpr{ pos: position{line: 263, col: 21, offset: 6927}, name: "Char", }, }, &litMatcher{ pos: position{line: 263, col: 27, offset: 6933}, val: "\"", ignoreCase: false, }, }, }, }, &actionExpr{ pos: position{line: 265, col: 5, offset: 6993}, run: (*parser).callonQuotedString8, expr: &seqExpr{ pos: position{line: 265, col: 5, offset: 6993}, exprs: []interface{}{ &litMatcher{ pos: position{line: 265, col: 5, offset: 6993}, val: "\"", ignoreCase: false, }, &zeroOrMoreExpr{ pos: position{line: 265, col: 9, offset: 6997}, expr: &ruleRefExpr{ pos: position{line: 265, col: 9, offset: 6997}, name: "Char", }, }, ¬Expr{ pos: position{line: 265, col: 15, offset: 7003}, expr: &litMatcher{ pos: position{line: 265, col: 16, offset: 7004}, val: "\"", ignoreCase: false, }, }, }, }, }, }, }, }, { name: "RawString", pos: position{line: 269, col: 1, offset: 7084}, expr: &actionExpr{ pos: position{line: 269, col: 14, offset: 7097}, run: (*parser).callonRawString1, expr: &seqExpr{ pos: position{line: 269, col: 14, offset: 7097}, exprs: []interface{}{ &litMatcher{ pos: position{line: 269, col: 14, offset: 7097}, val: "`", ignoreCase: false, }, &zeroOrMoreExpr{ pos: position{line: 269, col: 18, offset: 7101}, expr: &charClassMatcher{ pos: position{line: 269, col: 18, offset: 7101}, val: "[^`]", chars: []rune{'`'}, ignoreCase: false, inverted: true, }, }, &litMatcher{ pos: position{line: 269, col: 24, offset: 7107}, val: "`", ignoreCase: false, }, }, }, }, }, { name: "Bool", pos: position{line: 273, col: 1, offset: 7169}, expr: &actionExpr{ pos: position{line: 273, col: 9, offset: 7177}, run: (*parser).callonBool1, expr: &seqExpr{ pos: position{line: 273, col: 9, offset: 7177}, exprs: []interface{}{ &labeledExpr{ pos: position{line: 273, col: 9, offset: 7177}, label: "val", expr: &choiceExpr{ pos: position{line: 273, col: 14, offset: 7182}, alternatives: []interface{}{ &litMatcher{ pos: position{line: 273, col: 14, offset: 7182}, val: "true", ignoreCase: false, }, &litMatcher{ pos: position{line: 273, col: 23, offset: 7191}, val: "false", ignoreCase: false, }, }, }, }, ¬Expr{ pos: position{line: 273, col: 32, offset: 7200}, expr: &ruleRefExpr{ pos: position{line: 273, col: 33, offset: 7201}, name: "VarChar", }, }, }, }, }, }, { name: "Null", pos: position{line: 277, col: 1, offset: 7262}, expr: &actionExpr{ pos: position{line: 277, col: 9, offset: 7270}, run: (*parser).callonNull1, expr: &seqExpr{ pos: position{line: 277, col: 9, offset: 7270}, exprs: []interface{}{ &litMatcher{ pos: position{line: 277, col: 9, offset: 7270}, val: "null", ignoreCase: false, }, ¬Expr{ pos: position{line: 277, col: 16, offset: 7277}, expr: &ruleRefExpr{ pos: position{line: 277, col: 17, offset: 7278}, name: "VarChar", }, }, }, }, }, }, { name: "VarStart", pos: position{line: 281, col: 1, offset: 7331}, expr: &ruleRefExpr{ pos: position{line: 281, col: 13, offset: 7343}, name: "AsciiLetter", }, }, { name: "VarChar", pos: position{line: 283, col: 1, offset: 7356}, expr: &choiceExpr{ pos: position{line: 283, col: 12, offset: 7367}, alternatives: []interface{}{ &ruleRefExpr{ pos: position{line: 283, col: 12, offset: 7367}, name: "AsciiLetter", }, &ruleRefExpr{ pos: position{line: 283, col: 26, offset: 7381}, name: "DecimalDigit", }, }, }, }, { name: "AsciiLetter", pos: position{line: 285, col: 1, offset: 7395}, expr: &charClassMatcher{ pos: position{line: 285, col: 16, offset: 7410}, val: "[A-Za-z_]", chars: []rune{'_'}, ranges: []rune{'A', 'Z', 'a', 'z'}, ignoreCase: false, inverted: false, }, }, { name: "Char", pos: position{line: 287, col: 1, offset: 7421}, expr: &choiceExpr{ pos: position{line: 287, col: 9, offset: 7429}, alternatives: []interface{}{ &seqExpr{ pos: position{line: 287, col: 11, offset: 7431}, exprs: []interface{}{ ¬Expr{ pos: position{line: 287, col: 11, offset: 7431}, expr: &ruleRefExpr{ pos: position{line: 287, col: 12, offset: 7432}, name: "EscapedChar", }, }, &anyMatcher{ line: 287, col: 24, offset: 7444, }, }, }, &seqExpr{ pos: position{line: 287, col: 32, offset: 7452}, exprs: []interface{}{ &litMatcher{ pos: position{line: 287, col: 32, offset: 7452}, val: "\\", ignoreCase: false, }, &ruleRefExpr{ pos: position{line: 287, col: 37, offset: 7457}, name: "EscapeSequence", }, }, }, }, }, }, { name: "EscapedChar", pos: position{line: 289, col: 1, offset: 7475}, expr: &charClassMatcher{ pos: position{line: 289, col: 16, offset: 7490}, val: "[\\x00-\\x1f\"\\\\]", chars: []rune{'"', '\\'}, ranges: []rune{'\x00', '\x1f'}, ignoreCase: false, inverted: false, }, }, { name: "EscapeSequence", pos: position{line: 291, col: 1, offset: 7506}, expr: &choiceExpr{ pos: position{line: 291, col: 19, offset: 7524}, alternatives: []interface{}{ &ruleRefExpr{ pos: position{line: 291, col: 19, offset: 7524}, name: "SingleCharEscape", }, &ruleRefExpr{ pos: position{line: 291, col: 38, offset: 7543}, name: "UnicodeEscape", }, }, }, }, { name: "SingleCharEscape", pos: position{line: 293, col: 1, offset: 7558}, expr: &charClassMatcher{ pos: position{line: 293, col: 21, offset: 7578}, val: "[ \" \\\\ / b f n r t ]", chars: []rune{' ', '"', ' ', '\\', ' ', '/', ' ', 'b', ' ', 'f', ' ', 'n', ' ', 'r', ' ', 't', ' '}, ignoreCase: false, inverted: false, }, }, { name: "UnicodeEscape", pos: position{line: 295, col: 1, offset: 7600}, expr: &seqExpr{ pos: position{line: 295, col: 18, offset: 7617}, exprs: []interface{}{ &litMatcher{ pos: position{line: 295, col: 18, offset: 7617}, val: "u", ignoreCase: false, }, &ruleRefExpr{ pos: position{line: 295, col: 22, offset: 7621}, name: "HexDigit", }, &ruleRefExpr{ pos: position{line: 295, col: 31, offset: 7630}, name: "HexDigit", }, &ruleRefExpr{ pos: position{line: 295, col: 40, offset: 7639}, name: "HexDigit", }, &ruleRefExpr{ pos: position{line: 295, col: 49, offset: 7648}, name: "HexDigit", }, }, }, }, { name: "DecimalDigit", pos: position{line: 297, col: 1, offset: 7658}, expr: &charClassMatcher{ pos: position{line: 297, col: 17, offset: 7674}, val: "[0-9]", ranges: []rune{'0', '9'}, ignoreCase: false, inverted: false, }, }, { name: "NonZeroDecimalDigit", pos: position{line: 299, col: 1, offset: 7681}, expr: &charClassMatcher{ pos: position{line: 299, col: 24, offset: 7704}, val: "[1-9]", ranges: []rune{'1', '9'}, ignoreCase: false, inverted: false, }, }, { name: "HexDigit", pos: position{line: 301, col: 1, offset: 7711}, expr: &charClassMatcher{ pos: position{line: 301, col: 13, offset: 7723}, val: "[0-9a-fA-F]", ranges: []rune{'0', '9', 'a', 'f', 'A', 'F'}, ignoreCase: false, inverted: false, }, }, { name: "ws", displayName: "\"whitespace\"", pos: position{line: 303, col: 1, offset: 7736}, expr: &oneOrMoreExpr{ pos: position{line: 303, col: 20, offset: 7755}, expr: &charClassMatcher{ pos: position{line: 303, col: 20, offset: 7755}, val: "[ \\t\\r\\n]", chars: []rune{' ', '\t', '\r', '\n'}, ignoreCase: false, inverted: false, }, }, }, { name: "_", displayName: "\"whitespace\"", pos: position{line: 305, col: 1, offset: 7767}, expr: &zeroOrMoreExpr{ pos: position{line: 305, col: 19, offset: 7785}, expr: &choiceExpr{ pos: position{line: 305, col: 21, offset: 7787}, alternatives: []interface{}{ &charClassMatcher{ pos: position{line: 305, col: 21, offset: 7787}, val: "[ \\t\\r\\n]", chars: []rune{' ', '\t', '\r', '\n'}, ignoreCase: false, inverted: false, }, &ruleRefExpr{ pos: position{line: 305, col: 33, offset: 7799}, name: "Comment", }, }, }, }, }, { name: "Comment", pos: position{line: 307, col: 1, offset: 7811}, expr: &actionExpr{ pos: position{line: 307, col: 12, offset: 7822}, run: (*parser).callonComment1, expr: &seqExpr{ pos: position{line: 307, col: 12, offset: 7822}, exprs: []interface{}{ &zeroOrMoreExpr{ pos: position{line: 307, col: 12, offset: 7822}, expr: &charClassMatcher{ pos: position{line: 307, col: 12, offset: 7822}, val: "[ \\t]", chars: []rune{' ', '\t'}, ignoreCase: false, inverted: false, }, }, &litMatcher{ pos: position{line: 307, col: 19, offset: 7829}, val: "#", ignoreCase: false, }, &labeledExpr{ pos: position{line: 307, col: 23, offset: 7833}, label: "text", expr: &zeroOrMoreExpr{ pos: position{line: 307, col: 28, offset: 7838}, expr: &charClassMatcher{ pos: position{line: 307, col: 28, offset: 7838}, val: "[^\\r\\n]", chars: []rune{'\r', '\n'}, ignoreCase: false, inverted: true, }, }, }, }, }, }, }, { name: "EOF", pos: position{line: 311, col: 1, offset: 7885}, expr: ¬Expr{ pos: position{line: 311, col: 8, offset: 7892}, expr: &anyMatcher{ line: 311, col: 9, offset: 7893, }, }, }, }, } func (c *current) onProgram1(vals interface{}) (interface{}, error) { return makeProgram(c, vals) } func (p *parser) callonProgram1() (interface{}, error) { stack := p.vstack[len(p.vstack)-1] _ = stack return p.cur.onProgram1(stack["vals"]) } func (c *current) onStmt1(val interface{}) (interface{}, error) { return val, nil } func (p *parser) callonStmt1() (interface{}, error) { stack := p.vstack[len(p.vstack)-1] _ = stack return p.cur.onStmt1(stack["val"]) } func (c *current) onPackage1(val interface{}) (interface{}, error) { return makePackage(currentLocation(c), val) } func (p *parser) callonPackage1() (interface{}, error) { stack := p.vstack[len(p.vstack)-1] _ = stack return p.cur.onPackage1(stack["val"]) } func (c *current) onImport1(path, alias interface{}) (interface{}, error) { return makeImport(currentLocation(c), path, alias) } func (p *parser) callonImport1() (interface{}, error) { stack := p.vstack[len(p.vstack)-1] _ = stack return p.cur.onImport1(stack["path"], stack["alias"]) } func (c *current) onDefaultRules1(name, operator, value interface{}) (interface{}, error) { return makeDefaultRule(currentLocation(c), name, operator, value) } func (p *parser) callonDefaultRules1() (interface{}, error) { stack := p.vstack[len(p.vstack)-1] _ = stack return p.cur.onDefaultRules1(stack["name"], stack["operator"], stack["value"]) } func (c *current) onNormalRules1(head, rest interface{}) (interface{}, error) { return makeRule(currentLocation(c), head, rest) } func (p *parser) callonNormalRules1() (interface{}, error) { stack := p.vstack[len(p.vstack)-1] _ = stack return p.cur.onNormalRules1(stack["head"], stack["rest"]) } func (c *current) onPartialRuleHead1(name, args, value interface{}) (interface{}, error) { return makeRuleHead(currentLocation(c), name, args, nil, value) } func (p *parser) callonPartialRuleHead1() (interface{}, error) { stack := p.vstack[len(p.vstack)-1] _ = stack return p.cur.onPartialRuleHead1(stack["name"], stack["args"], stack["value"]) } func (c *current) onRuleHead1(name, key, value interface{}) (interface{}, error) { return makeRuleHead(currentLocation(c), name, nil, key, value) } func (p *parser) callonRuleHead1() (interface{}, error) { stack := p.vstack[len(p.vstack)-1] _ = stack return p.cur.onRuleHead1(stack["name"], stack["key"], stack["value"]) } func (c *current) onArgs1(list interface{}) (interface{}, error) { return makeArgs(list) } func (p *parser) callonArgs1() (interface{}, error) { stack := p.vstack[len(p.vstack)-1] _ = stack return p.cur.onArgs1(stack["list"]) } func (c *current) onElse1(value, body interface{}) (interface{}, error) { return makeRuleExt(currentLocation(c), value, body) } func (p *parser) callonElse1() (interface{}, error) { stack := p.vstack[len(p.vstack)-1] _ = stack return p.cur.onElse1(stack["value"], stack["body"]) } func (c *current) onRuleDup1(b interface{}) (interface{}, error) { return ruleExt{loc: currentLocation(c), body: b.(Body)}, nil } func (p *parser) callonRuleDup1() (interface{}, error) { stack := p.vstack[len(p.vstack)-1] _ = stack return p.cur.onRuleDup1(stack["b"]) } func (c *current) onNonEmptyBraceEnclosedBody1(val interface{}) (interface{}, error) { if val == nil { return NewBody(), fmt.Errorf("found empty body") } return val, nil } func (p *parser) callonNonEmptyBraceEnclosedBody1() (interface{}, error) { stack := p.vstack[len(p.vstack)-1] _ = stack return p.cur.onNonEmptyBraceEnclosedBody1(stack["val"]) } func (c *current) onBraceEnclosedBody1(val interface{}) (interface{}, error) { return makeBraceEnclosedBody(currentLocation(c), val) } func (p *parser) callonBraceEnclosedBody1() (interface{}, error) { stack := p.vstack[len(p.vstack)-1] _ = stack return p.cur.onBraceEnclosedBody1(stack["val"]) } func (c *current) onWhitespaceBody1(head, tail interface{}) (interface{}, error) { return makeBody(head, tail, 2) } func (p *parser) callonWhitespaceBody1() (interface{}, error) { stack := p.vstack[len(p.vstack)-1] _ = stack return p.cur.onWhitespaceBody1(stack["head"], stack["tail"]) } func (c *current) onNonWhitespaceBody1(head, tail interface{}) (interface{}, error) { return makeBody(head, tail, 3) } func (p *parser) callonNonWhitespaceBody1() (interface{}, error) { stack := p.vstack[len(p.vstack)-1] _ = stack return p.cur.onNonWhitespaceBody1(stack["head"], stack["tail"]) } func (c *current) onSomeDecl1(symbols interface{}) (interface{}, error) { return makeSomeDeclLiteral(currentLocation(c), symbols) } func (p *parser) callonSomeDecl1() (interface{}, error) { stack := p.vstack[len(p.vstack)-1] _ = stack return p.cur.onSomeDecl1(stack["symbols"]) } func (c *current) onSomeDeclList1(head, rest interface{}) (interface{}, error) { return makeSomeDeclSymbols(head, rest) } func (p *parser) callonSomeDeclList1() (interface{}, error) { stack := p.vstack[len(p.vstack)-1] _ = stack return p.cur.onSomeDeclList1(stack["head"], stack["rest"]) } func (c *current) onTermExpr1(negated, value, with interface{}) (interface{}, error) { return makeLiteral(negated, value, with) } func (p *parser) callonTermExpr1() (interface{}, error) { stack := p.vstack[len(p.vstack)-1] _ = stack return p.cur.onTermExpr1(stack["negated"], stack["value"], stack["with"]) } func (c *current) onLiteralExpr1(lhs, rest interface{}) (interface{}, error) { return makeLiteralExpr(currentLocation(c), lhs, rest) } func (p *parser) callonLiteralExpr1() (interface{}, error) { stack := p.vstack[len(p.vstack)-1] _ = stack return p.cur.onLiteralExpr1(stack["lhs"], stack["rest"]) } func (c *current) onLiteralExprOperator1(val interface{}) (interface{}, error) { return makeInfixOperator(currentLocation(c), c.text) } func (p *parser) callonLiteralExprOperator1() (interface{}, error) { stack := p.vstack[len(p.vstack)-1] _ = stack return p.cur.onLiteralExprOperator1(stack["val"]) } func (c *current) onNotKeyword1(val interface{}) (interface{}, error) { return val != nil, nil } func (p *parser) callonNotKeyword1() (interface{}, error) { stack := p.vstack[len(p.vstack)-1] _ = stack return p.cur.onNotKeyword1(stack["val"]) } func (c *current) onWithKeywordList1(head, rest interface{}) (interface{}, error) { return makeWithKeywordList(head, rest) } func (p *parser) callonWithKeywordList1() (interface{}, error) { stack := p.vstack[len(p.vstack)-1] _ = stack return p.cur.onWithKeywordList1(stack["head"], stack["rest"]) } func (c *current) onWithKeyword1(target, value interface{}) (interface{}, error) { return makeWithKeyword(currentLocation(c), target, value) } func (p *parser) callonWithKeyword1() (interface{}, error) { stack := p.vstack[len(p.vstack)-1] _ = stack return p.cur.onWithKeyword1(stack["target"], stack["value"]) } func (c *current) onExprTerm1(lhs, rest interface{}) (interface{}, error) { return makeExprTerm(currentLocation(c), lhs, rest) } func (p *parser) callonExprTerm1() (interface{}, error) { stack := p.vstack[len(p.vstack)-1] _ = stack return p.cur.onExprTerm1(stack["lhs"], stack["rest"]) } func (c *current) onExprTermPairList1(head, tail interface{}) (interface{}, error) { return makeExprTermPairList(head, tail) } func (p *parser) callonExprTermPairList1() (interface{}, error) { stack := p.vstack[len(p.vstack)-1] _ = stack return p.cur.onExprTermPairList1(stack["head"], stack["tail"]) } func (c *current) onExprTermList1(head, tail interface{}) (interface{}, error) { return makeExprTermList(head, tail) } func (p *parser) callonExprTermList1() (interface{}, error) { stack := p.vstack[len(p.vstack)-1] _ = stack return p.cur.onExprTermList1(stack["head"], stack["tail"]) } func (c *current) onExprTermPair1(key, value interface{}) (interface{}, error) { return makeExprTermPair(key, value) } func (p *parser) callonExprTermPair1() (interface{}, error) { stack := p.vstack[len(p.vstack)-1] _ = stack return p.cur.onExprTermPair1(stack["key"], stack["value"]) } func (c *current) onRelationOperator1(val interface{}) (interface{}, error) { return makeInfixOperator(currentLocation(c), c.text) } func (p *parser) callonRelationOperator1() (interface{}, error) { stack := p.vstack[len(p.vstack)-1] _ = stack return p.cur.onRelationOperator1(stack["val"]) } func (c *current) onRelationExpr1(lhs, rest interface{}) (interface{}, error) { return makeExprTerm(currentLocation(c), lhs, rest) } func (p *parser) callonRelationExpr1() (interface{}, error) { stack := p.vstack[len(p.vstack)-1] _ = stack return p.cur.onRelationExpr1(stack["lhs"], stack["rest"]) } func (c *current) onBitwiseOrOperator1(val interface{}) (interface{}, error) { return makeInfixOperator(currentLocation(c), c.text) } func (p *parser) callonBitwiseOrOperator1() (interface{}, error) { stack := p.vstack[len(p.vstack)-1] _ = stack return p.cur.onBitwiseOrOperator1(stack["val"]) } func (c *current) onBitwiseOrExpr1(lhs, rest interface{}) (interface{}, error) { return makeExprTerm(currentLocation(c), lhs, rest) } func (p *parser) callonBitwiseOrExpr1() (interface{}, error) { stack := p.vstack[len(p.vstack)-1] _ = stack return p.cur.onBitwiseOrExpr1(stack["lhs"], stack["rest"]) } func (c *current) onBitwiseAndOperator1(val interface{}) (interface{}, error) { return makeInfixOperator(currentLocation(c), c.text) } func (p *parser) callonBitwiseAndOperator1() (interface{}, error) { stack := p.vstack[len(p.vstack)-1] _ = stack return p.cur.onBitwiseAndOperator1(stack["val"]) } func (c *current) onBitwiseAndExpr1(lhs, rest interface{}) (interface{}, error) { return makeExprTerm(currentLocation(c), lhs, rest) } func (p *parser) callonBitwiseAndExpr1() (interface{}, error) { stack := p.vstack[len(p.vstack)-1] _ = stack return p.cur.onBitwiseAndExpr1(stack["lhs"], stack["rest"]) } func (c *current) onArithOperator1(val interface{}) (interface{}, error) { return makeInfixOperator(currentLocation(c), c.text) } func (p *parser) callonArithOperator1() (interface{}, error) { stack := p.vstack[len(p.vstack)-1] _ = stack return p.cur.onArithOperator1(stack["val"]) } func (c *current) onArithExpr1(lhs, rest interface{}) (interface{}, error) { return makeExprTerm(currentLocation(c), lhs, rest) } func (p *parser) callonArithExpr1() (interface{}, error) { stack := p.vstack[len(p.vstack)-1] _ = stack return p.cur.onArithExpr1(stack["lhs"], stack["rest"]) } func (c *current) onFactorOperator1(val interface{}) (interface{}, error) { return makeInfixOperator(currentLocation(c), c.text) } func (p *parser) callonFactorOperator1() (interface{}, error) { stack := p.vstack[len(p.vstack)-1] _ = stack return p.cur.onFactorOperator1(stack["val"]) } func (c *current) onFactorExpr2(expr interface{}) (interface{}, error) { return expr, nil } func (p *parser) callonFactorExpr2() (interface{}, error) { stack := p.vstack[len(p.vstack)-1] _ = stack return p.cur.onFactorExpr2(stack["expr"]) } func (c *current) onFactorExpr10(term interface{}) (interface{}, error) { return term, nil } func (p *parser) callonFactorExpr10() (interface{}, error) { stack := p.vstack[len(p.vstack)-1] _ = stack return p.cur.onFactorExpr10(stack["term"]) } func (c *current) onCall1(operator, args interface{}) (interface{}, error) { return makeCall(currentLocation(c), operator, args) } func (p *parser) callonCall1() (interface{}, error) { stack := p.vstack[len(p.vstack)-1] _ = stack return p.cur.onCall1(stack["operator"], stack["args"]) } func (c *current) onTerm1(val, refs interface{}) (interface{}, error) { return makeRef(currentLocation(c), val, refs) } func (p *parser) callonTerm1() (interface{}, error) { stack := p.vstack[len(p.vstack)-1] _ = stack return p.cur.onTerm1(stack["val"], stack["refs"]) } func (c *current) onTermPair1(key, value interface{}) (interface{}, error) { return makeExprTermPair(key, value) } func (p *parser) callonTermPair1() (interface{}, error) { stack := p.vstack[len(p.vstack)-1] _ = stack return p.cur.onTermPair1(stack["key"], stack["value"]) } func (c *current) onArrayComprehension1(head, body interface{}) (interface{}, error) { return makeArrayComprehension(currentLocation(c), head, body) } func (p *parser) callonArrayComprehension1() (interface{}, error) { stack := p.vstack[len(p.vstack)-1] _ = stack return p.cur.onArrayComprehension1(stack["head"], stack["body"]) } func (c *current) onObjectComprehension1(head, body interface{}) (interface{}, error) { return makeObjectComprehension(currentLocation(c), head, body) } func (p *parser) callonObjectComprehension1() (interface{}, error) { stack := p.vstack[len(p.vstack)-1] _ = stack return p.cur.onObjectComprehension1(stack["head"], stack["body"]) } func (c *current) onSetComprehension1(head, body interface{}) (interface{}, error) { return makeSetComprehension(currentLocation(c), head, body) } func (p *parser) callonSetComprehension1() (interface{}, error) { stack := p.vstack[len(p.vstack)-1] _ = stack return p.cur.onSetComprehension1(stack["head"], stack["body"]) } func (c *current) onObject1(list interface{}) (interface{}, error) { return makeObject(currentLocation(c), list) } func (p *parser) callonObject1() (interface{}, error) { stack := p.vstack[len(p.vstack)-1] _ = stack return p.cur.onObject1(stack["list"]) } func (c *current) onArray1(list interface{}) (interface{}, error) { return makeArray(currentLocation(c), list) } func (p *parser) callonArray1() (interface{}, error) { stack := p.vstack[len(p.vstack)-1] _ = stack return p.cur.onArray1(stack["list"]) } func (c *current) onSetEmpty1() (interface{}, error) { var empty []*Term return makeSet(currentLocation(c), empty) } func (p *parser) callonSetEmpty1() (interface{}, error) { stack := p.vstack[len(p.vstack)-1] _ = stack return p.cur.onSetEmpty1() } func (c *current) onSetNonEmpty1(list interface{}) (interface{}, error) { return makeSet(currentLocation(c), list) } func (p *parser) callonSetNonEmpty1() (interface{}, error) { stack := p.vstack[len(p.vstack)-1] _ = stack return p.cur.onSetNonEmpty1(stack["list"]) } func (c *current) onRef1(head, rest interface{}) (interface{}, error) { return makeRef(currentLocation(c), head, rest) } func (p *parser) callonRef1() (interface{}, error) { stack := p.vstack[len(p.vstack)-1] _ = stack return p.cur.onRef1(stack["head"], stack["rest"]) } func (c *current) onRefOperandDot1(val interface{}) (interface{}, error) { return makeRefOperandDot(currentLocation(c), val) } func (p *parser) callonRefOperandDot1() (interface{}, error) { stack := p.vstack[len(p.vstack)-1] _ = stack return p.cur.onRefOperandDot1(stack["val"]) } func (c *current) onRefOperandCanonical1(val interface{}) (interface{}, error) { return val, nil } func (p *parser) callonRefOperandCanonical1() (interface{}, error) { stack := p.vstack[len(p.vstack)-1] _ = stack return p.cur.onRefOperandCanonical1(stack["val"]) } func (c *current) onVar1(val interface{}) (interface{}, error) { return val.([]interface{})[0], nil } func (p *parser) callonVar1() (interface{}, error) { stack := p.vstack[len(p.vstack)-1] _ = stack return p.cur.onVar1(stack["val"]) } func (c *current) onVarChecked4(val interface{}) (bool, error) { return IsKeyword(string(val.(*Term).Value.(Var))), nil } func (p *parser) callonVarChecked4() (bool, error) { stack := p.vstack[len(p.vstack)-1] _ = stack return p.cur.onVarChecked4(stack["val"]) } func (c *current) onVarUnchecked1() (interface{}, error) { return makeVar(currentLocation(c), c.text) } func (p *parser) callonVarUnchecked1() (interface{}, error) { stack := p.vstack[len(p.vstack)-1] _ = stack return p.cur.onVarUnchecked1() } func (c *current) onNumber1() (interface{}, error) { return makeNumber(currentLocation(c), c.text) } func (p *parser) callonNumber1() (interface{}, error) { stack := p.vstack[len(p.vstack)-1] _ = stack return p.cur.onNumber1() } func (c *current) onQuotedString2() (interface{}, error) { return makeString(currentLocation(c), c.text) } func (p *parser) callonQuotedString2() (interface{}, error) { stack := p.vstack[len(p.vstack)-1] _ = stack return p.cur.onQuotedString2() } func (c *current) onQuotedString8() (interface{}, error) { return makeNonterminatedString(currentLocation(c), string(c.text)) } func (p *parser) callonQuotedString8() (interface{}, error) { stack := p.vstack[len(p.vstack)-1] _ = stack return p.cur.onQuotedString8() } func (c *current) onRawString1() (interface{}, error) { return makeRawString(currentLocation(c), c.text) } func (p *parser) callonRawString1() (interface{}, error) { stack := p.vstack[len(p.vstack)-1] _ = stack return p.cur.onRawString1() } func (c *current) onBool1(val interface{}) (interface{}, error) { return makeBool(currentLocation(c), c.text) } func (p *parser) callonBool1() (interface{}, error) { stack := p.vstack[len(p.vstack)-1] _ = stack return p.cur.onBool1(stack["val"]) } func (c *current) onNull1() (interface{}, error) { return makeNull(currentLocation(c)) } func (p *parser) callonNull1() (interface{}, error) { stack := p.vstack[len(p.vstack)-1] _ = stack return p.cur.onNull1() } func (c *current) onComment1(text interface{}) (interface{}, error) { return makeComments(c, text) } func (p *parser) callonComment1() (interface{}, error) { stack := p.vstack[len(p.vstack)-1] _ = stack return p.cur.onComment1(stack["text"]) } 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 }