// Code generated by pigeon; DO NOT EDIT.

package grammar

import (
	"bytes"
	"errors"
	"fmt"
	"io"
	"math"
	"os"
	"sort"
	"strconv"
	"strings"
	"unicode"
	"unicode/utf8"

	"github.com/mitchellh/pointerstructure"
)

var g = &grammar{
	rules: []*rule{
		{
			name: "Input",
			pos:  position{line: 12, col: 1, offset: 103},
			expr: &choiceExpr{
				pos: position{line: 12, col: 10, offset: 112},
				alternatives: []any{
					&actionExpr{
						pos: position{line: 12, col: 10, offset: 112},
						run: (*parser).callonInput2,
						expr: &seqExpr{
							pos: position{line: 12, col: 10, offset: 112},
							exprs: []any{
								&zeroOrOneExpr{
									pos: position{line: 12, col: 10, offset: 112},
									expr: &ruleRefExpr{
										pos:  position{line: 12, col: 10, offset: 112},
										name: "_",
									},
								},
								&litMatcher{
									pos:        position{line: 12, col: 13, offset: 115},
									val:        "(",
									ignoreCase: false,
									want:       "\"(\"",
								},
								&zeroOrOneExpr{
									pos: position{line: 12, col: 17, offset: 119},
									expr: &ruleRefExpr{
										pos:  position{line: 12, col: 17, offset: 119},
										name: "_",
									},
								},
								&labeledExpr{
									pos:   position{line: 12, col: 20, offset: 122},
									label: "expr",
									expr: &ruleRefExpr{
										pos:  position{line: 12, col: 25, offset: 127},
										name: "OrExpression",
									},
								},
								&zeroOrOneExpr{
									pos: position{line: 12, col: 38, offset: 140},
									expr: &ruleRefExpr{
										pos:  position{line: 12, col: 38, offset: 140},
										name: "_",
									},
								},
								&litMatcher{
									pos:        position{line: 12, col: 41, offset: 143},
									val:        ")",
									ignoreCase: false,
									want:       "\")\"",
								},
								&zeroOrOneExpr{
									pos: position{line: 12, col: 45, offset: 147},
									expr: &ruleRefExpr{
										pos:  position{line: 12, col: 45, offset: 147},
										name: "_",
									},
								},
								&ruleRefExpr{
									pos:  position{line: 12, col: 48, offset: 150},
									name: "EOF",
								},
							},
						},
					},
					&actionExpr{
						pos: position{line: 14, col: 5, offset: 180},
						run: (*parser).callonInput17,
						expr: &seqExpr{
							pos: position{line: 14, col: 5, offset: 180},
							exprs: []any{
								&zeroOrOneExpr{
									pos: position{line: 14, col: 5, offset: 180},
									expr: &ruleRefExpr{
										pos:  position{line: 14, col: 5, offset: 180},
										name: "_",
									},
								},
								&labeledExpr{
									pos:   position{line: 14, col: 8, offset: 183},
									label: "expr",
									expr: &ruleRefExpr{
										pos:  position{line: 14, col: 13, offset: 188},
										name: "OrExpression",
									},
								},
								&zeroOrOneExpr{
									pos: position{line: 14, col: 26, offset: 201},
									expr: &ruleRefExpr{
										pos:  position{line: 14, col: 26, offset: 201},
										name: "_",
									},
								},
								&ruleRefExpr{
									pos:  position{line: 14, col: 29, offset: 204},
									name: "EOF",
								},
							},
						},
					},
				},
			},
		},
		{
			name: "OrExpression",
			pos:  position{line: 18, col: 1, offset: 233},
			expr: &choiceExpr{
				pos: position{line: 18, col: 17, offset: 249},
				alternatives: []any{
					&actionExpr{
						pos: position{line: 18, col: 17, offset: 249},
						run: (*parser).callonOrExpression2,
						expr: &seqExpr{
							pos: position{line: 18, col: 17, offset: 249},
							exprs: []any{
								&labeledExpr{
									pos:   position{line: 18, col: 17, offset: 249},
									label: "left",
									expr: &ruleRefExpr{
										pos:  position{line: 18, col: 22, offset: 254},
										name: "AndExpression",
									},
								},
								&ruleRefExpr{
									pos:  position{line: 18, col: 36, offset: 268},
									name: "_",
								},
								&litMatcher{
									pos:        position{line: 18, col: 38, offset: 270},
									val:        "or",
									ignoreCase: false,
									want:       "\"or\"",
								},
								&ruleRefExpr{
									pos:  position{line: 18, col: 43, offset: 275},
									name: "_",
								},
								&labeledExpr{
									pos:   position{line: 18, col: 45, offset: 277},
									label: "right",
									expr: &ruleRefExpr{
										pos:  position{line: 18, col: 51, offset: 283},
										name: "OrExpression",
									},
								},
							},
						},
					},
					&actionExpr{
						pos: position{line: 24, col: 5, offset: 433},
						run: (*parser).callonOrExpression11,
						expr: &labeledExpr{
							pos:   position{line: 24, col: 5, offset: 433},
							label: "expr",
							expr: &ruleRefExpr{
								pos:  position{line: 24, col: 10, offset: 438},
								name: "AndExpression",
							},
						},
					},
					&actionExpr{
						pos: position{line: 26, col: 5, offset: 478},
						run: (*parser).callonOrExpression14,
						expr: &labeledExpr{
							pos:   position{line: 26, col: 5, offset: 478},
							label: "expr",
							expr: &ruleRefExpr{
								pos:  position{line: 26, col: 10, offset: 483},
								name: "CollectionExpression",
							},
						},
					},
				},
			},
		},
		{
			name: "AndExpression",
			pos:  position{line: 30, col: 1, offset: 529},
			expr: &choiceExpr{
				pos: position{line: 30, col: 18, offset: 546},
				alternatives: []any{
					&actionExpr{
						pos: position{line: 30, col: 18, offset: 546},
						run: (*parser).callonAndExpression2,
						expr: &seqExpr{
							pos: position{line: 30, col: 18, offset: 546},
							exprs: []any{
								&labeledExpr{
									pos:   position{line: 30, col: 18, offset: 546},
									label: "left",
									expr: &ruleRefExpr{
										pos:  position{line: 30, col: 23, offset: 551},
										name: "NotExpression",
									},
								},
								&ruleRefExpr{
									pos:  position{line: 30, col: 37, offset: 565},
									name: "_",
								},
								&litMatcher{
									pos:        position{line: 30, col: 39, offset: 567},
									val:        "and",
									ignoreCase: false,
									want:       "\"and\"",
								},
								&ruleRefExpr{
									pos:  position{line: 30, col: 45, offset: 573},
									name: "_",
								},
								&labeledExpr{
									pos:   position{line: 30, col: 47, offset: 575},
									label: "right",
									expr: &ruleRefExpr{
										pos:  position{line: 30, col: 53, offset: 581},
										name: "AndExpression",
									},
								},
							},
						},
					},
					&actionExpr{
						pos: position{line: 36, col: 5, offset: 733},
						run: (*parser).callonAndExpression11,
						expr: &labeledExpr{
							pos:   position{line: 36, col: 5, offset: 733},
							label: "expr",
							expr: &ruleRefExpr{
								pos:  position{line: 36, col: 10, offset: 738},
								name: "NotExpression",
							},
						},
					},
				},
			},
		},
		{
			name: "NotExpression",
			pos:  position{line: 40, col: 1, offset: 777},
			expr: &choiceExpr{
				pos: position{line: 40, col: 18, offset: 794},
				alternatives: []any{
					&actionExpr{
						pos: position{line: 40, col: 18, offset: 794},
						run: (*parser).callonNotExpression2,
						expr: &seqExpr{
							pos: position{line: 40, col: 18, offset: 794},
							exprs: []any{
								&litMatcher{
									pos:        position{line: 40, col: 18, offset: 794},
									val:        "not",
									ignoreCase: false,
									want:       "\"not\"",
								},
								&ruleRefExpr{
									pos:  position{line: 40, col: 24, offset: 800},
									name: "_",
								},
								&labeledExpr{
									pos:   position{line: 40, col: 26, offset: 802},
									label: "expr",
									expr: &ruleRefExpr{
										pos:  position{line: 40, col: 31, offset: 807},
										name: "NotExpression",
									},
								},
							},
						},
					},
					&actionExpr{
						pos: position{line: 51, col: 5, offset: 1194},
						run: (*parser).callonNotExpression8,
						expr: &labeledExpr{
							pos:   position{line: 51, col: 5, offset: 1194},
							label: "expr",
							expr: &ruleRefExpr{
								pos:  position{line: 51, col: 10, offset: 1199},
								name: "ParenthesizedExpression",
							},
						},
					},
				},
			},
		},
		{
			name: "CollectionExpression",
			pos:  position{line: 55, col: 1, offset: 1248},
			expr: &actionExpr{
				pos: position{line: 55, col: 25, offset: 1272},
				run: (*parser).callonCollectionExpression1,
				expr: &seqExpr{
					pos: position{line: 55, col: 25, offset: 1272},
					exprs: []any{
						&labeledExpr{
							pos:   position{line: 55, col: 25, offset: 1272},
							label: "op",
							expr: &choiceExpr{
								pos: position{line: 55, col: 29, offset: 1276},
								alternatives: []any{
									&ruleRefExpr{
										pos:  position{line: 55, col: 29, offset: 1276},
										name: "CollectionOpAny",
									},
									&ruleRefExpr{
										pos:  position{line: 55, col: 47, offset: 1294},
										name: "CollectionOpAll",
									},
								},
							},
						},
						&labeledExpr{
							pos:   position{line: 55, col: 64, offset: 1311},
							label: "selector",
							expr: &ruleRefExpr{
								pos:  position{line: 55, col: 73, offset: 1320},
								name: "Selector",
							},
						},
						&ruleRefExpr{
							pos:  position{line: 55, col: 82, offset: 1329},
							name: "_",
						},
						&litMatcher{
							pos:        position{line: 55, col: 84, offset: 1331},
							val:        "as",
							ignoreCase: false,
							want:       "\"as\"",
						},
						&ruleRefExpr{
							pos:  position{line: 55, col: 89, offset: 1336},
							name: "_",
						},
						&labeledExpr{
							pos:   position{line: 55, col: 91, offset: 1338},
							label: "binding",
							expr: &ruleRefExpr{
								pos:  position{line: 55, col: 99, offset: 1346},
								name: "CollectionIdentifiers",
							},
						},
						&zeroOrOneExpr{
							pos: position{line: 55, col: 121, offset: 1368},
							expr: &ruleRefExpr{
								pos:  position{line: 55, col: 121, offset: 1368},
								name: "_",
							},
						},
						&litMatcher{
							pos:        position{line: 55, col: 124, offset: 1371},
							val:        "{",
							ignoreCase: false,
							want:       "\"{\"",
						},
						&zeroOrOneExpr{
							pos: position{line: 55, col: 128, offset: 1375},
							expr: &ruleRefExpr{
								pos:  position{line: 55, col: 128, offset: 1375},
								name: "_",
							},
						},
						&labeledExpr{
							pos:   position{line: 55, col: 131, offset: 1378},
							label: "expr",
							expr: &ruleRefExpr{
								pos:  position{line: 55, col: 136, offset: 1383},
								name: "OrExpression",
							},
						},
						&zeroOrOneExpr{
							pos: position{line: 55, col: 149, offset: 1396},
							expr: &ruleRefExpr{
								pos:  position{line: 55, col: 149, offset: 1396},
								name: "_",
							},
						},
						&litMatcher{
							pos:        position{line: 55, col: 152, offset: 1399},
							val:        "}",
							ignoreCase: false,
							want:       "\"}\"",
						},
					},
				},
			},
		},
		{
			name:        "CollectionIdentifiers",
			displayName: "\"collection-identifiers\"",
			pos:         position{line: 64, col: 1, offset: 1625},
			expr: &choiceExpr{
				pos: position{line: 64, col: 51, offset: 1675},
				alternatives: []any{
					&actionExpr{
						pos: position{line: 64, col: 51, offset: 1675},
						run: (*parser).callonCollectionIdentifiers2,
						expr: &seqExpr{
							pos: position{line: 64, col: 51, offset: 1675},
							exprs: []any{
								&labeledExpr{
									pos:   position{line: 64, col: 51, offset: 1675},
									label: "id1",
									expr: &ruleRefExpr{
										pos:  position{line: 64, col: 55, offset: 1679},
										name: "Identifier",
									},
								},
								&zeroOrOneExpr{
									pos: position{line: 64, col: 66, offset: 1690},
									expr: &ruleRefExpr{
										pos:  position{line: 64, col: 66, offset: 1690},
										name: "_",
									},
								},
								&litMatcher{
									pos:        position{line: 64, col: 69, offset: 1693},
									val:        ",",
									ignoreCase: false,
									want:       "\",\"",
								},
								&zeroOrOneExpr{
									pos: position{line: 64, col: 73, offset: 1697},
									expr: &ruleRefExpr{
										pos:  position{line: 64, col: 73, offset: 1697},
										name: "_",
									},
								},
								&labeledExpr{
									pos:   position{line: 64, col: 76, offset: 1700},
									label: "id2",
									expr: &ruleRefExpr{
										pos:  position{line: 64, col: 80, offset: 1704},
										name: "Identifier",
									},
								},
							},
						},
					},
					&actionExpr{
						pos: position{line: 70, col: 5, offset: 1859},
						run: (*parser).callonCollectionIdentifiers13,
						expr: &seqExpr{
							pos: position{line: 70, col: 5, offset: 1859},
							exprs: []any{
								&labeledExpr{
									pos:   position{line: 70, col: 5, offset: 1859},
									label: "id1",
									expr: &ruleRefExpr{
										pos:  position{line: 70, col: 9, offset: 1863},
										name: "Identifier",
									},
								},
								&zeroOrOneExpr{
									pos: position{line: 70, col: 20, offset: 1874},
									expr: &ruleRefExpr{
										pos:  position{line: 70, col: 20, offset: 1874},
										name: "_",
									},
								},
								&litMatcher{
									pos:        position{line: 70, col: 23, offset: 1877},
									val:        ",",
									ignoreCase: false,
									want:       "\",\"",
								},
								&zeroOrOneExpr{
									pos: position{line: 70, col: 27, offset: 1881},
									expr: &ruleRefExpr{
										pos:  position{line: 70, col: 27, offset: 1881},
										name: "_",
									},
								},
								&litMatcher{
									pos:        position{line: 70, col: 30, offset: 1884},
									val:        "_",
									ignoreCase: false,
									want:       "\"_\"",
								},
							},
						},
					},
					&actionExpr{
						pos: position{line: 75, col: 5, offset: 1997},
						run: (*parser).callonCollectionIdentifiers23,
						expr: &seqExpr{
							pos: position{line: 75, col: 5, offset: 1997},
							exprs: []any{
								&litMatcher{
									pos:        position{line: 75, col: 5, offset: 1997},
									val:        "_",
									ignoreCase: false,
									want:       "\"_\"",
								},
								&zeroOrOneExpr{
									pos: position{line: 75, col: 9, offset: 2001},
									expr: &ruleRefExpr{
										pos:  position{line: 75, col: 9, offset: 2001},
										name: "_",
									},
								},
								&litMatcher{
									pos:        position{line: 75, col: 12, offset: 2004},
									val:        ",",
									ignoreCase: false,
									want:       "\",\"",
								},
								&zeroOrOneExpr{
									pos: position{line: 75, col: 16, offset: 2008},
									expr: &ruleRefExpr{
										pos:  position{line: 75, col: 16, offset: 2008},
										name: "_",
									},
								},
								&labeledExpr{
									pos:   position{line: 75, col: 19, offset: 2011},
									label: "id2",
									expr: &ruleRefExpr{
										pos:  position{line: 75, col: 23, offset: 2015},
										name: "Identifier",
									},
								},
							},
						},
					},
					&actionExpr{
						pos: position{line: 80, col: 5, offset: 2135},
						run: (*parser).callonCollectionIdentifiers33,
						expr: &labeledExpr{
							pos:   position{line: 80, col: 5, offset: 2135},
							label: "id",
							expr: &ruleRefExpr{
								pos:  position{line: 80, col: 8, offset: 2138},
								name: "Identifier",
							},
						},
					},
				},
			},
		},
		{
			name: "CollectionOpAny",
			pos:  position{line: 87, col: 1, offset: 2260},
			expr: &actionExpr{
				pos: position{line: 87, col: 20, offset: 2279},
				run: (*parser).callonCollectionOpAny1,
				expr: &seqExpr{
					pos: position{line: 87, col: 20, offset: 2279},
					exprs: []any{
						&litMatcher{
							pos:        position{line: 87, col: 20, offset: 2279},
							val:        "any",
							ignoreCase: false,
							want:       "\"any\"",
						},
						&ruleRefExpr{
							pos:  position{line: 87, col: 26, offset: 2285},
							name: "_",
						},
					},
				},
			},
		},
		{
			name: "CollectionOpAll",
			pos:  position{line: 91, col: 1, offset: 2323},
			expr: &actionExpr{
				pos: position{line: 91, col: 20, offset: 2342},
				run: (*parser).callonCollectionOpAll1,
				expr: &seqExpr{
					pos: position{line: 91, col: 20, offset: 2342},
					exprs: []any{
						&litMatcher{
							pos:        position{line: 91, col: 20, offset: 2342},
							val:        "all",
							ignoreCase: false,
							want:       "\"all\"",
						},
						&ruleRefExpr{
							pos:  position{line: 91, col: 26, offset: 2348},
							name: "_",
						},
					},
				},
			},
		},
		{
			name:        "ParenthesizedExpression",
			displayName: "\"grouping\"",
			pos:         position{line: 95, col: 1, offset: 2386},
			expr: &choiceExpr{
				pos: position{line: 95, col: 39, offset: 2424},
				alternatives: []any{
					&actionExpr{
						pos: position{line: 95, col: 39, offset: 2424},
						run: (*parser).callonParenthesizedExpression2,
						expr: &seqExpr{
							pos: position{line: 95, col: 39, offset: 2424},
							exprs: []any{
								&litMatcher{
									pos:        position{line: 95, col: 39, offset: 2424},
									val:        "(",
									ignoreCase: false,
									want:       "\"(\"",
								},
								&zeroOrOneExpr{
									pos: position{line: 95, col: 43, offset: 2428},
									expr: &ruleRefExpr{
										pos:  position{line: 95, col: 43, offset: 2428},
										name: "_",
									},
								},
								&labeledExpr{
									pos:   position{line: 95, col: 46, offset: 2431},
									label: "expr",
									expr: &ruleRefExpr{
										pos:  position{line: 95, col: 51, offset: 2436},
										name: "OrExpression",
									},
								},
								&zeroOrOneExpr{
									pos: position{line: 95, col: 64, offset: 2449},
									expr: &ruleRefExpr{
										pos:  position{line: 95, col: 64, offset: 2449},
										name: "_",
									},
								},
								&litMatcher{
									pos:        position{line: 95, col: 67, offset: 2452},
									val:        ")",
									ignoreCase: false,
									want:       "\")\"",
								},
							},
						},
					},
					&actionExpr{
						pos: position{line: 97, col: 5, offset: 2482},
						run: (*parser).callonParenthesizedExpression12,
						expr: &labeledExpr{
							pos:   position{line: 97, col: 5, offset: 2482},
							label: "expr",
							expr: &ruleRefExpr{
								pos:  position{line: 97, col: 10, offset: 2487},
								name: "MatchExpression",
							},
						},
					},
					&seqExpr{
						pos: position{line: 99, col: 5, offset: 2529},
						exprs: []any{
							&litMatcher{
								pos:        position{line: 99, col: 5, offset: 2529},
								val:        "(",
								ignoreCase: false,
								want:       "\"(\"",
							},
							&zeroOrOneExpr{
								pos: position{line: 99, col: 9, offset: 2533},
								expr: &ruleRefExpr{
									pos:  position{line: 99, col: 9, offset: 2533},
									name: "_",
								},
							},
							&ruleRefExpr{
								pos:  position{line: 99, col: 12, offset: 2536},
								name: "OrExpression",
							},
							&zeroOrOneExpr{
								pos: position{line: 99, col: 25, offset: 2549},
								expr: &ruleRefExpr{
									pos:  position{line: 99, col: 25, offset: 2549},
									name: "_",
								},
							},
							&notExpr{
								pos: position{line: 99, col: 28, offset: 2552},
								expr: &litMatcher{
									pos:        position{line: 99, col: 29, offset: 2553},
									val:        ")",
									ignoreCase: false,
									want:       "\")\"",
								},
							},
							&andCodeExpr{
								pos: position{line: 99, col: 33, offset: 2557},
								run: (*parser).callonParenthesizedExpression24,
							},
						},
					},
				},
			},
		},
		{
			name:        "MatchExpression",
			displayName: "\"match\"",
			pos:         position{line: 103, col: 1, offset: 2616},
			expr: &choiceExpr{
				pos: position{line: 103, col: 28, offset: 2643},
				alternatives: []any{
					&ruleRefExpr{
						pos:  position{line: 103, col: 28, offset: 2643},
						name: "MatchSelectorOpValue",
					},
					&ruleRefExpr{
						pos:  position{line: 103, col: 51, offset: 2666},
						name: "MatchSelectorOp",
					},
					&ruleRefExpr{
						pos:  position{line: 103, col: 69, offset: 2684},
						name: "MatchValueOpSelector",
					},
				},
			},
		},
		{
			name:        "MatchSelectorOpValue",
			displayName: "\"match\"",
			pos:         position{line: 105, col: 1, offset: 2706},
			expr: &actionExpr{
				pos: position{line: 105, col: 33, offset: 2738},
				run: (*parser).callonMatchSelectorOpValue1,
				expr: &seqExpr{
					pos: position{line: 105, col: 33, offset: 2738},
					exprs: []any{
						&labeledExpr{
							pos:   position{line: 105, col: 33, offset: 2738},
							label: "selector",
							expr: &ruleRefExpr{
								pos:  position{line: 105, col: 42, offset: 2747},
								name: "Selector",
							},
						},
						&labeledExpr{
							pos:   position{line: 105, col: 51, offset: 2756},
							label: "operator",
							expr: &choiceExpr{
								pos: position{line: 105, col: 61, offset: 2766},
								alternatives: []any{
									&ruleRefExpr{
										pos:  position{line: 105, col: 61, offset: 2766},
										name: "MatchEqual",
									},
									&ruleRefExpr{
										pos:  position{line: 105, col: 74, offset: 2779},
										name: "MatchNotEqual",
									},
									&ruleRefExpr{
										pos:  position{line: 105, col: 90, offset: 2795},
										name: "MatchContains",
									},
									&ruleRefExpr{
										pos:  position{line: 105, col: 106, offset: 2811},
										name: "MatchNotContains",
									},
									&ruleRefExpr{
										pos:  position{line: 105, col: 125, offset: 2830},
										name: "MatchMatches",
									},
									&ruleRefExpr{
										pos:  position{line: 105, col: 140, offset: 2845},
										name: "MatchNotMatches",
									},
								},
							},
						},
						&labeledExpr{
							pos:   position{line: 105, col: 157, offset: 2862},
							label: "value",
							expr: &ruleRefExpr{
								pos:  position{line: 105, col: 163, offset: 2868},
								name: "Value",
							},
						},
					},
				},
			},
		},
		{
			name:        "MatchSelectorOp",
			displayName: "\"match\"",
			pos:         position{line: 109, col: 1, offset: 3006},
			expr: &actionExpr{
				pos: position{line: 109, col: 28, offset: 3033},
				run: (*parser).callonMatchSelectorOp1,
				expr: &seqExpr{
					pos: position{line: 109, col: 28, offset: 3033},
					exprs: []any{
						&labeledExpr{
							pos:   position{line: 109, col: 28, offset: 3033},
							label: "selector",
							expr: &ruleRefExpr{
								pos:  position{line: 109, col: 37, offset: 3042},
								name: "Selector",
							},
						},
						&labeledExpr{
							pos:   position{line: 109, col: 46, offset: 3051},
							label: "operator",
							expr: &choiceExpr{
								pos: position{line: 109, col: 56, offset: 3061},
								alternatives: []any{
									&ruleRefExpr{
										pos:  position{line: 109, col: 56, offset: 3061},
										name: "MatchIsEmpty",
									},
									&ruleRefExpr{
										pos:  position{line: 109, col: 71, offset: 3076},
										name: "MatchIsNotEmpty",
									},
									&ruleRefExpr{
										pos:  position{line: 109, col: 89, offset: 3094},
										name: "MatchIsNil",
									},
									&ruleRefExpr{
										pos:  position{line: 109, col: 102, offset: 3107},
										name: "MatchIsNotNil",
									},
								},
							},
						},
					},
				},
			},
		},
		{
			name:        "MatchValueOpSelector",
			displayName: "\"match\"",
			pos:         position{line: 113, col: 1, offset: 3238},
			expr: &choiceExpr{
				pos: position{line: 113, col: 33, offset: 3270},
				alternatives: []any{
					&actionExpr{
						pos: position{line: 113, col: 33, offset: 3270},
						run: (*parser).callonMatchValueOpSelector2,
						expr: &seqExpr{
							pos: position{line: 113, col: 33, offset: 3270},
							exprs: []any{
								&labeledExpr{
									pos:   position{line: 113, col: 33, offset: 3270},
									label: "value",
									expr: &ruleRefExpr{
										pos:  position{line: 113, col: 39, offset: 3276},
										name: "Value",
									},
								},
								&labeledExpr{
									pos:   position{line: 113, col: 45, offset: 3282},
									label: "operator",
									expr: &choiceExpr{
										pos: position{line: 113, col: 55, offset: 3292},
										alternatives: []any{
											&ruleRefExpr{
												pos:  position{line: 113, col: 55, offset: 3292},
												name: "MatchIn",
											},
											&ruleRefExpr{
												pos:  position{line: 113, col: 65, offset: 3302},
												name: "MatchNotIn",
											},
										},
									},
								},
								&labeledExpr{
									pos:   position{line: 113, col: 77, offset: 3314},
									label: "selector",
									expr: &ruleRefExpr{
										pos:  position{line: 113, col: 86, offset: 3323},
										name: "Selector",
									},
								},
							},
						},
					},
					&seqExpr{
						pos: position{line: 115, col: 5, offset: 3465},
						exprs: []any{
							&ruleRefExpr{
								pos:  position{line: 115, col: 5, offset: 3465},
								name: "Value",
							},
							&labeledExpr{
								pos:   position{line: 115, col: 11, offset: 3471},
								label: "operator",
								expr: &choiceExpr{
									pos: position{line: 115, col: 21, offset: 3481},
									alternatives: []any{
										&ruleRefExpr{
											pos:  position{line: 115, col: 21, offset: 3481},
											name: "MatchIn",
										},
										&ruleRefExpr{
											pos:  position{line: 115, col: 31, offset: 3491},
											name: "MatchNotIn",
										},
									},
								},
							},
							&notExpr{
								pos: position{line: 115, col: 43, offset: 3503},
								expr: &ruleRefExpr{
									pos:  position{line: 115, col: 44, offset: 3504},
									name: "Selector",
								},
							},
							&andCodeExpr{
								pos: position{line: 115, col: 53, offset: 3513},
								run: (*parser).callonMatchValueOpSelector20,
							},
						},
					},
				},
			},
		},
		{
			name: "MatchEqual",
			pos:  position{line: 119, col: 1, offset: 3567},
			expr: &actionExpr{
				pos: position{line: 119, col: 15, offset: 3581},
				run: (*parser).callonMatchEqual1,
				expr: &seqExpr{
					pos: position{line: 119, col: 15, offset: 3581},
					exprs: []any{
						&zeroOrOneExpr{
							pos: position{line: 119, col: 15, offset: 3581},
							expr: &ruleRefExpr{
								pos:  position{line: 119, col: 15, offset: 3581},
								name: "_",
							},
						},
						&litMatcher{
							pos:        position{line: 119, col: 18, offset: 3584},
							val:        "==",
							ignoreCase: false,
							want:       "\"==\"",
						},
						&zeroOrOneExpr{
							pos: position{line: 119, col: 23, offset: 3589},
							expr: &ruleRefExpr{
								pos:  position{line: 119, col: 23, offset: 3589},
								name: "_",
							},
						},
					},
				},
			},
		},
		{
			name: "MatchNotEqual",
			pos:  position{line: 122, col: 1, offset: 3622},
			expr: &actionExpr{
				pos: position{line: 122, col: 18, offset: 3639},
				run: (*parser).callonMatchNotEqual1,
				expr: &seqExpr{
					pos: position{line: 122, col: 18, offset: 3639},
					exprs: []any{
						&zeroOrOneExpr{
							pos: position{line: 122, col: 18, offset: 3639},
							expr: &ruleRefExpr{
								pos:  position{line: 122, col: 18, offset: 3639},
								name: "_",
							},
						},
						&litMatcher{
							pos:        position{line: 122, col: 21, offset: 3642},
							val:        "!=",
							ignoreCase: false,
							want:       "\"!=\"",
						},
						&zeroOrOneExpr{
							pos: position{line: 122, col: 26, offset: 3647},
							expr: &ruleRefExpr{
								pos:  position{line: 122, col: 26, offset: 3647},
								name: "_",
							},
						},
					},
				},
			},
		},
		{
			name: "MatchIsEmpty",
			pos:  position{line: 125, col: 1, offset: 3683},
			expr: &actionExpr{
				pos: position{line: 125, col: 17, offset: 3699},
				run: (*parser).callonMatchIsEmpty1,
				expr: &seqExpr{
					pos: position{line: 125, col: 17, offset: 3699},
					exprs: []any{
						&ruleRefExpr{
							pos:  position{line: 125, col: 17, offset: 3699},
							name: "_",
						},
						&litMatcher{
							pos:        position{line: 125, col: 19, offset: 3701},
							val:        "is",
							ignoreCase: false,
							want:       "\"is\"",
						},
						&ruleRefExpr{
							pos:  position{line: 125, col: 24, offset: 3706},
							name: "_",
						},
						&litMatcher{
							pos:        position{line: 125, col: 26, offset: 3708},
							val:        "empty",
							ignoreCase: false,
							want:       "\"empty\"",
						},
					},
				},
			},
		},
		{
			name: "MatchIsNotEmpty",
			pos:  position{line: 128, col: 1, offset: 3748},
			expr: &actionExpr{
				pos: position{line: 128, col: 20, offset: 3767},
				run: (*parser).callonMatchIsNotEmpty1,
				expr: &seqExpr{
					pos: position{line: 128, col: 20, offset: 3767},
					exprs: []any{
						&ruleRefExpr{
							pos:  position{line: 128, col: 20, offset: 3767},
							name: "_",
						},
						&litMatcher{
							pos:        position{line: 128, col: 21, offset: 3768},
							val:        "is",
							ignoreCase: false,
							want:       "\"is\"",
						},
						&ruleRefExpr{
							pos:  position{line: 128, col: 26, offset: 3773},
							name: "_",
						},
						&litMatcher{
							pos:        position{line: 128, col: 28, offset: 3775},
							val:        "not",
							ignoreCase: false,
							want:       "\"not\"",
						},
						&ruleRefExpr{
							pos:  position{line: 128, col: 34, offset: 3781},
							name: "_",
						},
						&litMatcher{
							pos:        position{line: 128, col: 36, offset: 3783},
							val:        "empty",
							ignoreCase: false,
							want:       "\"empty\"",
						},
					},
				},
			},
		},
		{
			name: "MatchIn",
			pos:  position{line: 131, col: 1, offset: 3826},
			expr: &actionExpr{
				pos: position{line: 131, col: 12, offset: 3837},
				run: (*parser).callonMatchIn1,
				expr: &seqExpr{
					pos: position{line: 131, col: 12, offset: 3837},
					exprs: []any{
						&ruleRefExpr{
							pos:  position{line: 131, col: 12, offset: 3837},
							name: "_",
						},
						&litMatcher{
							pos:        position{line: 131, col: 14, offset: 3839},
							val:        "in",
							ignoreCase: false,
							want:       "\"in\"",
						},
						&ruleRefExpr{
							pos:  position{line: 131, col: 19, offset: 3844},
							name: "_",
						},
					},
				},
			},
		},
		{
			name: "MatchNotIn",
			pos:  position{line: 134, col: 1, offset: 3873},
			expr: &actionExpr{
				pos: position{line: 134, col: 15, offset: 3887},
				run: (*parser).callonMatchNotIn1,
				expr: &seqExpr{
					pos: position{line: 134, col: 15, offset: 3887},
					exprs: []any{
						&ruleRefExpr{
							pos:  position{line: 134, col: 15, offset: 3887},
							name: "_",
						},
						&litMatcher{
							pos:        position{line: 134, col: 17, offset: 3889},
							val:        "not",
							ignoreCase: false,
							want:       "\"not\"",
						},
						&ruleRefExpr{
							pos:  position{line: 134, col: 23, offset: 3895},
							name: "_",
						},
						&litMatcher{
							pos:        position{line: 134, col: 25, offset: 3897},
							val:        "in",
							ignoreCase: false,
							want:       "\"in\"",
						},
						&ruleRefExpr{
							pos:  position{line: 134, col: 30, offset: 3902},
							name: "_",
						},
					},
				},
			},
		},
		{
			name: "MatchContains",
			pos:  position{line: 137, col: 1, offset: 3934},
			expr: &actionExpr{
				pos: position{line: 137, col: 18, offset: 3951},
				run: (*parser).callonMatchContains1,
				expr: &seqExpr{
					pos: position{line: 137, col: 18, offset: 3951},
					exprs: []any{
						&ruleRefExpr{
							pos:  position{line: 137, col: 18, offset: 3951},
							name: "_",
						},
						&litMatcher{
							pos:        position{line: 137, col: 20, offset: 3953},
							val:        "contains",
							ignoreCase: false,
							want:       "\"contains\"",
						},
						&ruleRefExpr{
							pos:  position{line: 137, col: 31, offset: 3964},
							name: "_",
						},
					},
				},
			},
		},
		{
			name: "MatchNotContains",
			pos:  position{line: 140, col: 1, offset: 3993},
			expr: &actionExpr{
				pos: position{line: 140, col: 21, offset: 4013},
				run: (*parser).callonMatchNotContains1,
				expr: &seqExpr{
					pos: position{line: 140, col: 21, offset: 4013},
					exprs: []any{
						&ruleRefExpr{
							pos:  position{line: 140, col: 21, offset: 4013},
							name: "_",
						},
						&litMatcher{
							pos:        position{line: 140, col: 23, offset: 4015},
							val:        "not",
							ignoreCase: false,
							want:       "\"not\"",
						},
						&ruleRefExpr{
							pos:  position{line: 140, col: 29, offset: 4021},
							name: "_",
						},
						&litMatcher{
							pos:        position{line: 140, col: 31, offset: 4023},
							val:        "contains",
							ignoreCase: false,
							want:       "\"contains\"",
						},
						&ruleRefExpr{
							pos:  position{line: 140, col: 42, offset: 4034},
							name: "_",
						},
					},
				},
			},
		},
		{
			name: "MatchMatches",
			pos:  position{line: 143, col: 1, offset: 4066},
			expr: &actionExpr{
				pos: position{line: 143, col: 17, offset: 4082},
				run: (*parser).callonMatchMatches1,
				expr: &seqExpr{
					pos: position{line: 143, col: 17, offset: 4082},
					exprs: []any{
						&ruleRefExpr{
							pos:  position{line: 143, col: 17, offset: 4082},
							name: "_",
						},
						&litMatcher{
							pos:        position{line: 143, col: 19, offset: 4084},
							val:        "matches",
							ignoreCase: false,
							want:       "\"matches\"",
						},
						&ruleRefExpr{
							pos:  position{line: 143, col: 29, offset: 4094},
							name: "_",
						},
					},
				},
			},
		},
		{
			name: "MatchNotMatches",
			pos:  position{line: 146, col: 1, offset: 4128},
			expr: &actionExpr{
				pos: position{line: 146, col: 20, offset: 4147},
				run: (*parser).callonMatchNotMatches1,
				expr: &seqExpr{
					pos: position{line: 146, col: 20, offset: 4147},
					exprs: []any{
						&ruleRefExpr{
							pos:  position{line: 146, col: 20, offset: 4147},
							name: "_",
						},
						&litMatcher{
							pos:        position{line: 146, col: 22, offset: 4149},
							val:        "not",
							ignoreCase: false,
							want:       "\"not\"",
						},
						&ruleRefExpr{
							pos:  position{line: 146, col: 28, offset: 4155},
							name: "_",
						},
						&litMatcher{
							pos:        position{line: 146, col: 30, offset: 4157},
							val:        "matches",
							ignoreCase: false,
							want:       "\"matches\"",
						},
						&ruleRefExpr{
							pos:  position{line: 146, col: 40, offset: 4167},
							name: "_",
						},
					},
				},
			},
		},
		{
			name: "MatchIsNil",
			pos:  position{line: 149, col: 1, offset: 4204},
			expr: &actionExpr{
				pos: position{line: 149, col: 15, offset: 4218},
				run: (*parser).callonMatchIsNil1,
				expr: &seqExpr{
					pos: position{line: 149, col: 15, offset: 4218},
					exprs: []any{
						&ruleRefExpr{
							pos:  position{line: 149, col: 15, offset: 4218},
							name: "_",
						},
						&litMatcher{
							pos:        position{line: 149, col: 17, offset: 4220},
							val:        "is",
							ignoreCase: false,
							want:       "\"is\"",
						},
						&ruleRefExpr{
							pos:  position{line: 149, col: 22, offset: 4225},
							name: "_",
						},
						&litMatcher{
							pos:        position{line: 149, col: 24, offset: 4227},
							val:        "nil",
							ignoreCase: false,
							want:       "\"nil\"",
						},
					},
				},
			},
		},
		{
			name: "MatchIsNotNil",
			pos:  position{line: 152, col: 1, offset: 4263},
			expr: &actionExpr{
				pos: position{line: 152, col: 18, offset: 4280},
				run: (*parser).callonMatchIsNotNil1,
				expr: &seqExpr{
					pos: position{line: 152, col: 18, offset: 4280},
					exprs: []any{
						&ruleRefExpr{
							pos:  position{line: 152, col: 18, offset: 4280},
							name: "_",
						},
						&litMatcher{
							pos:        position{line: 152, col: 20, offset: 4282},
							val:        "is",
							ignoreCase: false,
							want:       "\"is\"",
						},
						&ruleRefExpr{
							pos:  position{line: 152, col: 25, offset: 4287},
							name: "_",
						},
						&litMatcher{
							pos:        position{line: 152, col: 27, offset: 4289},
							val:        "not",
							ignoreCase: false,
							want:       "\"not\"",
						},
						&ruleRefExpr{
							pos:  position{line: 152, col: 33, offset: 4295},
							name: "_",
						},
						&litMatcher{
							pos:        position{line: 152, col: 35, offset: 4297},
							val:        "nil",
							ignoreCase: false,
							want:       "\"nil\"",
						},
					},
				},
			},
		},
		{
			name:        "Selector",
			displayName: "\"selector\"",
			pos:         position{line: 156, col: 1, offset: 4337},
			expr: &choiceExpr{
				pos: position{line: 156, col: 24, offset: 4360},
				alternatives: []any{
					&actionExpr{
						pos: position{line: 156, col: 24, offset: 4360},
						run: (*parser).callonSelector2,
						expr: &seqExpr{
							pos: position{line: 156, col: 24, offset: 4360},
							exprs: []any{
								&labeledExpr{
									pos:   position{line: 156, col: 24, offset: 4360},
									label: "first",
									expr: &ruleRefExpr{
										pos:  position{line: 156, col: 30, offset: 4366},
										name: "Identifier",
									},
								},
								&labeledExpr{
									pos:   position{line: 156, col: 41, offset: 4377},
									label: "rest",
									expr: &zeroOrMoreExpr{
										pos: position{line: 156, col: 46, offset: 4382},
										expr: &ruleRefExpr{
											pos:  position{line: 156, col: 46, offset: 4382},
											name: "SelectorOrIndex",
										},
									},
								},
							},
						},
					},
					&actionExpr{
						pos: position{line: 167, col: 5, offset: 4646},
						run: (*parser).callonSelector9,
						expr: &seqExpr{
							pos: position{line: 167, col: 5, offset: 4646},
							exprs: []any{
								&litMatcher{
									pos:        position{line: 167, col: 5, offset: 4646},
									val:        "\"",
									ignoreCase: false,
									want:       "\"\\\"\"",
								},
								&labeledExpr{
									pos:   position{line: 167, col: 9, offset: 4650},
									label: "ptrsegs",
									expr: &zeroOrMoreExpr{
										pos: position{line: 167, col: 17, offset: 4658},
										expr: &ruleRefExpr{
											pos:  position{line: 167, col: 17, offset: 4658},
											name: "JsonPointerSegment",
										},
									},
								},
								&litMatcher{
									pos:        position{line: 167, col: 37, offset: 4678},
									val:        "\"",
									ignoreCase: false,
									want:       "\"\\\"\"",
								},
							},
						},
					},
				},
			},
		},
		{
			name: "JsonPointerSegment",
			pos:  position{line: 188, col: 1, offset: 5156},
			expr: &actionExpr{
				pos: position{line: 188, col: 23, offset: 5178},
				run: (*parser).callonJsonPointerSegment1,
				expr: &seqExpr{
					pos: position{line: 188, col: 23, offset: 5178},
					exprs: []any{
						&litMatcher{
							pos:        position{line: 188, col: 23, offset: 5178},
							val:        "/",
							ignoreCase: false,
							want:       "\"/\"",
						},
						&labeledExpr{
							pos:   position{line: 188, col: 27, offset: 5182},
							label: "ident",
							expr: &oneOrMoreExpr{
								pos: position{line: 188, col: 33, offset: 5188},
								expr: &charClassMatcher{
									pos:        position{line: 188, col: 33, offset: 5188},
									val:        "[\\pL\\pN-_.~:|]",
									chars:      []rune{'-', '_', '.', '~', ':', '|'},
									classes:    []*unicode.RangeTable{rangeTable("L"), rangeTable("N")},
									ignoreCase: false,
									inverted:   false,
								},
							},
						},
					},
				},
			},
		},
		{
			name: "Identifier",
			pos:  position{line: 192, col: 1, offset: 5243},
			expr: &actionExpr{
				pos: position{line: 192, col: 15, offset: 5257},
				run: (*parser).callonIdentifier1,
				expr: &seqExpr{
					pos: position{line: 192, col: 15, offset: 5257},
					exprs: []any{
						&charClassMatcher{
							pos:        position{line: 192, col: 15, offset: 5257},
							val:        "[a-zA-Z]",
							ranges:     []rune{'a', 'z', 'A', 'Z'},
							ignoreCase: false,
							inverted:   false,
						},
						&zeroOrMoreExpr{
							pos: position{line: 192, col: 24, offset: 5266},
							expr: &charClassMatcher{
								pos:        position{line: 192, col: 24, offset: 5266},
								val:        "[a-zA-Z0-9_/]",
								chars:      []rune{'_', '/'},
								ranges:     []rune{'a', 'z', 'A', 'Z', '0', '9'},
								ignoreCase: false,
								inverted:   false,
							},
						},
					},
				},
			},
		},
		{
			name: "SelectorOrIndex",
			pos:  position{line: 196, col: 1, offset: 5316},
			expr: &choiceExpr{
				pos: position{line: 196, col: 20, offset: 5335},
				alternatives: []any{
					&actionExpr{
						pos: position{line: 196, col: 20, offset: 5335},
						run: (*parser).callonSelectorOrIndex2,
						expr: &seqExpr{
							pos: position{line: 196, col: 20, offset: 5335},
							exprs: []any{
								&litMatcher{
									pos:        position{line: 196, col: 20, offset: 5335},
									val:        ".",
									ignoreCase: false,
									want:       "\".\"",
								},
								&labeledExpr{
									pos:   position{line: 196, col: 24, offset: 5339},
									label: "ident",
									expr: &ruleRefExpr{
										pos:  position{line: 196, col: 30, offset: 5345},
										name: "Identifier",
									},
								},
							},
						},
					},
					&actionExpr{
						pos: position{line: 198, col: 5, offset: 5383},
						run: (*parser).callonSelectorOrIndex7,
						expr: &labeledExpr{
							pos:   position{line: 198, col: 5, offset: 5383},
							label: "expr",
							expr: &ruleRefExpr{
								pos:  position{line: 198, col: 10, offset: 5388},
								name: "IndexExpression",
							},
						},
					},
					&actionExpr{
						pos: position{line: 200, col: 5, offset: 5430},
						run: (*parser).callonSelectorOrIndex10,
						expr: &seqExpr{
							pos: position{line: 200, col: 5, offset: 5430},
							exprs: []any{
								&litMatcher{
									pos:        position{line: 200, col: 5, offset: 5430},
									val:        ".",
									ignoreCase: false,
									want:       "\".\"",
								},
								&labeledExpr{
									pos:   position{line: 200, col: 9, offset: 5434},
									label: "idx",
									expr: &oneOrMoreExpr{
										pos: position{line: 200, col: 13, offset: 5438},
										expr: &charClassMatcher{
											pos:        position{line: 200, col: 13, offset: 5438},
											val:        "[0-9]",
											ranges:     []rune{'0', '9'},
											ignoreCase: false,
											inverted:   false,
										},
									},
								},
							},
						},
					},
				},
			},
		},
		{
			name:        "IndexExpression",
			displayName: "\"index\"",
			pos:         position{line: 204, col: 1, offset: 5484},
			expr: &choiceExpr{
				pos: position{line: 204, col: 28, offset: 5511},
				alternatives: []any{
					&actionExpr{
						pos: position{line: 204, col: 28, offset: 5511},
						run: (*parser).callonIndexExpression2,
						expr: &seqExpr{
							pos: position{line: 204, col: 28, offset: 5511},
							exprs: []any{
								&litMatcher{
									pos:        position{line: 204, col: 28, offset: 5511},
									val:        "[",
									ignoreCase: false,
									want:       "\"[\"",
								},
								&zeroOrOneExpr{
									pos: position{line: 204, col: 32, offset: 5515},
									expr: &ruleRefExpr{
										pos:  position{line: 204, col: 32, offset: 5515},
										name: "_",
									},
								},
								&labeledExpr{
									pos:   position{line: 204, col: 35, offset: 5518},
									label: "lit",
									expr: &ruleRefExpr{
										pos:  position{line: 204, col: 39, offset: 5522},
										name: "StringLiteral",
									},
								},
								&zeroOrOneExpr{
									pos: position{line: 204, col: 53, offset: 5536},
									expr: &ruleRefExpr{
										pos:  position{line: 204, col: 53, offset: 5536},
										name: "_",
									},
								},
								&litMatcher{
									pos:        position{line: 204, col: 56, offset: 5539},
									val:        "]",
									ignoreCase: false,
									want:       "\"]\"",
								},
							},
						},
					},
					&seqExpr{
						pos: position{line: 206, col: 5, offset: 5568},
						exprs: []any{
							&litMatcher{
								pos:        position{line: 206, col: 5, offset: 5568},
								val:        "[",
								ignoreCase: false,
								want:       "\"[\"",
							},
							&zeroOrOneExpr{
								pos: position{line: 206, col: 9, offset: 5572},
								expr: &ruleRefExpr{
									pos:  position{line: 206, col: 9, offset: 5572},
									name: "_",
								},
							},
							&notExpr{
								pos: position{line: 206, col: 12, offset: 5575},
								expr: &ruleRefExpr{
									pos:  position{line: 206, col: 13, offset: 5576},
									name: "StringLiteral",
								},
							},
							&andCodeExpr{
								pos: position{line: 206, col: 27, offset: 5590},
								run: (*parser).callonIndexExpression18,
							},
						},
					},
					&seqExpr{
						pos: position{line: 208, col: 5, offset: 5642},
						exprs: []any{
							&litMatcher{
								pos:        position{line: 208, col: 5, offset: 5642},
								val:        "[",
								ignoreCase: false,
								want:       "\"[\"",
							},
							&zeroOrOneExpr{
								pos: position{line: 208, col: 9, offset: 5646},
								expr: &ruleRefExpr{
									pos:  position{line: 208, col: 9, offset: 5646},
									name: "_",
								},
							},
							&ruleRefExpr{
								pos:  position{line: 208, col: 12, offset: 5649},
								name: "StringLiteral",
							},
							&zeroOrOneExpr{
								pos: position{line: 208, col: 26, offset: 5663},
								expr: &ruleRefExpr{
									pos:  position{line: 208, col: 26, offset: 5663},
									name: "_",
								},
							},
							&notExpr{
								pos: position{line: 208, col: 29, offset: 5666},
								expr: &litMatcher{
									pos:        position{line: 208, col: 30, offset: 5667},
									val:        "]",
									ignoreCase: false,
									want:       "\"]\"",
								},
							},
							&andCodeExpr{
								pos: position{line: 208, col: 34, offset: 5671},
								run: (*parser).callonIndexExpression28,
							},
						},
					},
				},
			},
		},
		{
			name:        "Value",
			displayName: "\"value\"",
			pos:         position{line: 212, col: 1, offset: 5734},
			expr: &choiceExpr{
				pos: position{line: 212, col: 18, offset: 5751},
				alternatives: []any{
					&actionExpr{
						pos: position{line: 212, col: 18, offset: 5751},
						run: (*parser).callonValue2,
						expr: &labeledExpr{
							pos:   position{line: 212, col: 18, offset: 5751},
							label: "selector",
							expr: &ruleRefExpr{
								pos:  position{line: 212, col: 27, offset: 5760},
								name: "Selector",
							},
						},
					},
					&actionExpr{
						pos: position{line: 214, col: 5, offset: 5836},
						run: (*parser).callonValue5,
						expr: &labeledExpr{
							pos:   position{line: 214, col: 5, offset: 5836},
							label: "n",
							expr: &ruleRefExpr{
								pos:  position{line: 214, col: 7, offset: 5838},
								name: "NumberLiteral",
							},
						},
					},
					&actionExpr{
						pos: position{line: 216, col: 5, offset: 5902},
						run: (*parser).callonValue8,
						expr: &labeledExpr{
							pos:   position{line: 216, col: 5, offset: 5902},
							label: "s",
							expr: &ruleRefExpr{
								pos:  position{line: 216, col: 7, offset: 5904},
								name: "StringLiteral",
							},
						},
					},
				},
			},
		},
		{
			name:        "NumberLiteral",
			displayName: "\"number\"",
			pos:         position{line: 220, col: 1, offset: 5967},
			expr: &choiceExpr{
				pos: position{line: 220, col: 27, offset: 5993},
				alternatives: []any{
					&actionExpr{
						pos: position{line: 220, col: 27, offset: 5993},
						run: (*parser).callonNumberLiteral2,
						expr: &seqExpr{
							pos: position{line: 220, col: 27, offset: 5993},
							exprs: []any{
								&zeroOrOneExpr{
									pos: position{line: 220, col: 27, offset: 5993},
									expr: &litMatcher{
										pos:        position{line: 220, col: 27, offset: 5993},
										val:        "-",
										ignoreCase: false,
										want:       "\"-\"",
									},
								},
								&ruleRefExpr{
									pos:  position{line: 220, col: 32, offset: 5998},
									name: "IntegerOrFloat",
								},
								&andExpr{
									pos: position{line: 220, col: 47, offset: 6013},
									expr: &ruleRefExpr{
										pos:  position{line: 220, col: 48, offset: 6014},
										name: "AfterNumbers",
									},
								},
							},
						},
					},
					&seqExpr{
						pos: position{line: 222, col: 5, offset: 6063},
						exprs: []any{
							&zeroOrOneExpr{
								pos: position{line: 222, col: 5, offset: 6063},
								expr: &litMatcher{
									pos:        position{line: 222, col: 5, offset: 6063},
									val:        "-",
									ignoreCase: false,
									want:       "\"-\"",
								},
							},
							&ruleRefExpr{
								pos:  position{line: 222, col: 10, offset: 6068},
								name: "IntegerOrFloat",
							},
							&notExpr{
								pos: position{line: 222, col: 25, offset: 6083},
								expr: &ruleRefExpr{
									pos:  position{line: 222, col: 26, offset: 6084},
									name: "AfterNumbers",
								},
							},
							&andCodeExpr{
								pos: position{line: 222, col: 39, offset: 6097},
								run: (*parser).callonNumberLiteral15,
							},
						},
					},
				},
			},
		},
		{
			name: "AfterNumbers",
			pos:  position{line: 226, col: 1, offset: 6157},
			expr: &andExpr{
				pos: position{line: 226, col: 17, offset: 6173},
				expr: &choiceExpr{
					pos: position{line: 226, col: 19, offset: 6175},
					alternatives: []any{
						&ruleRefExpr{
							pos:  position{line: 226, col: 19, offset: 6175},
							name: "_",
						},
						&ruleRefExpr{
							pos:  position{line: 226, col: 23, offset: 6179},
							name: "EOF",
						},
						&litMatcher{
							pos:        position{line: 226, col: 29, offset: 6185},
							val:        ")",
							ignoreCase: false,
							want:       "\")\"",
						},
					},
				},
			},
		},
		{
			name: "IntegerOrFloat",
			pos:  position{line: 228, col: 1, offset: 6191},
			expr: &seqExpr{
				pos: position{line: 228, col: 19, offset: 6209},
				exprs: []any{
					&choiceExpr{
						pos: position{line: 228, col: 20, offset: 6210},
						alternatives: []any{
							&litMatcher{
								pos:        position{line: 228, col: 20, offset: 6210},
								val:        "0",
								ignoreCase: false,
								want:       "\"0\"",
							},
							&seqExpr{
								pos: position{line: 228, col: 26, offset: 6216},
								exprs: []any{
									&charClassMatcher{
										pos:        position{line: 228, col: 26, offset: 6216},
										val:        "[1-9]",
										ranges:     []rune{'1', '9'},
										ignoreCase: false,
										inverted:   false,
									},
									&zeroOrMoreExpr{
										pos: position{line: 228, col: 31, offset: 6221},
										expr: &charClassMatcher{
											pos:        position{line: 228, col: 31, offset: 6221},
											val:        "[0-9]",
											ranges:     []rune{'0', '9'},
											ignoreCase: false,
											inverted:   false,
										},
									},
								},
							},
						},
					},
					&zeroOrOneExpr{
						pos: position{line: 228, col: 39, offset: 6229},
						expr: &seqExpr{
							pos: position{line: 228, col: 40, offset: 6230},
							exprs: []any{
								&litMatcher{
									pos:        position{line: 228, col: 40, offset: 6230},
									val:        ".",
									ignoreCase: false,
									want:       "\".\"",
								},
								&oneOrMoreExpr{
									pos: position{line: 228, col: 44, offset: 6234},
									expr: &charClassMatcher{
										pos:        position{line: 228, col: 44, offset: 6234},
										val:        "[0-9]",
										ranges:     []rune{'0', '9'},
										ignoreCase: false,
										inverted:   false,
									},
								},
							},
						},
					},
				},
			},
		},
		{
			name:        "StringLiteral",
			displayName: "\"string\"",
			pos:         position{line: 230, col: 1, offset: 6244},
			expr: &choiceExpr{
				pos: position{line: 230, col: 27, offset: 6270},
				alternatives: []any{
					&actionExpr{
						pos: position{line: 230, col: 27, offset: 6270},
						run: (*parser).callonStringLiteral2,
						expr: &choiceExpr{
							pos: position{line: 230, col: 28, offset: 6271},
							alternatives: []any{
								&seqExpr{
									pos: position{line: 230, col: 28, offset: 6271},
									exprs: []any{
										&litMatcher{
											pos:        position{line: 230, col: 28, offset: 6271},
											val:        "`",
											ignoreCase: false,
											want:       "\"`\"",
										},
										&zeroOrMoreExpr{
											pos: position{line: 230, col: 32, offset: 6275},
											expr: &ruleRefExpr{
												pos:  position{line: 230, col: 32, offset: 6275},
												name: "RawStringChar",
											},
										},
										&litMatcher{
											pos:        position{line: 230, col: 47, offset: 6290},
											val:        "`",
											ignoreCase: false,
											want:       "\"`\"",
										},
									},
								},
								&seqExpr{
									pos: position{line: 230, col: 53, offset: 6296},
									exprs: []any{
										&litMatcher{
											pos:        position{line: 230, col: 53, offset: 6296},
											val:        "\"",
											ignoreCase: false,
											want:       "\"\\\"\"",
										},
										&zeroOrMoreExpr{
											pos: position{line: 230, col: 57, offset: 6300},
											expr: &ruleRefExpr{
												pos:  position{line: 230, col: 57, offset: 6300},
												name: "DoubleStringChar",
											},
										},
										&litMatcher{
											pos:        position{line: 230, col: 75, offset: 6318},
											val:        "\"",
											ignoreCase: false,
											want:       "\"\\\"\"",
										},
									},
								},
							},
						},
					},
					&seqExpr{
						pos: position{line: 232, col: 5, offset: 6370},
						exprs: []any{
							&choiceExpr{
								pos: position{line: 232, col: 6, offset: 6371},
								alternatives: []any{
									&seqExpr{
										pos: position{line: 232, col: 6, offset: 6371},
										exprs: []any{
											&litMatcher{
												pos:        position{line: 232, col: 6, offset: 6371},
												val:        "`",
												ignoreCase: false,
												want:       "\"`\"",
											},
											&zeroOrMoreExpr{
												pos: position{line: 232, col: 10, offset: 6375},
												expr: &ruleRefExpr{
													pos:  position{line: 232, col: 10, offset: 6375},
													name: "RawStringChar",
												},
											},
										},
									},
									&seqExpr{
										pos: position{line: 232, col: 27, offset: 6392},
										exprs: []any{
											&litMatcher{
												pos:        position{line: 232, col: 27, offset: 6392},
												val:        "\"",
												ignoreCase: false,
												want:       "\"\\\"\"",
											},
											&zeroOrMoreExpr{
												pos: position{line: 232, col: 31, offset: 6396},
												expr: &ruleRefExpr{
													pos:  position{line: 232, col: 31, offset: 6396},
													name: "DoubleStringChar",
												},
											},
										},
									},
								},
							},
							&ruleRefExpr{
								pos:  position{line: 232, col: 50, offset: 6415},
								name: "EOF",
							},
							&andCodeExpr{
								pos: position{line: 232, col: 54, offset: 6419},
								run: (*parser).callonStringLiteral25,
							},
						},
					},
				},
			},
		},
		{
			name: "RawStringChar",
			pos:  position{line: 236, col: 1, offset: 6483},
			expr: &seqExpr{
				pos: position{line: 236, col: 18, offset: 6500},
				exprs: []any{
					&notExpr{
						pos: position{line: 236, col: 18, offset: 6500},
						expr: &litMatcher{
							pos:        position{line: 236, col: 19, offset: 6501},
							val:        "`",
							ignoreCase: false,
							want:       "\"`\"",
						},
					},
					&anyMatcher{
						line: 236, col: 23, offset: 6505,
					},
				},
			},
		},
		{
			name: "DoubleStringChar",
			pos:  position{line: 237, col: 1, offset: 6507},
			expr: &seqExpr{
				pos: position{line: 237, col: 21, offset: 6527},
				exprs: []any{
					&notExpr{
						pos: position{line: 237, col: 21, offset: 6527},
						expr: &litMatcher{
							pos:        position{line: 237, col: 22, offset: 6528},
							val:        "\"",
							ignoreCase: false,
							want:       "\"\\\"\"",
						},
					},
					&anyMatcher{
						line: 237, col: 26, offset: 6532,
					},
				},
			},
		},
		{
			name:        "_",
			displayName: "\"whitespace\"",
			pos:         position{line: 239, col: 1, offset: 6535},
			expr: &oneOrMoreExpr{
				pos: position{line: 239, col: 19, offset: 6553},
				expr: &charClassMatcher{
					pos:        position{line: 239, col: 19, offset: 6553},
					val:        "[ \\t\\r\\n]",
					chars:      []rune{' ', '\t', '\r', '\n'},
					ignoreCase: false,
					inverted:   false,
				},
			},
		},
		{
			name: "EOF",
			pos:  position{line: 241, col: 1, offset: 6565},
			expr: &notExpr{
				pos: position{line: 241, col: 8, offset: 6572},
				expr: &anyMatcher{
					line: 241, col: 9, offset: 6573,
				},
			},
		},
	},
}

