1package ast
2
3import (
4	"bytes"
5	"errors"
6	"fmt"
7	"io"
8	"io/ioutil"
9	"math"
10	"os"
11	"sort"
12	"strconv"
13	"strings"
14	"unicode"
15	"unicode/utf8"
16)
17
18var g = &grammar{
19	rules: []*rule{
20		{
21			name: "Program",
22			pos:  position{line: 5, col: 1, offset: 17},
23			expr: &actionExpr{
24				pos: position{line: 5, col: 12, offset: 28},
25				run: (*parser).callonProgram1,
26				expr: &seqExpr{
27					pos: position{line: 5, col: 12, offset: 28},
28					exprs: []interface{}{
29						&ruleRefExpr{
30							pos:  position{line: 5, col: 12, offset: 28},
31							name: "_",
32						},
33						&labeledExpr{
34							pos:   position{line: 5, col: 14, offset: 30},
35							label: "vals",
36							expr: &zeroOrOneExpr{
37								pos: position{line: 5, col: 19, offset: 35},
38								expr: &seqExpr{
39									pos: position{line: 5, col: 20, offset: 36},
40									exprs: []interface{}{
41										&ruleRefExpr{
42											pos:  position{line: 5, col: 20, offset: 36},
43											name: "Stmt",
44										},
45										&zeroOrMoreExpr{
46											pos: position{line: 5, col: 25, offset: 41},
47											expr: &seqExpr{
48												pos: position{line: 5, col: 26, offset: 42},
49												exprs: []interface{}{
50													&ruleRefExpr{
51														pos:  position{line: 5, col: 26, offset: 42},
52														name: "ws",
53													},
54													&ruleRefExpr{
55														pos:  position{line: 5, col: 29, offset: 45},
56														name: "Stmt",
57													},
58												},
59											},
60										},
61									},
62								},
63							},
64						},
65						&ruleRefExpr{
66							pos:  position{line: 5, col: 38, offset: 54},
67							name: "_",
68						},
69						&ruleRefExpr{
70							pos:  position{line: 5, col: 40, offset: 56},
71							name: "EOF",
72						},
73					},
74				},
75			},
76		},
77		{
78			name: "Stmt",
79			pos:  position{line: 9, col: 1, offset: 97},
80			expr: &actionExpr{
81				pos: position{line: 9, col: 9, offset: 105},
82				run: (*parser).callonStmt1,
83				expr: &labeledExpr{
84					pos:   position{line: 9, col: 9, offset: 105},
85					label: "val",
86					expr: &choiceExpr{
87						pos: position{line: 9, col: 14, offset: 110},
88						alternatives: []interface{}{
89							&ruleRefExpr{
90								pos:  position{line: 9, col: 14, offset: 110},
91								name: "Package",
92							},
93							&ruleRefExpr{
94								pos:  position{line: 9, col: 24, offset: 120},
95								name: "Import",
96							},
97							&ruleRefExpr{
98								pos:  position{line: 9, col: 33, offset: 129},
99								name: "Rules",
100							},
101							&ruleRefExpr{
102								pos:  position{line: 9, col: 41, offset: 137},
103								name: "Body",
104							},
105							&ruleRefExpr{
106								pos:  position{line: 9, col: 48, offset: 144},
107								name: "Comment",
108							},
109						},
110					},
111				},
112			},
113		},
114		{
115			name: "Package",
116			pos:  position{line: 13, col: 1, offset: 178},
117			expr: &actionExpr{
118				pos: position{line: 13, col: 12, offset: 189},
119				run: (*parser).callonPackage1,
120				expr: &seqExpr{
121					pos: position{line: 13, col: 12, offset: 189},
122					exprs: []interface{}{
123						&litMatcher{
124							pos:        position{line: 13, col: 12, offset: 189},
125							val:        "package",
126							ignoreCase: false,
127						},
128						&ruleRefExpr{
129							pos:  position{line: 13, col: 22, offset: 199},
130							name: "ws",
131						},
132						&labeledExpr{
133							pos:   position{line: 13, col: 25, offset: 202},
134							label: "val",
135							expr: &choiceExpr{
136								pos: position{line: 13, col: 30, offset: 207},
137								alternatives: []interface{}{
138									&ruleRefExpr{
139										pos:  position{line: 13, col: 30, offset: 207},
140										name: "Ref",
141									},
142									&ruleRefExpr{
143										pos:  position{line: 13, col: 36, offset: 213},
144										name: "Var",
145									},
146								},
147							},
148						},
149					},
150				},
151			},
152		},
153		{
154			name: "Import",
155			pos:  position{line: 17, col: 1, offset: 279},
156			expr: &actionExpr{
157				pos: position{line: 17, col: 11, offset: 289},
158				run: (*parser).callonImport1,
159				expr: &seqExpr{
160					pos: position{line: 17, col: 11, offset: 289},
161					exprs: []interface{}{
162						&litMatcher{
163							pos:        position{line: 17, col: 11, offset: 289},
164							val:        "import",
165							ignoreCase: false,
166						},
167						&ruleRefExpr{
168							pos:  position{line: 17, col: 20, offset: 298},
169							name: "ws",
170						},
171						&labeledExpr{
172							pos:   position{line: 17, col: 23, offset: 301},
173							label: "path",
174							expr: &choiceExpr{
175								pos: position{line: 17, col: 29, offset: 307},
176								alternatives: []interface{}{
177									&ruleRefExpr{
178										pos:  position{line: 17, col: 29, offset: 307},
179										name: "Ref",
180									},
181									&ruleRefExpr{
182										pos:  position{line: 17, col: 35, offset: 313},
183										name: "Var",
184									},
185								},
186							},
187						},
188						&labeledExpr{
189							pos:   position{line: 17, col: 40, offset: 318},
190							label: "alias",
191							expr: &zeroOrOneExpr{
192								pos: position{line: 17, col: 46, offset: 324},
193								expr: &seqExpr{
194									pos: position{line: 17, col: 47, offset: 325},
195									exprs: []interface{}{
196										&ruleRefExpr{
197											pos:  position{line: 17, col: 47, offset: 325},
198											name: "ws",
199										},
200										&litMatcher{
201											pos:        position{line: 17, col: 50, offset: 328},
202											val:        "as",
203											ignoreCase: false,
204										},
205										&ruleRefExpr{
206											pos:  position{line: 17, col: 55, offset: 333},
207											name: "ws",
208										},
209										&ruleRefExpr{
210											pos:  position{line: 17, col: 58, offset: 336},
211											name: "Var",
212										},
213									},
214								},
215							},
216						},
217					},
218				},
219			},
220		},
221		{
222			name: "Rules",
223			pos:  position{line: 21, col: 1, offset: 402},
224			expr: &choiceExpr{
225				pos: position{line: 21, col: 10, offset: 411},
226				alternatives: []interface{}{
227					&ruleRefExpr{
228						pos:  position{line: 21, col: 10, offset: 411},
229						name: "DefaultRules",
230					},
231					&ruleRefExpr{
232						pos:  position{line: 21, col: 25, offset: 426},
233						name: "NormalRules",
234					},
235				},
236			},
237		},
238		{
239			name: "DefaultRules",
240			pos:  position{line: 23, col: 1, offset: 439},
241			expr: &actionExpr{
242				pos: position{line: 23, col: 17, offset: 455},
243				run: (*parser).callonDefaultRules1,
244				expr: &seqExpr{
245					pos: position{line: 23, col: 17, offset: 455},
246					exprs: []interface{}{
247						&litMatcher{
248							pos:        position{line: 23, col: 17, offset: 455},
249							val:        "default",
250							ignoreCase: false,
251						},
252						&ruleRefExpr{
253							pos:  position{line: 23, col: 27, offset: 465},
254							name: "ws",
255						},
256						&labeledExpr{
257							pos:   position{line: 23, col: 30, offset: 468},
258							label: "name",
259							expr: &ruleRefExpr{
260								pos:  position{line: 23, col: 35, offset: 473},
261								name: "Var",
262							},
263						},
264						&ruleRefExpr{
265							pos:  position{line: 23, col: 39, offset: 477},
266							name: "_",
267						},
268						&litMatcher{
269							pos:        position{line: 23, col: 41, offset: 479},
270							val:        "=",
271							ignoreCase: false,
272						},
273						&ruleRefExpr{
274							pos:  position{line: 23, col: 45, offset: 483},
275							name: "_",
276						},
277						&labeledExpr{
278							pos:   position{line: 23, col: 47, offset: 485},
279							label: "value",
280							expr: &ruleRefExpr{
281								pos:  position{line: 23, col: 53, offset: 491},
282								name: "Term",
283							},
284						},
285					},
286				},
287			},
288		},
289		{
290			name: "NormalRules",
291			pos:  position{line: 27, col: 1, offset: 561},
292			expr: &actionExpr{
293				pos: position{line: 27, col: 16, offset: 576},
294				run: (*parser).callonNormalRules1,
295				expr: &seqExpr{
296					pos: position{line: 27, col: 16, offset: 576},
297					exprs: []interface{}{
298						&labeledExpr{
299							pos:   position{line: 27, col: 16, offset: 576},
300							label: "head",
301							expr: &ruleRefExpr{
302								pos:  position{line: 27, col: 21, offset: 581},
303								name: "RuleHead",
304							},
305						},
306						&ruleRefExpr{
307							pos:  position{line: 27, col: 30, offset: 590},
308							name: "_",
309						},
310						&labeledExpr{
311							pos:   position{line: 27, col: 32, offset: 592},
312							label: "rest",
313							expr: &seqExpr{
314								pos: position{line: 27, col: 38, offset: 598},
315								exprs: []interface{}{
316									&ruleRefExpr{
317										pos:  position{line: 27, col: 38, offset: 598},
318										name: "NonEmptyBraceEnclosedBody",
319									},
320									&zeroOrMoreExpr{
321										pos: position{line: 27, col: 64, offset: 624},
322										expr: &seqExpr{
323											pos: position{line: 27, col: 66, offset: 626},
324											exprs: []interface{}{
325												&ruleRefExpr{
326													pos:  position{line: 27, col: 66, offset: 626},
327													name: "_",
328												},
329												&ruleRefExpr{
330													pos:  position{line: 27, col: 68, offset: 628},
331													name: "RuleExt",
332												},
333											},
334										},
335									},
336								},
337							},
338						},
339					},
340				},
341			},
342		},
343		{
344			name: "RuleHead",
345			pos:  position{line: 31, col: 1, offset: 697},
346			expr: &actionExpr{
347				pos: position{line: 31, col: 13, offset: 709},
348				run: (*parser).callonRuleHead1,
349				expr: &seqExpr{
350					pos: position{line: 31, col: 13, offset: 709},
351					exprs: []interface{}{
352						&labeledExpr{
353							pos:   position{line: 31, col: 13, offset: 709},
354							label: "name",
355							expr: &ruleRefExpr{
356								pos:  position{line: 31, col: 18, offset: 714},
357								name: "Var",
358							},
359						},
360						&labeledExpr{
361							pos:   position{line: 31, col: 22, offset: 718},
362							label: "args",
363							expr: &zeroOrOneExpr{
364								pos: position{line: 31, col: 27, offset: 723},
365								expr: &seqExpr{
366									pos: position{line: 31, col: 29, offset: 725},
367									exprs: []interface{}{
368										&ruleRefExpr{
369											pos:  position{line: 31, col: 29, offset: 725},
370											name: "_",
371										},
372										&litMatcher{
373											pos:        position{line: 31, col: 31, offset: 727},
374											val:        "(",
375											ignoreCase: false,
376										},
377										&ruleRefExpr{
378											pos:  position{line: 31, col: 35, offset: 731},
379											name: "_",
380										},
381										&ruleRefExpr{
382											pos:  position{line: 31, col: 37, offset: 733},
383											name: "Args",
384										},
385										&ruleRefExpr{
386											pos:  position{line: 31, col: 42, offset: 738},
387											name: "_",
388										},
389										&litMatcher{
390											pos:        position{line: 31, col: 44, offset: 740},
391											val:        ")",
392											ignoreCase: false,
393										},
394										&ruleRefExpr{
395											pos:  position{line: 31, col: 48, offset: 744},
396											name: "_",
397										},
398									},
399								},
400							},
401						},
402						&labeledExpr{
403							pos:   position{line: 31, col: 53, offset: 749},
404							label: "key",
405							expr: &zeroOrOneExpr{
406								pos: position{line: 31, col: 57, offset: 753},
407								expr: &seqExpr{
408									pos: position{line: 31, col: 59, offset: 755},
409									exprs: []interface{}{
410										&ruleRefExpr{
411											pos:  position{line: 31, col: 59, offset: 755},
412											name: "_",
413										},
414										&litMatcher{
415											pos:        position{line: 31, col: 61, offset: 757},
416											val:        "[",
417											ignoreCase: false,
418										},
419										&ruleRefExpr{
420											pos:  position{line: 31, col: 65, offset: 761},
421											name: "_",
422										},
423										&ruleRefExpr{
424											pos:  position{line: 31, col: 67, offset: 763},
425											name: "ExprTerm",
426										},
427										&ruleRefExpr{
428											pos:  position{line: 31, col: 76, offset: 772},
429											name: "_",
430										},
431										&litMatcher{
432											pos:        position{line: 31, col: 78, offset: 774},
433											val:        "]",
434											ignoreCase: false,
435										},
436										&ruleRefExpr{
437											pos:  position{line: 31, col: 82, offset: 778},
438											name: "_",
439										},
440									},
441								},
442							},
443						},
444						&labeledExpr{
445							pos:   position{line: 31, col: 87, offset: 783},
446							label: "value",
447							expr: &zeroOrOneExpr{
448								pos: position{line: 31, col: 93, offset: 789},
449								expr: &seqExpr{
450									pos: position{line: 31, col: 95, offset: 791},
451									exprs: []interface{}{
452										&ruleRefExpr{
453											pos:  position{line: 31, col: 95, offset: 791},
454											name: "_",
455										},
456										&litMatcher{
457											pos:        position{line: 31, col: 97, offset: 793},
458											val:        "=",
459											ignoreCase: false,
460										},
461										&ruleRefExpr{
462											pos:  position{line: 31, col: 101, offset: 797},
463											name: "_",
464										},
465										&ruleRefExpr{
466											pos:  position{line: 31, col: 103, offset: 799},
467											name: "ExprTerm",
468										},
469									},
470								},
471							},
472						},
473					},
474				},
475			},
476		},
477		{
478			name: "Args",
479			pos:  position{line: 35, col: 1, offset: 884},
480			expr: &actionExpr{
481				pos: position{line: 35, col: 9, offset: 892},
482				run: (*parser).callonArgs1,
483				expr: &labeledExpr{
484					pos:   position{line: 35, col: 9, offset: 892},
485					label: "list",
486					expr: &ruleRefExpr{
487						pos:  position{line: 35, col: 14, offset: 897},
488						name: "ExprTermList",
489					},
490				},
491			},
492		},
493		{
494			name: "Else",
495			pos:  position{line: 39, col: 1, offset: 941},
496			expr: &actionExpr{
497				pos: position{line: 39, col: 9, offset: 949},
498				run: (*parser).callonElse1,
499				expr: &seqExpr{
500					pos: position{line: 39, col: 9, offset: 949},
501					exprs: []interface{}{
502						&litMatcher{
503							pos:        position{line: 39, col: 9, offset: 949},
504							val:        "else",
505							ignoreCase: false,
506						},
507						&labeledExpr{
508							pos:   position{line: 39, col: 16, offset: 956},
509							label: "value",
510							expr: &zeroOrOneExpr{
511								pos: position{line: 39, col: 22, offset: 962},
512								expr: &seqExpr{
513									pos: position{line: 39, col: 24, offset: 964},
514									exprs: []interface{}{
515										&ruleRefExpr{
516											pos:  position{line: 39, col: 24, offset: 964},
517											name: "_",
518										},
519										&litMatcher{
520											pos:        position{line: 39, col: 26, offset: 966},
521											val:        "=",
522											ignoreCase: false,
523										},
524										&ruleRefExpr{
525											pos:  position{line: 39, col: 30, offset: 970},
526											name: "_",
527										},
528										&ruleRefExpr{
529											pos:  position{line: 39, col: 32, offset: 972},
530											name: "Term",
531										},
532									},
533								},
534							},
535						},
536						&labeledExpr{
537							pos:   position{line: 39, col: 40, offset: 980},
538							label: "body",
539							expr: &seqExpr{
540								pos: position{line: 39, col: 47, offset: 987},
541								exprs: []interface{}{
542									&ruleRefExpr{
543										pos:  position{line: 39, col: 47, offset: 987},
544										name: "_",
545									},
546									&ruleRefExpr{
547										pos:  position{line: 39, col: 49, offset: 989},
548										name: "NonEmptyBraceEnclosedBody",
549									},
550								},
551							},
552						},
553					},
554				},
555			},
556		},
557		{
558			name: "RuleDup",
559			pos:  position{line: 43, col: 1, offset: 1078},
560			expr: &actionExpr{
561				pos: position{line: 43, col: 12, offset: 1089},
562				run: (*parser).callonRuleDup1,
563				expr: &labeledExpr{
564					pos:   position{line: 43, col: 12, offset: 1089},
565					label: "b",
566					expr: &ruleRefExpr{
567						pos:  position{line: 43, col: 14, offset: 1091},
568						name: "NonEmptyBraceEnclosedBody",
569					},
570				},
571			},
572		},
573		{
574			name: "RuleExt",
575			pos:  position{line: 47, col: 1, offset: 1187},
576			expr: &choiceExpr{
577				pos: position{line: 47, col: 12, offset: 1198},
578				alternatives: []interface{}{
579					&ruleRefExpr{
580						pos:  position{line: 47, col: 12, offset: 1198},
581						name: "Else",
582					},
583					&ruleRefExpr{
584						pos:  position{line: 47, col: 19, offset: 1205},
585						name: "RuleDup",
586					},
587				},
588			},
589		},
590		{
591			name: "Body",
592			pos:  position{line: 49, col: 1, offset: 1214},
593			expr: &choiceExpr{
594				pos: position{line: 49, col: 9, offset: 1222},
595				alternatives: []interface{}{
596					&ruleRefExpr{
597						pos:  position{line: 49, col: 9, offset: 1222},
598						name: "NonWhitespaceBody",
599					},
600					&ruleRefExpr{
601						pos:  position{line: 49, col: 29, offset: 1242},
602						name: "BraceEnclosedBody",
603					},
604				},
605			},
606		},
607		{
608			name: "NonEmptyBraceEnclosedBody",
609			pos:  position{line: 51, col: 1, offset: 1261},
610			expr: &actionExpr{
611				pos: position{line: 51, col: 30, offset: 1290},
612				run: (*parser).callonNonEmptyBraceEnclosedBody1,
613				expr: &seqExpr{
614					pos: position{line: 51, col: 30, offset: 1290},
615					exprs: []interface{}{
616						&litMatcher{
617							pos:        position{line: 51, col: 30, offset: 1290},
618							val:        "{",
619							ignoreCase: false,
620						},
621						&ruleRefExpr{
622							pos:  position{line: 51, col: 34, offset: 1294},
623							name: "_",
624						},
625						&labeledExpr{
626							pos:   position{line: 51, col: 36, offset: 1296},
627							label: "val",
628							expr: &zeroOrOneExpr{
629								pos: position{line: 51, col: 40, offset: 1300},
630								expr: &ruleRefExpr{
631									pos:  position{line: 51, col: 40, offset: 1300},
632									name: "WhitespaceBody",
633								},
634							},
635						},
636						&ruleRefExpr{
637							pos:  position{line: 51, col: 56, offset: 1316},
638							name: "_",
639						},
640						&litMatcher{
641							pos:        position{line: 51, col: 58, offset: 1318},
642							val:        "}",
643							ignoreCase: false,
644						},
645					},
646				},
647			},
648		},
649		{
650			name: "BraceEnclosedBody",
651			pos:  position{line: 58, col: 1, offset: 1413},
652			expr: &actionExpr{
653				pos: position{line: 58, col: 22, offset: 1434},
654				run: (*parser).callonBraceEnclosedBody1,
655				expr: &seqExpr{
656					pos: position{line: 58, col: 22, offset: 1434},
657					exprs: []interface{}{
658						&litMatcher{
659							pos:        position{line: 58, col: 22, offset: 1434},
660							val:        "{",
661							ignoreCase: false,
662						},
663						&ruleRefExpr{
664							pos:  position{line: 58, col: 26, offset: 1438},
665							name: "_",
666						},
667						&labeledExpr{
668							pos:   position{line: 58, col: 28, offset: 1440},
669							label: "val",
670							expr: &zeroOrOneExpr{
671								pos: position{line: 58, col: 32, offset: 1444},
672								expr: &ruleRefExpr{
673									pos:  position{line: 58, col: 32, offset: 1444},
674									name: "WhitespaceBody",
675								},
676							},
677						},
678						&ruleRefExpr{
679							pos:  position{line: 58, col: 48, offset: 1460},
680							name: "_",
681						},
682						&litMatcher{
683							pos:        position{line: 58, col: 50, offset: 1462},
684							val:        "}",
685							ignoreCase: false,
686						},
687					},
688				},
689			},
690		},
691		{
692			name: "WhitespaceBody",
693			pos:  position{line: 62, col: 1, offset: 1529},
694			expr: &actionExpr{
695				pos: position{line: 62, col: 19, offset: 1547},
696				run: (*parser).callonWhitespaceBody1,
697				expr: &seqExpr{
698					pos: position{line: 62, col: 19, offset: 1547},
699					exprs: []interface{}{
700						&labeledExpr{
701							pos:   position{line: 62, col: 19, offset: 1547},
702							label: "head",
703							expr: &ruleRefExpr{
704								pos:  position{line: 62, col: 24, offset: 1552},
705								name: "Literal",
706							},
707						},
708						&labeledExpr{
709							pos:   position{line: 62, col: 32, offset: 1560},
710							label: "tail",
711							expr: &zeroOrMoreExpr{
712								pos: position{line: 62, col: 37, offset: 1565},
713								expr: &seqExpr{
714									pos: position{line: 62, col: 38, offset: 1566},
715									exprs: []interface{}{
716										&ruleRefExpr{
717											pos:  position{line: 62, col: 38, offset: 1566},
718											name: "WhitespaceLiteralSeparator",
719										},
720										&ruleRefExpr{
721											pos:  position{line: 62, col: 65, offset: 1593},
722											name: "_",
723										},
724										&ruleRefExpr{
725											pos:  position{line: 62, col: 67, offset: 1595},
726											name: "Literal",
727										},
728									},
729								},
730							},
731						},
732					},
733				},
734			},
735		},
736		{
737			name: "NonWhitespaceBody",
738			pos:  position{line: 66, col: 1, offset: 1645},
739			expr: &actionExpr{
740				pos: position{line: 66, col: 22, offset: 1666},
741				run: (*parser).callonNonWhitespaceBody1,
742				expr: &seqExpr{
743					pos: position{line: 66, col: 22, offset: 1666},
744					exprs: []interface{}{
745						&labeledExpr{
746							pos:   position{line: 66, col: 22, offset: 1666},
747							label: "head",
748							expr: &ruleRefExpr{
749								pos:  position{line: 66, col: 27, offset: 1671},
750								name: "Literal",
751							},
752						},
753						&labeledExpr{
754							pos:   position{line: 66, col: 35, offset: 1679},
755							label: "tail",
756							expr: &zeroOrMoreExpr{
757								pos: position{line: 66, col: 40, offset: 1684},
758								expr: &seqExpr{
759									pos: position{line: 66, col: 42, offset: 1686},
760									exprs: []interface{}{
761										&ruleRefExpr{
762											pos:  position{line: 66, col: 42, offset: 1686},
763											name: "_",
764										},
765										&ruleRefExpr{
766											pos:  position{line: 66, col: 44, offset: 1688},
767											name: "NonWhitespaceLiteralSeparator",
768										},
769										&ruleRefExpr{
770											pos:  position{line: 66, col: 74, offset: 1718},
771											name: "_",
772										},
773										&ruleRefExpr{
774											pos:  position{line: 66, col: 76, offset: 1720},
775											name: "Literal",
776										},
777									},
778								},
779							},
780						},
781					},
782				},
783			},
784		},
785		{
786			name: "WhitespaceLiteralSeparator",
787			pos:  position{line: 70, col: 1, offset: 1770},
788			expr: &seqExpr{
789				pos: position{line: 70, col: 31, offset: 1800},
790				exprs: []interface{}{
791					&zeroOrMoreExpr{
792						pos: position{line: 70, col: 31, offset: 1800},
793						expr: &charClassMatcher{
794							pos:        position{line: 70, col: 31, offset: 1800},
795							val:        "[ \\t]",
796							chars:      []rune{' ', '\t'},
797							ignoreCase: false,
798							inverted:   false,
799						},
800					},
801					&choiceExpr{
802						pos: position{line: 70, col: 39, offset: 1808},
803						alternatives: []interface{}{
804							&seqExpr{
805								pos: position{line: 70, col: 40, offset: 1809},
806								exprs: []interface{}{
807									&ruleRefExpr{
808										pos:  position{line: 70, col: 40, offset: 1809},
809										name: "NonWhitespaceLiteralSeparator",
810									},
811									&zeroOrOneExpr{
812										pos: position{line: 70, col: 70, offset: 1839},
813										expr: &ruleRefExpr{
814											pos:  position{line: 70, col: 70, offset: 1839},
815											name: "Comment",
816										},
817									},
818								},
819							},
820							&seqExpr{
821								pos: position{line: 70, col: 83, offset: 1852},
822								exprs: []interface{}{
823									&zeroOrOneExpr{
824										pos: position{line: 70, col: 83, offset: 1852},
825										expr: &ruleRefExpr{
826											pos:  position{line: 70, col: 83, offset: 1852},
827											name: "Comment",
828										},
829									},
830									&charClassMatcher{
831										pos:        position{line: 70, col: 92, offset: 1861},
832										val:        "[\\r\\n]",
833										chars:      []rune{'\r', '\n'},
834										ignoreCase: false,
835										inverted:   false,
836									},
837								},
838							},
839						},
840					},
841				},
842			},
843		},
844		{
845			name: "NonWhitespaceLiteralSeparator",
846			pos:  position{line: 72, col: 1, offset: 1871},
847			expr: &litMatcher{
848				pos:        position{line: 72, col: 34, offset: 1904},
849				val:        ";",
850				ignoreCase: false,
851			},
852		},
853		{
854			name: "Literal",
855			pos:  position{line: 74, col: 1, offset: 1909},
856			expr: &actionExpr{
857				pos: position{line: 74, col: 12, offset: 1920},
858				run: (*parser).callonLiteral1,
859				expr: &seqExpr{
860					pos: position{line: 74, col: 12, offset: 1920},
861					exprs: []interface{}{
862						&labeledExpr{
863							pos:   position{line: 74, col: 12, offset: 1920},
864							label: "negated",
865							expr: &zeroOrOneExpr{
866								pos: position{line: 74, col: 20, offset: 1928},
867								expr: &ruleRefExpr{
868									pos:  position{line: 74, col: 20, offset: 1928},
869									name: "NotKeyword",
870								},
871							},
872						},
873						&labeledExpr{
874							pos:   position{line: 74, col: 32, offset: 1940},
875							label: "value",
876							expr: &ruleRefExpr{
877								pos:  position{line: 74, col: 38, offset: 1946},
878								name: "LiteralExpr",
879							},
880						},
881						&labeledExpr{
882							pos:   position{line: 74, col: 50, offset: 1958},
883							label: "with",
884							expr: &zeroOrOneExpr{
885								pos: position{line: 74, col: 55, offset: 1963},
886								expr: &ruleRefExpr{
887									pos:  position{line: 74, col: 55, offset: 1963},
888									name: "WithKeywordList",
889								},
890							},
891						},
892					},
893				},
894			},
895		},
896		{
897			name: "LiteralExpr",
898			pos:  position{line: 78, col: 1, offset: 2030},
899			expr: &actionExpr{
900				pos: position{line: 78, col: 16, offset: 2045},
901				run: (*parser).callonLiteralExpr1,
902				expr: &seqExpr{
903					pos: position{line: 78, col: 16, offset: 2045},
904					exprs: []interface{}{
905						&labeledExpr{
906							pos:   position{line: 78, col: 16, offset: 2045},
907							label: "lhs",
908							expr: &ruleRefExpr{
909								pos:  position{line: 78, col: 20, offset: 2049},
910								name: "ExprTerm",
911							},
912						},
913						&labeledExpr{
914							pos:   position{line: 78, col: 29, offset: 2058},
915							label: "rest",
916							expr: &zeroOrOneExpr{
917								pos: position{line: 78, col: 34, offset: 2063},
918								expr: &seqExpr{
919									pos: position{line: 78, col: 36, offset: 2065},
920									exprs: []interface{}{
921										&ruleRefExpr{
922											pos:  position{line: 78, col: 36, offset: 2065},
923											name: "_",
924										},
925										&ruleRefExpr{
926											pos:  position{line: 78, col: 38, offset: 2067},
927											name: "LiteralExprOperator",
928										},
929										&ruleRefExpr{
930											pos:  position{line: 78, col: 58, offset: 2087},
931											name: "_",
932										},
933										&ruleRefExpr{
934											pos:  position{line: 78, col: 60, offset: 2089},
935											name: "ExprTerm",
936										},
937									},
938								},
939							},
940						},
941					},
942				},
943			},
944		},
945		{
946			name: "LiteralExprOperator",
947			pos:  position{line: 82, col: 1, offset: 2163},
948			expr: &actionExpr{
949				pos: position{line: 82, col: 24, offset: 2186},
950				run: (*parser).callonLiteralExprOperator1,
951				expr: &labeledExpr{
952					pos:   position{line: 82, col: 24, offset: 2186},
953					label: "val",
954					expr: &choiceExpr{
955						pos: position{line: 82, col: 30, offset: 2192},
956						alternatives: []interface{}{
957							&litMatcher{
958								pos:        position{line: 82, col: 30, offset: 2192},
959								val:        ":=",
960								ignoreCase: false,
961							},
962							&litMatcher{
963								pos:        position{line: 82, col: 37, offset: 2199},
964								val:        "=",
965								ignoreCase: false,
966							},
967						},
968					},
969				},
970			},
971		},
972		{
973			name: "NotKeyword",
974			pos:  position{line: 86, col: 1, offset: 2267},
975			expr: &actionExpr{
976				pos: position{line: 86, col: 15, offset: 2281},
977				run: (*parser).callonNotKeyword1,
978				expr: &labeledExpr{
979					pos:   position{line: 86, col: 15, offset: 2281},
980					label: "val",
981					expr: &zeroOrOneExpr{
982						pos: position{line: 86, col: 19, offset: 2285},
983						expr: &seqExpr{
984							pos: position{line: 86, col: 20, offset: 2286},
985							exprs: []interface{}{
986								&litMatcher{
987									pos:        position{line: 86, col: 20, offset: 2286},
988									val:        "not",
989									ignoreCase: false,
990								},
991								&ruleRefExpr{
992									pos:  position{line: 86, col: 26, offset: 2292},
993									name: "ws",
994								},
995							},
996						},
997					},
998				},
999			},
1000		},
1001		{
1002			name: "WithKeywordList",
1003			pos:  position{line: 90, col: 1, offset: 2329},
1004			expr: &actionExpr{
1005				pos: position{line: 90, col: 20, offset: 2348},
1006				run: (*parser).callonWithKeywordList1,
1007				expr: &seqExpr{
1008					pos: position{line: 90, col: 20, offset: 2348},
1009					exprs: []interface{}{
1010						&ruleRefExpr{
1011							pos:  position{line: 90, col: 20, offset: 2348},
1012							name: "ws",
1013						},
1014						&labeledExpr{
1015							pos:   position{line: 90, col: 23, offset: 2351},
1016							label: "head",
1017							expr: &ruleRefExpr{
1018								pos:  position{line: 90, col: 28, offset: 2356},
1019								name: "WithKeyword",
1020							},
1021						},
1022						&labeledExpr{
1023							pos:   position{line: 90, col: 40, offset: 2368},
1024							label: "rest",
1025							expr: &zeroOrMoreExpr{
1026								pos: position{line: 90, col: 45, offset: 2373},
1027								expr: &seqExpr{
1028									pos: position{line: 90, col: 47, offset: 2375},
1029									exprs: []interface{}{
1030										&ruleRefExpr{
1031											pos:  position{line: 90, col: 47, offset: 2375},
1032											name: "ws",
1033										},
1034										&ruleRefExpr{
1035											pos:  position{line: 90, col: 50, offset: 2378},
1036											name: "WithKeyword",
1037										},
1038									},
1039								},
1040							},
1041						},
1042					},
1043				},
1044			},
1045		},
1046		{
1047			name: "WithKeyword",
1048			pos:  position{line: 94, col: 1, offset: 2441},
1049			expr: &actionExpr{
1050				pos: position{line: 94, col: 16, offset: 2456},
1051				run: (*parser).callonWithKeyword1,
1052				expr: &seqExpr{
1053					pos: position{line: 94, col: 16, offset: 2456},
1054					exprs: []interface{}{
1055						&litMatcher{
1056							pos:        position{line: 94, col: 16, offset: 2456},
1057							val:        "with",
1058							ignoreCase: false,
1059						},
1060						&ruleRefExpr{
1061							pos:  position{line: 94, col: 23, offset: 2463},
1062							name: "ws",
1063						},
1064						&labeledExpr{
1065							pos:   position{line: 94, col: 26, offset: 2466},
1066							label: "target",
1067							expr: &ruleRefExpr{
1068								pos:  position{line: 94, col: 33, offset: 2473},
1069								name: "ExprTerm",
1070							},
1071						},
1072						&ruleRefExpr{
1073							pos:  position{line: 94, col: 42, offset: 2482},
1074							name: "ws",
1075						},
1076						&litMatcher{
1077							pos:        position{line: 94, col: 45, offset: 2485},
1078							val:        "as",
1079							ignoreCase: false,
1080						},
1081						&ruleRefExpr{
1082							pos:  position{line: 94, col: 50, offset: 2490},
1083							name: "ws",
1084						},
1085						&labeledExpr{
1086							pos:   position{line: 94, col: 53, offset: 2493},
1087							label: "value",
1088							expr: &ruleRefExpr{
1089								pos:  position{line: 94, col: 59, offset: 2499},
1090								name: "ExprTerm",
1091							},
1092						},
1093					},
1094				},
1095			},
1096		},
1097		{
1098			name: "ExprTerm",
1099			pos:  position{line: 98, col: 1, offset: 2575},
1100			expr: &actionExpr{
1101				pos: position{line: 98, col: 13, offset: 2587},
1102				run: (*parser).callonExprTerm1,
1103				expr: &seqExpr{
1104					pos: position{line: 98, col: 13, offset: 2587},
1105					exprs: []interface{}{
1106						&labeledExpr{
1107							pos:   position{line: 98, col: 13, offset: 2587},
1108							label: "lhs",
1109							expr: &ruleRefExpr{
1110								pos:  position{line: 98, col: 17, offset: 2591},
1111								name: "RelationExpr",
1112							},
1113						},
1114						&labeledExpr{
1115							pos:   position{line: 98, col: 30, offset: 2604},
1116							label: "rest",
1117							expr: &zeroOrMoreExpr{
1118								pos: position{line: 98, col: 35, offset: 2609},
1119								expr: &seqExpr{
1120									pos: position{line: 98, col: 37, offset: 2611},
1121									exprs: []interface{}{
1122										&ruleRefExpr{
1123											pos:  position{line: 98, col: 37, offset: 2611},
1124											name: "_",
1125										},
1126										&ruleRefExpr{
1127											pos:  position{line: 98, col: 39, offset: 2613},
1128											name: "RelationOperator",
1129										},
1130										&ruleRefExpr{
1131											pos:  position{line: 98, col: 56, offset: 2630},
1132											name: "_",
1133										},
1134										&ruleRefExpr{
1135											pos:  position{line: 98, col: 58, offset: 2632},
1136											name: "RelationExpr",
1137										},
1138									},
1139								},
1140							},
1141						},
1142					},
1143				},
1144			},
1145		},
1146		{
1147			name: "ExprTermPairList",
1148			pos:  position{line: 102, col: 1, offset: 2708},
1149			expr: &actionExpr{
1150				pos: position{line: 102, col: 21, offset: 2728},
1151				run: (*parser).callonExprTermPairList1,
1152				expr: &seqExpr{
1153					pos: position{line: 102, col: 21, offset: 2728},
1154					exprs: []interface{}{
1155						&labeledExpr{
1156							pos:   position{line: 102, col: 21, offset: 2728},
1157							label: "head",
1158							expr: &zeroOrOneExpr{
1159								pos: position{line: 102, col: 26, offset: 2733},
1160								expr: &ruleRefExpr{
1161									pos:  position{line: 102, col: 26, offset: 2733},
1162									name: "ExprTermPair",
1163								},
1164							},
1165						},
1166						&labeledExpr{
1167							pos:   position{line: 102, col: 40, offset: 2747},
1168							label: "tail",
1169							expr: &zeroOrMoreExpr{
1170								pos: position{line: 102, col: 45, offset: 2752},
1171								expr: &seqExpr{
1172									pos: position{line: 102, col: 47, offset: 2754},
1173									exprs: []interface{}{
1174										&ruleRefExpr{
1175											pos:  position{line: 102, col: 47, offset: 2754},
1176											name: "_",
1177										},
1178										&litMatcher{
1179											pos:        position{line: 102, col: 49, offset: 2756},
1180											val:        ",",
1181											ignoreCase: false,
1182										},
1183										&ruleRefExpr{
1184											pos:  position{line: 102, col: 53, offset: 2760},
1185											name: "_",
1186										},
1187										&ruleRefExpr{
1188											pos:  position{line: 102, col: 55, offset: 2762},
1189											name: "ExprTermPair",
1190										},
1191									},
1192								},
1193							},
1194						},
1195						&ruleRefExpr{
1196							pos:  position{line: 102, col: 71, offset: 2778},
1197							name: "_",
1198						},
1199						&zeroOrOneExpr{
1200							pos: position{line: 102, col: 73, offset: 2780},
1201							expr: &litMatcher{
1202								pos:        position{line: 102, col: 73, offset: 2780},
1203								val:        ",",
1204								ignoreCase: false,
1205							},
1206						},
1207					},
1208				},
1209			},
1210		},
1211		{
1212			name: "ExprTermList",
1213			pos:  position{line: 106, col: 1, offset: 2834},
1214			expr: &actionExpr{
1215				pos: position{line: 106, col: 17, offset: 2850},
1216				run: (*parser).callonExprTermList1,
1217				expr: &seqExpr{
1218					pos: position{line: 106, col: 17, offset: 2850},
1219					exprs: []interface{}{
1220						&labeledExpr{
1221							pos:   position{line: 106, col: 17, offset: 2850},
1222							label: "head",
1223							expr: &zeroOrOneExpr{
1224								pos: position{line: 106, col: 22, offset: 2855},
1225								expr: &ruleRefExpr{
1226									pos:  position{line: 106, col: 22, offset: 2855},
1227									name: "ExprTerm",
1228								},
1229							},
1230						},
1231						&labeledExpr{
1232							pos:   position{line: 106, col: 32, offset: 2865},
1233							label: "tail",
1234							expr: &zeroOrMoreExpr{
1235								pos: position{line: 106, col: 37, offset: 2870},
1236								expr: &seqExpr{
1237									pos: position{line: 106, col: 39, offset: 2872},
1238									exprs: []interface{}{
1239										&ruleRefExpr{
1240											pos:  position{line: 106, col: 39, offset: 2872},
1241											name: "_",
1242										},
1243										&litMatcher{
1244											pos:        position{line: 106, col: 41, offset: 2874},
1245											val:        ",",
1246											ignoreCase: false,
1247										},
1248										&ruleRefExpr{
1249											pos:  position{line: 106, col: 45, offset: 2878},
1250											name: "_",
1251										},
1252										&ruleRefExpr{
1253											pos:  position{line: 106, col: 47, offset: 2880},
1254											name: "ExprTerm",
1255										},
1256									},
1257								},
1258							},
1259						},
1260						&ruleRefExpr{
1261							pos:  position{line: 106, col: 59, offset: 2892},
1262							name: "_",
1263						},
1264						&zeroOrOneExpr{
1265							pos: position{line: 106, col: 61, offset: 2894},
1266							expr: &litMatcher{
1267								pos:        position{line: 106, col: 61, offset: 2894},
1268								val:        ",",
1269								ignoreCase: false,
1270							},
1271						},
1272					},
1273				},
1274			},
1275		},
1276		{
1277			name: "ExprTermPair",
1278			pos:  position{line: 110, col: 1, offset: 2945},
1279			expr: &actionExpr{
1280				pos: position{line: 110, col: 17, offset: 2961},
1281				run: (*parser).callonExprTermPair1,
1282				expr: &seqExpr{
1283					pos: position{line: 110, col: 17, offset: 2961},
1284					exprs: []interface{}{
1285						&labeledExpr{
1286							pos:   position{line: 110, col: 17, offset: 2961},
1287							label: "key",
1288							expr: &ruleRefExpr{
1289								pos:  position{line: 110, col: 21, offset: 2965},
1290								name: "ExprTerm",
1291							},
1292						},
1293						&ruleRefExpr{
1294							pos:  position{line: 110, col: 30, offset: 2974},
1295							name: "_",
1296						},
1297						&litMatcher{
1298							pos:        position{line: 110, col: 32, offset: 2976},
1299							val:        ":",
1300							ignoreCase: false,
1301						},
1302						&ruleRefExpr{
1303							pos:  position{line: 110, col: 36, offset: 2980},
1304							name: "_",
1305						},
1306						&labeledExpr{
1307							pos:   position{line: 110, col: 38, offset: 2982},
1308							label: "value",
1309							expr: &ruleRefExpr{
1310								pos:  position{line: 110, col: 44, offset: 2988},
1311								name: "ExprTerm",
1312							},
1313						},
1314					},
1315				},
1316			},
1317		},
1318		{
1319			name: "RelationOperator",
1320			pos:  position{line: 114, col: 1, offset: 3042},
1321			expr: &actionExpr{
1322				pos: position{line: 114, col: 21, offset: 3062},
1323				run: (*parser).callonRelationOperator1,
1324				expr: &labeledExpr{
1325					pos:   position{line: 114, col: 21, offset: 3062},
1326					label: "val",
1327					expr: &choiceExpr{
1328						pos: position{line: 114, col: 26, offset: 3067},
1329						alternatives: []interface{}{
1330							&litMatcher{
1331								pos:        position{line: 114, col: 26, offset: 3067},
1332								val:        "==",
1333								ignoreCase: false,
1334							},
1335							&litMatcher{
1336								pos:        position{line: 114, col: 33, offset: 3074},
1337								val:        "!=",
1338								ignoreCase: false,
1339							},
1340							&litMatcher{
1341								pos:        position{line: 114, col: 40, offset: 3081},
1342								val:        "<=",
1343								ignoreCase: false,
1344							},
1345							&litMatcher{
1346								pos:        position{line: 114, col: 47, offset: 3088},
1347								val:        ">=",
1348								ignoreCase: false,
1349							},
1350							&litMatcher{
1351								pos:        position{line: 114, col: 54, offset: 3095},
1352								val:        ">",
1353								ignoreCase: false,
1354							},
1355							&litMatcher{
1356								pos:        position{line: 114, col: 60, offset: 3101},
1357								val:        "<",
1358								ignoreCase: false,
1359							},
1360						},
1361					},
1362				},
1363			},
1364		},
1365		{
1366			name: "RelationExpr",
1367			pos:  position{line: 118, col: 1, offset: 3168},
1368			expr: &actionExpr{
1369				pos: position{line: 118, col: 17, offset: 3184},
1370				run: (*parser).callonRelationExpr1,
1371				expr: &seqExpr{
1372					pos: position{line: 118, col: 17, offset: 3184},
1373					exprs: []interface{}{
1374						&labeledExpr{
1375							pos:   position{line: 118, col: 17, offset: 3184},
1376							label: "lhs",
1377							expr: &ruleRefExpr{
1378								pos:  position{line: 118, col: 21, offset: 3188},
1379								name: "BitwiseOrExpr",
1380							},
1381						},
1382						&labeledExpr{
1383							pos:   position{line: 118, col: 35, offset: 3202},
1384							label: "rest",
1385							expr: &zeroOrMoreExpr{
1386								pos: position{line: 118, col: 40, offset: 3207},
1387								expr: &seqExpr{
1388									pos: position{line: 118, col: 42, offset: 3209},
1389									exprs: []interface{}{
1390										&ruleRefExpr{
1391											pos:  position{line: 118, col: 42, offset: 3209},
1392											name: "_",
1393										},
1394										&ruleRefExpr{
1395											pos:  position{line: 118, col: 44, offset: 3211},
1396											name: "BitwiseOrOperator",
1397										},
1398										&ruleRefExpr{
1399											pos:  position{line: 118, col: 62, offset: 3229},
1400											name: "_",
1401										},
1402										&ruleRefExpr{
1403											pos:  position{line: 118, col: 64, offset: 3231},
1404											name: "BitwiseOrExpr",
1405										},
1406									},
1407								},
1408							},
1409						},
1410					},
1411				},
1412			},
1413		},
1414		{
1415			name: "BitwiseOrOperator",
1416			pos:  position{line: 122, col: 1, offset: 3307},
1417			expr: &actionExpr{
1418				pos: position{line: 122, col: 22, offset: 3328},
1419				run: (*parser).callonBitwiseOrOperator1,
1420				expr: &labeledExpr{
1421					pos:   position{line: 122, col: 22, offset: 3328},
1422					label: "val",
1423					expr: &litMatcher{
1424						pos:        position{line: 122, col: 26, offset: 3332},
1425						val:        "|",
1426						ignoreCase: false,
1427					},
1428				},
1429			},
1430		},
1431		{
1432			name: "BitwiseOrExpr",
1433			pos:  position{line: 126, col: 1, offset: 3398},
1434			expr: &actionExpr{
1435				pos: position{line: 126, col: 18, offset: 3415},
1436				run: (*parser).callonBitwiseOrExpr1,
1437				expr: &seqExpr{
1438					pos: position{line: 126, col: 18, offset: 3415},
1439					exprs: []interface{}{
1440						&labeledExpr{
1441							pos:   position{line: 126, col: 18, offset: 3415},
1442							label: "lhs",
1443							expr: &ruleRefExpr{
1444								pos:  position{line: 126, col: 22, offset: 3419},
1445								name: "BitwiseAndExpr",
1446							},
1447						},
1448						&labeledExpr{
1449							pos:   position{line: 126, col: 37, offset: 3434},
1450							label: "rest",
1451							expr: &zeroOrMoreExpr{
1452								pos: position{line: 126, col: 42, offset: 3439},
1453								expr: &seqExpr{
1454									pos: position{line: 126, col: 44, offset: 3441},
1455									exprs: []interface{}{
1456										&ruleRefExpr{
1457											pos:  position{line: 126, col: 44, offset: 3441},
1458											name: "_",
1459										},
1460										&ruleRefExpr{
1461											pos:  position{line: 126, col: 46, offset: 3443},
1462											name: "BitwiseAndOperator",
1463										},
1464										&ruleRefExpr{
1465											pos:  position{line: 126, col: 65, offset: 3462},
1466											name: "_",
1467										},
1468										&ruleRefExpr{
1469											pos:  position{line: 126, col: 67, offset: 3464},
1470											name: "BitwiseAndExpr",
1471										},
1472									},
1473								},
1474							},
1475						},
1476					},
1477				},
1478			},
1479		},
1480		{
1481			name: "BitwiseAndOperator",
1482			pos:  position{line: 130, col: 1, offset: 3541},
1483			expr: &actionExpr{
1484				pos: position{line: 130, col: 23, offset: 3563},
1485				run: (*parser).callonBitwiseAndOperator1,
1486				expr: &labeledExpr{
1487					pos:   position{line: 130, col: 23, offset: 3563},
1488					label: "val",
1489					expr: &litMatcher{
1490						pos:        position{line: 130, col: 27, offset: 3567},
1491						val:        "&",
1492						ignoreCase: false,
1493					},
1494				},
1495			},
1496		},
1497		{
1498			name: "BitwiseAndExpr",
1499			pos:  position{line: 134, col: 1, offset: 3633},
1500			expr: &actionExpr{
1501				pos: position{line: 134, col: 19, offset: 3651},
1502				run: (*parser).callonBitwiseAndExpr1,
1503				expr: &seqExpr{
1504					pos: position{line: 134, col: 19, offset: 3651},
1505					exprs: []interface{}{
1506						&labeledExpr{
1507							pos:   position{line: 134, col: 19, offset: 3651},
1508							label: "lhs",
1509							expr: &ruleRefExpr{
1510								pos:  position{line: 134, col: 23, offset: 3655},
1511								name: "ArithExpr",
1512							},
1513						},
1514						&labeledExpr{
1515							pos:   position{line: 134, col: 33, offset: 3665},
1516							label: "rest",
1517							expr: &zeroOrMoreExpr{
1518								pos: position{line: 134, col: 38, offset: 3670},
1519								expr: &seqExpr{
1520									pos: position{line: 134, col: 40, offset: 3672},
1521									exprs: []interface{}{
1522										&ruleRefExpr{
1523											pos:  position{line: 134, col: 40, offset: 3672},
1524											name: "_",
1525										},
1526										&ruleRefExpr{
1527											pos:  position{line: 134, col: 42, offset: 3674},
1528											name: "ArithOperator",
1529										},
1530										&ruleRefExpr{
1531											pos:  position{line: 134, col: 56, offset: 3688},
1532											name: "_",
1533										},
1534										&ruleRefExpr{
1535											pos:  position{line: 134, col: 58, offset: 3690},
1536											name: "ArithExpr",
1537										},
1538									},
1539								},
1540							},
1541						},
1542					},
1543				},
1544			},
1545		},
1546		{
1547			name: "ArithOperator",
1548			pos:  position{line: 138, col: 1, offset: 3762},
1549			expr: &actionExpr{
1550				pos: position{line: 138, col: 18, offset: 3779},
1551				run: (*parser).callonArithOperator1,
1552				expr: &labeledExpr{
1553					pos:   position{line: 138, col: 18, offset: 3779},
1554					label: "val",
1555					expr: &choiceExpr{
1556						pos: position{line: 138, col: 23, offset: 3784},
1557						alternatives: []interface{}{
1558							&litMatcher{
1559								pos:        position{line: 138, col: 23, offset: 3784},
1560								val:        "+",
1561								ignoreCase: false,
1562							},
1563							&litMatcher{
1564								pos:        position{line: 138, col: 29, offset: 3790},
1565								val:        "-",
1566								ignoreCase: false,
1567							},
1568						},
1569					},
1570				},
1571			},
1572		},
1573		{
1574			name: "ArithExpr",
1575			pos:  position{line: 142, col: 1, offset: 3857},
1576			expr: &actionExpr{
1577				pos: position{line: 142, col: 14, offset: 3870},
1578				run: (*parser).callonArithExpr1,
1579				expr: &seqExpr{
1580					pos: position{line: 142, col: 14, offset: 3870},
1581					exprs: []interface{}{
1582						&labeledExpr{
1583							pos:   position{line: 142, col: 14, offset: 3870},
1584							label: "lhs",
1585							expr: &ruleRefExpr{
1586								pos:  position{line: 142, col: 18, offset: 3874},
1587								name: "FactorExpr",
1588							},
1589						},
1590						&labeledExpr{
1591							pos:   position{line: 142, col: 29, offset: 3885},
1592							label: "rest",
1593							expr: &zeroOrMoreExpr{
1594								pos: position{line: 142, col: 34, offset: 3890},
1595								expr: &seqExpr{
1596									pos: position{line: 142, col: 36, offset: 3892},
1597									exprs: []interface{}{
1598										&ruleRefExpr{
1599											pos:  position{line: 142, col: 36, offset: 3892},
1600											name: "_",
1601										},
1602										&ruleRefExpr{
1603											pos:  position{line: 142, col: 38, offset: 3894},
1604											name: "FactorOperator",
1605										},
1606										&ruleRefExpr{
1607											pos:  position{line: 142, col: 53, offset: 3909},
1608											name: "_",
1609										},
1610										&ruleRefExpr{
1611											pos:  position{line: 142, col: 55, offset: 3911},
1612											name: "FactorExpr",
1613										},
1614									},
1615								},
1616							},
1617						},
1618					},
1619				},
1620			},
1621		},
1622		{
1623			name: "FactorOperator",
1624			pos:  position{line: 146, col: 1, offset: 3985},
1625			expr: &actionExpr{
1626				pos: position{line: 146, col: 19, offset: 4003},
1627				run: (*parser).callonFactorOperator1,
1628				expr: &labeledExpr{
1629					pos:   position{line: 146, col: 19, offset: 4003},
1630					label: "val",
1631					expr: &choiceExpr{
1632						pos: position{line: 146, col: 24, offset: 4008},
1633						alternatives: []interface{}{
1634							&litMatcher{
1635								pos:        position{line: 146, col: 24, offset: 4008},
1636								val:        "*",
1637								ignoreCase: false,
1638							},
1639							&litMatcher{
1640								pos:        position{line: 146, col: 30, offset: 4014},
1641								val:        "/",
1642								ignoreCase: false,
1643							},
1644							&litMatcher{
1645								pos:        position{line: 146, col: 36, offset: 4020},
1646								val:        "%",
1647								ignoreCase: false,
1648							},
1649						},
1650					},
1651				},
1652			},
1653		},
1654		{
1655			name: "FactorExpr",
1656			pos:  position{line: 150, col: 1, offset: 4086},
1657			expr: &choiceExpr{
1658				pos: position{line: 150, col: 15, offset: 4100},
1659				alternatives: []interface{}{
1660					&actionExpr{
1661						pos: position{line: 150, col: 15, offset: 4100},
1662						run: (*parser).callonFactorExpr2,
1663						expr: &seqExpr{
1664							pos: position{line: 150, col: 17, offset: 4102},
1665							exprs: []interface{}{
1666								&litMatcher{
1667									pos:        position{line: 150, col: 17, offset: 4102},
1668									val:        "(",
1669									ignoreCase: false,
1670								},
1671								&ruleRefExpr{
1672									pos:  position{line: 150, col: 21, offset: 4106},
1673									name: "_",
1674								},
1675								&labeledExpr{
1676									pos:   position{line: 150, col: 23, offset: 4108},
1677									label: "expr",
1678									expr: &ruleRefExpr{
1679										pos:  position{line: 150, col: 28, offset: 4113},
1680										name: "ExprTerm",
1681									},
1682								},
1683								&ruleRefExpr{
1684									pos:  position{line: 150, col: 37, offset: 4122},
1685									name: "_",
1686								},
1687								&litMatcher{
1688									pos:        position{line: 150, col: 39, offset: 4124},
1689									val:        ")",
1690									ignoreCase: false,
1691								},
1692							},
1693						},
1694					},
1695					&actionExpr{
1696						pos: position{line: 152, col: 5, offset: 4157},
1697						run: (*parser).callonFactorExpr10,
1698						expr: &labeledExpr{
1699							pos:   position{line: 152, col: 5, offset: 4157},
1700							label: "term",
1701							expr: &ruleRefExpr{
1702								pos:  position{line: 152, col: 10, offset: 4162},
1703								name: "Term",
1704							},
1705						},
1706					},
1707				},
1708			},
1709		},
1710		{
1711			name: "Call",
1712			pos:  position{line: 156, col: 1, offset: 4193},
1713			expr: &actionExpr{
1714				pos: position{line: 156, col: 9, offset: 4201},
1715				run: (*parser).callonCall1,
1716				expr: &seqExpr{
1717					pos: position{line: 156, col: 9, offset: 4201},
1718					exprs: []interface{}{
1719						&labeledExpr{
1720							pos:   position{line: 156, col: 9, offset: 4201},
1721							label: "operator",
1722							expr: &choiceExpr{
1723								pos: position{line: 156, col: 19, offset: 4211},
1724								alternatives: []interface{}{
1725									&ruleRefExpr{
1726										pos:  position{line: 156, col: 19, offset: 4211},
1727										name: "Ref",
1728									},
1729									&ruleRefExpr{
1730										pos:  position{line: 156, col: 25, offset: 4217},
1731										name: "Var",
1732									},
1733								},
1734							},
1735						},
1736						&litMatcher{
1737							pos:        position{line: 156, col: 30, offset: 4222},
1738							val:        "(",
1739							ignoreCase: false,
1740						},
1741						&ruleRefExpr{
1742							pos:  position{line: 156, col: 34, offset: 4226},
1743							name: "_",
1744						},
1745						&labeledExpr{
1746							pos:   position{line: 156, col: 36, offset: 4228},
1747							label: "args",
1748							expr: &ruleRefExpr{
1749								pos:  position{line: 156, col: 41, offset: 4233},
1750								name: "ExprTermList",
1751							},
1752						},
1753						&ruleRefExpr{
1754							pos:  position{line: 156, col: 54, offset: 4246},
1755							name: "_",
1756						},
1757						&litMatcher{
1758							pos:        position{line: 156, col: 56, offset: 4248},
1759							val:        ")",
1760							ignoreCase: false,
1761						},
1762					},
1763				},
1764			},
1765		},
1766		{
1767			name: "Term",
1768			pos:  position{line: 160, col: 1, offset: 4313},
1769			expr: &actionExpr{
1770				pos: position{line: 160, col: 9, offset: 4321},
1771				run: (*parser).callonTerm1,
1772				expr: &labeledExpr{
1773					pos:   position{line: 160, col: 9, offset: 4321},
1774					label: "val",
1775					expr: &choiceExpr{
1776						pos: position{line: 160, col: 15, offset: 4327},
1777						alternatives: []interface{}{
1778							&ruleRefExpr{
1779								pos:  position{line: 160, col: 15, offset: 4327},
1780								name: "Comprehension",
1781							},
1782							&ruleRefExpr{
1783								pos:  position{line: 160, col: 31, offset: 4343},
1784								name: "Composite",
1785							},
1786							&ruleRefExpr{
1787								pos:  position{line: 160, col: 43, offset: 4355},
1788								name: "Scalar",
1789							},
1790							&ruleRefExpr{
1791								pos:  position{line: 160, col: 52, offset: 4364},
1792								name: "Call",
1793							},
1794							&ruleRefExpr{
1795								pos:  position{line: 160, col: 59, offset: 4371},
1796								name: "Ref",
1797							},
1798							&ruleRefExpr{
1799								pos:  position{line: 160, col: 65, offset: 4377},
1800								name: "Var",
1801							},
1802						},
1803					},
1804				},
1805			},
1806		},
1807		{
1808			name: "TermPair",
1809			pos:  position{line: 164, col: 1, offset: 4408},
1810			expr: &actionExpr{
1811				pos: position{line: 164, col: 13, offset: 4420},
1812				run: (*parser).callonTermPair1,
1813				expr: &seqExpr{
1814					pos: position{line: 164, col: 13, offset: 4420},
1815					exprs: []interface{}{
1816						&labeledExpr{
1817							pos:   position{line: 164, col: 13, offset: 4420},
1818							label: "key",
1819							expr: &ruleRefExpr{
1820								pos:  position{line: 164, col: 17, offset: 4424},
1821								name: "Term",
1822							},
1823						},
1824						&ruleRefExpr{
1825							pos:  position{line: 164, col: 22, offset: 4429},
1826							name: "_",
1827						},
1828						&litMatcher{
1829							pos:        position{line: 164, col: 24, offset: 4431},
1830							val:        ":",
1831							ignoreCase: false,
1832						},
1833						&ruleRefExpr{
1834							pos:  position{line: 164, col: 28, offset: 4435},
1835							name: "_",
1836						},
1837						&labeledExpr{
1838							pos:   position{line: 164, col: 30, offset: 4437},
1839							label: "value",
1840							expr: &ruleRefExpr{
1841								pos:  position{line: 164, col: 36, offset: 4443},
1842								name: "Term",
1843							},
1844						},
1845					},
1846				},
1847			},
1848		},
1849		{
1850			name: "Comprehension",
1851			pos:  position{line: 168, col: 1, offset: 4493},
1852			expr: &choiceExpr{
1853				pos: position{line: 168, col: 18, offset: 4510},
1854				alternatives: []interface{}{
1855					&ruleRefExpr{
1856						pos:  position{line: 168, col: 18, offset: 4510},
1857						name: "ArrayComprehension",
1858					},
1859					&ruleRefExpr{
1860						pos:  position{line: 168, col: 39, offset: 4531},
1861						name: "ObjectComprehension",
1862					},
1863					&ruleRefExpr{
1864						pos:  position{line: 168, col: 61, offset: 4553},
1865						name: "SetComprehension",
1866					},
1867				},
1868			},
1869		},
1870		{
1871			name: "ArrayComprehension",
1872			pos:  position{line: 170, col: 1, offset: 4571},
1873			expr: &actionExpr{
1874				pos: position{line: 170, col: 23, offset: 4593},
1875				run: (*parser).callonArrayComprehension1,
1876				expr: &seqExpr{
1877					pos: position{line: 170, col: 23, offset: 4593},
1878					exprs: []interface{}{
1879						&litMatcher{
1880							pos:        position{line: 170, col: 23, offset: 4593},
1881							val:        "[",
1882							ignoreCase: false,
1883						},
1884						&ruleRefExpr{
1885							pos:  position{line: 170, col: 27, offset: 4597},
1886							name: "_",
1887						},
1888						&labeledExpr{
1889							pos:   position{line: 170, col: 29, offset: 4599},
1890							label: "head",
1891							expr: &ruleRefExpr{
1892								pos:  position{line: 170, col: 34, offset: 4604},
1893								name: "Term",
1894							},
1895						},
1896						&ruleRefExpr{
1897							pos:  position{line: 170, col: 39, offset: 4609},
1898							name: "_",
1899						},
1900						&litMatcher{
1901							pos:        position{line: 170, col: 41, offset: 4611},
1902							val:        "|",
1903							ignoreCase: false,
1904						},
1905						&ruleRefExpr{
1906							pos:  position{line: 170, col: 45, offset: 4615},
1907							name: "_",
1908						},
1909						&labeledExpr{
1910							pos:   position{line: 170, col: 47, offset: 4617},
1911							label: "body",
1912							expr: &ruleRefExpr{
1913								pos:  position{line: 170, col: 52, offset: 4622},
1914								name: "WhitespaceBody",
1915							},
1916						},
1917						&ruleRefExpr{
1918							pos:  position{line: 170, col: 67, offset: 4637},
1919							name: "_",
1920						},
1921						&litMatcher{
1922							pos:        position{line: 170, col: 69, offset: 4639},
1923							val:        "]",
1924							ignoreCase: false,
1925						},
1926					},
1927				},
1928			},
1929		},
1930		{
1931			name: "ObjectComprehension",
1932			pos:  position{line: 174, col: 1, offset: 4714},
1933			expr: &actionExpr{
1934				pos: position{line: 174, col: 24, offset: 4737},
1935				run: (*parser).callonObjectComprehension1,
1936				expr: &seqExpr{
1937					pos: position{line: 174, col: 24, offset: 4737},
1938					exprs: []interface{}{
1939						&litMatcher{
1940							pos:        position{line: 174, col: 24, offset: 4737},
1941							val:        "{",
1942							ignoreCase: false,
1943						},
1944						&ruleRefExpr{
1945							pos:  position{line: 174, col: 28, offset: 4741},
1946							name: "_",
1947						},
1948						&labeledExpr{
1949							pos:   position{line: 174, col: 30, offset: 4743},
1950							label: "head",
1951							expr: &ruleRefExpr{
1952								pos:  position{line: 174, col: 35, offset: 4748},
1953								name: "TermPair",
1954							},
1955						},
1956						&ruleRefExpr{
1957							pos:  position{line: 174, col: 45, offset: 4758},
1958							name: "_",
1959						},
1960						&litMatcher{
1961							pos:        position{line: 174, col: 47, offset: 4760},
1962							val:        "|",
1963							ignoreCase: false,
1964						},
1965						&ruleRefExpr{
1966							pos:  position{line: 174, col: 51, offset: 4764},
1967							name: "_",
1968						},
1969						&labeledExpr{
1970							pos:   position{line: 174, col: 53, offset: 4766},
1971							label: "body",
1972							expr: &ruleRefExpr{
1973								pos:  position{line: 174, col: 58, offset: 4771},
1974								name: "WhitespaceBody",
1975							},
1976						},
1977						&ruleRefExpr{
1978							pos:  position{line: 174, col: 73, offset: 4786},
1979							name: "_",
1980						},
1981						&litMatcher{
1982							pos:        position{line: 174, col: 75, offset: 4788},
1983							val:        "}",
1984							ignoreCase: false,
1985						},
1986					},
1987				},
1988			},
1989		},
1990		{
1991			name: "SetComprehension",
1992			pos:  position{line: 178, col: 1, offset: 4864},
1993			expr: &actionExpr{
1994				pos: position{line: 178, col: 21, offset: 4884},
1995				run: (*parser).callonSetComprehension1,
1996				expr: &seqExpr{
1997					pos: position{line: 178, col: 21, offset: 4884},
1998					exprs: []interface{}{
1999						&litMatcher{
2000							pos:        position{line: 178, col: 21, offset: 4884},
2001							val:        "{",
2002							ignoreCase: false,
2003						},
2004						&ruleRefExpr{
2005							pos:  position{line: 178, col: 25, offset: 4888},
2006							name: "_",
2007						},
2008						&labeledExpr{
2009							pos:   position{line: 178, col: 27, offset: 4890},
2010							label: "head",
2011							expr: &ruleRefExpr{
2012								pos:  position{line: 178, col: 32, offset: 4895},
2013								name: "Term",
2014							},
2015						},
2016						&ruleRefExpr{
2017							pos:  position{line: 178, col: 37, offset: 4900},
2018							name: "_",
2019						},
2020						&litMatcher{
2021							pos:        position{line: 178, col: 39, offset: 4902},
2022							val:        "|",
2023							ignoreCase: false,
2024						},
2025						&ruleRefExpr{
2026							pos:  position{line: 178, col: 43, offset: 4906},
2027							name: "_",
2028						},
2029						&labeledExpr{
2030							pos:   position{line: 178, col: 45, offset: 4908},
2031							label: "body",
2032							expr: &ruleRefExpr{
2033								pos:  position{line: 178, col: 50, offset: 4913},
2034								name: "WhitespaceBody",
2035							},
2036						},
2037						&ruleRefExpr{
2038							pos:  position{line: 178, col: 65, offset: 4928},
2039							name: "_",
2040						},
2041						&litMatcher{
2042							pos:        position{line: 178, col: 67, offset: 4930},
2043							val:        "}",
2044							ignoreCase: false,
2045						},
2046					},
2047				},
2048			},
2049		},
2050		{
2051			name: "Composite",
2052			pos:  position{line: 182, col: 1, offset: 5003},
2053			expr: &choiceExpr{
2054				pos: position{line: 182, col: 14, offset: 5016},
2055				alternatives: []interface{}{
2056					&ruleRefExpr{
2057						pos:  position{line: 182, col: 14, offset: 5016},
2058						name: "Object",
2059					},
2060					&ruleRefExpr{
2061						pos:  position{line: 182, col: 23, offset: 5025},
2062						name: "Array",
2063					},
2064					&ruleRefExpr{
2065						pos:  position{line: 182, col: 31, offset: 5033},
2066						name: "Set",
2067					},
2068				},
2069			},
2070		},
2071		{
2072			name: "Scalar",
2073			pos:  position{line: 184, col: 1, offset: 5038},
2074			expr: &choiceExpr{
2075				pos: position{line: 184, col: 11, offset: 5048},
2076				alternatives: []interface{}{
2077					&ruleRefExpr{
2078						pos:  position{line: 184, col: 11, offset: 5048},
2079						name: "Number",
2080					},
2081					&ruleRefExpr{
2082						pos:  position{line: 184, col: 20, offset: 5057},
2083						name: "String",
2084					},
2085					&ruleRefExpr{
2086						pos:  position{line: 184, col: 29, offset: 5066},
2087						name: "Bool",
2088					},
2089					&ruleRefExpr{
2090						pos:  position{line: 184, col: 36, offset: 5073},
2091						name: "Null",
2092					},
2093				},
2094			},
2095		},
2096		{
2097			name: "Object",
2098			pos:  position{line: 186, col: 1, offset: 5079},
2099			expr: &actionExpr{
2100				pos: position{line: 186, col: 11, offset: 5089},
2101				run: (*parser).callonObject1,
2102				expr: &seqExpr{
2103					pos: position{line: 186, col: 11, offset: 5089},
2104					exprs: []interface{}{
2105						&litMatcher{
2106							pos:        position{line: 186, col: 11, offset: 5089},
2107							val:        "{",
2108							ignoreCase: false,
2109						},
2110						&ruleRefExpr{
2111							pos:  position{line: 186, col: 15, offset: 5093},
2112							name: "_",
2113						},
2114						&labeledExpr{
2115							pos:   position{line: 186, col: 17, offset: 5095},
2116							label: "list",
2117							expr: &ruleRefExpr{
2118								pos:  position{line: 186, col: 22, offset: 5100},
2119								name: "ExprTermPairList",
2120							},
2121						},
2122						&ruleRefExpr{
2123							pos:  position{line: 186, col: 39, offset: 5117},
2124							name: "_",
2125						},
2126						&litMatcher{
2127							pos:        position{line: 186, col: 41, offset: 5119},
2128							val:        "}",
2129							ignoreCase: false,
2130						},
2131					},
2132				},
2133			},
2134		},
2135		{
2136			name: "Array",
2137			pos:  position{line: 190, col: 1, offset: 5176},
2138			expr: &actionExpr{
2139				pos: position{line: 190, col: 10, offset: 5185},
2140				run: (*parser).callonArray1,
2141				expr: &seqExpr{
2142					pos: position{line: 190, col: 10, offset: 5185},
2143					exprs: []interface{}{
2144						&litMatcher{
2145							pos:        position{line: 190, col: 10, offset: 5185},
2146							val:        "[",
2147							ignoreCase: false,
2148						},
2149						&ruleRefExpr{
2150							pos:  position{line: 190, col: 14, offset: 5189},
2151							name: "_",
2152						},
2153						&labeledExpr{
2154							pos:   position{line: 190, col: 16, offset: 5191},
2155							label: "list",
2156							expr: &ruleRefExpr{
2157								pos:  position{line: 190, col: 21, offset: 5196},
2158								name: "ExprTermList",
2159							},
2160						},
2161						&ruleRefExpr{
2162							pos:  position{line: 190, col: 34, offset: 5209},
2163							name: "_",
2164						},
2165						&litMatcher{
2166							pos:        position{line: 190, col: 36, offset: 5211},
2167							val:        "]",
2168							ignoreCase: false,
2169						},
2170					},
2171				},
2172			},
2173		},
2174		{
2175			name: "Set",
2176			pos:  position{line: 194, col: 1, offset: 5267},
2177			expr: &choiceExpr{
2178				pos: position{line: 194, col: 8, offset: 5274},
2179				alternatives: []interface{}{
2180					&ruleRefExpr{
2181						pos:  position{line: 194, col: 8, offset: 5274},
2182						name: "SetEmpty",
2183					},
2184					&ruleRefExpr{
2185						pos:  position{line: 194, col: 19, offset: 5285},
2186						name: "SetNonEmpty",
2187					},
2188				},
2189			},
2190		},
2191		{
2192			name: "SetEmpty",
2193			pos:  position{line: 196, col: 1, offset: 5298},
2194			expr: &actionExpr{
2195				pos: position{line: 196, col: 13, offset: 5310},
2196				run: (*parser).callonSetEmpty1,
2197				expr: &seqExpr{
2198					pos: position{line: 196, col: 13, offset: 5310},
2199					exprs: []interface{}{
2200						&litMatcher{
2201							pos:        position{line: 196, col: 13, offset: 5310},
2202							val:        "set(",
2203							ignoreCase: false,
2204						},
2205						&ruleRefExpr{
2206							pos:  position{line: 196, col: 20, offset: 5317},
2207							name: "_",
2208						},
2209						&litMatcher{
2210							pos:        position{line: 196, col: 22, offset: 5319},
2211							val:        ")",
2212							ignoreCase: false,
2213						},
2214					},
2215				},
2216			},
2217		},
2218		{
2219			name: "SetNonEmpty",
2220			pos:  position{line: 201, col: 1, offset: 5396},
2221			expr: &actionExpr{
2222				pos: position{line: 201, col: 16, offset: 5411},
2223				run: (*parser).callonSetNonEmpty1,
2224				expr: &seqExpr{
2225					pos: position{line: 201, col: 16, offset: 5411},
2226					exprs: []interface{}{
2227						&litMatcher{
2228							pos:        position{line: 201, col: 16, offset: 5411},
2229							val:        "{",
2230							ignoreCase: false,
2231						},
2232						&ruleRefExpr{
2233							pos:  position{line: 201, col: 20, offset: 5415},
2234							name: "_",
2235						},
2236						&labeledExpr{
2237							pos:   position{line: 201, col: 22, offset: 5417},
2238							label: "list",
2239							expr: &ruleRefExpr{
2240								pos:  position{line: 201, col: 27, offset: 5422},
2241								name: "ExprTermList",
2242							},
2243						},
2244						&ruleRefExpr{
2245							pos:  position{line: 201, col: 40, offset: 5435},
2246							name: "_",
2247						},
2248						&litMatcher{
2249							pos:        position{line: 201, col: 42, offset: 5437},
2250							val:        "}",
2251							ignoreCase: false,
2252						},
2253					},
2254				},
2255			},
2256		},
2257		{
2258			name: "Ref",
2259			pos:  position{line: 205, col: 1, offset: 5491},
2260			expr: &actionExpr{
2261				pos: position{line: 205, col: 8, offset: 5498},
2262				run: (*parser).callonRef1,
2263				expr: &seqExpr{
2264					pos: position{line: 205, col: 8, offset: 5498},
2265					exprs: []interface{}{
2266						&labeledExpr{
2267							pos:   position{line: 205, col: 8, offset: 5498},
2268							label: "head",
2269							expr: &ruleRefExpr{
2270								pos:  position{line: 205, col: 13, offset: 5503},
2271								name: "Var",
2272							},
2273						},
2274						&labeledExpr{
2275							pos:   position{line: 205, col: 17, offset: 5507},
2276							label: "rest",
2277							expr: &oneOrMoreExpr{
2278								pos: position{line: 205, col: 22, offset: 5512},
2279								expr: &ruleRefExpr{
2280									pos:  position{line: 205, col: 22, offset: 5512},
2281									name: "RefOperand",
2282								},
2283							},
2284						},
2285					},
2286				},
2287			},
2288		},
2289		{
2290			name: "RefOperand",
2291			pos:  position{line: 209, col: 1, offset: 5580},
2292			expr: &choiceExpr{
2293				pos: position{line: 209, col: 15, offset: 5594},
2294				alternatives: []interface{}{
2295					&ruleRefExpr{
2296						pos:  position{line: 209, col: 15, offset: 5594},
2297						name: "RefOperandDot",
2298					},
2299					&ruleRefExpr{
2300						pos:  position{line: 209, col: 31, offset: 5610},
2301						name: "RefOperandCanonical",
2302					},
2303				},
2304			},
2305		},
2306		{
2307			name: "RefOperandDot",
2308			pos:  position{line: 211, col: 1, offset: 5631},
2309			expr: &actionExpr{
2310				pos: position{line: 211, col: 18, offset: 5648},
2311				run: (*parser).callonRefOperandDot1,
2312				expr: &seqExpr{
2313					pos: position{line: 211, col: 18, offset: 5648},
2314					exprs: []interface{}{
2315						&litMatcher{
2316							pos:        position{line: 211, col: 18, offset: 5648},
2317							val:        ".",
2318							ignoreCase: false,
2319						},
2320						&labeledExpr{
2321							pos:   position{line: 211, col: 22, offset: 5652},
2322							label: "val",
2323							expr: &ruleRefExpr{
2324								pos:  position{line: 211, col: 26, offset: 5656},
2325								name: "Var",
2326							},
2327						},
2328					},
2329				},
2330			},
2331		},
2332		{
2333			name: "RefOperandCanonical",
2334			pos:  position{line: 215, col: 1, offset: 5719},
2335			expr: &actionExpr{
2336				pos: position{line: 215, col: 24, offset: 5742},
2337				run: (*parser).callonRefOperandCanonical1,
2338				expr: &seqExpr{
2339					pos: position{line: 215, col: 24, offset: 5742},
2340					exprs: []interface{}{
2341						&litMatcher{
2342							pos:        position{line: 215, col: 24, offset: 5742},
2343							val:        "[",
2344							ignoreCase: false,
2345						},
2346						&labeledExpr{
2347							pos:   position{line: 215, col: 28, offset: 5746},
2348							label: "val",
2349							expr: &ruleRefExpr{
2350								pos:  position{line: 215, col: 32, offset: 5750},
2351								name: "ExprTerm",
2352							},
2353						},
2354						&litMatcher{
2355							pos:        position{line: 215, col: 41, offset: 5759},
2356							val:        "]",
2357							ignoreCase: false,
2358						},
2359					},
2360				},
2361			},
2362		},
2363		{
2364			name: "Var",
2365			pos:  position{line: 219, col: 1, offset: 5788},
2366			expr: &actionExpr{
2367				pos: position{line: 219, col: 8, offset: 5795},
2368				run: (*parser).callonVar1,
2369				expr: &labeledExpr{
2370					pos:   position{line: 219, col: 8, offset: 5795},
2371					label: "val",
2372					expr: &ruleRefExpr{
2373						pos:  position{line: 219, col: 12, offset: 5799},
2374						name: "VarChecked",
2375					},
2376				},
2377			},
2378		},
2379		{
2380			name: "VarChecked",
2381			pos:  position{line: 223, col: 1, offset: 5854},
2382			expr: &seqExpr{
2383				pos: position{line: 223, col: 15, offset: 5868},
2384				exprs: []interface{}{
2385					&labeledExpr{
2386						pos:   position{line: 223, col: 15, offset: 5868},
2387						label: "val",
2388						expr: &ruleRefExpr{
2389							pos:  position{line: 223, col: 19, offset: 5872},
2390							name: "VarUnchecked",
2391						},
2392					},
2393					&notCodeExpr{
2394						pos: position{line: 223, col: 32, offset: 5885},
2395						run: (*parser).callonVarChecked4,
2396					},
2397				},
2398			},
2399		},
2400		{
2401			name: "VarUnchecked",
2402			pos:  position{line: 227, col: 1, offset: 5950},
2403			expr: &actionExpr{
2404				pos: position{line: 227, col: 17, offset: 5966},
2405				run: (*parser).callonVarUnchecked1,
2406				expr: &seqExpr{
2407					pos: position{line: 227, col: 17, offset: 5966},
2408					exprs: []interface{}{
2409						&ruleRefExpr{
2410							pos:  position{line: 227, col: 17, offset: 5966},
2411							name: "AsciiLetter",
2412						},
2413						&zeroOrMoreExpr{
2414							pos: position{line: 227, col: 29, offset: 5978},
2415							expr: &choiceExpr{
2416								pos: position{line: 227, col: 30, offset: 5979},
2417								alternatives: []interface{}{
2418									&ruleRefExpr{
2419										pos:  position{line: 227, col: 30, offset: 5979},
2420										name: "AsciiLetter",
2421									},
2422									&ruleRefExpr{
2423										pos:  position{line: 227, col: 44, offset: 5993},
2424										name: "DecimalDigit",
2425									},
2426								},
2427							},
2428						},
2429					},
2430				},
2431			},
2432		},
2433		{
2434			name: "Number",
2435			pos:  position{line: 231, col: 1, offset: 6060},
2436			expr: &actionExpr{
2437				pos: position{line: 231, col: 11, offset: 6070},
2438				run: (*parser).callonNumber1,
2439				expr: &seqExpr{
2440					pos: position{line: 231, col: 11, offset: 6070},
2441					exprs: []interface{}{
2442						&zeroOrOneExpr{
2443							pos: position{line: 231, col: 11, offset: 6070},
2444							expr: &litMatcher{
2445								pos:        position{line: 231, col: 11, offset: 6070},
2446								val:        "-",
2447								ignoreCase: false,
2448							},
2449						},
2450						&choiceExpr{
2451							pos: position{line: 231, col: 18, offset: 6077},
2452							alternatives: []interface{}{
2453								&ruleRefExpr{
2454									pos:  position{line: 231, col: 18, offset: 6077},
2455									name: "Float",
2456								},
2457								&ruleRefExpr{
2458									pos:  position{line: 231, col: 26, offset: 6085},
2459									name: "Integer",
2460								},
2461							},
2462						},
2463					},
2464				},
2465			},
2466		},
2467		{
2468			name: "Float",
2469			pos:  position{line: 235, col: 1, offset: 6150},
2470			expr: &choiceExpr{
2471				pos: position{line: 235, col: 10, offset: 6159},
2472				alternatives: []interface{}{
2473					&ruleRefExpr{
2474						pos:  position{line: 235, col: 10, offset: 6159},
2475						name: "ExponentFloat",
2476					},
2477					&ruleRefExpr{
2478						pos:  position{line: 235, col: 26, offset: 6175},
2479						name: "PointFloat",
2480					},
2481				},
2482			},
2483		},
2484		{
2485			name: "ExponentFloat",
2486			pos:  position{line: 237, col: 1, offset: 6187},
2487			expr: &seqExpr{
2488				pos: position{line: 237, col: 18, offset: 6204},
2489				exprs: []interface{}{
2490					&choiceExpr{
2491						pos: position{line: 237, col: 20, offset: 6206},
2492						alternatives: []interface{}{
2493							&ruleRefExpr{
2494								pos:  position{line: 237, col: 20, offset: 6206},
2495								name: "PointFloat",
2496							},
2497							&ruleRefExpr{
2498								pos:  position{line: 237, col: 33, offset: 6219},
2499								name: "Integer",
2500							},
2501						},
2502					},
2503					&ruleRefExpr{
2504						pos:  position{line: 237, col: 43, offset: 6229},
2505						name: "Exponent",
2506					},
2507				},
2508			},
2509		},
2510		{
2511			name: "PointFloat",
2512			pos:  position{line: 239, col: 1, offset: 6239},
2513			expr: &seqExpr{
2514				pos: position{line: 239, col: 15, offset: 6253},
2515				exprs: []interface{}{
2516					&zeroOrOneExpr{
2517						pos: position{line: 239, col: 15, offset: 6253},
2518						expr: &ruleRefExpr{
2519							pos:  position{line: 239, col: 15, offset: 6253},
2520							name: "Integer",
2521						},
2522					},
2523					&ruleRefExpr{
2524						pos:  position{line: 239, col: 24, offset: 6262},
2525						name: "Fraction",
2526					},
2527				},
2528			},
2529		},
2530		{
2531			name: "Fraction",
2532			pos:  position{line: 241, col: 1, offset: 6272},
2533			expr: &seqExpr{
2534				pos: position{line: 241, col: 13, offset: 6284},
2535				exprs: []interface{}{
2536					&litMatcher{
2537						pos:        position{line: 241, col: 13, offset: 6284},
2538						val:        ".",
2539						ignoreCase: false,
2540					},
2541					&oneOrMoreExpr{
2542						pos: position{line: 241, col: 17, offset: 6288},
2543						expr: &ruleRefExpr{
2544							pos:  position{line: 241, col: 17, offset: 6288},
2545							name: "DecimalDigit",
2546						},
2547					},
2548				},
2549			},
2550		},
2551		{
2552			name: "Exponent",
2553			pos:  position{line: 243, col: 1, offset: 6303},
2554			expr: &seqExpr{
2555				pos: position{line: 243, col: 13, offset: 6315},
2556				exprs: []interface{}{
2557					&litMatcher{
2558						pos:        position{line: 243, col: 13, offset: 6315},
2559						val:        "e",
2560						ignoreCase: true,
2561					},
2562					&zeroOrOneExpr{
2563						pos: position{line: 243, col: 18, offset: 6320},
2564						expr: &charClassMatcher{
2565							pos:        position{line: 243, col: 18, offset: 6320},
2566							val:        "[+-]",
2567							chars:      []rune{'+', '-'},
2568							ignoreCase: false,
2569							inverted:   false,
2570						},
2571					},
2572					&oneOrMoreExpr{
2573						pos: position{line: 243, col: 24, offset: 6326},
2574						expr: &ruleRefExpr{
2575							pos:  position{line: 243, col: 24, offset: 6326},
2576							name: "DecimalDigit",
2577						},
2578					},
2579				},
2580			},
2581		},
2582		{
2583			name: "Integer",
2584			pos:  position{line: 245, col: 1, offset: 6341},
2585			expr: &choiceExpr{
2586				pos: position{line: 245, col: 12, offset: 6352},
2587				alternatives: []interface{}{
2588					&litMatcher{
2589						pos:        position{line: 245, col: 12, offset: 6352},
2590						val:        "0",
2591						ignoreCase: false,
2592					},
2593					&seqExpr{
2594						pos: position{line: 245, col: 20, offset: 6360},
2595						exprs: []interface{}{
2596							&ruleRefExpr{
2597								pos:  position{line: 245, col: 20, offset: 6360},
2598								name: "NonZeroDecimalDigit",
2599							},
2600							&zeroOrMoreExpr{
2601								pos: position{line: 245, col: 40, offset: 6380},
2602								expr: &ruleRefExpr{
2603									pos:  position{line: 245, col: 40, offset: 6380},
2604									name: "DecimalDigit",
2605								},
2606							},
2607						},
2608					},
2609				},
2610			},
2611		},
2612		{
2613			name: "String",
2614			pos:  position{line: 247, col: 1, offset: 6397},
2615			expr: &choiceExpr{
2616				pos: position{line: 247, col: 11, offset: 6407},
2617				alternatives: []interface{}{
2618					&ruleRefExpr{
2619						pos:  position{line: 247, col: 11, offset: 6407},
2620						name: "QuotedString",
2621					},
2622					&ruleRefExpr{
2623						pos:  position{line: 247, col: 26, offset: 6422},
2624						name: "RawString",
2625					},
2626				},
2627			},
2628		},
2629		{
2630			name: "QuotedString",
2631			pos:  position{line: 249, col: 1, offset: 6433},
2632			expr: &actionExpr{
2633				pos: position{line: 249, col: 17, offset: 6449},
2634				run: (*parser).callonQuotedString1,
2635				expr: &seqExpr{
2636					pos: position{line: 249, col: 17, offset: 6449},
2637					exprs: []interface{}{
2638						&litMatcher{
2639							pos:        position{line: 249, col: 17, offset: 6449},
2640							val:        "\"",
2641							ignoreCase: false,
2642						},
2643						&zeroOrMoreExpr{
2644							pos: position{line: 249, col: 21, offset: 6453},
2645							expr: &ruleRefExpr{
2646								pos:  position{line: 249, col: 21, offset: 6453},
2647								name: "Char",
2648							},
2649						},
2650						&litMatcher{
2651							pos:        position{line: 249, col: 27, offset: 6459},
2652							val:        "\"",
2653							ignoreCase: false,
2654						},
2655					},
2656				},
2657			},
2658		},
2659		{
2660			name: "RawString",
2661			pos:  position{line: 253, col: 1, offset: 6518},
2662			expr: &actionExpr{
2663				pos: position{line: 253, col: 14, offset: 6531},
2664				run: (*parser).callonRawString1,
2665				expr: &seqExpr{
2666					pos: position{line: 253, col: 14, offset: 6531},
2667					exprs: []interface{}{
2668						&litMatcher{
2669							pos:        position{line: 253, col: 14, offset: 6531},
2670							val:        "`",
2671							ignoreCase: false,
2672						},
2673						&zeroOrMoreExpr{
2674							pos: position{line: 253, col: 18, offset: 6535},
2675							expr: &charClassMatcher{
2676								pos:        position{line: 253, col: 18, offset: 6535},
2677								val:        "[^`]",
2678								chars:      []rune{'`'},
2679								ignoreCase: false,
2680								inverted:   true,
2681							},
2682						},
2683						&litMatcher{
2684							pos:        position{line: 253, col: 24, offset: 6541},
2685							val:        "`",
2686							ignoreCase: false,
2687						},
2688					},
2689				},
2690			},
2691		},
2692		{
2693			name: "Bool",
2694			pos:  position{line: 257, col: 1, offset: 6603},
2695			expr: &actionExpr{
2696				pos: position{line: 257, col: 9, offset: 6611},
2697				run: (*parser).callonBool1,
2698				expr: &labeledExpr{
2699					pos:   position{line: 257, col: 9, offset: 6611},
2700					label: "val",
2701					expr: &choiceExpr{
2702						pos: position{line: 257, col: 14, offset: 6616},
2703						alternatives: []interface{}{
2704							&litMatcher{
2705								pos:        position{line: 257, col: 14, offset: 6616},
2706								val:        "true",
2707								ignoreCase: false,
2708							},
2709							&litMatcher{
2710								pos:        position{line: 257, col: 23, offset: 6625},
2711								val:        "false",
2712								ignoreCase: false,
2713							},
2714						},
2715					},
2716				},
2717			},
2718		},
2719		{
2720			name: "Null",
2721			pos:  position{line: 261, col: 1, offset: 6687},
2722			expr: &actionExpr{
2723				pos: position{line: 261, col: 9, offset: 6695},
2724				run: (*parser).callonNull1,
2725				expr: &litMatcher{
2726					pos:        position{line: 261, col: 9, offset: 6695},
2727					val:        "null",
2728					ignoreCase: false,
2729				},
2730			},
2731		},
2732		{
2733			name: "AsciiLetter",
2734			pos:  position{line: 265, col: 1, offset: 6747},
2735			expr: &charClassMatcher{
2736				pos:        position{line: 265, col: 16, offset: 6762},
2737				val:        "[A-Za-z_]",
2738				chars:      []rune{'_'},
2739				ranges:     []rune{'A', 'Z', 'a', 'z'},
2740				ignoreCase: false,
2741				inverted:   false,
2742			},
2743		},
2744		{
2745			name: "Char",
2746			pos:  position{line: 267, col: 1, offset: 6773},
2747			expr: &choiceExpr{
2748				pos: position{line: 267, col: 9, offset: 6781},
2749				alternatives: []interface{}{
2750					&seqExpr{
2751						pos: position{line: 267, col: 11, offset: 6783},
2752						exprs: []interface{}{
2753							&notExpr{
2754								pos: position{line: 267, col: 11, offset: 6783},
2755								expr: &ruleRefExpr{
2756									pos:  position{line: 267, col: 12, offset: 6784},
2757									name: "EscapedChar",
2758								},
2759							},
2760							&anyMatcher{
2761								line: 267, col: 24, offset: 6796,
2762							},
2763						},
2764					},
2765					&seqExpr{
2766						pos: position{line: 267, col: 32, offset: 6804},
2767						exprs: []interface{}{
2768							&litMatcher{
2769								pos:        position{line: 267, col: 32, offset: 6804},
2770								val:        "\\",
2771								ignoreCase: false,
2772							},
2773							&ruleRefExpr{
2774								pos:  position{line: 267, col: 37, offset: 6809},
2775								name: "EscapeSequence",
2776							},
2777						},
2778					},
2779				},
2780			},
2781		},
2782		{
2783			name: "EscapedChar",
2784			pos:  position{line: 269, col: 1, offset: 6827},
2785			expr: &charClassMatcher{
2786				pos:        position{line: 269, col: 16, offset: 6842},
2787				val:        "[\\x00-\\x1f\"\\\\]",
2788				chars:      []rune{'"', '\\'},
2789				ranges:     []rune{'\x00', '\x1f'},
2790				ignoreCase: false,
2791				inverted:   false,
2792			},
2793		},
2794		{
2795			name: "EscapeSequence",
2796			pos:  position{line: 271, col: 1, offset: 6858},
2797			expr: &choiceExpr{
2798				pos: position{line: 271, col: 19, offset: 6876},
2799				alternatives: []interface{}{
2800					&ruleRefExpr{
2801						pos:  position{line: 271, col: 19, offset: 6876},
2802						name: "SingleCharEscape",
2803					},
2804					&ruleRefExpr{
2805						pos:  position{line: 271, col: 38, offset: 6895},
2806						name: "UnicodeEscape",
2807					},
2808				},
2809			},
2810		},
2811		{
2812			name: "SingleCharEscape",
2813			pos:  position{line: 273, col: 1, offset: 6910},
2814			expr: &charClassMatcher{
2815				pos:        position{line: 273, col: 21, offset: 6930},
2816				val:        "[ \" \\\\ / b f n r t ]",
2817				chars:      []rune{' ', '"', ' ', '\\', ' ', '/', ' ', 'b', ' ', 'f', ' ', 'n', ' ', 'r', ' ', 't', ' '},
2818				ignoreCase: false,
2819				inverted:   false,
2820			},
2821		},
2822		{
2823			name: "UnicodeEscape",
2824			pos:  position{line: 275, col: 1, offset: 6952},
2825			expr: &seqExpr{
2826				pos: position{line: 275, col: 18, offset: 6969},
2827				exprs: []interface{}{
2828					&litMatcher{
2829						pos:        position{line: 275, col: 18, offset: 6969},
2830						val:        "u",
2831						ignoreCase: false,
2832					},
2833					&ruleRefExpr{
2834						pos:  position{line: 275, col: 22, offset: 6973},
2835						name: "HexDigit",
2836					},
2837					&ruleRefExpr{
2838						pos:  position{line: 275, col: 31, offset: 6982},
2839						name: "HexDigit",
2840					},
2841					&ruleRefExpr{
2842						pos:  position{line: 275, col: 40, offset: 6991},
2843						name: "HexDigit",
2844					},
2845					&ruleRefExpr{
2846						pos:  position{line: 275, col: 49, offset: 7000},
2847						name: "HexDigit",
2848					},
2849				},
2850			},
2851		},
2852		{
2853			name: "DecimalDigit",
2854			pos:  position{line: 277, col: 1, offset: 7010},
2855			expr: &charClassMatcher{
2856				pos:        position{line: 277, col: 17, offset: 7026},
2857				val:        "[0-9]",
2858				ranges:     []rune{'0', '9'},
2859				ignoreCase: false,
2860				inverted:   false,
2861			},
2862		},
2863		{
2864			name: "NonZeroDecimalDigit",
2865			pos:  position{line: 279, col: 1, offset: 7033},
2866			expr: &charClassMatcher{
2867				pos:        position{line: 279, col: 24, offset: 7056},
2868				val:        "[1-9]",
2869				ranges:     []rune{'1', '9'},
2870				ignoreCase: false,
2871				inverted:   false,
2872			},
2873		},
2874		{
2875			name: "HexDigit",
2876			pos:  position{line: 281, col: 1, offset: 7063},
2877			expr: &charClassMatcher{
2878				pos:        position{line: 281, col: 13, offset: 7075},
2879				val:        "[0-9a-fA-F]",
2880				ranges:     []rune{'0', '9', 'a', 'f', 'A', 'F'},
2881				ignoreCase: false,
2882				inverted:   false,
2883			},
2884		},
2885		{
2886			name:        "ws",
2887			displayName: "\"whitespace\"",
2888			pos:         position{line: 283, col: 1, offset: 7088},
2889			expr: &oneOrMoreExpr{
2890				pos: position{line: 283, col: 20, offset: 7107},
2891				expr: &charClassMatcher{
2892					pos:        position{line: 283, col: 20, offset: 7107},
2893					val:        "[ \\t\\r\\n]",
2894					chars:      []rune{' ', '\t', '\r', '\n'},
2895					ignoreCase: false,
2896					inverted:   false,
2897				},
2898			},
2899		},
2900		{
2901			name:        "_",
2902			displayName: "\"whitespace\"",
2903			pos:         position{line: 285, col: 1, offset: 7119},
2904			expr: &zeroOrMoreExpr{
2905				pos: position{line: 285, col: 19, offset: 7137},
2906				expr: &choiceExpr{
2907					pos: position{line: 285, col: 21, offset: 7139},
2908					alternatives: []interface{}{
2909						&charClassMatcher{
2910							pos:        position{line: 285, col: 21, offset: 7139},
2911							val:        "[ \\t\\r\\n]",
2912							chars:      []rune{' ', '\t', '\r', '\n'},
2913							ignoreCase: false,
2914							inverted:   false,
2915						},
2916						&ruleRefExpr{
2917							pos:  position{line: 285, col: 33, offset: 7151},
2918							name: "Comment",
2919						},
2920					},
2921				},
2922			},
2923		},
2924		{
2925			name: "Comment",
2926			pos:  position{line: 287, col: 1, offset: 7163},
2927			expr: &actionExpr{
2928				pos: position{line: 287, col: 12, offset: 7174},
2929				run: (*parser).callonComment1,
2930				expr: &seqExpr{
2931					pos: position{line: 287, col: 12, offset: 7174},
2932					exprs: []interface{}{
2933						&zeroOrMoreExpr{
2934							pos: position{line: 287, col: 12, offset: 7174},
2935							expr: &charClassMatcher{
2936								pos:        position{line: 287, col: 12, offset: 7174},
2937								val:        "[ \\t]",
2938								chars:      []rune{' ', '\t'},
2939								ignoreCase: false,
2940								inverted:   false,
2941							},
2942						},
2943						&litMatcher{
2944							pos:        position{line: 287, col: 19, offset: 7181},
2945							val:        "#",
2946							ignoreCase: false,
2947						},
2948						&labeledExpr{
2949							pos:   position{line: 287, col: 23, offset: 7185},
2950							label: "text",
2951							expr: &zeroOrMoreExpr{
2952								pos: position{line: 287, col: 28, offset: 7190},
2953								expr: &charClassMatcher{
2954									pos:        position{line: 287, col: 28, offset: 7190},
2955									val:        "[^\\r\\n]",
2956									chars:      []rune{'\r', '\n'},
2957									ignoreCase: false,
2958									inverted:   true,
2959								},
2960							},
2961						},
2962					},
2963				},
2964			},
2965		},
2966		{
2967			name: "EOF",
2968			pos:  position{line: 291, col: 1, offset: 7237},
2969			expr: &notExpr{
2970				pos: position{line: 291, col: 8, offset: 7244},
2971				expr: &anyMatcher{
2972					line: 291, col: 9, offset: 7245,
2973				},
2974			},
2975		},
2976	},
2977}
2978
2979func (c *current) onProgram1(vals interface{}) (interface{}, error) {
2980	return makeProgram(c, vals)
2981}
2982
2983func (p *parser) callonProgram1() (interface{}, error) {
2984	stack := p.vstack[len(p.vstack)-1]
2985	_ = stack
2986	return p.cur.onProgram1(stack["vals"])
2987}
2988
2989func (c *current) onStmt1(val interface{}) (interface{}, error) {
2990	return val, nil
2991}
2992
2993func (p *parser) callonStmt1() (interface{}, error) {
2994	stack := p.vstack[len(p.vstack)-1]
2995	_ = stack
2996	return p.cur.onStmt1(stack["val"])
2997}
2998
2999func (c *current) onPackage1(val interface{}) (interface{}, error) {
3000	return makePackage(currentLocation(c), val)
3001
3002}
3003
3004func (p *parser) callonPackage1() (interface{}, error) {
3005	stack := p.vstack[len(p.vstack)-1]
3006	_ = stack
3007	return p.cur.onPackage1(stack["val"])
3008}
3009
3010func (c *current) onImport1(path, alias interface{}) (interface{}, error) {
3011	return makeImport(currentLocation(c), path, alias)
3012}
3013
3014func (p *parser) callonImport1() (interface{}, error) {
3015	stack := p.vstack[len(p.vstack)-1]
3016	_ = stack
3017	return p.cur.onImport1(stack["path"], stack["alias"])
3018}
3019
3020func (c *current) onDefaultRules1(name, value interface{}) (interface{}, error) {
3021	return makeDefaultRule(currentLocation(c), name, value)
3022}
3023
3024func (p *parser) callonDefaultRules1() (interface{}, error) {
3025	stack := p.vstack[len(p.vstack)-1]
3026	_ = stack
3027	return p.cur.onDefaultRules1(stack["name"], stack["value"])
3028}
3029
3030func (c *current) onNormalRules1(head, rest interface{}) (interface{}, error) {
3031	return makeRule(currentLocation(c), head, rest)
3032}
3033
3034func (p *parser) callonNormalRules1() (interface{}, error) {
3035	stack := p.vstack[len(p.vstack)-1]
3036	_ = stack
3037	return p.cur.onNormalRules1(stack["head"], stack["rest"])
3038}
3039
3040func (c *current) onRuleHead1(name, args, key, value interface{}) (interface{}, error) {
3041	return makeRuleHead(currentLocation(c), name, args, key, value)
3042}
3043
3044func (p *parser) callonRuleHead1() (interface{}, error) {
3045	stack := p.vstack[len(p.vstack)-1]
3046	_ = stack
3047	return p.cur.onRuleHead1(stack["name"], stack["args"], stack["key"], stack["value"])
3048}
3049
3050func (c *current) onArgs1(list interface{}) (interface{}, error) {
3051	return makeArgs(list)
3052}
3053
3054func (p *parser) callonArgs1() (interface{}, error) {
3055	stack := p.vstack[len(p.vstack)-1]
3056	_ = stack
3057	return p.cur.onArgs1(stack["list"])
3058}
3059
3060func (c *current) onElse1(value, body interface{}) (interface{}, error) {
3061	return makeRuleExt(currentLocation(c), value, body)
3062}
3063
3064func (p *parser) callonElse1() (interface{}, error) {
3065	stack := p.vstack[len(p.vstack)-1]
3066	_ = stack
3067	return p.cur.onElse1(stack["value"], stack["body"])
3068}
3069
3070func (c *current) onRuleDup1(b interface{}) (interface{}, error) {
3071	return ruleExt{loc: currentLocation(c), body: b.(Body)}, nil
3072}
3073
3074func (p *parser) callonRuleDup1() (interface{}, error) {
3075	stack := p.vstack[len(p.vstack)-1]
3076	_ = stack
3077	return p.cur.onRuleDup1(stack["b"])
3078}
3079
3080func (c *current) onNonEmptyBraceEnclosedBody1(val interface{}) (interface{}, error) {
3081	if val == nil {
3082		panic("body must be non-empty")
3083	}
3084	return val, nil
3085}
3086
3087func (p *parser) callonNonEmptyBraceEnclosedBody1() (interface{}, error) {
3088	stack := p.vstack[len(p.vstack)-1]
3089	_ = stack
3090	return p.cur.onNonEmptyBraceEnclosedBody1(stack["val"])
3091}
3092
3093func (c *current) onBraceEnclosedBody1(val interface{}) (interface{}, error) {
3094	return makeBraceEnclosedBody(currentLocation(c), val)
3095}
3096
3097func (p *parser) callonBraceEnclosedBody1() (interface{}, error) {
3098	stack := p.vstack[len(p.vstack)-1]
3099	_ = stack
3100	return p.cur.onBraceEnclosedBody1(stack["val"])
3101}
3102
3103func (c *current) onWhitespaceBody1(head, tail interface{}) (interface{}, error) {
3104	return makeBody(head, tail, 2)
3105}
3106
3107func (p *parser) callonWhitespaceBody1() (interface{}, error) {
3108	stack := p.vstack[len(p.vstack)-1]
3109	_ = stack
3110	return p.cur.onWhitespaceBody1(stack["head"], stack["tail"])
3111}
3112
3113func (c *current) onNonWhitespaceBody1(head, tail interface{}) (interface{}, error) {
3114	return makeBody(head, tail, 3)
3115}
3116
3117func (p *parser) callonNonWhitespaceBody1() (interface{}, error) {
3118	stack := p.vstack[len(p.vstack)-1]
3119	_ = stack
3120	return p.cur.onNonWhitespaceBody1(stack["head"], stack["tail"])
3121}
3122
3123func (c *current) onLiteral1(negated, value, with interface{}) (interface{}, error) {
3124	return makeLiteral(negated, value, with)
3125}
3126
3127func (p *parser) callonLiteral1() (interface{}, error) {
3128	stack := p.vstack[len(p.vstack)-1]
3129	_ = stack
3130	return p.cur.onLiteral1(stack["negated"], stack["value"], stack["with"])
3131}
3132
3133func (c *current) onLiteralExpr1(lhs, rest interface{}) (interface{}, error) {
3134	return makeLiteralExpr(currentLocation(c), lhs, rest)
3135}
3136
3137func (p *parser) callonLiteralExpr1() (interface{}, error) {
3138	stack := p.vstack[len(p.vstack)-1]
3139	_ = stack
3140	return p.cur.onLiteralExpr1(stack["lhs"], stack["rest"])
3141}
3142
3143func (c *current) onLiteralExprOperator1(val interface{}) (interface{}, error) {
3144	return makeInfixOperator(currentLocation(c), c.text)
3145}
3146
3147func (p *parser) callonLiteralExprOperator1() (interface{}, error) {
3148	stack := p.vstack[len(p.vstack)-1]
3149	_ = stack
3150	return p.cur.onLiteralExprOperator1(stack["val"])
3151}
3152
3153func (c *current) onNotKeyword1(val interface{}) (interface{}, error) {
3154	return val != nil, nil
3155}
3156
3157func (p *parser) callonNotKeyword1() (interface{}, error) {
3158	stack := p.vstack[len(p.vstack)-1]
3159	_ = stack
3160	return p.cur.onNotKeyword1(stack["val"])
3161}
3162
3163func (c *current) onWithKeywordList1(head, rest interface{}) (interface{}, error) {
3164	return makeWithKeywordList(head, rest)
3165}
3166
3167func (p *parser) callonWithKeywordList1() (interface{}, error) {
3168	stack := p.vstack[len(p.vstack)-1]
3169	_ = stack
3170	return p.cur.onWithKeywordList1(stack["head"], stack["rest"])
3171}
3172
3173func (c *current) onWithKeyword1(target, value interface{}) (interface{}, error) {
3174	return makeWithKeyword(currentLocation(c), target, value)
3175}
3176
3177func (p *parser) callonWithKeyword1() (interface{}, error) {
3178	stack := p.vstack[len(p.vstack)-1]
3179	_ = stack
3180	return p.cur.onWithKeyword1(stack["target"], stack["value"])
3181}
3182
3183func (c *current) onExprTerm1(lhs, rest interface{}) (interface{}, error) {
3184	return makeExprTerm(currentLocation(c), lhs, rest)
3185}
3186
3187func (p *parser) callonExprTerm1() (interface{}, error) {
3188	stack := p.vstack[len(p.vstack)-1]
3189	_ = stack
3190	return p.cur.onExprTerm1(stack["lhs"], stack["rest"])
3191}
3192
3193func (c *current) onExprTermPairList1(head, tail interface{}) (interface{}, error) {
3194	return makeExprTermPairList(head, tail)
3195}
3196
3197func (p *parser) callonExprTermPairList1() (interface{}, error) {
3198	stack := p.vstack[len(p.vstack)-1]
3199	_ = stack
3200	return p.cur.onExprTermPairList1(stack["head"], stack["tail"])
3201}
3202
3203func (c *current) onExprTermList1(head, tail interface{}) (interface{}, error) {
3204	return makeExprTermList(head, tail)
3205}
3206
3207func (p *parser) callonExprTermList1() (interface{}, error) {
3208	stack := p.vstack[len(p.vstack)-1]
3209	_ = stack
3210	return p.cur.onExprTermList1(stack["head"], stack["tail"])
3211}
3212
3213func (c *current) onExprTermPair1(key, value interface{}) (interface{}, error) {
3214	return makeExprTermPair(key, value)
3215}
3216
3217func (p *parser) callonExprTermPair1() (interface{}, error) {
3218	stack := p.vstack[len(p.vstack)-1]
3219	_ = stack
3220	return p.cur.onExprTermPair1(stack["key"], stack["value"])
3221}
3222
3223func (c *current) onRelationOperator1(val interface{}) (interface{}, error) {
3224	return makeInfixOperator(currentLocation(c), c.text)
3225}
3226
3227func (p *parser) callonRelationOperator1() (interface{}, error) {
3228	stack := p.vstack[len(p.vstack)-1]
3229	_ = stack
3230	return p.cur.onRelationOperator1(stack["val"])
3231}
3232
3233func (c *current) onRelationExpr1(lhs, rest interface{}) (interface{}, error) {
3234	return makeExprTerm(currentLocation(c), lhs, rest)
3235}
3236
3237func (p *parser) callonRelationExpr1() (interface{}, error) {
3238	stack := p.vstack[len(p.vstack)-1]
3239	_ = stack
3240	return p.cur.onRelationExpr1(stack["lhs"], stack["rest"])
3241}
3242
3243func (c *current) onBitwiseOrOperator1(val interface{}) (interface{}, error) {
3244	return makeInfixOperator(currentLocation(c), c.text)
3245}
3246
3247func (p *parser) callonBitwiseOrOperator1() (interface{}, error) {
3248	stack := p.vstack[len(p.vstack)-1]
3249	_ = stack
3250	return p.cur.onBitwiseOrOperator1(stack["val"])
3251}
3252
3253func (c *current) onBitwiseOrExpr1(lhs, rest interface{}) (interface{}, error) {
3254	return makeExprTerm(currentLocation(c), lhs, rest)
3255}
3256
3257func (p *parser) callonBitwiseOrExpr1() (interface{}, error) {
3258	stack := p.vstack[len(p.vstack)-1]
3259	_ = stack
3260	return p.cur.onBitwiseOrExpr1(stack["lhs"], stack["rest"])
3261}
3262
3263func (c *current) onBitwiseAndOperator1(val interface{}) (interface{}, error) {
3264	return makeInfixOperator(currentLocation(c), c.text)
3265}
3266
3267func (p *parser) callonBitwiseAndOperator1() (interface{}, error) {
3268	stack := p.vstack[len(p.vstack)-1]
3269	_ = stack
3270	return p.cur.onBitwiseAndOperator1(stack["val"])
3271}
3272
3273func (c *current) onBitwiseAndExpr1(lhs, rest interface{}) (interface{}, error) {
3274	return makeExprTerm(currentLocation(c), lhs, rest)
3275}
3276
3277func (p *parser) callonBitwiseAndExpr1() (interface{}, error) {
3278	stack := p.vstack[len(p.vstack)-1]
3279	_ = stack
3280	return p.cur.onBitwiseAndExpr1(stack["lhs"], stack["rest"])
3281}
3282
3283func (c *current) onArithOperator1(val interface{}) (interface{}, error) {
3284	return makeInfixOperator(currentLocation(c), c.text)
3285}
3286
3287func (p *parser) callonArithOperator1() (interface{}, error) {
3288	stack := p.vstack[len(p.vstack)-1]
3289	_ = stack
3290	return p.cur.onArithOperator1(stack["val"])
3291}
3292
3293func (c *current) onArithExpr1(lhs, rest interface{}) (interface{}, error) {
3294	return makeExprTerm(currentLocation(c), lhs, rest)
3295}
3296
3297func (p *parser) callonArithExpr1() (interface{}, error) {
3298	stack := p.vstack[len(p.vstack)-1]
3299	_ = stack
3300	return p.cur.onArithExpr1(stack["lhs"], stack["rest"])
3301}
3302
3303func (c *current) onFactorOperator1(val interface{}) (interface{}, error) {
3304	return makeInfixOperator(currentLocation(c), c.text)
3305}
3306
3307func (p *parser) callonFactorOperator1() (interface{}, error) {
3308	stack := p.vstack[len(p.vstack)-1]
3309	_ = stack
3310	return p.cur.onFactorOperator1(stack["val"])
3311}
3312
3313func (c *current) onFactorExpr2(expr interface{}) (interface{}, error) {
3314	return expr, nil
3315}
3316
3317func (p *parser) callonFactorExpr2() (interface{}, error) {
3318	stack := p.vstack[len(p.vstack)-1]
3319	_ = stack
3320	return p.cur.onFactorExpr2(stack["expr"])
3321}
3322
3323func (c *current) onFactorExpr10(term interface{}) (interface{}, error) {
3324	return term, nil
3325}
3326
3327func (p *parser) callonFactorExpr10() (interface{}, error) {
3328	stack := p.vstack[len(p.vstack)-1]
3329	_ = stack
3330	return p.cur.onFactorExpr10(stack["term"])
3331}
3332
3333func (c *current) onCall1(operator, args interface{}) (interface{}, error) {
3334	return makeCall(currentLocation(c), operator, args)
3335}
3336
3337func (p *parser) callonCall1() (interface{}, error) {
3338	stack := p.vstack[len(p.vstack)-1]
3339	_ = stack
3340	return p.cur.onCall1(stack["operator"], stack["args"])
3341}
3342
3343func (c *current) onTerm1(val interface{}) (interface{}, error) {
3344	return val, nil
3345}
3346
3347func (p *parser) callonTerm1() (interface{}, error) {
3348	stack := p.vstack[len(p.vstack)-1]
3349	_ = stack
3350	return p.cur.onTerm1(stack["val"])
3351}
3352
3353func (c *current) onTermPair1(key, value interface{}) (interface{}, error) {
3354	return makeExprTermPair(key, value)
3355}
3356
3357func (p *parser) callonTermPair1() (interface{}, error) {
3358	stack := p.vstack[len(p.vstack)-1]
3359	_ = stack
3360	return p.cur.onTermPair1(stack["key"], stack["value"])
3361}
3362
3363func (c *current) onArrayComprehension1(head, body interface{}) (interface{}, error) {
3364	return makeArrayComprehension(currentLocation(c), head, body)
3365}
3366
3367func (p *parser) callonArrayComprehension1() (interface{}, error) {
3368	stack := p.vstack[len(p.vstack)-1]
3369	_ = stack
3370	return p.cur.onArrayComprehension1(stack["head"], stack["body"])
3371}
3372
3373func (c *current) onObjectComprehension1(head, body interface{}) (interface{}, error) {
3374	return makeObjectComprehension(currentLocation(c), head, body)
3375}
3376
3377func (p *parser) callonObjectComprehension1() (interface{}, error) {
3378	stack := p.vstack[len(p.vstack)-1]
3379	_ = stack
3380	return p.cur.onObjectComprehension1(stack["head"], stack["body"])
3381}
3382
3383func (c *current) onSetComprehension1(head, body interface{}) (interface{}, error) {
3384	return makeSetComprehension(currentLocation(c), head, body)
3385}
3386
3387func (p *parser) callonSetComprehension1() (interface{}, error) {
3388	stack := p.vstack[len(p.vstack)-1]
3389	_ = stack
3390	return p.cur.onSetComprehension1(stack["head"], stack["body"])
3391}
3392
3393func (c *current) onObject1(list interface{}) (interface{}, error) {
3394	return makeObject(currentLocation(c), list)
3395}
3396
3397func (p *parser) callonObject1() (interface{}, error) {
3398	stack := p.vstack[len(p.vstack)-1]
3399	_ = stack
3400	return p.cur.onObject1(stack["list"])
3401}
3402
3403func (c *current) onArray1(list interface{}) (interface{}, error) {
3404	return makeArray(currentLocation(c), list)
3405}
3406
3407func (p *parser) callonArray1() (interface{}, error) {
3408	stack := p.vstack[len(p.vstack)-1]
3409	_ = stack
3410	return p.cur.onArray1(stack["list"])
3411}
3412
3413func (c *current) onSetEmpty1() (interface{}, error) {
3414	var empty []*Term
3415	return makeSet(currentLocation(c), empty)
3416}
3417
3418func (p *parser) callonSetEmpty1() (interface{}, error) {
3419	stack := p.vstack[len(p.vstack)-1]
3420	_ = stack
3421	return p.cur.onSetEmpty1()
3422}
3423
3424func (c *current) onSetNonEmpty1(list interface{}) (interface{}, error) {
3425	return makeSet(currentLocation(c), list)
3426}
3427
3428func (p *parser) callonSetNonEmpty1() (interface{}, error) {
3429	stack := p.vstack[len(p.vstack)-1]
3430	_ = stack
3431	return p.cur.onSetNonEmpty1(stack["list"])
3432}
3433
3434func (c *current) onRef1(head, rest interface{}) (interface{}, error) {
3435	return makeRef(currentLocation(c), head, rest)
3436}
3437
3438func (p *parser) callonRef1() (interface{}, error) {
3439	stack := p.vstack[len(p.vstack)-1]
3440	_ = stack
3441	return p.cur.onRef1(stack["head"], stack["rest"])
3442}
3443
3444func (c *current) onRefOperandDot1(val interface{}) (interface{}, error) {
3445	return makeRefOperandDot(currentLocation(c), val)
3446}
3447
3448func (p *parser) callonRefOperandDot1() (interface{}, error) {
3449	stack := p.vstack[len(p.vstack)-1]
3450	_ = stack
3451	return p.cur.onRefOperandDot1(stack["val"])
3452}
3453
3454func (c *current) onRefOperandCanonical1(val interface{}) (interface{}, error) {
3455	return val, nil
3456}
3457
3458func (p *parser) callonRefOperandCanonical1() (interface{}, error) {
3459	stack := p.vstack[len(p.vstack)-1]
3460	_ = stack
3461	return p.cur.onRefOperandCanonical1(stack["val"])
3462}
3463
3464func (c *current) onVar1(val interface{}) (interface{}, error) {
3465	return val.([]interface{})[0], nil
3466}
3467
3468func (p *parser) callonVar1() (interface{}, error) {
3469	stack := p.vstack[len(p.vstack)-1]
3470	_ = stack
3471	return p.cur.onVar1(stack["val"])
3472}
3473
3474func (c *current) onVarChecked4(val interface{}) (bool, error) {
3475	return IsKeyword(string(val.(*Term).Value.(Var))), nil
3476}
3477
3478func (p *parser) callonVarChecked4() (bool, error) {
3479	stack := p.vstack[len(p.vstack)-1]
3480	_ = stack
3481	return p.cur.onVarChecked4(stack["val"])
3482}
3483
3484func (c *current) onVarUnchecked1() (interface{}, error) {
3485	return makeVar(currentLocation(c), c.text)
3486}
3487
3488func (p *parser) callonVarUnchecked1() (interface{}, error) {
3489	stack := p.vstack[len(p.vstack)-1]
3490	_ = stack
3491	return p.cur.onVarUnchecked1()
3492}
3493
3494func (c *current) onNumber1() (interface{}, error) {
3495	return makeNumber(currentLocation(c), c.text)
3496}
3497
3498func (p *parser) callonNumber1() (interface{}, error) {
3499	stack := p.vstack[len(p.vstack)-1]
3500	_ = stack
3501	return p.cur.onNumber1()
3502}
3503
3504func (c *current) onQuotedString1() (interface{}, error) {
3505	return makeString(currentLocation(c), c.text)
3506}
3507
3508func (p *parser) callonQuotedString1() (interface{}, error) {
3509	stack := p.vstack[len(p.vstack)-1]
3510	_ = stack
3511	return p.cur.onQuotedString1()
3512}
3513
3514func (c *current) onRawString1() (interface{}, error) {
3515	return makeRawString(currentLocation(c), c.text)
3516}
3517
3518func (p *parser) callonRawString1() (interface{}, error) {
3519	stack := p.vstack[len(p.vstack)-1]
3520	_ = stack
3521	return p.cur.onRawString1()
3522}
3523
3524func (c *current) onBool1(val interface{}) (interface{}, error) {
3525	return makeBool(currentLocation(c), c.text)
3526}
3527
3528func (p *parser) callonBool1() (interface{}, error) {
3529	stack := p.vstack[len(p.vstack)-1]
3530	_ = stack
3531	return p.cur.onBool1(stack["val"])
3532}
3533
3534func (c *current) onNull1() (interface{}, error) {
3535	return makeNull(currentLocation(c))
3536}
3537
3538func (p *parser) callonNull1() (interface{}, error) {
3539	stack := p.vstack[len(p.vstack)-1]
3540	_ = stack
3541	return p.cur.onNull1()
3542}
3543
3544func (c *current) onComment1(text interface{}) (interface{}, error) {
3545	return makeComments(c, text)
3546}
3547
3548func (p *parser) callonComment1() (interface{}, error) {
3549	stack := p.vstack[len(p.vstack)-1]
3550	_ = stack
3551	return p.cur.onComment1(stack["text"])
3552}
3553
3554var (
3555	// errNoRule is returned when the grammar to parse has no rule.
3556	errNoRule = errors.New("grammar has no rule")
3557
3558	// errInvalidEntrypoint is returned when the specified entrypoint rule
3559	// does not exit.
3560	errInvalidEntrypoint = errors.New("invalid entrypoint")
3561
3562	// errInvalidEncoding is returned when the source is not properly
3563	// utf8-encoded.
3564	errInvalidEncoding = errors.New("invalid encoding")
3565
3566	// errMaxExprCnt is used to signal that the maximum number of
3567	// expressions have been parsed.
3568	errMaxExprCnt = errors.New("max number of expresssions parsed")
3569)
3570
3571// Option is a function that can set an option on the parser. It returns
3572// the previous setting as an Option.
3573type Option func(*parser) Option
3574
3575// MaxExpressions creates an Option to stop parsing after the provided
3576// number of expressions have been parsed, if the value is 0 then the parser will
3577// parse for as many steps as needed (possibly an infinite number).
3578//
3579// The default for maxExprCnt is 0.
3580func MaxExpressions(maxExprCnt uint64) Option {
3581	return func(p *parser) Option {
3582		oldMaxExprCnt := p.maxExprCnt
3583		p.maxExprCnt = maxExprCnt
3584		return MaxExpressions(oldMaxExprCnt)
3585	}
3586}
3587
3588// Entrypoint creates an Option to set the rule name to use as entrypoint.
3589// The rule name must have been specified in the -alternate-entrypoints
3590// if generating the parser with the -optimize-grammar flag, otherwise
3591// it may have been optimized out. Passing an empty string sets the
3592// entrypoint to the first rule in the grammar.
3593//
3594// The default is to start parsing at the first rule in the grammar.
3595func Entrypoint(ruleName string) Option {
3596	return func(p *parser) Option {
3597		oldEntrypoint := p.entrypoint
3598		p.entrypoint = ruleName
3599		if ruleName == "" {
3600			p.entrypoint = g.rules[0].name
3601		}
3602		return Entrypoint(oldEntrypoint)
3603	}
3604}
3605
3606// Statistics adds a user provided Stats struct to the parser to allow
3607// the user to process the results after the parsing has finished.
3608// Also the key for the "no match" counter is set.
3609//
3610// Example usage:
3611//
3612//     input := "input"
3613//     stats := Stats{}
3614//     _, err := Parse("input-file", []byte(input), Statistics(&stats, "no match"))
3615//     if err != nil {
3616//         log.Panicln(err)
3617//     }
3618//     b, err := json.MarshalIndent(stats.ChoiceAltCnt, "", "  ")
3619//     if err != nil {
3620//         log.Panicln(err)
3621//     }
3622//     fmt.Println(string(b))
3623//
3624func Statistics(stats *Stats, choiceNoMatch string) Option {
3625	return func(p *parser) Option {
3626		oldStats := p.Stats
3627		p.Stats = stats
3628		oldChoiceNoMatch := p.choiceNoMatch
3629		p.choiceNoMatch = choiceNoMatch
3630		if p.Stats.ChoiceAltCnt == nil {
3631			p.Stats.ChoiceAltCnt = make(map[string]map[string]int)
3632		}
3633		return Statistics(oldStats, oldChoiceNoMatch)
3634	}
3635}
3636
3637// Debug creates an Option to set the debug flag to b. When set to true,
3638// debugging information is printed to stdout while parsing.
3639//
3640// The default is false.
3641func Debug(b bool) Option {
3642	return func(p *parser) Option {
3643		old := p.debug
3644		p.debug = b
3645		return Debug(old)
3646	}
3647}
3648
3649// Memoize creates an Option to set the memoize flag to b. When set to true,
3650// the parser will cache all results so each expression is evaluated only
3651// once. This guarantees linear parsing time even for pathological cases,
3652// at the expense of more memory and slower times for typical cases.
3653//
3654// The default is false.
3655func Memoize(b bool) Option {
3656	return func(p *parser) Option {
3657		old := p.memoize
3658		p.memoize = b
3659		return Memoize(old)
3660	}
3661}
3662
3663// AllowInvalidUTF8 creates an Option to allow invalid UTF-8 bytes.
3664// Every invalid UTF-8 byte is treated as a utf8.RuneError (U+FFFD)
3665// by character class matchers and is matched by the any matcher.
3666// The returned matched value, c.text and c.offset are NOT affected.
3667//
3668// The default is false.
3669func AllowInvalidUTF8(b bool) Option {
3670	return func(p *parser) Option {
3671		old := p.allowInvalidUTF8
3672		p.allowInvalidUTF8 = b
3673		return AllowInvalidUTF8(old)
3674	}
3675}
3676
3677// Recover creates an Option to set the recover flag to b. When set to
3678// true, this causes the parser to recover from panics and convert it
3679// to an error. Setting it to false can be useful while debugging to
3680// access the full stack trace.
3681//
3682// The default is true.
3683func Recover(b bool) Option {
3684	return func(p *parser) Option {
3685		old := p.recover
3686		p.recover = b
3687		return Recover(old)
3688	}
3689}
3690
3691// GlobalStore creates an Option to set a key to a certain value in
3692// the globalStore.
3693func GlobalStore(key string, value interface{}) Option {
3694	return func(p *parser) Option {
3695		old := p.cur.globalStore[key]
3696		p.cur.globalStore[key] = value
3697		return GlobalStore(key, old)
3698	}
3699}
3700
3701// InitState creates an Option to set a key to a certain value in
3702// the global "state" store.
3703func InitState(key string, value interface{}) Option {
3704	return func(p *parser) Option {
3705		old := p.cur.state[key]
3706		p.cur.state[key] = value
3707		return InitState(key, old)
3708	}
3709}
3710
3711// ParseFile parses the file identified by filename.
3712func ParseFile(filename string, opts ...Option) (i interface{}, err error) {
3713	f, err := os.Open(filename)
3714	if err != nil {
3715		return nil, err
3716	}
3717	defer func() {
3718		if closeErr := f.Close(); closeErr != nil {
3719			err = closeErr
3720		}
3721	}()
3722	return ParseReader(filename, f, opts...)
3723}
3724
3725// ParseReader parses the data from r using filename as information in the
3726// error messages.
3727func ParseReader(filename string, r io.Reader, opts ...Option) (interface{}, error) {
3728	b, err := ioutil.ReadAll(r)
3729	if err != nil {
3730		return nil, err
3731	}
3732
3733	return Parse(filename, b, opts...)
3734}
3735
3736// Parse parses the data from b using filename as information in the
3737// error messages.
3738func Parse(filename string, b []byte, opts ...Option) (interface{}, error) {
3739	return newParser(filename, b, opts...).parse(g)
3740}
3741
3742// position records a position in the text.
3743type position struct {
3744	line, col, offset int
3745}
3746
3747func (p position) String() string {
3748	return fmt.Sprintf("%d:%d [%d]", p.line, p.col, p.offset)
3749}
3750
3751// savepoint stores all state required to go back to this point in the
3752// parser.
3753type savepoint struct {
3754	position
3755	rn rune
3756	w  int
3757}
3758
3759type current struct {
3760	pos  position // start position of the match
3761	text []byte   // raw text of the match
3762
3763	// state is a store for arbitrary key,value pairs that the user wants to be
3764	// tied to the backtracking of the parser.
3765	// This is always rolled back if a parsing rule fails.
3766	state storeDict
3767
3768	// globalStore is a general store for the user to store arbitrary key-value
3769	// pairs that they need to manage and that they do not want tied to the
3770	// backtracking of the parser. This is only modified by the user and never
3771	// rolled back by the parser. It is always up to the user to keep this in a
3772	// consistent state.
3773	globalStore storeDict
3774}
3775
3776type storeDict map[string]interface{}
3777
3778// the AST types...
3779
3780type grammar struct {
3781	pos   position
3782	rules []*rule
3783}
3784
3785type rule struct {
3786	pos         position
3787	name        string
3788	displayName string
3789	expr        interface{}
3790}
3791
3792type choiceExpr struct {
3793	pos          position
3794	alternatives []interface{}
3795}
3796
3797type actionExpr struct {
3798	pos  position
3799	expr interface{}
3800	run  func(*parser) (interface{}, error)
3801}
3802
3803type recoveryExpr struct {
3804	pos          position
3805	expr         interface{}
3806	recoverExpr  interface{}
3807	failureLabel []string
3808}
3809
3810type seqExpr struct {
3811	pos   position
3812	exprs []interface{}
3813}
3814
3815type throwExpr struct {
3816	pos   position
3817	label string
3818}
3819
3820type labeledExpr struct {
3821	pos   position
3822	label string
3823	expr  interface{}
3824}
3825
3826type expr struct {
3827	pos  position
3828	expr interface{}
3829}
3830
3831type andExpr expr
3832type notExpr expr
3833type zeroOrOneExpr expr
3834type zeroOrMoreExpr expr
3835type oneOrMoreExpr expr
3836
3837type ruleRefExpr struct {
3838	pos  position
3839	name string
3840}
3841
3842type stateCodeExpr struct {
3843	pos position
3844	run func(*parser) error
3845}
3846
3847type andCodeExpr struct {
3848	pos position
3849	run func(*parser) (bool, error)
3850}
3851
3852type notCodeExpr struct {
3853	pos position
3854	run func(*parser) (bool, error)
3855}
3856
3857type litMatcher struct {
3858	pos        position
3859	val        string
3860	ignoreCase bool
3861}
3862
3863type charClassMatcher struct {
3864	pos             position
3865	val             string
3866	basicLatinChars [128]bool
3867	chars           []rune
3868	ranges          []rune
3869	classes         []*unicode.RangeTable
3870	ignoreCase      bool
3871	inverted        bool
3872}
3873
3874type anyMatcher position
3875
3876// errList cumulates the errors found by the parser.
3877type errList []error
3878
3879func (e *errList) add(err error) {
3880	*e = append(*e, err)
3881}
3882
3883func (e errList) err() error {
3884	if len(e) == 0 {
3885		return nil
3886	}
3887	e.dedupe()
3888	return e
3889}
3890
3891func (e *errList) dedupe() {
3892	var cleaned []error
3893	set := make(map[string]bool)
3894	for _, err := range *e {
3895		if msg := err.Error(); !set[msg] {
3896			set[msg] = true
3897			cleaned = append(cleaned, err)
3898		}
3899	}
3900	*e = cleaned
3901}
3902
3903func (e errList) Error() string {
3904	switch len(e) {
3905	case 0:
3906		return ""
3907	case 1:
3908		return e[0].Error()
3909	default:
3910		var buf bytes.Buffer
3911
3912		for i, err := range e {
3913			if i > 0 {
3914				buf.WriteRune('\n')
3915			}
3916			buf.WriteString(err.Error())
3917		}
3918		return buf.String()
3919	}
3920}
3921
3922// parserError wraps an error with a prefix indicating the rule in which
3923// the error occurred. The original error is stored in the Inner field.
3924type parserError struct {
3925	Inner    error
3926	pos      position
3927	prefix   string
3928	expected []string
3929}
3930
3931// Error returns the error message.
3932func (p *parserError) Error() string {
3933	return p.prefix + ": " + p.Inner.Error()
3934}
3935
3936// newParser creates a parser with the specified input source and options.
3937func newParser(filename string, b []byte, opts ...Option) *parser {
3938	stats := Stats{
3939		ChoiceAltCnt: make(map[string]map[string]int),
3940	}
3941
3942	p := &parser{
3943		filename: filename,
3944		errs:     new(errList),
3945		data:     b,
3946		pt:       savepoint{position: position{line: 1}},
3947		recover:  true,
3948		cur: current{
3949			state:       make(storeDict),
3950			globalStore: make(storeDict),
3951		},
3952		maxFailPos:      position{col: 1, line: 1},
3953		maxFailExpected: make([]string, 0, 20),
3954		Stats:           &stats,
3955		// start rule is rule [0] unless an alternate entrypoint is specified
3956		entrypoint: g.rules[0].name,
3957		emptyState: make(storeDict),
3958	}
3959	p.setOptions(opts)
3960
3961	if p.maxExprCnt == 0 {
3962		p.maxExprCnt = math.MaxUint64
3963	}
3964
3965	return p
3966}
3967
3968// setOptions applies the options to the parser.
3969func (p *parser) setOptions(opts []Option) {
3970	for _, opt := range opts {
3971		opt(p)
3972	}
3973}
3974
3975type resultTuple struct {
3976	v   interface{}
3977	b   bool
3978	end savepoint
3979}
3980
3981const choiceNoMatch = -1
3982
3983// Stats stores some statistics, gathered during parsing
3984type Stats struct {
3985	// ExprCnt counts the number of expressions processed during parsing
3986	// This value is compared to the maximum number of expressions allowed
3987	// (set by the MaxExpressions option).
3988	ExprCnt uint64
3989
3990	// ChoiceAltCnt is used to count for each ordered choice expression,
3991	// which alternative is used how may times.
3992	// These numbers allow to optimize the order of the ordered choice expression
3993	// to increase the performance of the parser
3994	//
3995	// The outer key of ChoiceAltCnt is composed of the name of the rule as well
3996	// as the line and the column of the ordered choice.
3997	// The inner key of ChoiceAltCnt is the number (one-based) of the matching alternative.
3998	// For each alternative the number of matches are counted. If an ordered choice does not
3999	// match, a special counter is incremented. The name of this counter is set with
4000	// the parser option Statistics.
4001	// For an alternative to be included in ChoiceAltCnt, it has to match at least once.
4002	ChoiceAltCnt map[string]map[string]int
4003}
4004
4005type parser struct {
4006	filename string
4007	pt       savepoint
4008	cur      current
4009
4010	data []byte
4011	errs *errList
4012
4013	depth   int
4014	recover bool
4015	debug   bool
4016
4017	memoize bool
4018	// memoization table for the packrat algorithm:
4019	// map[offset in source] map[expression or rule] {value, match}
4020	memo map[int]map[interface{}]resultTuple
4021
4022	// rules table, maps the rule identifier to the rule node
4023	rules map[string]*rule
4024	// variables stack, map of label to value
4025	vstack []map[string]interface{}
4026	// rule stack, allows identification of the current rule in errors
4027	rstack []*rule
4028
4029	// parse fail
4030	maxFailPos            position
4031	maxFailExpected       []string
4032	maxFailInvertExpected bool
4033
4034	// max number of expressions to be parsed
4035	maxExprCnt uint64
4036	// entrypoint for the parser
4037	entrypoint string
4038
4039	allowInvalidUTF8 bool
4040
4041	*Stats
4042
4043	choiceNoMatch string
4044	// recovery expression stack, keeps track of the currently available recovery expression, these are traversed in reverse
4045	recoveryStack []map[string]interface{}
4046
4047	// emptyState contains an empty storeDict, which is used to optimize cloneState if global "state" store is not used.
4048	emptyState storeDict
4049}
4050
4051// push a variable set on the vstack.
4052func (p *parser) pushV() {
4053	if cap(p.vstack) == len(p.vstack) {
4054		// create new empty slot in the stack
4055		p.vstack = append(p.vstack, nil)
4056	} else {
4057		// slice to 1 more
4058		p.vstack = p.vstack[:len(p.vstack)+1]
4059	}
4060
4061	// get the last args set
4062	m := p.vstack[len(p.vstack)-1]
4063	if m != nil && len(m) == 0 {
4064		// empty map, all good
4065		return
4066	}
4067
4068	m = make(map[string]interface{})
4069	p.vstack[len(p.vstack)-1] = m
4070}
4071
4072// pop a variable set from the vstack.
4073func (p *parser) popV() {
4074	// if the map is not empty, clear it
4075	m := p.vstack[len(p.vstack)-1]
4076	if len(m) > 0 {
4077		// GC that map
4078		p.vstack[len(p.vstack)-1] = nil
4079	}
4080	p.vstack = p.vstack[:len(p.vstack)-1]
4081}
4082
4083// push a recovery expression with its labels to the recoveryStack
4084func (p *parser) pushRecovery(labels []string, expr interface{}) {
4085	if cap(p.recoveryStack) == len(p.recoveryStack) {
4086		// create new empty slot in the stack
4087		p.recoveryStack = append(p.recoveryStack, nil)
4088	} else {
4089		// slice to 1 more
4090		p.recoveryStack = p.recoveryStack[:len(p.recoveryStack)+1]
4091	}
4092
4093	m := make(map[string]interface{}, len(labels))
4094	for _, fl := range labels {
4095		m[fl] = expr
4096	}
4097	p.recoveryStack[len(p.recoveryStack)-1] = m
4098}
4099
4100// pop a recovery expression from the recoveryStack
4101func (p *parser) popRecovery() {
4102	// GC that map
4103	p.recoveryStack[len(p.recoveryStack)-1] = nil
4104
4105	p.recoveryStack = p.recoveryStack[:len(p.recoveryStack)-1]
4106}
4107
4108func (p *parser) print(prefix, s string) string {
4109	if !p.debug {
4110		return s
4111	}
4112
4113	fmt.Printf("%s %d:%d:%d: %s [%#U]\n",
4114		prefix, p.pt.line, p.pt.col, p.pt.offset, s, p.pt.rn)
4115	return s
4116}
4117
4118func (p *parser) in(s string) string {
4119	p.depth++
4120	return p.print(strings.Repeat(" ", p.depth)+">", s)
4121}
4122
4123func (p *parser) out(s string) string {
4124	p.depth--
4125	return p.print(strings.Repeat(" ", p.depth)+"<", s)
4126}
4127
4128func (p *parser) addErr(err error) {
4129	p.addErrAt(err, p.pt.position, []string{})
4130}
4131
4132func (p *parser) addErrAt(err error, pos position, expected []string) {
4133	var buf bytes.Buffer
4134	if p.filename != "" {
4135		buf.WriteString(p.filename)
4136	}
4137	if buf.Len() > 0 {
4138		buf.WriteString(":")
4139	}
4140	buf.WriteString(fmt.Sprintf("%d:%d (%d)", pos.line, pos.col, pos.offset))
4141	if len(p.rstack) > 0 {
4142		if buf.Len() > 0 {
4143			buf.WriteString(": ")
4144		}
4145		rule := p.rstack[len(p.rstack)-1]
4146		if rule.displayName != "" {
4147			buf.WriteString("rule " + rule.displayName)
4148		} else {
4149			buf.WriteString("rule " + rule.name)
4150		}
4151	}
4152	pe := &parserError{Inner: err, pos: pos, prefix: buf.String(), expected: expected}
4153	p.errs.add(pe)
4154}
4155
4156func (p *parser) failAt(fail bool, pos position, want string) {
4157	// process fail if parsing fails and not inverted or parsing succeeds and invert is set
4158	if fail == p.maxFailInvertExpected {
4159		if pos.offset < p.maxFailPos.offset {
4160			return
4161		}
4162
4163		if pos.offset > p.maxFailPos.offset {
4164			p.maxFailPos = pos
4165			p.maxFailExpected = p.maxFailExpected[:0]
4166		}
4167
4168		if p.maxFailInvertExpected {
4169			want = "!" + want
4170		}
4171		p.maxFailExpected = append(p.maxFailExpected, want)
4172	}
4173}
4174
4175// read advances the parser to the next rune.
4176func (p *parser) read() {
4177	p.pt.offset += p.pt.w
4178	rn, n := utf8.DecodeRune(p.data[p.pt.offset:])
4179	p.pt.rn = rn
4180	p.pt.w = n
4181	p.pt.col++
4182	if rn == '\n' {
4183		p.pt.line++
4184		p.pt.col = 0
4185	}
4186
4187	if rn == utf8.RuneError && n == 1 { // see utf8.DecodeRune
4188		if !p.allowInvalidUTF8 {
4189			p.addErr(errInvalidEncoding)
4190		}
4191	}
4192}
4193
4194// restore parser position to the savepoint pt.
4195func (p *parser) restore(pt savepoint) {
4196	if p.debug {
4197		defer p.out(p.in("restore"))
4198	}
4199	if pt.offset == p.pt.offset {
4200		return
4201	}
4202	p.pt = pt
4203}
4204
4205// Cloner is implemented by any value that has a Clone method, which returns a
4206// copy of the value. This is mainly used for types which are not passed by
4207// value (e.g map, slice, chan) or structs that contain such types.
4208//
4209// This is used in conjunction with the global state feature to create proper
4210// copies of the state to allow the parser to properly restore the state in
4211// the case of backtracking.
4212type Cloner interface {
4213	Clone() interface{}
4214}
4215
4216// clone and return parser current state.
4217func (p *parser) cloneState() storeDict {
4218	if p.debug {
4219		defer p.out(p.in("cloneState"))
4220	}
4221
4222	if len(p.cur.state) == 0 {
4223		if len(p.emptyState) > 0 {
4224			p.emptyState = make(storeDict)
4225		}
4226		return p.emptyState
4227	}
4228
4229	state := make(storeDict, len(p.cur.state))
4230	for k, v := range p.cur.state {
4231		if c, ok := v.(Cloner); ok {
4232			state[k] = c.Clone()
4233		} else {
4234			state[k] = v
4235		}
4236	}
4237	return state
4238}
4239
4240// restore parser current state to the state storeDict.
4241// every restoreState should applied only one time for every cloned state
4242func (p *parser) restoreState(state storeDict) {
4243	if p.debug {
4244		defer p.out(p.in("restoreState"))
4245	}
4246	p.cur.state = state
4247}
4248
4249// get the slice of bytes from the savepoint start to the current position.
4250func (p *parser) sliceFrom(start savepoint) []byte {
4251	return p.data[start.position.offset:p.pt.position.offset]
4252}
4253
4254func (p *parser) getMemoized(node interface{}) (resultTuple, bool) {
4255	if len(p.memo) == 0 {
4256		return resultTuple{}, false
4257	}
4258	m := p.memo[p.pt.offset]
4259	if len(m) == 0 {
4260		return resultTuple{}, false
4261	}
4262	res, ok := m[node]
4263	return res, ok
4264}
4265
4266func (p *parser) setMemoized(pt savepoint, node interface{}, tuple resultTuple) {
4267	if p.memo == nil {
4268		p.memo = make(map[int]map[interface{}]resultTuple)
4269	}
4270	m := p.memo[pt.offset]
4271	if m == nil {
4272		m = make(map[interface{}]resultTuple)
4273		p.memo[pt.offset] = m
4274	}
4275	m[node] = tuple
4276}
4277
4278func (p *parser) buildRulesTable(g *grammar) {
4279	p.rules = make(map[string]*rule, len(g.rules))
4280	for _, r := range g.rules {
4281		p.rules[r.name] = r
4282	}
4283}
4284
4285func (p *parser) parse(g *grammar) (val interface{}, err error) {
4286	if len(g.rules) == 0 {
4287		p.addErr(errNoRule)
4288		return nil, p.errs.err()
4289	}
4290
4291	// TODO : not super critical but this could be generated
4292	p.buildRulesTable(g)
4293
4294	if p.recover {
4295		// panic can be used in action code to stop parsing immediately
4296		// and return the panic as an error.
4297		defer func() {
4298			if e := recover(); e != nil {
4299				if p.debug {
4300					defer p.out(p.in("panic handler"))
4301				}
4302				val = nil
4303				switch e := e.(type) {
4304				case error:
4305					p.addErr(e)
4306				default:
4307					p.addErr(fmt.Errorf("%v", e))
4308				}
4309				err = p.errs.err()
4310			}
4311		}()
4312	}
4313
4314	startRule, ok := p.rules[p.entrypoint]
4315	if !ok {
4316		p.addErr(errInvalidEntrypoint)
4317		return nil, p.errs.err()
4318	}
4319
4320	p.read() // advance to first rune
4321	val, ok = p.parseRule(startRule)
4322	if !ok {
4323		if len(*p.errs) == 0 {
4324			// If parsing fails, but no errors have been recorded, the expected values
4325			// for the farthest parser position are returned as error.
4326			maxFailExpectedMap := make(map[string]struct{}, len(p.maxFailExpected))
4327			for _, v := range p.maxFailExpected {
4328				maxFailExpectedMap[v] = struct{}{}
4329			}
4330			expected := make([]string, 0, len(maxFailExpectedMap))
4331			eof := false
4332			if _, ok := maxFailExpectedMap["!."]; ok {
4333				delete(maxFailExpectedMap, "!.")
4334				eof = true
4335			}
4336			for k := range maxFailExpectedMap {
4337				expected = append(expected, k)
4338			}
4339			sort.Strings(expected)
4340			if eof {
4341				expected = append(expected, "EOF")
4342			}
4343			p.addErrAt(errors.New("no match found, expected: "+listJoin(expected, ", ", "or")), p.maxFailPos, expected)
4344		}
4345
4346		return nil, p.errs.err()
4347	}
4348	return val, p.errs.err()
4349}
4350
4351func listJoin(list []string, sep string, lastSep string) string {
4352	switch len(list) {
4353	case 0:
4354		return ""
4355	case 1:
4356		return list[0]
4357	default:
4358		return fmt.Sprintf("%s %s %s", strings.Join(list[:len(list)-1], sep), lastSep, list[len(list)-1])
4359	}
4360}
4361
4362func (p *parser) parseRule(rule *rule) (interface{}, bool) {
4363	if p.debug {
4364		defer p.out(p.in("parseRule " + rule.name))
4365	}
4366
4367	if p.memoize {
4368		res, ok := p.getMemoized(rule)
4369		if ok {
4370			p.restore(res.end)
4371			return res.v, res.b
4372		}
4373	}
4374
4375	start := p.pt
4376	p.rstack = append(p.rstack, rule)
4377	p.pushV()
4378	val, ok := p.parseExpr(rule.expr)
4379	p.popV()
4380	p.rstack = p.rstack[:len(p.rstack)-1]
4381	if ok && p.debug {
4382		p.print(strings.Repeat(" ", p.depth)+"MATCH", string(p.sliceFrom(start)))
4383	}
4384
4385	if p.memoize {
4386		p.setMemoized(start, rule, resultTuple{val, ok, p.pt})
4387	}
4388	return val, ok
4389}
4390
4391func (p *parser) parseExpr(expr interface{}) (interface{}, bool) {
4392	var pt savepoint
4393
4394	if p.memoize {
4395		res, ok := p.getMemoized(expr)
4396		if ok {
4397			p.restore(res.end)
4398			return res.v, res.b
4399		}
4400		pt = p.pt
4401	}
4402
4403	p.ExprCnt++
4404	if p.ExprCnt > p.maxExprCnt {
4405		panic(errMaxExprCnt)
4406	}
4407
4408	var val interface{}
4409	var ok bool
4410	switch expr := expr.(type) {
4411	case *actionExpr:
4412		val, ok = p.parseActionExpr(expr)
4413	case *andCodeExpr:
4414		val, ok = p.parseAndCodeExpr(expr)
4415	case *andExpr:
4416		val, ok = p.parseAndExpr(expr)
4417	case *anyMatcher:
4418		val, ok = p.parseAnyMatcher(expr)
4419	case *charClassMatcher:
4420		val, ok = p.parseCharClassMatcher(expr)
4421	case *choiceExpr:
4422		val, ok = p.parseChoiceExpr(expr)
4423	case *labeledExpr:
4424		val, ok = p.parseLabeledExpr(expr)
4425	case *litMatcher:
4426		val, ok = p.parseLitMatcher(expr)
4427	case *notCodeExpr:
4428		val, ok = p.parseNotCodeExpr(expr)
4429	case *notExpr:
4430		val, ok = p.parseNotExpr(expr)
4431	case *oneOrMoreExpr:
4432		val, ok = p.parseOneOrMoreExpr(expr)
4433	case *recoveryExpr:
4434		val, ok = p.parseRecoveryExpr(expr)
4435	case *ruleRefExpr:
4436		val, ok = p.parseRuleRefExpr(expr)
4437	case *seqExpr:
4438		val, ok = p.parseSeqExpr(expr)
4439	case *stateCodeExpr:
4440		val, ok = p.parseStateCodeExpr(expr)
4441	case *throwExpr:
4442		val, ok = p.parseThrowExpr(expr)
4443	case *zeroOrMoreExpr:
4444		val, ok = p.parseZeroOrMoreExpr(expr)
4445	case *zeroOrOneExpr:
4446		val, ok = p.parseZeroOrOneExpr(expr)
4447	default:
4448		panic(fmt.Sprintf("unknown expression type %T", expr))
4449	}
4450	if p.memoize {
4451		p.setMemoized(pt, expr, resultTuple{val, ok, p.pt})
4452	}
4453	return val, ok
4454}
4455
4456func (p *parser) parseActionExpr(act *actionExpr) (interface{}, bool) {
4457	if p.debug {
4458		defer p.out(p.in("parseActionExpr"))
4459	}
4460
4461	start := p.pt
4462	val, ok := p.parseExpr(act.expr)
4463	if ok {
4464		p.cur.pos = start.position
4465		p.cur.text = p.sliceFrom(start)
4466		state := p.cloneState()
4467		actVal, err := act.run(p)
4468		if err != nil {
4469			p.addErrAt(err, start.position, []string{})
4470		}
4471		p.restoreState(state)
4472
4473		val = actVal
4474	}
4475	if ok && p.debug {
4476		p.print(strings.Repeat(" ", p.depth)+"MATCH", string(p.sliceFrom(start)))
4477	}
4478	return val, ok
4479}
4480
4481func (p *parser) parseAndCodeExpr(and *andCodeExpr) (interface{}, bool) {
4482	if p.debug {
4483		defer p.out(p.in("parseAndCodeExpr"))
4484	}
4485
4486	state := p.cloneState()
4487
4488	ok, err := and.run(p)
4489	if err != nil {
4490		p.addErr(err)
4491	}
4492	p.restoreState(state)
4493
4494	return nil, ok
4495}
4496
4497func (p *parser) parseAndExpr(and *andExpr) (interface{}, bool) {
4498	if p.debug {
4499		defer p.out(p.in("parseAndExpr"))
4500	}
4501
4502	pt := p.pt
4503	state := p.cloneState()
4504	p.pushV()
4505	_, ok := p.parseExpr(and.expr)
4506	p.popV()
4507	p.restoreState(state)
4508	p.restore(pt)
4509
4510	return nil, ok
4511}
4512
4513func (p *parser) parseAnyMatcher(any *anyMatcher) (interface{}, bool) {
4514	if p.debug {
4515		defer p.out(p.in("parseAnyMatcher"))
4516	}
4517
4518	if p.pt.rn == utf8.RuneError && p.pt.w == 0 {
4519		// EOF - see utf8.DecodeRune
4520		p.failAt(false, p.pt.position, ".")
4521		return nil, false
4522	}
4523	start := p.pt
4524	p.read()
4525	p.failAt(true, start.position, ".")
4526	return p.sliceFrom(start), true
4527}
4528
4529func (p *parser) parseCharClassMatcher(chr *charClassMatcher) (interface{}, bool) {
4530	if p.debug {
4531		defer p.out(p.in("parseCharClassMatcher"))
4532	}
4533
4534	cur := p.pt.rn
4535	start := p.pt
4536
4537	// can't match EOF
4538	if cur == utf8.RuneError && p.pt.w == 0 { // see utf8.DecodeRune
4539		p.failAt(false, start.position, chr.val)
4540		return nil, false
4541	}
4542
4543	if chr.ignoreCase {
4544		cur = unicode.ToLower(cur)
4545	}
4546
4547	// try to match in the list of available chars
4548	for _, rn := range chr.chars {
4549		if rn == cur {
4550			if chr.inverted {
4551				p.failAt(false, start.position, chr.val)
4552				return nil, false
4553			}
4554			p.read()
4555			p.failAt(true, start.position, chr.val)
4556			return p.sliceFrom(start), true
4557		}
4558	}
4559
4560	// try to match in the list of ranges
4561	for i := 0; i < len(chr.ranges); i += 2 {
4562		if cur >= chr.ranges[i] && cur <= chr.ranges[i+1] {
4563			if chr.inverted {
4564				p.failAt(false, start.position, chr.val)
4565				return nil, false
4566			}
4567			p.read()
4568			p.failAt(true, start.position, chr.val)
4569			return p.sliceFrom(start), true
4570		}
4571	}
4572
4573	// try to match in the list of Unicode classes
4574	for _, cl := range chr.classes {
4575		if unicode.Is(cl, cur) {
4576			if chr.inverted {
4577				p.failAt(false, start.position, chr.val)
4578				return nil, false
4579			}
4580			p.read()
4581			p.failAt(true, start.position, chr.val)
4582			return p.sliceFrom(start), true
4583		}
4584	}
4585
4586	if chr.inverted {
4587		p.read()
4588		p.failAt(true, start.position, chr.val)
4589		return p.sliceFrom(start), true
4590	}
4591	p.failAt(false, start.position, chr.val)
4592	return nil, false
4593}
4594
4595func (p *parser) incChoiceAltCnt(ch *choiceExpr, altI int) {
4596	choiceIdent := fmt.Sprintf("%s %d:%d", p.rstack[len(p.rstack)-1].name, ch.pos.line, ch.pos.col)
4597	m := p.ChoiceAltCnt[choiceIdent]
4598	if m == nil {
4599		m = make(map[string]int)
4600		p.ChoiceAltCnt[choiceIdent] = m
4601	}
4602	// We increment altI by 1, so the keys do not start at 0
4603	alt := strconv.Itoa(altI + 1)
4604	if altI == choiceNoMatch {
4605		alt = p.choiceNoMatch
4606	}
4607	m[alt]++
4608}
4609
4610func (p *parser) parseChoiceExpr(ch *choiceExpr) (interface{}, bool) {
4611	if p.debug {
4612		defer p.out(p.in("parseChoiceExpr"))
4613	}
4614
4615	for altI, alt := range ch.alternatives {
4616		// dummy assignment to prevent compile error if optimized
4617		_ = altI
4618
4619		state := p.cloneState()
4620
4621		p.pushV()
4622		val, ok := p.parseExpr(alt)
4623		p.popV()
4624		if ok {
4625			p.incChoiceAltCnt(ch, altI)
4626			return val, ok
4627		}
4628		p.restoreState(state)
4629	}
4630	p.incChoiceAltCnt(ch, choiceNoMatch)
4631	return nil, false
4632}
4633
4634func (p *parser) parseLabeledExpr(lab *labeledExpr) (interface{}, bool) {
4635	if p.debug {
4636		defer p.out(p.in("parseLabeledExpr"))
4637	}
4638
4639	p.pushV()
4640	val, ok := p.parseExpr(lab.expr)
4641	p.popV()
4642	if ok && lab.label != "" {
4643		m := p.vstack[len(p.vstack)-1]
4644		m[lab.label] = val
4645	}
4646	return val, ok
4647}
4648
4649func (p *parser) parseLitMatcher(lit *litMatcher) (interface{}, bool) {
4650	if p.debug {
4651		defer p.out(p.in("parseLitMatcher"))
4652	}
4653
4654	ignoreCase := ""
4655	if lit.ignoreCase {
4656		ignoreCase = "i"
4657	}
4658	val := fmt.Sprintf("%q%s", lit.val, ignoreCase)
4659	start := p.pt
4660	for _, want := range lit.val {
4661		cur := p.pt.rn
4662		if lit.ignoreCase {
4663			cur = unicode.ToLower(cur)
4664		}
4665		if cur != want {
4666			p.failAt(false, start.position, val)
4667			p.restore(start)
4668			return nil, false
4669		}
4670		p.read()
4671	}
4672	p.failAt(true, start.position, val)
4673	return p.sliceFrom(start), true
4674}
4675
4676func (p *parser) parseNotCodeExpr(not *notCodeExpr) (interface{}, bool) {
4677	if p.debug {
4678		defer p.out(p.in("parseNotCodeExpr"))
4679	}
4680
4681	state := p.cloneState()
4682
4683	ok, err := not.run(p)
4684	if err != nil {
4685		p.addErr(err)
4686	}
4687	p.restoreState(state)
4688
4689	return nil, !ok
4690}
4691
4692func (p *parser) parseNotExpr(not *notExpr) (interface{}, bool) {
4693	if p.debug {
4694		defer p.out(p.in("parseNotExpr"))
4695	}
4696
4697	pt := p.pt
4698	state := p.cloneState()
4699	p.pushV()
4700	p.maxFailInvertExpected = !p.maxFailInvertExpected
4701	_, ok := p.parseExpr(not.expr)
4702	p.maxFailInvertExpected = !p.maxFailInvertExpected
4703	p.popV()
4704	p.restoreState(state)
4705	p.restore(pt)
4706
4707	return nil, !ok
4708}
4709
4710func (p *parser) parseOneOrMoreExpr(expr *oneOrMoreExpr) (interface{}, bool) {
4711	if p.debug {
4712		defer p.out(p.in("parseOneOrMoreExpr"))
4713	}
4714
4715	var vals []interface{}
4716
4717	for {
4718		p.pushV()
4719		val, ok := p.parseExpr(expr.expr)
4720		p.popV()
4721		if !ok {
4722			if len(vals) == 0 {
4723				// did not match once, no match
4724				return nil, false
4725			}
4726			return vals, true
4727		}
4728		vals = append(vals, val)
4729	}
4730}
4731
4732func (p *parser) parseRecoveryExpr(recover *recoveryExpr) (interface{}, bool) {
4733	if p.debug {
4734		defer p.out(p.in("parseRecoveryExpr (" + strings.Join(recover.failureLabel, ",") + ")"))
4735	}
4736
4737	p.pushRecovery(recover.failureLabel, recover.recoverExpr)
4738	val, ok := p.parseExpr(recover.expr)
4739	p.popRecovery()
4740
4741	return val, ok
4742}
4743
4744func (p *parser) parseRuleRefExpr(ref *ruleRefExpr) (interface{}, bool) {
4745	if p.debug {
4746		defer p.out(p.in("parseRuleRefExpr " + ref.name))
4747	}
4748
4749	if ref.name == "" {
4750		panic(fmt.Sprintf("%s: invalid rule: missing name", ref.pos))
4751	}
4752
4753	rule := p.rules[ref.name]
4754	if rule == nil {
4755		p.addErr(fmt.Errorf("undefined rule: %s", ref.name))
4756		return nil, false
4757	}
4758	return p.parseRule(rule)
4759}
4760
4761func (p *parser) parseSeqExpr(seq *seqExpr) (interface{}, bool) {
4762	if p.debug {
4763		defer p.out(p.in("parseSeqExpr"))
4764	}
4765
4766	vals := make([]interface{}, 0, len(seq.exprs))
4767
4768	pt := p.pt
4769	state := p.cloneState()
4770	for _, expr := range seq.exprs {
4771		val, ok := p.parseExpr(expr)
4772		if !ok {
4773			p.restoreState(state)
4774			p.restore(pt)
4775			return nil, false
4776		}
4777		vals = append(vals, val)
4778	}
4779	return vals, true
4780}
4781
4782func (p *parser) parseStateCodeExpr(state *stateCodeExpr) (interface{}, bool) {
4783	if p.debug {
4784		defer p.out(p.in("parseStateCodeExpr"))
4785	}
4786
4787	err := state.run(p)
4788	if err != nil {
4789		p.addErr(err)
4790	}
4791	return nil, true
4792}
4793
4794func (p *parser) parseThrowExpr(expr *throwExpr) (interface{}, bool) {
4795	if p.debug {
4796		defer p.out(p.in("parseThrowExpr"))
4797	}
4798
4799	for i := len(p.recoveryStack) - 1; i >= 0; i-- {
4800		if recoverExpr, ok := p.recoveryStack[i][expr.label]; ok {
4801			if val, ok := p.parseExpr(recoverExpr); ok {
4802				return val, ok
4803			}
4804		}
4805	}
4806
4807	return nil, false
4808}
4809
4810func (p *parser) parseZeroOrMoreExpr(expr *zeroOrMoreExpr) (interface{}, bool) {
4811	if p.debug {
4812		defer p.out(p.in("parseZeroOrMoreExpr"))
4813	}
4814
4815	var vals []interface{}
4816
4817	for {
4818		p.pushV()
4819		val, ok := p.parseExpr(expr.expr)
4820		p.popV()
4821		if !ok {
4822			return vals, true
4823		}
4824		vals = append(vals, val)
4825	}
4826}
4827
4828func (p *parser) parseZeroOrOneExpr(expr *zeroOrOneExpr) (interface{}, bool) {
4829	if p.debug {
4830		defer p.out(p.in("parseZeroOrOneExpr"))
4831	}
4832
4833	p.pushV()
4834	val, _ := p.parseExpr(expr.expr)
4835	p.popV()
4836	// whether it matched or not, consider it a match
4837	return val, true
4838}
4839