4912 lines
128 KiB
Go
4912 lines
128 KiB
Go
// Code generated by pigeon; DO NOT EDIT.
|
|
|
|
// Package promql implements a promql parser to build flux query specifications from promql.
|
|
package promql
|
|
|
|
import (
|
|
"bytes"
|
|
"errors"
|
|
"fmt"
|
|
"io"
|
|
"io/ioutil"
|
|
"math"
|
|
"os"
|
|
"sort"
|
|
"strconv"
|
|
"strings"
|
|
"time"
|
|
"unicode"
|
|
"unicode/utf8"
|
|
)
|
|
|
|
// DO NOT EDIT: This file is auto generated by the pigeon PEG parser generator.
|
|
|
|
//lint:file-ignore SA6001 Ignore all unused code, it's generated
|
|
|
|
var reservedWords = map[string]bool{}
|
|
|
|
var g = &grammar{
|
|
rules: []*rule{
|
|
{
|
|
name: "Grammar",
|
|
pos: position{line: 13, col: 1, offset: 300},
|
|
expr: &actionExpr{
|
|
pos: position{line: 13, col: 12, offset: 311},
|
|
run: (*parser).callonGrammar1,
|
|
expr: &seqExpr{
|
|
pos: position{line: 13, col: 12, offset: 311},
|
|
exprs: []interface{}{
|
|
&labeledExpr{
|
|
pos: position{line: 13, col: 12, offset: 311},
|
|
label: "grammar",
|
|
expr: &choiceExpr{
|
|
pos: position{line: 13, col: 22, offset: 321},
|
|
alternatives: []interface{}{
|
|
&ruleRefExpr{
|
|
pos: position{line: 13, col: 22, offset: 321},
|
|
name: "Comment",
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 13, col: 32, offset: 331},
|
|
name: "AggregateExpression",
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 13, col: 54, offset: 353},
|
|
name: "VectorSelector",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 13, col: 71, offset: 370},
|
|
name: "EOF",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
{
|
|
name: "SourceChar",
|
|
pos: position{line: 17, col: 1, offset: 403},
|
|
expr: &anyMatcher{
|
|
line: 17, col: 14, offset: 416,
|
|
},
|
|
},
|
|
{
|
|
name: "Comment",
|
|
pos: position{line: 19, col: 1, offset: 419},
|
|
expr: &actionExpr{
|
|
pos: position{line: 19, col: 11, offset: 429},
|
|
run: (*parser).callonComment1,
|
|
expr: &seqExpr{
|
|
pos: position{line: 19, col: 11, offset: 429},
|
|
exprs: []interface{}{
|
|
&litMatcher{
|
|
pos: position{line: 19, col: 11, offset: 429},
|
|
val: "#",
|
|
ignoreCase: false,
|
|
},
|
|
&zeroOrMoreExpr{
|
|
pos: position{line: 19, col: 15, offset: 433},
|
|
expr: &seqExpr{
|
|
pos: position{line: 19, col: 17, offset: 435},
|
|
exprs: []interface{}{
|
|
¬Expr{
|
|
pos: position{line: 19, col: 17, offset: 435},
|
|
expr: &ruleRefExpr{
|
|
pos: position{line: 19, col: 18, offset: 436},
|
|
name: "EOL",
|
|
},
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 19, col: 22, offset: 440},
|
|
name: "SourceChar",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
{
|
|
name: "Identifier",
|
|
pos: position{line: 23, col: 1, offset: 500},
|
|
expr: &actionExpr{
|
|
pos: position{line: 23, col: 14, offset: 513},
|
|
run: (*parser).callonIdentifier1,
|
|
expr: &labeledExpr{
|
|
pos: position{line: 23, col: 14, offset: 513},
|
|
label: "ident",
|
|
expr: &ruleRefExpr{
|
|
pos: position{line: 23, col: 20, offset: 519},
|
|
name: "IdentifierName",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
{
|
|
name: "IdentifierName",
|
|
pos: position{line: 30, col: 1, offset: 692},
|
|
expr: &actionExpr{
|
|
pos: position{line: 30, col: 18, offset: 709},
|
|
run: (*parser).callonIdentifierName1,
|
|
expr: &seqExpr{
|
|
pos: position{line: 30, col: 18, offset: 709},
|
|
exprs: []interface{}{
|
|
&ruleRefExpr{
|
|
pos: position{line: 30, col: 18, offset: 709},
|
|
name: "IdentifierStart",
|
|
},
|
|
&zeroOrMoreExpr{
|
|
pos: position{line: 30, col: 34, offset: 725},
|
|
expr: &ruleRefExpr{
|
|
pos: position{line: 30, col: 34, offset: 725},
|
|
name: "IdentifierPart",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
{
|
|
name: "IdentifierStart",
|
|
pos: position{line: 33, col: 1, offset: 776},
|
|
expr: &charClassMatcher{
|
|
pos: position{line: 33, col: 19, offset: 794},
|
|
val: "[\\pL_]",
|
|
chars: []rune{'_'},
|
|
classes: []*unicode.RangeTable{rangeTable("L")},
|
|
ignoreCase: false,
|
|
inverted: false,
|
|
},
|
|
},
|
|
{
|
|
name: "IdentifierPart",
|
|
pos: position{line: 34, col: 1, offset: 801},
|
|
expr: &choiceExpr{
|
|
pos: position{line: 34, col: 18, offset: 818},
|
|
alternatives: []interface{}{
|
|
&ruleRefExpr{
|
|
pos: position{line: 34, col: 18, offset: 818},
|
|
name: "IdentifierStart",
|
|
},
|
|
&charClassMatcher{
|
|
pos: position{line: 34, col: 36, offset: 836},
|
|
val: "[\\p{Nd}]",
|
|
classes: []*unicode.RangeTable{rangeTable("Nd")},
|
|
ignoreCase: false,
|
|
inverted: false,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
{
|
|
name: "StringLiteral",
|
|
pos: position{line: 36, col: 1, offset: 846},
|
|
expr: &choiceExpr{
|
|
pos: position{line: 36, col: 17, offset: 862},
|
|
alternatives: []interface{}{
|
|
&actionExpr{
|
|
pos: position{line: 36, col: 17, offset: 862},
|
|
run: (*parser).callonStringLiteral2,
|
|
expr: &choiceExpr{
|
|
pos: position{line: 36, col: 19, offset: 864},
|
|
alternatives: []interface{}{
|
|
&seqExpr{
|
|
pos: position{line: 36, col: 19, offset: 864},
|
|
exprs: []interface{}{
|
|
&litMatcher{
|
|
pos: position{line: 36, col: 19, offset: 864},
|
|
val: "\"",
|
|
ignoreCase: false,
|
|
},
|
|
&zeroOrMoreExpr{
|
|
pos: position{line: 36, col: 23, offset: 868},
|
|
expr: &ruleRefExpr{
|
|
pos: position{line: 36, col: 23, offset: 868},
|
|
name: "DoubleStringChar",
|
|
},
|
|
},
|
|
&litMatcher{
|
|
pos: position{line: 36, col: 41, offset: 886},
|
|
val: "\"",
|
|
ignoreCase: false,
|
|
},
|
|
},
|
|
},
|
|
&seqExpr{
|
|
pos: position{line: 36, col: 47, offset: 892},
|
|
exprs: []interface{}{
|
|
&litMatcher{
|
|
pos: position{line: 36, col: 47, offset: 892},
|
|
val: "'",
|
|
ignoreCase: false,
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 36, col: 51, offset: 896},
|
|
name: "SingleStringChar",
|
|
},
|
|
&litMatcher{
|
|
pos: position{line: 36, col: 68, offset: 913},
|
|
val: "'",
|
|
ignoreCase: false,
|
|
},
|
|
},
|
|
},
|
|
&seqExpr{
|
|
pos: position{line: 36, col: 74, offset: 919},
|
|
exprs: []interface{}{
|
|
&litMatcher{
|
|
pos: position{line: 36, col: 74, offset: 919},
|
|
val: "`",
|
|
ignoreCase: false,
|
|
},
|
|
&zeroOrMoreExpr{
|
|
pos: position{line: 36, col: 78, offset: 923},
|
|
expr: &ruleRefExpr{
|
|
pos: position{line: 36, col: 78, offset: 923},
|
|
name: "RawStringChar",
|
|
},
|
|
},
|
|
&litMatcher{
|
|
pos: position{line: 36, col: 93, offset: 938},
|
|
val: "`",
|
|
ignoreCase: false,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
&actionExpr{
|
|
pos: position{line: 42, col: 5, offset: 1084},
|
|
run: (*parser).callonStringLiteral18,
|
|
expr: &choiceExpr{
|
|
pos: position{line: 42, col: 7, offset: 1086},
|
|
alternatives: []interface{}{
|
|
&seqExpr{
|
|
pos: position{line: 42, col: 9, offset: 1088},
|
|
exprs: []interface{}{
|
|
&litMatcher{
|
|
pos: position{line: 42, col: 9, offset: 1088},
|
|
val: "\"",
|
|
ignoreCase: false,
|
|
},
|
|
&zeroOrMoreExpr{
|
|
pos: position{line: 42, col: 13, offset: 1092},
|
|
expr: &ruleRefExpr{
|
|
pos: position{line: 42, col: 13, offset: 1092},
|
|
name: "DoubleStringChar",
|
|
},
|
|
},
|
|
&choiceExpr{
|
|
pos: position{line: 42, col: 33, offset: 1112},
|
|
alternatives: []interface{}{
|
|
&ruleRefExpr{
|
|
pos: position{line: 42, col: 33, offset: 1112},
|
|
name: "EOL",
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 42, col: 39, offset: 1118},
|
|
name: "EOF",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
&seqExpr{
|
|
pos: position{line: 42, col: 51, offset: 1130},
|
|
exprs: []interface{}{
|
|
&litMatcher{
|
|
pos: position{line: 42, col: 51, offset: 1130},
|
|
val: "'",
|
|
ignoreCase: false,
|
|
},
|
|
&zeroOrOneExpr{
|
|
pos: position{line: 42, col: 55, offset: 1134},
|
|
expr: &ruleRefExpr{
|
|
pos: position{line: 42, col: 55, offset: 1134},
|
|
name: "SingleStringChar",
|
|
},
|
|
},
|
|
&choiceExpr{
|
|
pos: position{line: 42, col: 75, offset: 1154},
|
|
alternatives: []interface{}{
|
|
&ruleRefExpr{
|
|
pos: position{line: 42, col: 75, offset: 1154},
|
|
name: "EOL",
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 42, col: 81, offset: 1160},
|
|
name: "EOF",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
&seqExpr{
|
|
pos: position{line: 42, col: 91, offset: 1170},
|
|
exprs: []interface{}{
|
|
&litMatcher{
|
|
pos: position{line: 42, col: 91, offset: 1170},
|
|
val: "`",
|
|
ignoreCase: false,
|
|
},
|
|
&zeroOrMoreExpr{
|
|
pos: position{line: 42, col: 95, offset: 1174},
|
|
expr: &ruleRefExpr{
|
|
pos: position{line: 42, col: 95, offset: 1174},
|
|
name: "RawStringChar",
|
|
},
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 42, col: 110, offset: 1189},
|
|
name: "EOF",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
{
|
|
name: "DoubleStringChar",
|
|
pos: position{line: 46, col: 1, offset: 1260},
|
|
expr: &choiceExpr{
|
|
pos: position{line: 46, col: 20, offset: 1279},
|
|
alternatives: []interface{}{
|
|
&seqExpr{
|
|
pos: position{line: 46, col: 20, offset: 1279},
|
|
exprs: []interface{}{
|
|
¬Expr{
|
|
pos: position{line: 46, col: 20, offset: 1279},
|
|
expr: &choiceExpr{
|
|
pos: position{line: 46, col: 23, offset: 1282},
|
|
alternatives: []interface{}{
|
|
&litMatcher{
|
|
pos: position{line: 46, col: 23, offset: 1282},
|
|
val: "\"",
|
|
ignoreCase: false,
|
|
},
|
|
&litMatcher{
|
|
pos: position{line: 46, col: 29, offset: 1288},
|
|
val: "\\",
|
|
ignoreCase: false,
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 46, col: 36, offset: 1295},
|
|
name: "EOL",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 46, col: 42, offset: 1301},
|
|
name: "SourceChar",
|
|
},
|
|
},
|
|
},
|
|
&seqExpr{
|
|
pos: position{line: 46, col: 55, offset: 1314},
|
|
exprs: []interface{}{
|
|
&litMatcher{
|
|
pos: position{line: 46, col: 55, offset: 1314},
|
|
val: "\\",
|
|
ignoreCase: false,
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 46, col: 60, offset: 1319},
|
|
name: "DoubleStringEscape",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
{
|
|
name: "SingleStringChar",
|
|
pos: position{line: 47, col: 1, offset: 1338},
|
|
expr: &choiceExpr{
|
|
pos: position{line: 47, col: 20, offset: 1357},
|
|
alternatives: []interface{}{
|
|
&seqExpr{
|
|
pos: position{line: 47, col: 20, offset: 1357},
|
|
exprs: []interface{}{
|
|
¬Expr{
|
|
pos: position{line: 47, col: 20, offset: 1357},
|
|
expr: &choiceExpr{
|
|
pos: position{line: 47, col: 23, offset: 1360},
|
|
alternatives: []interface{}{
|
|
&litMatcher{
|
|
pos: position{line: 47, col: 23, offset: 1360},
|
|
val: "'",
|
|
ignoreCase: false,
|
|
},
|
|
&litMatcher{
|
|
pos: position{line: 47, col: 29, offset: 1366},
|
|
val: "\\",
|
|
ignoreCase: false,
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 47, col: 36, offset: 1373},
|
|
name: "EOL",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 47, col: 42, offset: 1379},
|
|
name: "SourceChar",
|
|
},
|
|
},
|
|
},
|
|
&seqExpr{
|
|
pos: position{line: 47, col: 55, offset: 1392},
|
|
exprs: []interface{}{
|
|
&litMatcher{
|
|
pos: position{line: 47, col: 55, offset: 1392},
|
|
val: "\\",
|
|
ignoreCase: false,
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 47, col: 60, offset: 1397},
|
|
name: "SingleStringEscape",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
{
|
|
name: "RawStringChar",
|
|
pos: position{line: 48, col: 1, offset: 1416},
|
|
expr: &seqExpr{
|
|
pos: position{line: 48, col: 17, offset: 1432},
|
|
exprs: []interface{}{
|
|
¬Expr{
|
|
pos: position{line: 48, col: 17, offset: 1432},
|
|
expr: &litMatcher{
|
|
pos: position{line: 48, col: 18, offset: 1433},
|
|
val: "`",
|
|
ignoreCase: false,
|
|
},
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 48, col: 22, offset: 1437},
|
|
name: "SourceChar",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
{
|
|
name: "DoubleStringEscape",
|
|
pos: position{line: 50, col: 1, offset: 1449},
|
|
expr: &choiceExpr{
|
|
pos: position{line: 50, col: 22, offset: 1470},
|
|
alternatives: []interface{}{
|
|
&choiceExpr{
|
|
pos: position{line: 50, col: 24, offset: 1472},
|
|
alternatives: []interface{}{
|
|
&litMatcher{
|
|
pos: position{line: 50, col: 24, offset: 1472},
|
|
val: "\"",
|
|
ignoreCase: false,
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 50, col: 30, offset: 1478},
|
|
name: "CommonEscapeSequence",
|
|
},
|
|
},
|
|
},
|
|
&actionExpr{
|
|
pos: position{line: 51, col: 7, offset: 1507},
|
|
run: (*parser).callonDoubleStringEscape5,
|
|
expr: &choiceExpr{
|
|
pos: position{line: 51, col: 9, offset: 1509},
|
|
alternatives: []interface{}{
|
|
&ruleRefExpr{
|
|
pos: position{line: 51, col: 9, offset: 1509},
|
|
name: "SourceChar",
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 51, col: 22, offset: 1522},
|
|
name: "EOL",
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 51, col: 28, offset: 1528},
|
|
name: "EOF",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
{
|
|
name: "SingleStringEscape",
|
|
pos: position{line: 54, col: 1, offset: 1593},
|
|
expr: &choiceExpr{
|
|
pos: position{line: 54, col: 22, offset: 1614},
|
|
alternatives: []interface{}{
|
|
&choiceExpr{
|
|
pos: position{line: 54, col: 24, offset: 1616},
|
|
alternatives: []interface{}{
|
|
&litMatcher{
|
|
pos: position{line: 54, col: 24, offset: 1616},
|
|
val: "'",
|
|
ignoreCase: false,
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 54, col: 30, offset: 1622},
|
|
name: "CommonEscapeSequence",
|
|
},
|
|
},
|
|
},
|
|
&actionExpr{
|
|
pos: position{line: 55, col: 7, offset: 1651},
|
|
run: (*parser).callonSingleStringEscape5,
|
|
expr: &choiceExpr{
|
|
pos: position{line: 55, col: 9, offset: 1653},
|
|
alternatives: []interface{}{
|
|
&ruleRefExpr{
|
|
pos: position{line: 55, col: 9, offset: 1653},
|
|
name: "SourceChar",
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 55, col: 22, offset: 1666},
|
|
name: "EOL",
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 55, col: 28, offset: 1672},
|
|
name: "EOF",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
{
|
|
name: "CommonEscapeSequence",
|
|
pos: position{line: 59, col: 1, offset: 1738},
|
|
expr: &choiceExpr{
|
|
pos: position{line: 59, col: 24, offset: 1761},
|
|
alternatives: []interface{}{
|
|
&ruleRefExpr{
|
|
pos: position{line: 59, col: 24, offset: 1761},
|
|
name: "SingleCharEscape",
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 59, col: 43, offset: 1780},
|
|
name: "OctalEscape",
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 59, col: 57, offset: 1794},
|
|
name: "HexEscape",
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 59, col: 69, offset: 1806},
|
|
name: "LongUnicodeEscape",
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 59, col: 89, offset: 1826},
|
|
name: "ShortUnicodeEscape",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
{
|
|
name: "SingleCharEscape",
|
|
pos: position{line: 60, col: 1, offset: 1845},
|
|
expr: &choiceExpr{
|
|
pos: position{line: 60, col: 20, offset: 1864},
|
|
alternatives: []interface{}{
|
|
&litMatcher{
|
|
pos: position{line: 60, col: 20, offset: 1864},
|
|
val: "a",
|
|
ignoreCase: false,
|
|
},
|
|
&litMatcher{
|
|
pos: position{line: 60, col: 26, offset: 1870},
|
|
val: "b",
|
|
ignoreCase: false,
|
|
},
|
|
&litMatcher{
|
|
pos: position{line: 60, col: 32, offset: 1876},
|
|
val: "n",
|
|
ignoreCase: false,
|
|
},
|
|
&litMatcher{
|
|
pos: position{line: 60, col: 38, offset: 1882},
|
|
val: "f",
|
|
ignoreCase: false,
|
|
},
|
|
&litMatcher{
|
|
pos: position{line: 60, col: 44, offset: 1888},
|
|
val: "r",
|
|
ignoreCase: false,
|
|
},
|
|
&litMatcher{
|
|
pos: position{line: 60, col: 50, offset: 1894},
|
|
val: "t",
|
|
ignoreCase: false,
|
|
},
|
|
&litMatcher{
|
|
pos: position{line: 60, col: 56, offset: 1900},
|
|
val: "v",
|
|
ignoreCase: false,
|
|
},
|
|
&litMatcher{
|
|
pos: position{line: 60, col: 62, offset: 1906},
|
|
val: "\\",
|
|
ignoreCase: false,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
{
|
|
name: "OctalEscape",
|
|
pos: position{line: 61, col: 1, offset: 1911},
|
|
expr: &choiceExpr{
|
|
pos: position{line: 61, col: 15, offset: 1925},
|
|
alternatives: []interface{}{
|
|
&seqExpr{
|
|
pos: position{line: 61, col: 15, offset: 1925},
|
|
exprs: []interface{}{
|
|
&ruleRefExpr{
|
|
pos: position{line: 61, col: 15, offset: 1925},
|
|
name: "OctalDigit",
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 61, col: 26, offset: 1936},
|
|
name: "OctalDigit",
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 61, col: 37, offset: 1947},
|
|
name: "OctalDigit",
|
|
},
|
|
},
|
|
},
|
|
&actionExpr{
|
|
pos: position{line: 62, col: 7, offset: 1964},
|
|
run: (*parser).callonOctalEscape6,
|
|
expr: &seqExpr{
|
|
pos: position{line: 62, col: 7, offset: 1964},
|
|
exprs: []interface{}{
|
|
&ruleRefExpr{
|
|
pos: position{line: 62, col: 7, offset: 1964},
|
|
name: "OctalDigit",
|
|
},
|
|
&choiceExpr{
|
|
pos: position{line: 62, col: 20, offset: 1977},
|
|
alternatives: []interface{}{
|
|
&ruleRefExpr{
|
|
pos: position{line: 62, col: 20, offset: 1977},
|
|
name: "SourceChar",
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 62, col: 33, offset: 1990},
|
|
name: "EOL",
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 62, col: 39, offset: 1996},
|
|
name: "EOF",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
{
|
|
name: "HexEscape",
|
|
pos: position{line: 65, col: 1, offset: 2057},
|
|
expr: &choiceExpr{
|
|
pos: position{line: 65, col: 13, offset: 2069},
|
|
alternatives: []interface{}{
|
|
&seqExpr{
|
|
pos: position{line: 65, col: 13, offset: 2069},
|
|
exprs: []interface{}{
|
|
&litMatcher{
|
|
pos: position{line: 65, col: 13, offset: 2069},
|
|
val: "x",
|
|
ignoreCase: false,
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 65, col: 17, offset: 2073},
|
|
name: "HexDigit",
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 65, col: 26, offset: 2082},
|
|
name: "HexDigit",
|
|
},
|
|
},
|
|
},
|
|
&actionExpr{
|
|
pos: position{line: 66, col: 7, offset: 2097},
|
|
run: (*parser).callonHexEscape6,
|
|
expr: &seqExpr{
|
|
pos: position{line: 66, col: 7, offset: 2097},
|
|
exprs: []interface{}{
|
|
&litMatcher{
|
|
pos: position{line: 66, col: 7, offset: 2097},
|
|
val: "x",
|
|
ignoreCase: false,
|
|
},
|
|
&choiceExpr{
|
|
pos: position{line: 66, col: 13, offset: 2103},
|
|
alternatives: []interface{}{
|
|
&ruleRefExpr{
|
|
pos: position{line: 66, col: 13, offset: 2103},
|
|
name: "SourceChar",
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 66, col: 26, offset: 2116},
|
|
name: "EOL",
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 66, col: 32, offset: 2122},
|
|
name: "EOF",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
{
|
|
name: "LongUnicodeEscape",
|
|
pos: position{line: 69, col: 1, offset: 2189},
|
|
expr: &choiceExpr{
|
|
pos: position{line: 70, col: 5, offset: 2214},
|
|
alternatives: []interface{}{
|
|
&actionExpr{
|
|
pos: position{line: 70, col: 5, offset: 2214},
|
|
run: (*parser).callonLongUnicodeEscape2,
|
|
expr: &seqExpr{
|
|
pos: position{line: 70, col: 5, offset: 2214},
|
|
exprs: []interface{}{
|
|
&litMatcher{
|
|
pos: position{line: 70, col: 5, offset: 2214},
|
|
val: "U",
|
|
ignoreCase: false,
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 70, col: 9, offset: 2218},
|
|
name: "HexDigit",
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 70, col: 18, offset: 2227},
|
|
name: "HexDigit",
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 70, col: 27, offset: 2236},
|
|
name: "HexDigit",
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 70, col: 36, offset: 2245},
|
|
name: "HexDigit",
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 70, col: 45, offset: 2254},
|
|
name: "HexDigit",
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 70, col: 54, offset: 2263},
|
|
name: "HexDigit",
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 70, col: 63, offset: 2272},
|
|
name: "HexDigit",
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 70, col: 72, offset: 2281},
|
|
name: "HexDigit",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
&actionExpr{
|
|
pos: position{line: 73, col: 7, offset: 2383},
|
|
run: (*parser).callonLongUnicodeEscape13,
|
|
expr: &seqExpr{
|
|
pos: position{line: 73, col: 7, offset: 2383},
|
|
exprs: []interface{}{
|
|
&litMatcher{
|
|
pos: position{line: 73, col: 7, offset: 2383},
|
|
val: "U",
|
|
ignoreCase: false,
|
|
},
|
|
&choiceExpr{
|
|
pos: position{line: 73, col: 13, offset: 2389},
|
|
alternatives: []interface{}{
|
|
&ruleRefExpr{
|
|
pos: position{line: 73, col: 13, offset: 2389},
|
|
name: "SourceChar",
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 73, col: 26, offset: 2402},
|
|
name: "EOL",
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 73, col: 32, offset: 2408},
|
|
name: "EOF",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
{
|
|
name: "ShortUnicodeEscape",
|
|
pos: position{line: 76, col: 1, offset: 2471},
|
|
expr: &choiceExpr{
|
|
pos: position{line: 77, col: 5, offset: 2497},
|
|
alternatives: []interface{}{
|
|
&actionExpr{
|
|
pos: position{line: 77, col: 5, offset: 2497},
|
|
run: (*parser).callonShortUnicodeEscape2,
|
|
expr: &seqExpr{
|
|
pos: position{line: 77, col: 5, offset: 2497},
|
|
exprs: []interface{}{
|
|
&litMatcher{
|
|
pos: position{line: 77, col: 5, offset: 2497},
|
|
val: "u",
|
|
ignoreCase: false,
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 77, col: 9, offset: 2501},
|
|
name: "HexDigit",
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 77, col: 18, offset: 2510},
|
|
name: "HexDigit",
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 77, col: 27, offset: 2519},
|
|
name: "HexDigit",
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 77, col: 36, offset: 2528},
|
|
name: "HexDigit",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
&actionExpr{
|
|
pos: position{line: 80, col: 7, offset: 2630},
|
|
run: (*parser).callonShortUnicodeEscape9,
|
|
expr: &seqExpr{
|
|
pos: position{line: 80, col: 7, offset: 2630},
|
|
exprs: []interface{}{
|
|
&litMatcher{
|
|
pos: position{line: 80, col: 7, offset: 2630},
|
|
val: "u",
|
|
ignoreCase: false,
|
|
},
|
|
&choiceExpr{
|
|
pos: position{line: 80, col: 13, offset: 2636},
|
|
alternatives: []interface{}{
|
|
&ruleRefExpr{
|
|
pos: position{line: 80, col: 13, offset: 2636},
|
|
name: "SourceChar",
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 80, col: 26, offset: 2649},
|
|
name: "EOL",
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 80, col: 32, offset: 2655},
|
|
name: "EOF",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
{
|
|
name: "OctalDigit",
|
|
pos: position{line: 84, col: 1, offset: 2719},
|
|
expr: &charClassMatcher{
|
|
pos: position{line: 84, col: 14, offset: 2732},
|
|
val: "[0-7]",
|
|
ranges: []rune{'0', '7'},
|
|
ignoreCase: false,
|
|
inverted: false,
|
|
},
|
|
},
|
|
{
|
|
name: "DecimalDigit",
|
|
pos: position{line: 85, col: 1, offset: 2738},
|
|
expr: &charClassMatcher{
|
|
pos: position{line: 85, col: 16, offset: 2753},
|
|
val: "[0-9]",
|
|
ranges: []rune{'0', '9'},
|
|
ignoreCase: false,
|
|
inverted: false,
|
|
},
|
|
},
|
|
{
|
|
name: "HexDigit",
|
|
pos: position{line: 86, col: 1, offset: 2759},
|
|
expr: &charClassMatcher{
|
|
pos: position{line: 86, col: 12, offset: 2770},
|
|
val: "[0-9a-f]i",
|
|
ranges: []rune{'0', '9', 'a', 'f'},
|
|
ignoreCase: true,
|
|
inverted: false,
|
|
},
|
|
},
|
|
{
|
|
name: "CharClassMatcher",
|
|
pos: position{line: 88, col: 1, offset: 2781},
|
|
expr: &choiceExpr{
|
|
pos: position{line: 88, col: 20, offset: 2800},
|
|
alternatives: []interface{}{
|
|
&actionExpr{
|
|
pos: position{line: 88, col: 20, offset: 2800},
|
|
run: (*parser).callonCharClassMatcher2,
|
|
expr: &seqExpr{
|
|
pos: position{line: 88, col: 20, offset: 2800},
|
|
exprs: []interface{}{
|
|
&litMatcher{
|
|
pos: position{line: 88, col: 20, offset: 2800},
|
|
val: "[",
|
|
ignoreCase: false,
|
|
},
|
|
&zeroOrMoreExpr{
|
|
pos: position{line: 88, col: 24, offset: 2804},
|
|
expr: &choiceExpr{
|
|
pos: position{line: 88, col: 26, offset: 2806},
|
|
alternatives: []interface{}{
|
|
&ruleRefExpr{
|
|
pos: position{line: 88, col: 26, offset: 2806},
|
|
name: "ClassCharRange",
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 88, col: 43, offset: 2823},
|
|
name: "ClassChar",
|
|
},
|
|
&seqExpr{
|
|
pos: position{line: 88, col: 55, offset: 2835},
|
|
exprs: []interface{}{
|
|
&litMatcher{
|
|
pos: position{line: 88, col: 55, offset: 2835},
|
|
val: "\\",
|
|
ignoreCase: false,
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 88, col: 60, offset: 2840},
|
|
name: "UnicodeClassEscape",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
&litMatcher{
|
|
pos: position{line: 88, col: 82, offset: 2862},
|
|
val: "]",
|
|
ignoreCase: false,
|
|
},
|
|
&zeroOrOneExpr{
|
|
pos: position{line: 88, col: 86, offset: 2866},
|
|
expr: &litMatcher{
|
|
pos: position{line: 88, col: 86, offset: 2866},
|
|
val: "i",
|
|
ignoreCase: false,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
&actionExpr{
|
|
pos: position{line: 90, col: 5, offset: 2908},
|
|
run: (*parser).callonCharClassMatcher15,
|
|
expr: &seqExpr{
|
|
pos: position{line: 90, col: 5, offset: 2908},
|
|
exprs: []interface{}{
|
|
&litMatcher{
|
|
pos: position{line: 90, col: 5, offset: 2908},
|
|
val: "[",
|
|
ignoreCase: false,
|
|
},
|
|
&zeroOrMoreExpr{
|
|
pos: position{line: 90, col: 9, offset: 2912},
|
|
expr: &seqExpr{
|
|
pos: position{line: 90, col: 11, offset: 2914},
|
|
exprs: []interface{}{
|
|
¬Expr{
|
|
pos: position{line: 90, col: 11, offset: 2914},
|
|
expr: &ruleRefExpr{
|
|
pos: position{line: 90, col: 14, offset: 2917},
|
|
name: "EOL",
|
|
},
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 90, col: 20, offset: 2923},
|
|
name: "SourceChar",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
&choiceExpr{
|
|
pos: position{line: 90, col: 36, offset: 2939},
|
|
alternatives: []interface{}{
|
|
&ruleRefExpr{
|
|
pos: position{line: 90, col: 36, offset: 2939},
|
|
name: "EOL",
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 90, col: 42, offset: 2945},
|
|
name: "EOF",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
{
|
|
name: "ClassCharRange",
|
|
pos: position{line: 94, col: 1, offset: 3017},
|
|
expr: &seqExpr{
|
|
pos: position{line: 94, col: 18, offset: 3034},
|
|
exprs: []interface{}{
|
|
&ruleRefExpr{
|
|
pos: position{line: 94, col: 18, offset: 3034},
|
|
name: "ClassChar",
|
|
},
|
|
&litMatcher{
|
|
pos: position{line: 94, col: 28, offset: 3044},
|
|
val: "-",
|
|
ignoreCase: false,
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 94, col: 32, offset: 3048},
|
|
name: "ClassChar",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
{
|
|
name: "ClassChar",
|
|
pos: position{line: 95, col: 1, offset: 3058},
|
|
expr: &choiceExpr{
|
|
pos: position{line: 95, col: 13, offset: 3070},
|
|
alternatives: []interface{}{
|
|
&seqExpr{
|
|
pos: position{line: 95, col: 13, offset: 3070},
|
|
exprs: []interface{}{
|
|
¬Expr{
|
|
pos: position{line: 95, col: 13, offset: 3070},
|
|
expr: &choiceExpr{
|
|
pos: position{line: 95, col: 16, offset: 3073},
|
|
alternatives: []interface{}{
|
|
&litMatcher{
|
|
pos: position{line: 95, col: 16, offset: 3073},
|
|
val: "]",
|
|
ignoreCase: false,
|
|
},
|
|
&litMatcher{
|
|
pos: position{line: 95, col: 22, offset: 3079},
|
|
val: "\\",
|
|
ignoreCase: false,
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 95, col: 29, offset: 3086},
|
|
name: "EOL",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 95, col: 35, offset: 3092},
|
|
name: "SourceChar",
|
|
},
|
|
},
|
|
},
|
|
&seqExpr{
|
|
pos: position{line: 95, col: 48, offset: 3105},
|
|
exprs: []interface{}{
|
|
&litMatcher{
|
|
pos: position{line: 95, col: 48, offset: 3105},
|
|
val: "\\",
|
|
ignoreCase: false,
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 95, col: 53, offset: 3110},
|
|
name: "CharClassEscape",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
{
|
|
name: "CharClassEscape",
|
|
pos: position{line: 96, col: 1, offset: 3126},
|
|
expr: &choiceExpr{
|
|
pos: position{line: 96, col: 19, offset: 3144},
|
|
alternatives: []interface{}{
|
|
&choiceExpr{
|
|
pos: position{line: 96, col: 21, offset: 3146},
|
|
alternatives: []interface{}{
|
|
&litMatcher{
|
|
pos: position{line: 96, col: 21, offset: 3146},
|
|
val: "]",
|
|
ignoreCase: false,
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 96, col: 27, offset: 3152},
|
|
name: "CommonEscapeSequence",
|
|
},
|
|
},
|
|
},
|
|
&actionExpr{
|
|
pos: position{line: 97, col: 7, offset: 3181},
|
|
run: (*parser).callonCharClassEscape5,
|
|
expr: &seqExpr{
|
|
pos: position{line: 97, col: 7, offset: 3181},
|
|
exprs: []interface{}{
|
|
¬Expr{
|
|
pos: position{line: 97, col: 7, offset: 3181},
|
|
expr: &litMatcher{
|
|
pos: position{line: 97, col: 8, offset: 3182},
|
|
val: "p",
|
|
ignoreCase: false,
|
|
},
|
|
},
|
|
&choiceExpr{
|
|
pos: position{line: 97, col: 14, offset: 3188},
|
|
alternatives: []interface{}{
|
|
&ruleRefExpr{
|
|
pos: position{line: 97, col: 14, offset: 3188},
|
|
name: "SourceChar",
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 97, col: 27, offset: 3201},
|
|
name: "EOL",
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 97, col: 33, offset: 3207},
|
|
name: "EOF",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
{
|
|
name: "UnicodeClassEscape",
|
|
pos: position{line: 101, col: 1, offset: 3273},
|
|
expr: &seqExpr{
|
|
pos: position{line: 101, col: 22, offset: 3294},
|
|
exprs: []interface{}{
|
|
&litMatcher{
|
|
pos: position{line: 101, col: 22, offset: 3294},
|
|
val: "p",
|
|
ignoreCase: false,
|
|
},
|
|
&choiceExpr{
|
|
pos: position{line: 102, col: 7, offset: 3307},
|
|
alternatives: []interface{}{
|
|
&ruleRefExpr{
|
|
pos: position{line: 102, col: 7, offset: 3307},
|
|
name: "SingleCharUnicodeClass",
|
|
},
|
|
&actionExpr{
|
|
pos: position{line: 103, col: 7, offset: 3336},
|
|
run: (*parser).callonUnicodeClassEscape5,
|
|
expr: &seqExpr{
|
|
pos: position{line: 103, col: 7, offset: 3336},
|
|
exprs: []interface{}{
|
|
¬Expr{
|
|
pos: position{line: 103, col: 7, offset: 3336},
|
|
expr: &litMatcher{
|
|
pos: position{line: 103, col: 8, offset: 3337},
|
|
val: "{",
|
|
ignoreCase: false,
|
|
},
|
|
},
|
|
&choiceExpr{
|
|
pos: position{line: 103, col: 14, offset: 3343},
|
|
alternatives: []interface{}{
|
|
&ruleRefExpr{
|
|
pos: position{line: 103, col: 14, offset: 3343},
|
|
name: "SourceChar",
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 103, col: 27, offset: 3356},
|
|
name: "EOL",
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 103, col: 33, offset: 3362},
|
|
name: "EOF",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
&actionExpr{
|
|
pos: position{line: 104, col: 7, offset: 3433},
|
|
run: (*parser).callonUnicodeClassEscape13,
|
|
expr: &seqExpr{
|
|
pos: position{line: 104, col: 7, offset: 3433},
|
|
exprs: []interface{}{
|
|
&litMatcher{
|
|
pos: position{line: 104, col: 7, offset: 3433},
|
|
val: "{",
|
|
ignoreCase: false,
|
|
},
|
|
&labeledExpr{
|
|
pos: position{line: 104, col: 11, offset: 3437},
|
|
label: "ident",
|
|
expr: &ruleRefExpr{
|
|
pos: position{line: 104, col: 17, offset: 3443},
|
|
name: "IdentifierName",
|
|
},
|
|
},
|
|
&litMatcher{
|
|
pos: position{line: 104, col: 32, offset: 3458},
|
|
val: "}",
|
|
ignoreCase: false,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
&actionExpr{
|
|
pos: position{line: 110, col: 7, offset: 3622},
|
|
run: (*parser).callonUnicodeClassEscape19,
|
|
expr: &seqExpr{
|
|
pos: position{line: 110, col: 7, offset: 3622},
|
|
exprs: []interface{}{
|
|
&litMatcher{
|
|
pos: position{line: 110, col: 7, offset: 3622},
|
|
val: "{",
|
|
ignoreCase: false,
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 110, col: 11, offset: 3626},
|
|
name: "IdentifierName",
|
|
},
|
|
&choiceExpr{
|
|
pos: position{line: 110, col: 28, offset: 3643},
|
|
alternatives: []interface{}{
|
|
&litMatcher{
|
|
pos: position{line: 110, col: 28, offset: 3643},
|
|
val: "]",
|
|
ignoreCase: false,
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 110, col: 34, offset: 3649},
|
|
name: "EOL",
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 110, col: 40, offset: 3655},
|
|
name: "EOF",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
{
|
|
name: "SingleCharUnicodeClass",
|
|
pos: position{line: 115, col: 1, offset: 3735},
|
|
expr: &charClassMatcher{
|
|
pos: position{line: 115, col: 26, offset: 3760},
|
|
val: "[LMNCPZS]",
|
|
chars: []rune{'L', 'M', 'N', 'C', 'P', 'Z', 'S'},
|
|
ignoreCase: false,
|
|
inverted: false,
|
|
},
|
|
},
|
|
{
|
|
name: "Number",
|
|
pos: position{line: 118, col: 1, offset: 3772},
|
|
expr: &actionExpr{
|
|
pos: position{line: 118, col: 10, offset: 3781},
|
|
run: (*parser).callonNumber1,
|
|
expr: &seqExpr{
|
|
pos: position{line: 118, col: 10, offset: 3781},
|
|
exprs: []interface{}{
|
|
&zeroOrOneExpr{
|
|
pos: position{line: 118, col: 10, offset: 3781},
|
|
expr: &litMatcher{
|
|
pos: position{line: 118, col: 10, offset: 3781},
|
|
val: "-",
|
|
ignoreCase: false,
|
|
},
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 118, col: 15, offset: 3786},
|
|
name: "Integer",
|
|
},
|
|
&zeroOrOneExpr{
|
|
pos: position{line: 118, col: 23, offset: 3794},
|
|
expr: &seqExpr{
|
|
pos: position{line: 118, col: 25, offset: 3796},
|
|
exprs: []interface{}{
|
|
&litMatcher{
|
|
pos: position{line: 118, col: 25, offset: 3796},
|
|
val: ".",
|
|
ignoreCase: false,
|
|
},
|
|
&oneOrMoreExpr{
|
|
pos: position{line: 118, col: 29, offset: 3800},
|
|
expr: &ruleRefExpr{
|
|
pos: position{line: 118, col: 29, offset: 3800},
|
|
name: "Digit",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
{
|
|
name: "Integer",
|
|
pos: position{line: 122, col: 1, offset: 3852},
|
|
expr: &choiceExpr{
|
|
pos: position{line: 122, col: 11, offset: 3862},
|
|
alternatives: []interface{}{
|
|
&litMatcher{
|
|
pos: position{line: 122, col: 11, offset: 3862},
|
|
val: "0",
|
|
ignoreCase: false,
|
|
},
|
|
&actionExpr{
|
|
pos: position{line: 122, col: 17, offset: 3868},
|
|
run: (*parser).callonInteger3,
|
|
expr: &seqExpr{
|
|
pos: position{line: 122, col: 17, offset: 3868},
|
|
exprs: []interface{}{
|
|
&ruleRefExpr{
|
|
pos: position{line: 122, col: 17, offset: 3868},
|
|
name: "NonZeroDigit",
|
|
},
|
|
&zeroOrMoreExpr{
|
|
pos: position{line: 122, col: 30, offset: 3881},
|
|
expr: &ruleRefExpr{
|
|
pos: position{line: 122, col: 30, offset: 3881},
|
|
name: "Digit",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
{
|
|
name: "NonZeroDigit",
|
|
pos: position{line: 126, col: 1, offset: 3945},
|
|
expr: &charClassMatcher{
|
|
pos: position{line: 126, col: 16, offset: 3960},
|
|
val: "[1-9]",
|
|
ranges: []rune{'1', '9'},
|
|
ignoreCase: false,
|
|
inverted: false,
|
|
},
|
|
},
|
|
{
|
|
name: "Digit",
|
|
pos: position{line: 127, col: 1, offset: 3966},
|
|
expr: &charClassMatcher{
|
|
pos: position{line: 127, col: 9, offset: 3974},
|
|
val: "[0-9]",
|
|
ranges: []rune{'0', '9'},
|
|
ignoreCase: false,
|
|
inverted: false,
|
|
},
|
|
},
|
|
{
|
|
name: "LabelBlock",
|
|
pos: position{line: 129, col: 1, offset: 3981},
|
|
expr: &choiceExpr{
|
|
pos: position{line: 129, col: 14, offset: 3994},
|
|
alternatives: []interface{}{
|
|
&actionExpr{
|
|
pos: position{line: 129, col: 14, offset: 3994},
|
|
run: (*parser).callonLabelBlock2,
|
|
expr: &seqExpr{
|
|
pos: position{line: 129, col: 14, offset: 3994},
|
|
exprs: []interface{}{
|
|
&litMatcher{
|
|
pos: position{line: 129, col: 14, offset: 3994},
|
|
val: "{",
|
|
ignoreCase: false,
|
|
},
|
|
&labeledExpr{
|
|
pos: position{line: 129, col: 18, offset: 3998},
|
|
label: "block",
|
|
expr: &ruleRefExpr{
|
|
pos: position{line: 129, col: 24, offset: 4004},
|
|
name: "LabelMatches",
|
|
},
|
|
},
|
|
&litMatcher{
|
|
pos: position{line: 129, col: 37, offset: 4017},
|
|
val: "}",
|
|
ignoreCase: false,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
&actionExpr{
|
|
pos: position{line: 131, col: 5, offset: 4049},
|
|
run: (*parser).callonLabelBlock8,
|
|
expr: &seqExpr{
|
|
pos: position{line: 131, col: 5, offset: 4049},
|
|
exprs: []interface{}{
|
|
&litMatcher{
|
|
pos: position{line: 131, col: 5, offset: 4049},
|
|
val: "{",
|
|
ignoreCase: false,
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 131, col: 9, offset: 4053},
|
|
name: "LabelMatches",
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 131, col: 22, offset: 4066},
|
|
name: "EOF",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
{
|
|
name: "NanoSecondUnits",
|
|
pos: position{line: 135, col: 1, offset: 4131},
|
|
expr: &actionExpr{
|
|
pos: position{line: 135, col: 19, offset: 4149},
|
|
run: (*parser).callonNanoSecondUnits1,
|
|
expr: &litMatcher{
|
|
pos: position{line: 135, col: 19, offset: 4149},
|
|
val: "ns",
|
|
ignoreCase: false,
|
|
},
|
|
},
|
|
},
|
|
{
|
|
name: "MicroSecondUnits",
|
|
pos: position{line: 140, col: 1, offset: 4254},
|
|
expr: &actionExpr{
|
|
pos: position{line: 140, col: 20, offset: 4273},
|
|
run: (*parser).callonMicroSecondUnits1,
|
|
expr: &choiceExpr{
|
|
pos: position{line: 140, col: 21, offset: 4274},
|
|
alternatives: []interface{}{
|
|
&litMatcher{
|
|
pos: position{line: 140, col: 21, offset: 4274},
|
|
val: "us",
|
|
ignoreCase: false,
|
|
},
|
|
&litMatcher{
|
|
pos: position{line: 140, col: 28, offset: 4281},
|
|
val: "µs",
|
|
ignoreCase: false,
|
|
},
|
|
&litMatcher{
|
|
pos: position{line: 140, col: 35, offset: 4289},
|
|
val: "μs",
|
|
ignoreCase: false,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
{
|
|
name: "MilliSecondUnits",
|
|
pos: position{line: 145, col: 1, offset: 4398},
|
|
expr: &actionExpr{
|
|
pos: position{line: 145, col: 20, offset: 4417},
|
|
run: (*parser).callonMilliSecondUnits1,
|
|
expr: &litMatcher{
|
|
pos: position{line: 145, col: 20, offset: 4417},
|
|
val: "ms",
|
|
ignoreCase: false,
|
|
},
|
|
},
|
|
},
|
|
{
|
|
name: "SecondUnits",
|
|
pos: position{line: 150, col: 1, offset: 4524},
|
|
expr: &actionExpr{
|
|
pos: position{line: 150, col: 15, offset: 4538},
|
|
run: (*parser).callonSecondUnits1,
|
|
expr: &litMatcher{
|
|
pos: position{line: 150, col: 15, offset: 4538},
|
|
val: "s",
|
|
ignoreCase: false,
|
|
},
|
|
},
|
|
},
|
|
{
|
|
name: "MinuteUnits",
|
|
pos: position{line: 154, col: 1, offset: 4575},
|
|
expr: &actionExpr{
|
|
pos: position{line: 154, col: 15, offset: 4589},
|
|
run: (*parser).callonMinuteUnits1,
|
|
expr: &litMatcher{
|
|
pos: position{line: 154, col: 15, offset: 4589},
|
|
val: "m",
|
|
ignoreCase: false,
|
|
},
|
|
},
|
|
},
|
|
{
|
|
name: "HourUnits",
|
|
pos: position{line: 158, col: 1, offset: 4626},
|
|
expr: &actionExpr{
|
|
pos: position{line: 158, col: 13, offset: 4638},
|
|
run: (*parser).callonHourUnits1,
|
|
expr: &litMatcher{
|
|
pos: position{line: 158, col: 13, offset: 4638},
|
|
val: "h",
|
|
ignoreCase: false,
|
|
},
|
|
},
|
|
},
|
|
{
|
|
name: "DayUnits",
|
|
pos: position{line: 162, col: 1, offset: 4673},
|
|
expr: &actionExpr{
|
|
pos: position{line: 162, col: 12, offset: 4684},
|
|
run: (*parser).callonDayUnits1,
|
|
expr: &litMatcher{
|
|
pos: position{line: 162, col: 12, offset: 4684},
|
|
val: "d",
|
|
ignoreCase: false,
|
|
},
|
|
},
|
|
},
|
|
{
|
|
name: "WeekUnits",
|
|
pos: position{line: 168, col: 1, offset: 4892},
|
|
expr: &actionExpr{
|
|
pos: position{line: 168, col: 13, offset: 4904},
|
|
run: (*parser).callonWeekUnits1,
|
|
expr: &litMatcher{
|
|
pos: position{line: 168, col: 13, offset: 4904},
|
|
val: "w",
|
|
ignoreCase: false,
|
|
},
|
|
},
|
|
},
|
|
{
|
|
name: "YearUnits",
|
|
pos: position{line: 174, col: 1, offset: 5115},
|
|
expr: &actionExpr{
|
|
pos: position{line: 174, col: 13, offset: 5127},
|
|
run: (*parser).callonYearUnits1,
|
|
expr: &litMatcher{
|
|
pos: position{line: 174, col: 13, offset: 5127},
|
|
val: "y",
|
|
ignoreCase: false,
|
|
},
|
|
},
|
|
},
|
|
{
|
|
name: "DurationUnits",
|
|
pos: position{line: 180, col: 1, offset: 5324},
|
|
expr: &choiceExpr{
|
|
pos: position{line: 180, col: 18, offset: 5341},
|
|
alternatives: []interface{}{
|
|
&ruleRefExpr{
|
|
pos: position{line: 180, col: 18, offset: 5341},
|
|
name: "NanoSecondUnits",
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 180, col: 36, offset: 5359},
|
|
name: "MicroSecondUnits",
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 180, col: 55, offset: 5378},
|
|
name: "MilliSecondUnits",
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 180, col: 74, offset: 5397},
|
|
name: "SecondUnits",
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 180, col: 88, offset: 5411},
|
|
name: "MinuteUnits",
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 180, col: 102, offset: 5425},
|
|
name: "HourUnits",
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 180, col: 114, offset: 5437},
|
|
name: "DayUnits",
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 180, col: 125, offset: 5448},
|
|
name: "WeekUnits",
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 180, col: 137, offset: 5460},
|
|
name: "YearUnits",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
{
|
|
name: "Duration",
|
|
pos: position{line: 182, col: 1, offset: 5472},
|
|
expr: &actionExpr{
|
|
pos: position{line: 182, col: 12, offset: 5483},
|
|
run: (*parser).callonDuration1,
|
|
expr: &seqExpr{
|
|
pos: position{line: 182, col: 12, offset: 5483},
|
|
exprs: []interface{}{
|
|
&labeledExpr{
|
|
pos: position{line: 182, col: 12, offset: 5483},
|
|
label: "dur",
|
|
expr: &ruleRefExpr{
|
|
pos: position{line: 182, col: 16, offset: 5487},
|
|
name: "Integer",
|
|
},
|
|
},
|
|
&labeledExpr{
|
|
pos: position{line: 182, col: 24, offset: 5495},
|
|
label: "units",
|
|
expr: &ruleRefExpr{
|
|
pos: position{line: 182, col: 30, offset: 5501},
|
|
name: "DurationUnits",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
{
|
|
name: "Operators",
|
|
pos: position{line: 188, col: 1, offset: 5650},
|
|
expr: &choiceExpr{
|
|
pos: position{line: 188, col: 13, offset: 5662},
|
|
alternatives: []interface{}{
|
|
&litMatcher{
|
|
pos: position{line: 188, col: 13, offset: 5662},
|
|
val: "-",
|
|
ignoreCase: false,
|
|
},
|
|
&litMatcher{
|
|
pos: position{line: 188, col: 19, offset: 5668},
|
|
val: "+",
|
|
ignoreCase: false,
|
|
},
|
|
&litMatcher{
|
|
pos: position{line: 188, col: 25, offset: 5674},
|
|
val: "*",
|
|
ignoreCase: false,
|
|
},
|
|
&litMatcher{
|
|
pos: position{line: 188, col: 31, offset: 5680},
|
|
val: "%",
|
|
ignoreCase: false,
|
|
},
|
|
&litMatcher{
|
|
pos: position{line: 188, col: 37, offset: 5686},
|
|
val: "/",
|
|
ignoreCase: false,
|
|
},
|
|
&litMatcher{
|
|
pos: position{line: 188, col: 43, offset: 5692},
|
|
val: "==",
|
|
ignoreCase: false,
|
|
},
|
|
&litMatcher{
|
|
pos: position{line: 188, col: 50, offset: 5699},
|
|
val: "!=",
|
|
ignoreCase: false,
|
|
},
|
|
&litMatcher{
|
|
pos: position{line: 188, col: 57, offset: 5706},
|
|
val: "<=",
|
|
ignoreCase: false,
|
|
},
|
|
&litMatcher{
|
|
pos: position{line: 188, col: 64, offset: 5713},
|
|
val: "<",
|
|
ignoreCase: false,
|
|
},
|
|
&litMatcher{
|
|
pos: position{line: 188, col: 70, offset: 5719},
|
|
val: ">=",
|
|
ignoreCase: false,
|
|
},
|
|
&litMatcher{
|
|
pos: position{line: 188, col: 77, offset: 5726},
|
|
val: ">",
|
|
ignoreCase: false,
|
|
},
|
|
&litMatcher{
|
|
pos: position{line: 188, col: 83, offset: 5732},
|
|
val: "=~",
|
|
ignoreCase: false,
|
|
},
|
|
&litMatcher{
|
|
pos: position{line: 188, col: 90, offset: 5739},
|
|
val: "!~",
|
|
ignoreCase: false,
|
|
},
|
|
&litMatcher{
|
|
pos: position{line: 188, col: 97, offset: 5746},
|
|
val: "^",
|
|
ignoreCase: false,
|
|
},
|
|
&litMatcher{
|
|
pos: position{line: 188, col: 103, offset: 5752},
|
|
val: "=",
|
|
ignoreCase: false,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
{
|
|
name: "LabelOperators",
|
|
pos: position{line: 190, col: 1, offset: 5757},
|
|
expr: &choiceExpr{
|
|
pos: position{line: 190, col: 19, offset: 5775},
|
|
alternatives: []interface{}{
|
|
&actionExpr{
|
|
pos: position{line: 190, col: 19, offset: 5775},
|
|
run: (*parser).callonLabelOperators2,
|
|
expr: &litMatcher{
|
|
pos: position{line: 190, col: 19, offset: 5775},
|
|
val: "!=",
|
|
ignoreCase: false,
|
|
},
|
|
},
|
|
&actionExpr{
|
|
pos: position{line: 192, col: 5, offset: 5811},
|
|
run: (*parser).callonLabelOperators4,
|
|
expr: &litMatcher{
|
|
pos: position{line: 192, col: 5, offset: 5811},
|
|
val: "=~",
|
|
ignoreCase: false,
|
|
},
|
|
},
|
|
&actionExpr{
|
|
pos: position{line: 194, col: 5, offset: 5849},
|
|
run: (*parser).callonLabelOperators6,
|
|
expr: &litMatcher{
|
|
pos: position{line: 194, col: 5, offset: 5849},
|
|
val: "!~",
|
|
ignoreCase: false,
|
|
},
|
|
},
|
|
&actionExpr{
|
|
pos: position{line: 196, col: 5, offset: 5889},
|
|
run: (*parser).callonLabelOperators8,
|
|
expr: &litMatcher{
|
|
pos: position{line: 196, col: 5, offset: 5889},
|
|
val: "=",
|
|
ignoreCase: false,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
{
|
|
name: "Label",
|
|
pos: position{line: 200, col: 1, offset: 5920},
|
|
expr: &ruleRefExpr{
|
|
pos: position{line: 200, col: 9, offset: 5928},
|
|
name: "Identifier",
|
|
},
|
|
},
|
|
{
|
|
name: "LabelMatch",
|
|
pos: position{line: 201, col: 1, offset: 5939},
|
|
expr: &actionExpr{
|
|
pos: position{line: 201, col: 14, offset: 5952},
|
|
run: (*parser).callonLabelMatch1,
|
|
expr: &seqExpr{
|
|
pos: position{line: 201, col: 14, offset: 5952},
|
|
exprs: []interface{}{
|
|
&labeledExpr{
|
|
pos: position{line: 201, col: 14, offset: 5952},
|
|
label: "label",
|
|
expr: &ruleRefExpr{
|
|
pos: position{line: 201, col: 20, offset: 5958},
|
|
name: "Label",
|
|
},
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 201, col: 26, offset: 5964},
|
|
name: "__",
|
|
},
|
|
&labeledExpr{
|
|
pos: position{line: 201, col: 29, offset: 5967},
|
|
label: "op",
|
|
expr: &ruleRefExpr{
|
|
pos: position{line: 201, col: 32, offset: 5970},
|
|
name: "LabelOperators",
|
|
},
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 201, col: 47, offset: 5985},
|
|
name: "__",
|
|
},
|
|
&labeledExpr{
|
|
pos: position{line: 201, col: 50, offset: 5988},
|
|
label: "match",
|
|
expr: &choiceExpr{
|
|
pos: position{line: 201, col: 58, offset: 5996},
|
|
alternatives: []interface{}{
|
|
&ruleRefExpr{
|
|
pos: position{line: 201, col: 58, offset: 5996},
|
|
name: "StringLiteral",
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 201, col: 74, offset: 6012},
|
|
name: "Number",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
{
|
|
name: "LabelMatches",
|
|
pos: position{line: 204, col: 1, offset: 6102},
|
|
expr: &actionExpr{
|
|
pos: position{line: 204, col: 16, offset: 6117},
|
|
run: (*parser).callonLabelMatches1,
|
|
expr: &seqExpr{
|
|
pos: position{line: 204, col: 16, offset: 6117},
|
|
exprs: []interface{}{
|
|
&labeledExpr{
|
|
pos: position{line: 204, col: 16, offset: 6117},
|
|
label: "first",
|
|
expr: &ruleRefExpr{
|
|
pos: position{line: 204, col: 22, offset: 6123},
|
|
name: "LabelMatch",
|
|
},
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 204, col: 33, offset: 6134},
|
|
name: "__",
|
|
},
|
|
&labeledExpr{
|
|
pos: position{line: 204, col: 36, offset: 6137},
|
|
label: "rest",
|
|
expr: &zeroOrMoreExpr{
|
|
pos: position{line: 204, col: 41, offset: 6142},
|
|
expr: &ruleRefExpr{
|
|
pos: position{line: 204, col: 41, offset: 6142},
|
|
name: "LabelMatchesRest",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
{
|
|
name: "LabelMatchesRest",
|
|
pos: position{line: 208, col: 1, offset: 6221},
|
|
expr: &actionExpr{
|
|
pos: position{line: 208, col: 21, offset: 6241},
|
|
run: (*parser).callonLabelMatchesRest1,
|
|
expr: &seqExpr{
|
|
pos: position{line: 208, col: 21, offset: 6241},
|
|
exprs: []interface{}{
|
|
&litMatcher{
|
|
pos: position{line: 208, col: 21, offset: 6241},
|
|
val: ",",
|
|
ignoreCase: false,
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 208, col: 25, offset: 6245},
|
|
name: "__",
|
|
},
|
|
&labeledExpr{
|
|
pos: position{line: 208, col: 28, offset: 6248},
|
|
label: "match",
|
|
expr: &ruleRefExpr{
|
|
pos: position{line: 208, col: 34, offset: 6254},
|
|
name: "LabelMatch",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
{
|
|
name: "LabelList",
|
|
pos: position{line: 212, col: 1, offset: 6292},
|
|
expr: &choiceExpr{
|
|
pos: position{line: 212, col: 13, offset: 6304},
|
|
alternatives: []interface{}{
|
|
&actionExpr{
|
|
pos: position{line: 212, col: 13, offset: 6304},
|
|
run: (*parser).callonLabelList2,
|
|
expr: &seqExpr{
|
|
pos: position{line: 212, col: 14, offset: 6305},
|
|
exprs: []interface{}{
|
|
&litMatcher{
|
|
pos: position{line: 212, col: 14, offset: 6305},
|
|
val: "(",
|
|
ignoreCase: false,
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 212, col: 18, offset: 6309},
|
|
name: "__",
|
|
},
|
|
&litMatcher{
|
|
pos: position{line: 212, col: 21, offset: 6312},
|
|
val: ")",
|
|
ignoreCase: false,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
&actionExpr{
|
|
pos: position{line: 214, col: 6, offset: 6344},
|
|
run: (*parser).callonLabelList7,
|
|
expr: &seqExpr{
|
|
pos: position{line: 214, col: 6, offset: 6344},
|
|
exprs: []interface{}{
|
|
&litMatcher{
|
|
pos: position{line: 214, col: 6, offset: 6344},
|
|
val: "(",
|
|
ignoreCase: false,
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 214, col: 10, offset: 6348},
|
|
name: "__",
|
|
},
|
|
&labeledExpr{
|
|
pos: position{line: 214, col: 13, offset: 6351},
|
|
label: "label",
|
|
expr: &ruleRefExpr{
|
|
pos: position{line: 214, col: 19, offset: 6357},
|
|
name: "Label",
|
|
},
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 214, col: 25, offset: 6363},
|
|
name: "__",
|
|
},
|
|
&labeledExpr{
|
|
pos: position{line: 214, col: 28, offset: 6366},
|
|
label: "rest",
|
|
expr: &zeroOrMoreExpr{
|
|
pos: position{line: 214, col: 33, offset: 6371},
|
|
expr: &ruleRefExpr{
|
|
pos: position{line: 214, col: 33, offset: 6371},
|
|
name: "LabelListRest",
|
|
},
|
|
},
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 214, col: 48, offset: 6386},
|
|
name: "__",
|
|
},
|
|
&litMatcher{
|
|
pos: position{line: 214, col: 51, offset: 6389},
|
|
val: ")",
|
|
ignoreCase: false,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
{
|
|
name: "LabelListRest",
|
|
pos: position{line: 218, col: 1, offset: 6455},
|
|
expr: &actionExpr{
|
|
pos: position{line: 218, col: 18, offset: 6472},
|
|
run: (*parser).callonLabelListRest1,
|
|
expr: &seqExpr{
|
|
pos: position{line: 218, col: 18, offset: 6472},
|
|
exprs: []interface{}{
|
|
&litMatcher{
|
|
pos: position{line: 218, col: 18, offset: 6472},
|
|
val: ",",
|
|
ignoreCase: false,
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 218, col: 22, offset: 6476},
|
|
name: "__",
|
|
},
|
|
&labeledExpr{
|
|
pos: position{line: 218, col: 25, offset: 6479},
|
|
label: "label",
|
|
expr: &ruleRefExpr{
|
|
pos: position{line: 218, col: 31, offset: 6485},
|
|
name: "Label",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
{
|
|
name: "VectorSelector",
|
|
pos: position{line: 222, col: 1, offset: 6518},
|
|
expr: &actionExpr{
|
|
pos: position{line: 222, col: 18, offset: 6535},
|
|
run: (*parser).callonVectorSelector1,
|
|
expr: &seqExpr{
|
|
pos: position{line: 222, col: 18, offset: 6535},
|
|
exprs: []interface{}{
|
|
&labeledExpr{
|
|
pos: position{line: 222, col: 18, offset: 6535},
|
|
label: "metric",
|
|
expr: &ruleRefExpr{
|
|
pos: position{line: 222, col: 25, offset: 6542},
|
|
name: "Identifier",
|
|
},
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 222, col: 36, offset: 6553},
|
|
name: "__",
|
|
},
|
|
&labeledExpr{
|
|
pos: position{line: 222, col: 40, offset: 6557},
|
|
label: "block",
|
|
expr: &zeroOrOneExpr{
|
|
pos: position{line: 222, col: 46, offset: 6563},
|
|
expr: &ruleRefExpr{
|
|
pos: position{line: 222, col: 46, offset: 6563},
|
|
name: "LabelBlock",
|
|
},
|
|
},
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 222, col: 58, offset: 6575},
|
|
name: "__",
|
|
},
|
|
&labeledExpr{
|
|
pos: position{line: 222, col: 61, offset: 6578},
|
|
label: "rng",
|
|
expr: &zeroOrOneExpr{
|
|
pos: position{line: 222, col: 65, offset: 6582},
|
|
expr: &ruleRefExpr{
|
|
pos: position{line: 222, col: 65, offset: 6582},
|
|
name: "Range",
|
|
},
|
|
},
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 222, col: 72, offset: 6589},
|
|
name: "__",
|
|
},
|
|
&labeledExpr{
|
|
pos: position{line: 222, col: 75, offset: 6592},
|
|
label: "offset",
|
|
expr: &zeroOrOneExpr{
|
|
pos: position{line: 222, col: 82, offset: 6599},
|
|
expr: &ruleRefExpr{
|
|
pos: position{line: 222, col: 82, offset: 6599},
|
|
name: "Offset",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
{
|
|
name: "Range",
|
|
pos: position{line: 226, col: 1, offset: 6677},
|
|
expr: &actionExpr{
|
|
pos: position{line: 226, col: 9, offset: 6685},
|
|
run: (*parser).callonRange1,
|
|
expr: &seqExpr{
|
|
pos: position{line: 226, col: 9, offset: 6685},
|
|
exprs: []interface{}{
|
|
&litMatcher{
|
|
pos: position{line: 226, col: 9, offset: 6685},
|
|
val: "[",
|
|
ignoreCase: false,
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 226, col: 13, offset: 6689},
|
|
name: "__",
|
|
},
|
|
&labeledExpr{
|
|
pos: position{line: 226, col: 16, offset: 6692},
|
|
label: "dur",
|
|
expr: &ruleRefExpr{
|
|
pos: position{line: 226, col: 20, offset: 6696},
|
|
name: "Duration",
|
|
},
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 226, col: 29, offset: 6705},
|
|
name: "__",
|
|
},
|
|
&litMatcher{
|
|
pos: position{line: 226, col: 32, offset: 6708},
|
|
val: "]",
|
|
ignoreCase: false,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
{
|
|
name: "Offset",
|
|
pos: position{line: 230, col: 1, offset: 6737},
|
|
expr: &actionExpr{
|
|
pos: position{line: 230, col: 10, offset: 6746},
|
|
run: (*parser).callonOffset1,
|
|
expr: &seqExpr{
|
|
pos: position{line: 230, col: 10, offset: 6746},
|
|
exprs: []interface{}{
|
|
&litMatcher{
|
|
pos: position{line: 230, col: 10, offset: 6746},
|
|
val: "offset",
|
|
ignoreCase: true,
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 230, col: 20, offset: 6756},
|
|
name: "__",
|
|
},
|
|
&labeledExpr{
|
|
pos: position{line: 230, col: 23, offset: 6759},
|
|
label: "dur",
|
|
expr: &ruleRefExpr{
|
|
pos: position{line: 230, col: 27, offset: 6763},
|
|
name: "Duration",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
{
|
|
name: "CountValueOperator",
|
|
pos: position{line: 234, col: 1, offset: 6797},
|
|
expr: &actionExpr{
|
|
pos: position{line: 234, col: 22, offset: 6818},
|
|
run: (*parser).callonCountValueOperator1,
|
|
expr: &litMatcher{
|
|
pos: position{line: 234, col: 22, offset: 6818},
|
|
val: "count_values",
|
|
ignoreCase: true,
|
|
},
|
|
},
|
|
},
|
|
{
|
|
name: "BinaryAggregateOperators",
|
|
pos: position{line: 240, col: 1, offset: 6903},
|
|
expr: &actionExpr{
|
|
pos: position{line: 240, col: 29, offset: 6931},
|
|
run: (*parser).callonBinaryAggregateOperators1,
|
|
expr: &labeledExpr{
|
|
pos: position{line: 240, col: 29, offset: 6931},
|
|
label: "op",
|
|
expr: &choiceExpr{
|
|
pos: position{line: 240, col: 33, offset: 6935},
|
|
alternatives: []interface{}{
|
|
&litMatcher{
|
|
pos: position{line: 240, col: 33, offset: 6935},
|
|
val: "topk",
|
|
ignoreCase: true,
|
|
},
|
|
&litMatcher{
|
|
pos: position{line: 240, col: 43, offset: 6945},
|
|
val: "bottomk",
|
|
ignoreCase: true,
|
|
},
|
|
&litMatcher{
|
|
pos: position{line: 240, col: 56, offset: 6958},
|
|
val: "quantile",
|
|
ignoreCase: true,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
{
|
|
name: "UnaryAggregateOperators",
|
|
pos: position{line: 246, col: 1, offset: 7060},
|
|
expr: &actionExpr{
|
|
pos: position{line: 246, col: 27, offset: 7086},
|
|
run: (*parser).callonUnaryAggregateOperators1,
|
|
expr: &labeledExpr{
|
|
pos: position{line: 246, col: 27, offset: 7086},
|
|
label: "op",
|
|
expr: &choiceExpr{
|
|
pos: position{line: 246, col: 31, offset: 7090},
|
|
alternatives: []interface{}{
|
|
&litMatcher{
|
|
pos: position{line: 246, col: 31, offset: 7090},
|
|
val: "sum",
|
|
ignoreCase: true,
|
|
},
|
|
&litMatcher{
|
|
pos: position{line: 246, col: 40, offset: 7099},
|
|
val: "min",
|
|
ignoreCase: true,
|
|
},
|
|
&litMatcher{
|
|
pos: position{line: 246, col: 49, offset: 7108},
|
|
val: "max",
|
|
ignoreCase: true,
|
|
},
|
|
&litMatcher{
|
|
pos: position{line: 246, col: 58, offset: 7117},
|
|
val: "avg",
|
|
ignoreCase: true,
|
|
},
|
|
&litMatcher{
|
|
pos: position{line: 246, col: 67, offset: 7126},
|
|
val: "stddev",
|
|
ignoreCase: true,
|
|
},
|
|
&litMatcher{
|
|
pos: position{line: 246, col: 79, offset: 7138},
|
|
val: "stdvar",
|
|
ignoreCase: true,
|
|
},
|
|
&litMatcher{
|
|
pos: position{line: 246, col: 91, offset: 7150},
|
|
val: "count",
|
|
ignoreCase: true,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
{
|
|
name: "AggregateOperators",
|
|
pos: position{line: 252, col: 1, offset: 7249},
|
|
expr: &choiceExpr{
|
|
pos: position{line: 252, col: 22, offset: 7270},
|
|
alternatives: []interface{}{
|
|
&ruleRefExpr{
|
|
pos: position{line: 252, col: 22, offset: 7270},
|
|
name: "CountValueOperator",
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 252, col: 43, offset: 7291},
|
|
name: "BinaryAggregateOperators",
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 252, col: 70, offset: 7318},
|
|
name: "UnaryAggregateOperators",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
{
|
|
name: "AggregateBy",
|
|
pos: position{line: 254, col: 1, offset: 7343},
|
|
expr: &actionExpr{
|
|
pos: position{line: 254, col: 15, offset: 7357},
|
|
run: (*parser).callonAggregateBy1,
|
|
expr: &seqExpr{
|
|
pos: position{line: 254, col: 15, offset: 7357},
|
|
exprs: []interface{}{
|
|
&litMatcher{
|
|
pos: position{line: 254, col: 15, offset: 7357},
|
|
val: "by",
|
|
ignoreCase: true,
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 254, col: 21, offset: 7363},
|
|
name: "__",
|
|
},
|
|
&labeledExpr{
|
|
pos: position{line: 254, col: 24, offset: 7366},
|
|
label: "labels",
|
|
expr: &ruleRefExpr{
|
|
pos: position{line: 254, col: 31, offset: 7373},
|
|
name: "LabelList",
|
|
},
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 254, col: 41, offset: 7383},
|
|
name: "__",
|
|
},
|
|
&labeledExpr{
|
|
pos: position{line: 254, col: 44, offset: 7386},
|
|
label: "keep",
|
|
expr: &zeroOrOneExpr{
|
|
pos: position{line: 254, col: 49, offset: 7391},
|
|
expr: &litMatcher{
|
|
pos: position{line: 254, col: 49, offset: 7391},
|
|
val: "keep_common",
|
|
ignoreCase: true,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
{
|
|
name: "AggregateWithout",
|
|
pos: position{line: 261, col: 1, offset: 7504},
|
|
expr: &actionExpr{
|
|
pos: position{line: 261, col: 20, offset: 7523},
|
|
run: (*parser).callonAggregateWithout1,
|
|
expr: &seqExpr{
|
|
pos: position{line: 261, col: 20, offset: 7523},
|
|
exprs: []interface{}{
|
|
&litMatcher{
|
|
pos: position{line: 261, col: 20, offset: 7523},
|
|
val: "without",
|
|
ignoreCase: true,
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 261, col: 31, offset: 7534},
|
|
name: "__",
|
|
},
|
|
&labeledExpr{
|
|
pos: position{line: 261, col: 34, offset: 7537},
|
|
label: "labels",
|
|
expr: &ruleRefExpr{
|
|
pos: position{line: 261, col: 41, offset: 7544},
|
|
name: "LabelList",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
{
|
|
name: "AggregateGroup",
|
|
pos: position{line: 268, col: 1, offset: 7656},
|
|
expr: &choiceExpr{
|
|
pos: position{line: 268, col: 18, offset: 7673},
|
|
alternatives: []interface{}{
|
|
&ruleRefExpr{
|
|
pos: position{line: 268, col: 18, offset: 7673},
|
|
name: "AggregateBy",
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 268, col: 32, offset: 7687},
|
|
name: "AggregateWithout",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
{
|
|
name: "AggregateExpression",
|
|
pos: position{line: 270, col: 1, offset: 7705},
|
|
expr: &choiceExpr{
|
|
pos: position{line: 271, col: 1, offset: 7727},
|
|
alternatives: []interface{}{
|
|
&actionExpr{
|
|
pos: position{line: 271, col: 1, offset: 7727},
|
|
run: (*parser).callonAggregateExpression2,
|
|
expr: &seqExpr{
|
|
pos: position{line: 271, col: 1, offset: 7727},
|
|
exprs: []interface{}{
|
|
&labeledExpr{
|
|
pos: position{line: 271, col: 1, offset: 7727},
|
|
label: "op",
|
|
expr: &ruleRefExpr{
|
|
pos: position{line: 271, col: 4, offset: 7730},
|
|
name: "CountValueOperator",
|
|
},
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 271, col: 24, offset: 7750},
|
|
name: "__",
|
|
},
|
|
&litMatcher{
|
|
pos: position{line: 271, col: 27, offset: 7753},
|
|
val: "(",
|
|
ignoreCase: false,
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 271, col: 31, offset: 7757},
|
|
name: "__",
|
|
},
|
|
&labeledExpr{
|
|
pos: position{line: 271, col: 34, offset: 7760},
|
|
label: "param",
|
|
expr: &ruleRefExpr{
|
|
pos: position{line: 271, col: 40, offset: 7766},
|
|
name: "StringLiteral",
|
|
},
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 271, col: 54, offset: 7780},
|
|
name: "__",
|
|
},
|
|
&litMatcher{
|
|
pos: position{line: 271, col: 57, offset: 7783},
|
|
val: ",",
|
|
ignoreCase: false,
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 271, col: 61, offset: 7787},
|
|
name: "__",
|
|
},
|
|
&labeledExpr{
|
|
pos: position{line: 271, col: 64, offset: 7790},
|
|
label: "vector",
|
|
expr: &ruleRefExpr{
|
|
pos: position{line: 271, col: 71, offset: 7797},
|
|
name: "VectorSelector",
|
|
},
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 271, col: 86, offset: 7812},
|
|
name: "__",
|
|
},
|
|
&litMatcher{
|
|
pos: position{line: 271, col: 89, offset: 7815},
|
|
val: ")",
|
|
ignoreCase: false,
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 271, col: 93, offset: 7819},
|
|
name: "__",
|
|
},
|
|
&labeledExpr{
|
|
pos: position{line: 271, col: 96, offset: 7822},
|
|
label: "group",
|
|
expr: &zeroOrOneExpr{
|
|
pos: position{line: 271, col: 102, offset: 7828},
|
|
expr: &ruleRefExpr{
|
|
pos: position{line: 271, col: 102, offset: 7828},
|
|
name: "AggregateGroup",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
&actionExpr{
|
|
pos: position{line: 277, col: 1, offset: 7976},
|
|
run: (*parser).callonAggregateExpression22,
|
|
expr: &seqExpr{
|
|
pos: position{line: 277, col: 1, offset: 7976},
|
|
exprs: []interface{}{
|
|
&labeledExpr{
|
|
pos: position{line: 277, col: 1, offset: 7976},
|
|
label: "op",
|
|
expr: &ruleRefExpr{
|
|
pos: position{line: 277, col: 4, offset: 7979},
|
|
name: "CountValueOperator",
|
|
},
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 277, col: 24, offset: 7999},
|
|
name: "__",
|
|
},
|
|
&labeledExpr{
|
|
pos: position{line: 277, col: 27, offset: 8002},
|
|
label: "group",
|
|
expr: &zeroOrOneExpr{
|
|
pos: position{line: 277, col: 33, offset: 8008},
|
|
expr: &ruleRefExpr{
|
|
pos: position{line: 277, col: 33, offset: 8008},
|
|
name: "AggregateGroup",
|
|
},
|
|
},
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 277, col: 49, offset: 8024},
|
|
name: "__",
|
|
},
|
|
&litMatcher{
|
|
pos: position{line: 277, col: 52, offset: 8027},
|
|
val: "(",
|
|
ignoreCase: false,
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 277, col: 56, offset: 8031},
|
|
name: "__",
|
|
},
|
|
&labeledExpr{
|
|
pos: position{line: 277, col: 59, offset: 8034},
|
|
label: "param",
|
|
expr: &ruleRefExpr{
|
|
pos: position{line: 277, col: 65, offset: 8040},
|
|
name: "StringLiteral",
|
|
},
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 277, col: 79, offset: 8054},
|
|
name: "__",
|
|
},
|
|
&litMatcher{
|
|
pos: position{line: 277, col: 82, offset: 8057},
|
|
val: ",",
|
|
ignoreCase: false,
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 277, col: 86, offset: 8061},
|
|
name: "__",
|
|
},
|
|
&labeledExpr{
|
|
pos: position{line: 277, col: 89, offset: 8064},
|
|
label: "vector",
|
|
expr: &ruleRefExpr{
|
|
pos: position{line: 277, col: 96, offset: 8071},
|
|
name: "VectorSelector",
|
|
},
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 277, col: 111, offset: 8086},
|
|
name: "__",
|
|
},
|
|
&litMatcher{
|
|
pos: position{line: 277, col: 114, offset: 8089},
|
|
val: ")",
|
|
ignoreCase: false,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
&actionExpr{
|
|
pos: position{line: 283, col: 1, offset: 8225},
|
|
run: (*parser).callonAggregateExpression42,
|
|
expr: &seqExpr{
|
|
pos: position{line: 283, col: 1, offset: 8225},
|
|
exprs: []interface{}{
|
|
&labeledExpr{
|
|
pos: position{line: 283, col: 1, offset: 8225},
|
|
label: "op",
|
|
expr: &ruleRefExpr{
|
|
pos: position{line: 283, col: 4, offset: 8228},
|
|
name: "BinaryAggregateOperators",
|
|
},
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 283, col: 30, offset: 8254},
|
|
name: "__",
|
|
},
|
|
&litMatcher{
|
|
pos: position{line: 283, col: 33, offset: 8257},
|
|
val: "(",
|
|
ignoreCase: false,
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 283, col: 37, offset: 8261},
|
|
name: "__",
|
|
},
|
|
&labeledExpr{
|
|
pos: position{line: 283, col: 41, offset: 8265},
|
|
label: "param",
|
|
expr: &ruleRefExpr{
|
|
pos: position{line: 283, col: 47, offset: 8271},
|
|
name: "Number",
|
|
},
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 283, col: 54, offset: 8278},
|
|
name: "__",
|
|
},
|
|
&litMatcher{
|
|
pos: position{line: 283, col: 57, offset: 8281},
|
|
val: ",",
|
|
ignoreCase: false,
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 283, col: 61, offset: 8285},
|
|
name: "__",
|
|
},
|
|
&labeledExpr{
|
|
pos: position{line: 283, col: 64, offset: 8288},
|
|
label: "vector",
|
|
expr: &ruleRefExpr{
|
|
pos: position{line: 283, col: 71, offset: 8295},
|
|
name: "VectorSelector",
|
|
},
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 283, col: 86, offset: 8310},
|
|
name: "__",
|
|
},
|
|
&litMatcher{
|
|
pos: position{line: 283, col: 89, offset: 8313},
|
|
val: ")",
|
|
ignoreCase: false,
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 283, col: 93, offset: 8317},
|
|
name: "__",
|
|
},
|
|
&labeledExpr{
|
|
pos: position{line: 283, col: 96, offset: 8320},
|
|
label: "group",
|
|
expr: &zeroOrOneExpr{
|
|
pos: position{line: 283, col: 102, offset: 8326},
|
|
expr: &ruleRefExpr{
|
|
pos: position{line: 283, col: 102, offset: 8326},
|
|
name: "AggregateGroup",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
&actionExpr{
|
|
pos: position{line: 289, col: 1, offset: 8467},
|
|
run: (*parser).callonAggregateExpression62,
|
|
expr: &seqExpr{
|
|
pos: position{line: 289, col: 1, offset: 8467},
|
|
exprs: []interface{}{
|
|
&labeledExpr{
|
|
pos: position{line: 289, col: 1, offset: 8467},
|
|
label: "op",
|
|
expr: &ruleRefExpr{
|
|
pos: position{line: 289, col: 4, offset: 8470},
|
|
name: "BinaryAggregateOperators",
|
|
},
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 289, col: 30, offset: 8496},
|
|
name: "__",
|
|
},
|
|
&labeledExpr{
|
|
pos: position{line: 289, col: 33, offset: 8499},
|
|
label: "group",
|
|
expr: &zeroOrOneExpr{
|
|
pos: position{line: 289, col: 39, offset: 8505},
|
|
expr: &ruleRefExpr{
|
|
pos: position{line: 289, col: 39, offset: 8505},
|
|
name: "AggregateGroup",
|
|
},
|
|
},
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 289, col: 55, offset: 8521},
|
|
name: "__",
|
|
},
|
|
&litMatcher{
|
|
pos: position{line: 289, col: 58, offset: 8524},
|
|
val: "(",
|
|
ignoreCase: false,
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 289, col: 62, offset: 8528},
|
|
name: "__",
|
|
},
|
|
&labeledExpr{
|
|
pos: position{line: 289, col: 66, offset: 8532},
|
|
label: "param",
|
|
expr: &ruleRefExpr{
|
|
pos: position{line: 289, col: 72, offset: 8538},
|
|
name: "Number",
|
|
},
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 289, col: 79, offset: 8545},
|
|
name: "__",
|
|
},
|
|
&litMatcher{
|
|
pos: position{line: 289, col: 82, offset: 8548},
|
|
val: ",",
|
|
ignoreCase: false,
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 289, col: 86, offset: 8552},
|
|
name: "__",
|
|
},
|
|
&labeledExpr{
|
|
pos: position{line: 289, col: 89, offset: 8555},
|
|
label: "vector",
|
|
expr: &ruleRefExpr{
|
|
pos: position{line: 289, col: 96, offset: 8562},
|
|
name: "VectorSelector",
|
|
},
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 289, col: 111, offset: 8577},
|
|
name: "__",
|
|
},
|
|
&litMatcher{
|
|
pos: position{line: 289, col: 114, offset: 8580},
|
|
val: ")",
|
|
ignoreCase: false,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
&actionExpr{
|
|
pos: position{line: 295, col: 1, offset: 8709},
|
|
run: (*parser).callonAggregateExpression82,
|
|
expr: &seqExpr{
|
|
pos: position{line: 295, col: 1, offset: 8709},
|
|
exprs: []interface{}{
|
|
&labeledExpr{
|
|
pos: position{line: 295, col: 1, offset: 8709},
|
|
label: "op",
|
|
expr: &ruleRefExpr{
|
|
pos: position{line: 295, col: 4, offset: 8712},
|
|
name: "UnaryAggregateOperators",
|
|
},
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 295, col: 29, offset: 8737},
|
|
name: "__",
|
|
},
|
|
&litMatcher{
|
|
pos: position{line: 295, col: 32, offset: 8740},
|
|
val: "(",
|
|
ignoreCase: false,
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 295, col: 36, offset: 8744},
|
|
name: "__",
|
|
},
|
|
&labeledExpr{
|
|
pos: position{line: 295, col: 39, offset: 8747},
|
|
label: "vector",
|
|
expr: &ruleRefExpr{
|
|
pos: position{line: 295, col: 46, offset: 8754},
|
|
name: "VectorSelector",
|
|
},
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 295, col: 61, offset: 8769},
|
|
name: "__",
|
|
},
|
|
&litMatcher{
|
|
pos: position{line: 295, col: 64, offset: 8772},
|
|
val: ")",
|
|
ignoreCase: false,
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 295, col: 68, offset: 8776},
|
|
name: "__",
|
|
},
|
|
&labeledExpr{
|
|
pos: position{line: 295, col: 71, offset: 8779},
|
|
label: "group",
|
|
expr: &zeroOrOneExpr{
|
|
pos: position{line: 295, col: 77, offset: 8785},
|
|
expr: &ruleRefExpr{
|
|
pos: position{line: 295, col: 77, offset: 8785},
|
|
name: "AggregateGroup",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
&actionExpr{
|
|
pos: position{line: 299, col: 1, offset: 8878},
|
|
run: (*parser).callonAggregateExpression97,
|
|
expr: &seqExpr{
|
|
pos: position{line: 299, col: 1, offset: 8878},
|
|
exprs: []interface{}{
|
|
&labeledExpr{
|
|
pos: position{line: 299, col: 1, offset: 8878},
|
|
label: "op",
|
|
expr: &ruleRefExpr{
|
|
pos: position{line: 299, col: 4, offset: 8881},
|
|
name: "UnaryAggregateOperators",
|
|
},
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 299, col: 29, offset: 8906},
|
|
name: "__",
|
|
},
|
|
&labeledExpr{
|
|
pos: position{line: 299, col: 32, offset: 8909},
|
|
label: "group",
|
|
expr: &zeroOrOneExpr{
|
|
pos: position{line: 299, col: 38, offset: 8915},
|
|
expr: &ruleRefExpr{
|
|
pos: position{line: 299, col: 38, offset: 8915},
|
|
name: "AggregateGroup",
|
|
},
|
|
},
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 299, col: 54, offset: 8931},
|
|
name: "__",
|
|
},
|
|
&litMatcher{
|
|
pos: position{line: 299, col: 57, offset: 8934},
|
|
val: "(",
|
|
ignoreCase: false,
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 299, col: 61, offset: 8938},
|
|
name: "__",
|
|
},
|
|
&labeledExpr{
|
|
pos: position{line: 299, col: 64, offset: 8941},
|
|
label: "vector",
|
|
expr: &ruleRefExpr{
|
|
pos: position{line: 299, col: 71, offset: 8948},
|
|
name: "VectorSelector",
|
|
},
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 299, col: 86, offset: 8963},
|
|
name: "__",
|
|
},
|
|
&litMatcher{
|
|
pos: position{line: 299, col: 89, offset: 8966},
|
|
val: ")",
|
|
ignoreCase: false,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
{
|
|
name: "__",
|
|
pos: position{line: 303, col: 1, offset: 9046},
|
|
expr: &zeroOrMoreExpr{
|
|
pos: position{line: 303, col: 6, offset: 9051},
|
|
expr: &choiceExpr{
|
|
pos: position{line: 303, col: 8, offset: 9053},
|
|
alternatives: []interface{}{
|
|
&ruleRefExpr{
|
|
pos: position{line: 303, col: 8, offset: 9053},
|
|
name: "Whitespace",
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 303, col: 21, offset: 9066},
|
|
name: "EOL",
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 303, col: 27, offset: 9072},
|
|
name: "Comment",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
{
|
|
name: "_",
|
|
pos: position{line: 304, col: 1, offset: 9083},
|
|
expr: &zeroOrMoreExpr{
|
|
pos: position{line: 304, col: 5, offset: 9087},
|
|
expr: &ruleRefExpr{
|
|
pos: position{line: 304, col: 5, offset: 9087},
|
|
name: "Whitespace",
|
|
},
|
|
},
|
|
},
|
|
{
|
|
name: "Whitespace",
|
|
pos: position{line: 306, col: 1, offset: 9100},
|
|
expr: &charClassMatcher{
|
|
pos: position{line: 306, col: 14, offset: 9113},
|
|
val: "[ \\t\\r]",
|
|
chars: []rune{' ', '\t', '\r'},
|
|
ignoreCase: false,
|
|
inverted: false,
|
|
},
|
|
},
|
|
{
|
|
name: "EOL",
|
|
pos: position{line: 307, col: 1, offset: 9121},
|
|
expr: &litMatcher{
|
|
pos: position{line: 307, col: 7, offset: 9127},
|
|
val: "\n",
|
|
ignoreCase: false,
|
|
},
|
|
},
|
|
{
|
|
name: "EOS",
|
|
pos: position{line: 308, col: 1, offset: 9132},
|
|
expr: &choiceExpr{
|
|
pos: position{line: 308, col: 7, offset: 9138},
|
|
alternatives: []interface{}{
|
|
&seqExpr{
|
|
pos: position{line: 308, col: 7, offset: 9138},
|
|
exprs: []interface{}{
|
|
&ruleRefExpr{
|
|
pos: position{line: 308, col: 7, offset: 9138},
|
|
name: "__",
|
|
},
|
|
&litMatcher{
|
|
pos: position{line: 308, col: 10, offset: 9141},
|
|
val: ";",
|
|
ignoreCase: false,
|
|
},
|
|
},
|
|
},
|
|
&seqExpr{
|
|
pos: position{line: 308, col: 16, offset: 9147},
|
|
exprs: []interface{}{
|
|
&ruleRefExpr{
|
|
pos: position{line: 308, col: 16, offset: 9147},
|
|
name: "_",
|
|
},
|
|
&zeroOrOneExpr{
|
|
pos: position{line: 308, col: 18, offset: 9149},
|
|
expr: &ruleRefExpr{
|
|
pos: position{line: 308, col: 18, offset: 9149},
|
|
name: "SingleLineComment",
|
|
},
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 308, col: 37, offset: 9168},
|
|
name: "EOL",
|
|
},
|
|
},
|
|
},
|
|
&seqExpr{
|
|
pos: position{line: 308, col: 43, offset: 9174},
|
|
exprs: []interface{}{
|
|
&ruleRefExpr{
|
|
pos: position{line: 308, col: 43, offset: 9174},
|
|
name: "__",
|
|
},
|
|
&ruleRefExpr{
|
|
pos: position{line: 308, col: 46, offset: 9177},
|
|
name: "EOF",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
{
|
|
name: "EOF",
|
|
pos: position{line: 310, col: 1, offset: 9182},
|
|
expr: ¬Expr{
|
|
pos: position{line: 310, col: 7, offset: 9188},
|
|
expr: &anyMatcher{
|
|
line: 310, col: 8, offset: 9189,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
}
|
|
|
|
func (c *current) onGrammar1(grammar interface{}) (interface{}, error) {
|
|
return grammar, nil
|
|
}
|
|
|
|
func (p *parser) callonGrammar1() (interface{}, error) {
|
|
stack := p.vstack[len(p.vstack)-1]
|
|
_ = stack
|
|
return p.cur.onGrammar1(stack["grammar"])
|
|
}
|
|
|
|
func (c *current) onComment1() (interface{}, error) {
|
|
return &Comment{string(c.text)}, nil
|
|
}
|
|
|
|
func (p *parser) callonComment1() (interface{}, error) {
|
|
stack := p.vstack[len(p.vstack)-1]
|
|
_ = stack
|
|
return p.cur.onComment1()
|
|
}
|
|
|
|
func (c *current) onIdentifier1(ident interface{}) (interface{}, error) {
|
|
if reservedWords[string(c.text)] {
|
|
return nil, errors.New("identifier is a reserved word")
|
|
}
|
|
return &Identifier{ident.(string)}, nil
|
|
}
|
|
|
|
func (p *parser) callonIdentifier1() (interface{}, error) {
|
|
stack := p.vstack[len(p.vstack)-1]
|
|
_ = stack
|
|
return p.cur.onIdentifier1(stack["ident"])
|
|
}
|
|
|
|
func (c *current) onIdentifierName1() (interface{}, error) {
|
|
return string(c.text), nil
|
|
}
|
|
|
|
func (p *parser) callonIdentifierName1() (interface{}, error) {
|
|
stack := p.vstack[len(p.vstack)-1]
|
|
_ = stack
|
|
return p.cur.onIdentifierName1()
|
|
}
|
|
|
|
func (c *current) onStringLiteral2() (interface{}, error) {
|
|
str, err := strconv.Unquote(string(c.text))
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &StringLiteral{str}, nil
|
|
}
|
|
|
|
func (p *parser) callonStringLiteral2() (interface{}, error) {
|
|
stack := p.vstack[len(p.vstack)-1]
|
|
_ = stack
|
|
return p.cur.onStringLiteral2()
|
|
}
|
|
|
|
func (c *current) onStringLiteral18() (interface{}, error) {
|
|
return nil, errors.New("string literal not terminated")
|
|
}
|
|
|
|
func (p *parser) callonStringLiteral18() (interface{}, error) {
|
|
stack := p.vstack[len(p.vstack)-1]
|
|
_ = stack
|
|
return p.cur.onStringLiteral18()
|
|
}
|
|
|
|
func (c *current) onDoubleStringEscape5() (interface{}, error) {
|
|
return nil, errors.New("invalid escape character")
|
|
}
|
|
|
|
func (p *parser) callonDoubleStringEscape5() (interface{}, error) {
|
|
stack := p.vstack[len(p.vstack)-1]
|
|
_ = stack
|
|
return p.cur.onDoubleStringEscape5()
|
|
}
|
|
|
|
func (c *current) onSingleStringEscape5() (interface{}, error) {
|
|
return nil, errors.New("invalid escape character")
|
|
}
|
|
|
|
func (p *parser) callonSingleStringEscape5() (interface{}, error) {
|
|
stack := p.vstack[len(p.vstack)-1]
|
|
_ = stack
|
|
return p.cur.onSingleStringEscape5()
|
|
}
|
|
|
|
func (c *current) onOctalEscape6() (interface{}, error) {
|
|
return nil, errors.New("invalid octal escape")
|
|
}
|
|
|
|
func (p *parser) callonOctalEscape6() (interface{}, error) {
|
|
stack := p.vstack[len(p.vstack)-1]
|
|
_ = stack
|
|
return p.cur.onOctalEscape6()
|
|
}
|
|
|
|
func (c *current) onHexEscape6() (interface{}, error) {
|
|
return nil, errors.New("invalid hexadecimal escape")
|
|
}
|
|
|
|
func (p *parser) callonHexEscape6() (interface{}, error) {
|
|
stack := p.vstack[len(p.vstack)-1]
|
|
_ = stack
|
|
return p.cur.onHexEscape6()
|
|
}
|
|
|
|
func (c *current) onLongUnicodeEscape2() (interface{}, error) {
|
|
return validateUnicodeEscape(string(c.text), "invalid Unicode escape")
|
|
|
|
}
|
|
|
|
func (p *parser) callonLongUnicodeEscape2() (interface{}, error) {
|
|
stack := p.vstack[len(p.vstack)-1]
|
|
_ = stack
|
|
return p.cur.onLongUnicodeEscape2()
|
|
}
|
|
|
|
func (c *current) onLongUnicodeEscape13() (interface{}, error) {
|
|
return nil, errors.New("invalid Unicode escape")
|
|
}
|
|
|
|
func (p *parser) callonLongUnicodeEscape13() (interface{}, error) {
|
|
stack := p.vstack[len(p.vstack)-1]
|
|
_ = stack
|
|
return p.cur.onLongUnicodeEscape13()
|
|
}
|
|
|
|
func (c *current) onShortUnicodeEscape2() (interface{}, error) {
|
|
return validateUnicodeEscape(string(c.text), "invalid Unicode escape")
|
|
|
|
}
|
|
|
|
func (p *parser) callonShortUnicodeEscape2() (interface{}, error) {
|
|
stack := p.vstack[len(p.vstack)-1]
|
|
_ = stack
|
|
return p.cur.onShortUnicodeEscape2()
|
|
}
|
|
|
|
func (c *current) onShortUnicodeEscape9() (interface{}, error) {
|
|
return nil, errors.New("invalid Unicode escape")
|
|
}
|
|
|
|
func (p *parser) callonShortUnicodeEscape9() (interface{}, error) {
|
|
stack := p.vstack[len(p.vstack)-1]
|
|
_ = stack
|
|
return p.cur.onShortUnicodeEscape9()
|
|
}
|
|
|
|
func (c *current) onCharClassMatcher2() (interface{}, error) {
|
|
return string(c.text), nil
|
|
}
|
|
|
|
func (p *parser) callonCharClassMatcher2() (interface{}, error) {
|
|
stack := p.vstack[len(p.vstack)-1]
|
|
_ = stack
|
|
return p.cur.onCharClassMatcher2()
|
|
}
|
|
|
|
func (c *current) onCharClassMatcher15() (interface{}, error) {
|
|
return nil, errors.New("character class not terminated")
|
|
}
|
|
|
|
func (p *parser) callonCharClassMatcher15() (interface{}, error) {
|
|
stack := p.vstack[len(p.vstack)-1]
|
|
_ = stack
|
|
return p.cur.onCharClassMatcher15()
|
|
}
|
|
|
|
func (c *current) onCharClassEscape5() (interface{}, error) {
|
|
return nil, errors.New("invalid escape character")
|
|
}
|
|
|
|
func (p *parser) callonCharClassEscape5() (interface{}, error) {
|
|
stack := p.vstack[len(p.vstack)-1]
|
|
_ = stack
|
|
return p.cur.onCharClassEscape5()
|
|
}
|
|
|
|
func (c *current) onUnicodeClassEscape5() (interface{}, error) {
|
|
return nil, errors.New("invalid Unicode class escape")
|
|
}
|
|
|
|
func (p *parser) callonUnicodeClassEscape5() (interface{}, error) {
|
|
stack := p.vstack[len(p.vstack)-1]
|
|
_ = stack
|
|
return p.cur.onUnicodeClassEscape5()
|
|
}
|
|
|
|
func (c *current) onUnicodeClassEscape13(ident interface{}) (interface{}, error) {
|
|
if !unicodeClasses[ident.(string)] {
|
|
return nil, errors.New("invalid Unicode class escape")
|
|
}
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
func (p *parser) callonUnicodeClassEscape13() (interface{}, error) {
|
|
stack := p.vstack[len(p.vstack)-1]
|
|
_ = stack
|
|
return p.cur.onUnicodeClassEscape13(stack["ident"])
|
|
}
|
|
|
|
func (c *current) onUnicodeClassEscape19() (interface{}, error) {
|
|
return nil, errors.New("unicode class not terminated")
|
|
|
|
}
|
|
|
|
func (p *parser) callonUnicodeClassEscape19() (interface{}, error) {
|
|
stack := p.vstack[len(p.vstack)-1]
|
|
_ = stack
|
|
return p.cur.onUnicodeClassEscape19()
|
|
}
|
|
|
|
func (c *current) onNumber1() (interface{}, error) {
|
|
return NewNumber(string(c.text))
|
|
}
|
|
|
|
func (p *parser) callonNumber1() (interface{}, error) {
|
|
stack := p.vstack[len(p.vstack)-1]
|
|
_ = stack
|
|
return p.cur.onNumber1()
|
|
}
|
|
|
|
func (c *current) onInteger3() (interface{}, error) {
|
|
return strconv.ParseInt(string(c.text), 10, 64)
|
|
}
|
|
|
|
func (p *parser) callonInteger3() (interface{}, error) {
|
|
stack := p.vstack[len(p.vstack)-1]
|
|
_ = stack
|
|
return p.cur.onInteger3()
|
|
}
|
|
|
|
func (c *current) onLabelBlock2(block interface{}) (interface{}, error) {
|
|
return block, nil
|
|
}
|
|
|
|
func (p *parser) callonLabelBlock2() (interface{}, error) {
|
|
stack := p.vstack[len(p.vstack)-1]
|
|
_ = stack
|
|
return p.cur.onLabelBlock2(stack["block"])
|
|
}
|
|
|
|
func (c *current) onLabelBlock8() (interface{}, error) {
|
|
return nil, errors.New("code block not terminated")
|
|
}
|
|
|
|
func (p *parser) callonLabelBlock8() (interface{}, error) {
|
|
stack := p.vstack[len(p.vstack)-1]
|
|
_ = stack
|
|
return p.cur.onLabelBlock8()
|
|
}
|
|
|
|
func (c *current) onNanoSecondUnits1() (interface{}, error) {
|
|
// Prometheus doesn't support nanoseconds, but, influx does
|
|
return time.Nanosecond, nil
|
|
}
|
|
|
|
func (p *parser) callonNanoSecondUnits1() (interface{}, error) {
|
|
stack := p.vstack[len(p.vstack)-1]
|
|
_ = stack
|
|
return p.cur.onNanoSecondUnits1()
|
|
}
|
|
|
|
func (c *current) onMicroSecondUnits1() (interface{}, error) {
|
|
// Prometheus doesn't support nanoseconds, but, influx does
|
|
return time.Microsecond, nil
|
|
}
|
|
|
|
func (p *parser) callonMicroSecondUnits1() (interface{}, error) {
|
|
stack := p.vstack[len(p.vstack)-1]
|
|
_ = stack
|
|
return p.cur.onMicroSecondUnits1()
|
|
}
|
|
|
|
func (c *current) onMilliSecondUnits1() (interface{}, error) {
|
|
// Prometheus doesn't support nanoseconds, but, influx does
|
|
return time.Millisecond, nil
|
|
}
|
|
|
|
func (p *parser) callonMilliSecondUnits1() (interface{}, error) {
|
|
stack := p.vstack[len(p.vstack)-1]
|
|
_ = stack
|
|
return p.cur.onMilliSecondUnits1()
|
|
}
|
|
|
|
func (c *current) onSecondUnits1() (interface{}, error) {
|
|
return time.Second, nil
|
|
}
|
|
|
|
func (p *parser) callonSecondUnits1() (interface{}, error) {
|
|
stack := p.vstack[len(p.vstack)-1]
|
|
_ = stack
|
|
return p.cur.onSecondUnits1()
|
|
}
|
|
|
|
func (c *current) onMinuteUnits1() (interface{}, error) {
|
|
return time.Minute, nil
|
|
}
|
|
|
|
func (p *parser) callonMinuteUnits1() (interface{}, error) {
|
|
stack := p.vstack[len(p.vstack)-1]
|
|
_ = stack
|
|
return p.cur.onMinuteUnits1()
|
|
}
|
|
|
|
func (c *current) onHourUnits1() (interface{}, error) {
|
|
return time.Hour, nil
|
|
}
|
|
|
|
func (p *parser) callonHourUnits1() (interface{}, error) {
|
|
stack := p.vstack[len(p.vstack)-1]
|
|
_ = stack
|
|
return p.cur.onHourUnits1()
|
|
}
|
|
|
|
func (c *current) onDayUnits1() (interface{}, error) {
|
|
// Prometheus always assumes exactly 24 hours in a day
|
|
// https://github.com/prometheus/common/blob/61f87aac8082fa8c3c5655c7608d7478d46ac2ad/model/time.go#L180
|
|
return time.Hour * 24, nil
|
|
}
|
|
|
|
func (p *parser) callonDayUnits1() (interface{}, error) {
|
|
stack := p.vstack[len(p.vstack)-1]
|
|
_ = stack
|
|
return p.cur.onDayUnits1()
|
|
}
|
|
|
|
func (c *current) onWeekUnits1() (interface{}, error) {
|
|
// Prometheus always assumes exactly 7 days in a week
|
|
// https://github.com/prometheus/common/blob/61f87aac8082fa8c3c5655c7608d7478d46ac2ad/model/time.go#L180
|
|
return time.Hour * 24 * 7, nil
|
|
}
|
|
|
|
func (p *parser) callonWeekUnits1() (interface{}, error) {
|
|
stack := p.vstack[len(p.vstack)-1]
|
|
_ = stack
|
|
return p.cur.onWeekUnits1()
|
|
}
|
|
|
|
func (c *current) onYearUnits1() (interface{}, error) {
|
|
// Prometheus always assumes 365 days
|
|
// https://github.com/prometheus/common/blob/61f87aac8082fa8c3c5655c7608d7478d46ac2ad/model/time.go#L180
|
|
return time.Hour * 24 * 365, nil
|
|
}
|
|
|
|
func (p *parser) callonYearUnits1() (interface{}, error) {
|
|
stack := p.vstack[len(p.vstack)-1]
|
|
_ = stack
|
|
return p.cur.onYearUnits1()
|
|
}
|
|
|
|
func (c *current) onDuration1(dur, units interface{}) (interface{}, error) {
|
|
nanos := time.Duration(dur.(int64))
|
|
conversion := units.(time.Duration)
|
|
return time.Duration(nanos) * conversion, nil
|
|
}
|
|
|
|
func (p *parser) callonDuration1() (interface{}, error) {
|
|
stack := p.vstack[len(p.vstack)-1]
|
|
_ = stack
|
|
return p.cur.onDuration1(stack["dur"], stack["units"])
|
|
}
|
|
|
|
func (c *current) onLabelOperators2() (interface{}, error) {
|
|
return NotEqual, nil
|
|
}
|
|
|
|
func (p *parser) callonLabelOperators2() (interface{}, error) {
|
|
stack := p.vstack[len(p.vstack)-1]
|
|
_ = stack
|
|
return p.cur.onLabelOperators2()
|
|
}
|
|
|
|
func (c *current) onLabelOperators4() (interface{}, error) {
|
|
return RegexMatch, nil
|
|
}
|
|
|
|
func (p *parser) callonLabelOperators4() (interface{}, error) {
|
|
stack := p.vstack[len(p.vstack)-1]
|
|
_ = stack
|
|
return p.cur.onLabelOperators4()
|
|
}
|
|
|
|
func (c *current) onLabelOperators6() (interface{}, error) {
|
|
return RegexNoMatch, nil
|
|
}
|
|
|
|
func (p *parser) callonLabelOperators6() (interface{}, error) {
|
|
stack := p.vstack[len(p.vstack)-1]
|
|
_ = stack
|
|
return p.cur.onLabelOperators6()
|
|
}
|
|
|
|
func (c *current) onLabelOperators8() (interface{}, error) {
|
|
return Equal, nil
|
|
}
|
|
|
|
func (p *parser) callonLabelOperators8() (interface{}, error) {
|
|
stack := p.vstack[len(p.vstack)-1]
|
|
_ = stack
|
|
return p.cur.onLabelOperators8()
|
|
}
|
|
|
|
func (c *current) onLabelMatch1(label, op, match interface{}) (interface{}, error) {
|
|
return NewLabelMatcher(label.(*Identifier), op.(MatchKind), match.(Arg))
|
|
}
|
|
|
|
func (p *parser) callonLabelMatch1() (interface{}, error) {
|
|
stack := p.vstack[len(p.vstack)-1]
|
|
_ = stack
|
|
return p.cur.onLabelMatch1(stack["label"], stack["op"], stack["match"])
|
|
}
|
|
|
|
func (c *current) onLabelMatches1(first, rest interface{}) (interface{}, error) {
|
|
return NewLabelMatches(first.(*LabelMatcher), rest)
|
|
}
|
|
|
|
func (p *parser) callonLabelMatches1() (interface{}, error) {
|
|
stack := p.vstack[len(p.vstack)-1]
|
|
_ = stack
|
|
return p.cur.onLabelMatches1(stack["first"], stack["rest"])
|
|
}
|
|
|
|
func (c *current) onLabelMatchesRest1(match interface{}) (interface{}, error) {
|
|
return match, nil
|
|
}
|
|
|
|
func (p *parser) callonLabelMatchesRest1() (interface{}, error) {
|
|
stack := p.vstack[len(p.vstack)-1]
|
|
_ = stack
|
|
return p.cur.onLabelMatchesRest1(stack["match"])
|
|
}
|
|
|
|
func (c *current) onLabelList2() (interface{}, error) {
|
|
return nil, nil
|
|
}
|
|
|
|
func (p *parser) callonLabelList2() (interface{}, error) {
|
|
stack := p.vstack[len(p.vstack)-1]
|
|
_ = stack
|
|
return p.cur.onLabelList2()
|
|
}
|
|
|
|
func (c *current) onLabelList7(label, rest interface{}) (interface{}, error) {
|
|
return NewIdentifierList(label.(*Identifier), rest)
|
|
}
|
|
|
|
func (p *parser) callonLabelList7() (interface{}, error) {
|
|
stack := p.vstack[len(p.vstack)-1]
|
|
_ = stack
|
|
return p.cur.onLabelList7(stack["label"], stack["rest"])
|
|
}
|
|
|
|
func (c *current) onLabelListRest1(label interface{}) (interface{}, error) {
|
|
return label, nil
|
|
}
|
|
|
|
func (p *parser) callonLabelListRest1() (interface{}, error) {
|
|
stack := p.vstack[len(p.vstack)-1]
|
|
_ = stack
|
|
return p.cur.onLabelListRest1(stack["label"])
|
|
}
|
|
|
|
func (c *current) onVectorSelector1(metric, block, rng, offset interface{}) (interface{}, error) {
|
|
return NewSelector(metric.(*Identifier), block, rng, offset)
|
|
}
|
|
|
|
func (p *parser) callonVectorSelector1() (interface{}, error) {
|
|
stack := p.vstack[len(p.vstack)-1]
|
|
_ = stack
|
|
return p.cur.onVectorSelector1(stack["metric"], stack["block"], stack["rng"], stack["offset"])
|
|
}
|
|
|
|
func (c *current) onRange1(dur interface{}) (interface{}, error) {
|
|
return dur, nil
|
|
}
|
|
|
|
func (p *parser) callonRange1() (interface{}, error) {
|
|
stack := p.vstack[len(p.vstack)-1]
|
|
_ = stack
|
|
return p.cur.onRange1(stack["dur"])
|
|
}
|
|
|
|
func (c *current) onOffset1(dur interface{}) (interface{}, error) {
|
|
return dur, nil
|
|
}
|
|
|
|
func (p *parser) callonOffset1() (interface{}, error) {
|
|
stack := p.vstack[len(p.vstack)-1]
|
|
_ = stack
|
|
return p.cur.onOffset1(stack["dur"])
|
|
}
|
|
|
|
func (c *current) onCountValueOperator1() (interface{}, error) {
|
|
return &Operator{
|
|
Kind: CountValuesKind,
|
|
}, nil
|
|
}
|
|
|
|
func (p *parser) callonCountValueOperator1() (interface{}, error) {
|
|
stack := p.vstack[len(p.vstack)-1]
|
|
_ = stack
|
|
return p.cur.onCountValueOperator1()
|
|
}
|
|
|
|
func (c *current) onBinaryAggregateOperators1(op interface{}) (interface{}, error) {
|
|
return &Operator{
|
|
Kind: ToOperatorKind(string(op.([]byte))),
|
|
}, nil
|
|
}
|
|
|
|
func (p *parser) callonBinaryAggregateOperators1() (interface{}, error) {
|
|
stack := p.vstack[len(p.vstack)-1]
|
|
_ = stack
|
|
return p.cur.onBinaryAggregateOperators1(stack["op"])
|
|
}
|
|
|
|
func (c *current) onUnaryAggregateOperators1(op interface{}) (interface{}, error) {
|
|
return &Operator{
|
|
Kind: ToOperatorKind(string(op.([]byte))),
|
|
}, nil
|
|
}
|
|
|
|
func (p *parser) callonUnaryAggregateOperators1() (interface{}, error) {
|
|
stack := p.vstack[len(p.vstack)-1]
|
|
_ = stack
|
|
return p.cur.onUnaryAggregateOperators1(stack["op"])
|
|
}
|
|
|
|
func (c *current) onAggregateBy1(labels, keep interface{}) (interface{}, error) {
|
|
return &Aggregate{
|
|
By: true,
|
|
Labels: labels.([]*Identifier),
|
|
}, nil
|
|
}
|
|
|
|
func (p *parser) callonAggregateBy1() (interface{}, error) {
|
|
stack := p.vstack[len(p.vstack)-1]
|
|
_ = stack
|
|
return p.cur.onAggregateBy1(stack["labels"], stack["keep"])
|
|
}
|
|
|
|
func (c *current) onAggregateWithout1(labels interface{}) (interface{}, error) {
|
|
return &Aggregate{
|
|
Without: true,
|
|
Labels: labels.([]*Identifier),
|
|
}, nil
|
|
}
|
|
|
|
func (p *parser) callonAggregateWithout1() (interface{}, error) {
|
|
stack := p.vstack[len(p.vstack)-1]
|
|
_ = stack
|
|
return p.cur.onAggregateWithout1(stack["labels"])
|
|
}
|
|
|
|
func (c *current) onAggregateExpression2(op, param, vector, group interface{}) (interface{}, error) {
|
|
oper := op.(*Operator)
|
|
oper.Arg = param.(*StringLiteral)
|
|
return NewAggregateExpr(oper, vector.(*Selector), group)
|
|
}
|
|
|
|
func (p *parser) callonAggregateExpression2() (interface{}, error) {
|
|
stack := p.vstack[len(p.vstack)-1]
|
|
_ = stack
|
|
return p.cur.onAggregateExpression2(stack["op"], stack["param"], stack["vector"], stack["group"])
|
|
}
|
|
|
|
func (c *current) onAggregateExpression22(op, group, param, vector interface{}) (interface{}, error) {
|
|
oper := op.(*Operator)
|
|
oper.Arg = param.(*StringLiteral)
|
|
return NewAggregateExpr(oper, vector.(*Selector), group)
|
|
}
|
|
|
|
func (p *parser) callonAggregateExpression22() (interface{}, error) {
|
|
stack := p.vstack[len(p.vstack)-1]
|
|
_ = stack
|
|
return p.cur.onAggregateExpression22(stack["op"], stack["group"], stack["param"], stack["vector"])
|
|
}
|
|
|
|
func (c *current) onAggregateExpression42(op, param, vector, group interface{}) (interface{}, error) {
|
|
oper := op.(*Operator)
|
|
oper.Arg = param.(*Number)
|
|
return NewAggregateExpr(oper, vector.(*Selector), group)
|
|
}
|
|
|
|
func (p *parser) callonAggregateExpression42() (interface{}, error) {
|
|
stack := p.vstack[len(p.vstack)-1]
|
|
_ = stack
|
|
return p.cur.onAggregateExpression42(stack["op"], stack["param"], stack["vector"], stack["group"])
|
|
}
|
|
|
|
func (c *current) onAggregateExpression62(op, group, param, vector interface{}) (interface{}, error) {
|
|
oper := op.(*Operator)
|
|
oper.Arg = param.(*Number)
|
|
return NewAggregateExpr(oper, vector.(*Selector), group)
|
|
}
|
|
|
|
func (p *parser) callonAggregateExpression62() (interface{}, error) {
|
|
stack := p.vstack[len(p.vstack)-1]
|
|
_ = stack
|
|
return p.cur.onAggregateExpression62(stack["op"], stack["group"], stack["param"], stack["vector"])
|
|
}
|
|
|
|
func (c *current) onAggregateExpression82(op, vector, group interface{}) (interface{}, error) {
|
|
return NewAggregateExpr(op.(*Operator), vector.(*Selector), group)
|
|
}
|
|
|
|
func (p *parser) callonAggregateExpression82() (interface{}, error) {
|
|
stack := p.vstack[len(p.vstack)-1]
|
|
_ = stack
|
|
return p.cur.onAggregateExpression82(stack["op"], stack["vector"], stack["group"])
|
|
}
|
|
|
|
func (c *current) onAggregateExpression97(op, group, vector interface{}) (interface{}, error) {
|
|
return NewAggregateExpr(op.(*Operator), vector.(*Selector), group)
|
|
}
|
|
|
|
func (p *parser) callonAggregateExpression97() (interface{}, error) {
|
|
stack := p.vstack[len(p.vstack)-1]
|
|
_ = stack
|
|
return p.cur.onAggregateExpression97(stack["op"], stack["group"], stack["vector"])
|
|
}
|
|
|
|
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
|
|
}
|
|
|
|
func rangeTable(class string) *unicode.RangeTable {
|
|
if rt, ok := unicode.Categories[class]; ok {
|
|
return rt
|
|
}
|
|
if rt, ok := unicode.Properties[class]; ok {
|
|
return rt
|
|
}
|
|
if rt, ok := unicode.Scripts[class]; ok {
|
|
return rt
|
|
}
|
|
|
|
// cannot happen
|
|
panic(fmt.Sprintf("invalid Unicode class: %s", class))
|
|
}
|