func (c *current) onInput2(expr any) (any, error) {
	return expr, nil
}

func (p *parser) callonInput2() (any, error) {
	stack := p.vstack[len(p.vstack)-1]
	_ = stack
	return p.cur.onInput2(stack["expr"])
}

func (c *current) onInput17(expr any) (any, error) {
	return expr, nil
}

func (p *parser) callonInput17() (any, error) {
	stack := p.vstack[len(p.vstack)-1]
	_ = stack
	return p.cur.onInput17(stack["expr"])
}

func (c *current) onOrExpression2(left, right any) (any, error) {
	return &BinaryExpression{
		Operator: BinaryOpOr,
		Left:     left.(Expression),
		Right:    right.(Expression),
	}, nil
}

func (p *parser) callonOrExpression2() (any, error) {
	stack := p.vstack[len(p.vstack)-1]
	_ = stack
	return p.cur.onOrExpression2(stack["left"], stack["right"])
}

func (c *current) onOrExpression11(expr any) (any, error) {
	return expr, nil
}

func (p *parser) callonOrExpression11() (any, error) {
	stack := p.vstack[len(p.vstack)-1]
	_ = stack
	return p.cur.onOrExpression11(stack["expr"])
}

func (c *current) onOrExpression14(expr any) (any, error) {
	return expr, nil
}

func (p *parser) callonOrExpression14() (any, error) {
	stack := p.vstack[len(p.vstack)-1]
	_ = stack
	return p.cur.onOrExpression14(stack["expr"])
}

func (c *current) onAndExpression2(left, right any) (any, error) {
	return &BinaryExpression{
		Operator: BinaryOpAnd,
		Left:     left.(Expression),
		Right:    right.(Expression),
	}, nil
}

func (p *parser) callonAndExpression2() (any, error) {
	stack := p.vstack[len(p.vstack)-1]
	_ = stack
	return p.cur.onAndExpression2(stack["left"], stack["right"])
}

func (c *current) onAndExpression11(expr any) (any, error) {
	return expr, nil
}

func (p *parser) callonAndExpression11() (any, error) {
	stack := p.vstack[len(p.vstack)-1]
	_ = stack
	return p.cur.onAndExpression11(stack["expr"])
}

func (c *current) onNotExpression2(expr any) (any, error) {
	if unary, ok := expr.(*UnaryExpression); ok && unary.Operator == UnaryOpNot {
		// small optimization to get rid unnecessary levels of AST nodes
		// for things like:  not not foo == 3  which is equivalent to foo == 3
		return unary.Operand, nil
	}

	return &UnaryExpression{
		Operator: UnaryOpNot,
		Operand:  expr.(Expression),
	}, nil
}

func (p *parser) callonNotExpression2() (any, error) {
	stack := p.vstack[len(p.vstack)-1]
	_ = stack
	return p.cur.onNotExpression2(stack["expr"])
}

func (c *current) onNotExpression8(expr any) (any, error) {
	return expr, nil
}

func (p *parser) callonNotExpression8() (any, error) {
	stack := p.vstack[len(p.vstack)-1]
	_ = stack
	return p.cur.onNotExpression8(stack["expr"])
}

func (c *current) onCollectionExpression1(op, selector, binding, expr any) (any, error) {
	return &CollectionExpression{
		Op:          op.(CollectionOperator),
		Selector:    selector.(Selector),
		NameBinding: binding.(CollectionNameBinding),
		Inner:       expr.(Expression),
	}, nil
}

func (p *parser) callonCollectionExpression1() (any, error) {
	stack := p.vstack[len(p.vstack)-1]
	_ = stack
	return p.cur.onCollectionExpression1(stack["op"], stack["selector"], stack["binding"], stack["expr"])
}

func (c *current) onCollectionIdentifiers2(id1, id2 any) (any, error) {
	return CollectionNameBinding{
		Mode:  CollectionBindIndexAndValue,
		Index: id1.(string),
		Value: id2.(string),
	}, nil
}

func (p *parser) callonCollectionIdentifiers2() (any, error) {
	stack := p.vstack[len(p.vstack)-1]
	_ = stack
	return p.cur.onCollectionIdentifiers2(stack["id1"], stack["id2"])
}

func (c *current) onCollectionIdentifiers13(id1 any) (any, error) {
	return CollectionNameBinding{
		Mode:  CollectionBindIndex,
		Index: id1.(string),
	}, nil
}

func (p *parser) callonCollectionIdentifiers13() (any, error) {
	stack := p.vstack[len(p.vstack)-1]
	_ = stack
	return p.cur.onCollectionIdentifiers13(stack["id1"])
}

func (c *current) onCollectionIdentifiers23(id2 any) (any, error) {
	return CollectionNameBinding{
		Mode:  CollectionBindValue,
		Value: id2.(string),
	}, nil
}

func (p *parser) callonCollectionIdentifiers23() (any, error) {
	stack := p.vstack[len(p.vstack)-1]
	_ = stack
	return p.cur.onCollectionIdentifiers23(stack["id2"])
}

func (c *current) onCollectionIdentifiers33(id any) (any, error) {
	return CollectionNameBinding{
		Mode:    CollectionBindDefault,
		Default: id.(string),
	}, nil
}

func (p *parser) callonCollectionIdentifiers33() (any, error) {
	stack := p.vstack[len(p.vstack)-1]
	_ = stack
	return p.cur.onCollectionIdentifiers33(stack["id"])
}

func (c *current) onCollectionOpAny1() (any, error) {
	return CollectionOpAny, nil
}

func (p *parser) callonCollectionOpAny1() (any, error) {
	stack := p.vstack[len(p.vstack)-1]
	_ = stack
	return p.cur.onCollectionOpAny1()
}

func (c *current) onCollectionOpAll1() (any, error) {
	return CollectionOpAll, nil
}

func (p *parser) callonCollectionOpAll1() (any, error) {
	stack := p.vstack[len(p.vstack)-1]
	_ = stack
	return p.cur.onCollectionOpAll1()
}

func (c *current) onParenthesizedExpression2(expr any) (any, error) {
	return expr, nil
}

func (p *parser) callonParenthesizedExpression2() (any, error) {
	stack := p.vstack[len(p.vstack)-1]
	_ = stack
	return p.cur.onParenthesizedExpression2(stack["expr"])
}

func (c *current) onParenthesizedExpression12(expr any) (any, error) {
	return expr, nil
}

func (p *parser) callonParenthesizedExpression12() (any, error) {
	stack := p.vstack[len(p.vstack)-1]
	_ = stack
	return p.cur.onParenthesizedExpression12(stack["expr"])
}

func (c *current) onParenthesizedExpression24() (bool, error) {
	return false, errors.New("Unmatched parentheses")
}

func (p *parser) callonParenthesizedExpression24() (bool, error) {
	stack := p.vstack[len(p.vstack)-1]
	_ = stack
	return p.cur.onParenthesizedExpression24()
}

func (c *current) onMatchSelectorOpValue1(selector, operator, value any) (any, error) {
	return &MatchExpression{Selector: selector.(Selector), Operator: operator.(MatchOperator), Value: value.(*MatchValue)}, nil
}

func (p *parser) callonMatchSelectorOpValue1() (any, error) {
	stack := p.vstack[len(p.vstack)-1]
	_ = stack
	return p.cur.onMatchSelectorOpValue1(stack["selector"], stack["operator"], stack["value"])
}

func (c *current) onMatchSelectorOp1(selector, operator any) (any, error) {
	return &MatchExpression{Selector: selector.(Selector), Operator: operator.(MatchOperator), Value: nil}, nil
}

func (p *parser) callonMatchSelectorOp1() (any, error) {
	stack := p.vstack[len(p.vstack)-1]
	_ = stack
	return p.cur.onMatchSelectorOp1(stack["selector"], stack["operator"])
}

func (c *current) onMatchValueOpSelector2(value, operator, selector any) (any, error) {
	return &MatchExpression{Selector: selector.(Selector), Operator: operator.(MatchOperator), Value: value.(*MatchValue)}, nil
}

func (p *parser) callonMatchValueOpSelector2() (any, error) {
	stack := p.vstack[len(p.vstack)-1]
	_ = stack
	return p.cur.onMatchValueOpSelector2(stack["value"], stack["operator"], stack["selector"])
}

func (c *current) onMatchValueOpSelector20(operator any) (bool, error) {
	return false, errors.New("Invalid selector")
}

func (p *parser) callonMatchValueOpSelector20() (bool, error) {
	stack := p.vstack[len(p.vstack)-1]
	_ = stack
	return p.cur.onMatchValueOpSelector20(stack["operator"])
}

func (c *current) onMatchEqual1() (any, error) {
	return MatchEqual, nil
}

func (p *parser) callonMatchEqual1() (any, error) {
	stack := p.vstack[len(p.vstack)-1]
	_ = stack
	return p.cur.onMatchEqual1()
}

func (c *current) onMatchNotEqual1() (any, error) {
	return MatchNotEqual, nil
}

func (p *parser) callonMatchNotEqual1() (any, error) {
	stack := p.vstack[len(p.vstack)-1]
	_ = stack
	return p.cur.onMatchNotEqual1()
}

func (c *current) onMatchIsEmpty1() (any, error) {
	return MatchIsEmpty, nil
}

func (p *parser) callonMatchIsEmpty1() (any, error) {
	stack := p.vstack[len(p.vstack)-1]
	_ = stack
	return p.cur.onMatchIsEmpty1()
}

func (c *current) onMatchIsNotEmpty1() (any, error) {
	return MatchIsNotEmpty, nil
}

func (p *parser) callonMatchIsNotEmpty1() (any, error) {
	stack := p.vstack[len(p.vstack)-1]
	_ = stack
	return p.cur.onMatchIsNotEmpty1()
}

func (c *current) onMatchIn1() (any, error) {
	return MatchIn, nil
}

func (p *parser) callonMatchIn1() (any, error) {
	stack := p.vstack[len(p.vstack)-1]
	_ = stack
	return p.cur.onMatchIn1()
}

func (c *current) onMatchNotIn1() (any, error) {
	return MatchNotIn, nil
}

func (p *parser) callonMatchNotIn1() (any, error) {
	stack := p.vstack[len(p.vstack)-1]
	_ = stack
	return p.cur.onMatchNotIn1()
}

func (c *current) onMatchContains1() (any, error) {
	return MatchIn, nil
}

func (p *parser) callonMatchContains1() (any, error) {
	stack := p.vstack[len(p.vstack)-1]
	_ = stack
	return p.cur.onMatchContains1()
}

func (c *current) onMatchNotContains1() (any, error) {
	return MatchNotIn, nil
}

func (p *parser) callonMatchNotContains1() (any, error) {
	stack := p.vstack[len(p.vstack)-1]
	_ = stack
	return p.cur.onMatchNotContains1()
}

func (c *current) onMatchMatches1() (any, error) {
	return MatchMatches, nil
}

func (p *parser) callonMatchMatches1() (any, error) {
	stack := p.vstack[len(p.vstack)-1]
	_ = stack
	return p.cur.onMatchMatches1()
}

func (c *current) onMatchNotMatches1() (any, error) {
	return MatchNotMatches, nil
}

func (p *parser) callonMatchNotMatches1() (any, error) {
	stack := p.vstack[len(p.vstack)-1]
	_ = stack
	return p.cur.onMatchNotMatches1()
}

func (c *current) onMatchIsNil1() (any, error) {
	return MatchIsNil, nil
}

func (p *parser) callonMatchIsNil1() (any, error) {
	stack := p.vstack[len(p.vstack)-1]
	_ = stack
	return p.cur.onMatchIsNil1()
}

func (c *current) onMatchIsNotNil1() (any, error) {
	return MatchIsNotNil, nil
}

func (p *parser) callonMatchIsNotNil1() (any, error) {
	stack := p.vstack[len(p.vstack)-1]
	_ = stack
	return p.cur.onMatchIsNotNil1()
}

func (c *current) onSelector2(first, rest any) (any, error) {
	sel := Selector{
		Type: SelectorTypeBexpr,
		Path: []string{first.(string)},
	}
	if rest != nil {
		for _, v := range rest.([]interface{}) {
			sel.Path = append(sel.Path, v.(string))
		}
	}
	return sel, nil
}

func (p *parser) callonSelector2() (any, error) {
	stack := p.vstack[len(p.vstack)-1]
	_ = stack
	return p.cur.onSelector2(stack["first"], stack["rest"])
}

func (c *current) onSelector9(ptrsegs any) (any, error) {
	sel := Selector{
		Type: SelectorTypeJsonPointer,
	}
	if ptrsegs != nil {
		for _, v := range ptrsegs.([]interface{}) {
			sel.Path = append(sel.Path, v.(string))
		}
	}

	// Validate and cache
	ptrStr := fmt.Sprintf("/%s", strings.Join(sel.Path, "/"))
	ptr, err := pointerstructure.Parse(ptrStr)
	if err != nil {
		return nil, fmt.Errorf("error validating json pointer: %w", err)
	}
	sel.Path = ptr.Parts

	return sel, nil
}

func (p *parser) callonSelector9() (any, error) {
	stack := p.vstack[len(p.vstack)-1]
	_ = stack
	return p.cur.onSelector9(stack["ptrsegs"])
}

func (c *current) onJsonPointerSegment1(ident any) (any, error) {
	return string(c.text)[1:], nil
}

func (p *parser) callonJsonPointerSegment1() (any, error) {
	stack := p.vstack[len(p.vstack)-1]
	_ = stack
	return p.cur.onJsonPointerSegment1(stack["ident"])
}

func (c *current) onIdentifier1() (any, error) {
	return string(c.text), nil
}

func (p *parser) callonIdentifier1() (any, error) {
	stack := p.vstack[len(p.vstack)-1]
	_ = stack
	return p.cur.onIdentifier1()
}

func (c *current) onSelectorOrIndex2(ident any) (any, error) {
	return ident, nil
}

func (p *parser) callonSelectorOrIndex2() (any, error) {
	stack := p.vstack[len(p.vstack)-1]
	_ = stack
	return p.cur.onSelectorOrIndex2(stack["ident"])
}

func (c *current) onSelectorOrIndex7(expr any) (any, error) {
	return expr, nil
}

func (p *parser) callonSelectorOrIndex7() (any, error) {
	stack := p.vstack[len(p.vstack)-1]
	_ = stack
	return p.cur.onSelectorOrIndex7(stack["expr"])
}

func (c *current) onSelectorOrIndex10(idx any) (any, error) {
	return string(c.text)[1:], nil
}

func (p *parser) callonSelectorOrIndex10() (any, error) {
	stack := p.vstack[len(p.vstack)-1]
	_ = stack
	return p.cur.onSelectorOrIndex10(stack["idx"])
}

func (c *current) onIndexExpression2(lit any) (any, error) {
	return lit, nil
}

func (p *parser) callonIndexExpression2() (any, error) {
	stack := p.vstack[len(p.vstack)-1]
	_ = stack
	return p.cur.onIndexExpression2(stack["lit"])
}

func (c *current) onIndexExpression18() (bool, error) {
	return false, errors.New("Invalid index")
}

func (p *parser) callonIndexExpression18() (bool, error) {
	stack := p.vstack[len(p.vstack)-1]
	_ = stack
	return p.cur.onIndexExpression18()
}

func (c *current) onIndexExpression28() (bool, error) {
	return false, errors.New("Unclosed index expression")
}

func (p *parser) callonIndexExpression28() (bool, error) {
	stack := p.vstack[len(p.vstack)-1]
	_ = stack
	return p.cur.onIndexExpression28()
}

func (c *current) onValue2(selector any) (any, error) {
	return &MatchValue{Raw: selector.(Selector).String()}, nil
}

func (p *parser) callonValue2() (any, error) {
	stack := p.vstack[len(p.vstack)-1]
	_ = stack
	return p.cur.onValue2(stack["selector"])
}

func (c *current) onValue5(n any) (any, error) {
	return &MatchValue{Raw: n.(string)}, nil
}

func (p *parser) callonValue5() (any, error) {
	stack := p.vstack[len(p.vstack)-1]
	_ = stack
	return p.cur.onValue5(stack["n"])
}

func (c *current) onValue8(s any) (any, error) {
	return &MatchValue{Raw: s.(string)}, nil
}

func (p *parser) callonValue8() (any, error) {
	stack := p.vstack[len(p.vstack)-1]
	_ = stack
	return p.cur.onValue8(stack["s"])
}

func (c *current) onNumberLiteral2() (any, error) {
	return string(c.text), nil
}

func (p *parser) callonNumberLiteral2() (any, error) {
	stack := p.vstack[len(p.vstack)-1]
	_ = stack
	return p.cur.onNumberLiteral2()
}

func (c *current) onNumberLiteral15() (bool, error) {
	return false, errors.New("Invalid number literal")
}

func (p *parser) callonNumberLiteral15() (bool, error) {
	stack := p.vstack[len(p.vstack)-1]
	_ = stack
	return p.cur.onNumberLiteral15()
}

func (c *current) onStringLiteral2() (any, error) {
	return strconv.Unquote(string(c.text))
}

func (p *parser) callonStringLiteral2() (any, error) {
	stack := p.vstack[len(p.vstack)-1]
	_ = stack
	return p.cur.onStringLiteral2()
}

func (c *current) onStringLiteral25() (bool, error) {
	return false, errors.New("Unterminated string literal")
}

func (p *parser) callonStringLiteral25() (bool, error) {
	stack := p.vstack[len(p.vstack)-1]
	_ = stack
	return p.cur.onStringLiteral25()
}

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 expressions 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)
	}
}

// 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 any) Option {
	return func(p *parser) Option {
		old := p.cur.globalStore[key]
		p.cur.globalStore[key] = value
		return GlobalStore(key, old)
	}
}

// ParseFile parses the file identified by filename.
func ParseFile(filename string, opts ...Option) (i any, 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) (any, error) {
	b, err := io.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) (any, 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 strconv.Itoa(p.line) + ":" + strconv.Itoa(p.col) + " [" + strconv.Itoa(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

	// 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]any

// the AST types...

type grammar struct {
	pos   position
	rules []*rule
}

type rule struct {
	pos         position
	name        string
	displayName string
	expr        any
}

type choiceExpr struct {
	pos          position
	alternatives []any
}

type actionExpr struct {
	pos  position
	expr any
	run  func(*parser) (any, error)
}

type recoveryExpr struct {
	pos          position
	expr         any
	recoverExpr  any
	failureLabel []string
}

type seqExpr struct {
	pos   position
	exprs []any
}

type throwExpr struct {
	pos   position
	label string
}

type labeledExpr struct {
	pos   position
	label string
	expr  any
}

type expr struct {
	pos  position
	expr any
}

type (
	andExpr        expr
	notExpr        expr
	zeroOrOneExpr  expr
	zeroOrMoreExpr expr
	oneOrMoreExpr  expr
)

type ruleRefExpr struct {
	pos  position
	name string
}

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
	want       string
}

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{
			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   any
	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

	// rules table, maps the rule identifier to the rule node
	rules map[string]*rule
	// variables stack, map of label to value
	vstack []map[string]any
	// 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]any
}

// 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]any)
	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 any) {
	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]any, 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) 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 pt.offset == p.pt.offset {
		return
	}
	p.pt = pt
}

// 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) 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 any, 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 {
				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.parseRuleWrap(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 strings.Join(list[:len(list)-1], sep) + " " + lastSep + " " + list[len(list)-1]
	}
}

func (p *parser) parseRuleWrap(rule *rule) (any, bool) {
	var (
		val any
		ok  bool
	)

	val, ok = p.parseRule(rule)

	return val, ok
}

func (p *parser) parseRule(rule *rule) (any, bool) {
	p.rstack = append(p.rstack, rule)
	p.pushV()
	val, ok := p.parseExprWrap(rule.expr)
	p.popV()
	p.rstack = p.rstack[:len(p.rstack)-1]
	return val, ok
}

func (p *parser) parseExprWrap(expr any) (any, bool) {
	val, ok := p.parseExpr(expr)

	return val, ok
}

func (p *parser) parseExpr(expr any) (any, bool) {
	p.ExprCnt++
	if p.ExprCnt > p.maxExprCnt {
		panic(errMaxExprCnt)
	}

	var val any
	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 *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))
	}
	return val, ok
}

func (p *parser) parseActionExpr(act *actionExpr) (any, bool) {
	start := p.pt
	val, ok := p.parseExprWrap(act.expr)
	if ok {
		p.cur.pos = start.position
		p.cur.text = p.sliceFrom(start)
		actVal, err := act.run(p)
		if err != nil {
			p.addErrAt(err, start.position, []string{})
		}

		val = actVal
	}
	return val, ok
}

func (p *parser) parseAndCodeExpr(and *andCodeExpr) (any, bool) {

	ok, err := and.run(p)
	if err != nil {
		p.addErr(err)
	}

	return nil, ok
}

func (p *parser) parseAndExpr(and *andExpr) (any, bool) {
	pt := p.pt
	p.pushV()
	_, ok := p.parseExprWrap(and.expr)
	p.popV()
	p.restore(pt)

	return nil, ok
}

func (p *parser) parseAnyMatcher(any *anyMatcher) (any, bool) {
	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) (any, bool) {
	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) parseChoiceExpr(ch *choiceExpr) (any, bool) {

	for altI, alt := range ch.alternatives {
		// dummy assignment to prevent compile error if optimized
		_ = altI

		p.pushV()
		val, ok := p.parseExprWrap(alt)
		p.popV()
		if ok {
			return val, ok
		}
	}
	return nil, false
}

func (p *parser) parseLabeledExpr(lab *labeledExpr) (any, bool) {
	p.pushV()
	val, ok := p.parseExprWrap(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) (any, bool) {
	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, lit.want)
			p.restore(start)
			return nil, false
		}
		p.read()
	}
	p.failAt(true, start.position, lit.want)
	return p.sliceFrom(start), true
}

func (p *parser) parseNotCodeExpr(not *notCodeExpr) (any, bool) {
	ok, err := not.run(p)
	if err != nil {
		p.addErr(err)
	}

	return nil, !ok
}

func (p *parser) parseNotExpr(not *notExpr) (any, bool) {
	pt := p.pt
	p.pushV()
	p.maxFailInvertExpected = !p.maxFailInvertExpected
	_, ok := p.parseExprWrap(not.expr)
	p.maxFailInvertExpected = !p.maxFailInvertExpected
	p.popV()
	p.restore(pt)

	return nil, !ok
}

func (p *parser) parseOneOrMoreExpr(expr *oneOrMoreExpr) (any, bool) {
	var vals []any

	for {
		p.pushV()
		val, ok := p.parseExprWrap(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) (any, bool) {

	p.pushRecovery(recover.failureLabel, recover.recoverExpr)
	val, ok := p.parseExprWrap(recover.expr)
	p.popRecovery()

	return val, ok
}

func (p *parser) parseRuleRefExpr(ref *ruleRefExpr) (any, bool) {
	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.parseRuleWrap(rule)
}

func (p *parser) parseSeqExpr(seq *seqExpr) (any, bool) {
	vals := make([]any, 0, len(seq.exprs))

	pt := p.pt
	for _, expr := range seq.exprs {
		val, ok := p.parseExprWrap(expr)
		if !ok {
			p.restore(pt)
			return nil, false
		}
		vals = append(vals, val)
	}
	return vals, true
}

func (p *parser) parseThrowExpr(expr *throwExpr) (any, bool) {

	for i := len(p.recoveryStack) - 1; i >= 0; i-- {
		if recoverExpr, ok := p.recoveryStack[i][expr.label]; ok {
			if val, ok := p.parseExprWrap(recoverExpr); ok {
				return val, ok
			}
		}
	}

	return nil, false
}

func (p *parser) parseZeroOrMoreExpr(expr *zeroOrMoreExpr) (any, bool) {
	var vals []any

	for {
		p.pushV()
		val, ok := p.parseExprWrap(expr.expr)
		p.popV()
		if !ok {
			return vals, true
		}
		vals = append(vals, val)
	}
}

func (p *parser) parseZeroOrOneExpr(expr *zeroOrOneExpr) (any, bool) {
	p.pushV()
	val, _ := p.parseExprWrap(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))
}
