blob: c80a7dcab225e7f44deef6eceb48675414afa0a7 [file] [log] [blame]
Pete Bentleya5c947b2019-08-09 14:24:27 +00001package main
2
3import (
4 "fmt"
5 "math"
6 "sort"
7 "strconv"
8)
9
10const endSymbol rune = 1114112
11
12/* The rule types inferred from the grammar are below. */
13type pegRule uint8
14
15const (
16 ruleUnknown pegRule = iota
17 ruleStatement
18 ruleAssignment
19 ruleVariable
20 ruleExpression
21 ruleStringLiteral
22 ruleQuotedText
23 ruleEscapedChar
24 ruleIndexing
25 ruleIndex
26 ruleSearch
27 ruleAction
28 ruleCommand
29 ruleFunction
30 ruleArgs
31 ruleQuery
32 ruleConjunctions
33 ruleConjunction
34 ruleField
35 ruleRelation
36 ruleWS
37)
38
39var rul3s = [...]string{
40 "Unknown",
41 "Statement",
42 "Assignment",
43 "Variable",
44 "Expression",
45 "StringLiteral",
46 "QuotedText",
47 "EscapedChar",
48 "Indexing",
49 "Index",
50 "Search",
51 "Action",
52 "Command",
53 "Function",
54 "Args",
55 "Query",
56 "Conjunctions",
57 "Conjunction",
58 "Field",
59 "Relation",
60 "WS",
61}
62
63type token32 struct {
64 pegRule
65 begin, end uint32
66}
67
68func (t *token32) String() string {
69 return fmt.Sprintf("\x1B[34m%v\x1B[m %v %v", rul3s[t.pegRule], t.begin, t.end)
70}
71
72type node32 struct {
73 token32
74 up, next *node32
75}
76
77func (node *node32) print(pretty bool, buffer string) {
78 var print func(node *node32, depth int)
79 print = func(node *node32, depth int) {
80 for node != nil {
81 for c := 0; c < depth; c++ {
82 fmt.Printf(" ")
83 }
84 rule := rul3s[node.pegRule]
85 quote := strconv.Quote(string(([]rune(buffer)[node.begin:node.end])))
86 if !pretty {
87 fmt.Printf("%v %v\n", rule, quote)
88 } else {
89 fmt.Printf("\x1B[34m%v\x1B[m %v\n", rule, quote)
90 }
91 if node.up != nil {
92 print(node.up, depth+1)
93 }
94 node = node.next
95 }
96 }
97 print(node, 0)
98}
99
100func (node *node32) Print(buffer string) {
101 node.print(false, buffer)
102}
103
104func (node *node32) PrettyPrint(buffer string) {
105 node.print(true, buffer)
106}
107
108type tokens32 struct {
109 tree []token32
110}
111
112func (t *tokens32) Trim(length uint32) {
113 t.tree = t.tree[:length]
114}
115
116func (t *tokens32) Print() {
117 for _, token := range t.tree {
118 fmt.Println(token.String())
119 }
120}
121
122func (t *tokens32) AST() *node32 {
123 type element struct {
124 node *node32
125 down *element
126 }
127 tokens := t.Tokens()
128 var stack *element
129 for _, token := range tokens {
130 if token.begin == token.end {
131 continue
132 }
133 node := &node32{token32: token}
134 for stack != nil && stack.node.begin >= token.begin && stack.node.end <= token.end {
135 stack.node.next = node.up
136 node.up = stack.node
137 stack = stack.down
138 }
139 stack = &element{node: node, down: stack}
140 }
141 if stack != nil {
142 return stack.node
143 }
144 return nil
145}
146
147func (t *tokens32) PrintSyntaxTree(buffer string) {
148 t.AST().Print(buffer)
149}
150
151func (t *tokens32) PrettyPrintSyntaxTree(buffer string) {
152 t.AST().PrettyPrint(buffer)
153}
154
155func (t *tokens32) Add(rule pegRule, begin, end, index uint32) {
156 if tree := t.tree; int(index) >= len(tree) {
157 expanded := make([]token32, 2*len(tree))
158 copy(expanded, tree)
159 t.tree = expanded
160 }
161 t.tree[index] = token32{
162 pegRule: rule,
163 begin: begin,
164 end: end,
165 }
166}
167
168func (t *tokens32) Tokens() []token32 {
169 return t.tree
170}
171
172type Statement struct {
173 Buffer string
174 buffer []rune
175 rules [21]func() bool
176 parse func(rule ...int) error
177 reset func()
178 Pretty bool
179 tokens32
180}
181
182func (p *Statement) Parse(rule ...int) error {
183 return p.parse(rule...)
184}
185
186func (p *Statement) Reset() {
187 p.reset()
188}
189
190type textPosition struct {
191 line, symbol int
192}
193
194type textPositionMap map[int]textPosition
195
196func translatePositions(buffer []rune, positions []int) textPositionMap {
197 length, translations, j, line, symbol := len(positions), make(textPositionMap, len(positions)), 0, 1, 0
198 sort.Ints(positions)
199
200search:
201 for i, c := range buffer {
202 if c == '\n' {
203 line, symbol = line+1, 0
204 } else {
205 symbol++
206 }
207 if i == positions[j] {
208 translations[positions[j]] = textPosition{line, symbol}
209 for j++; j < length; j++ {
210 if i != positions[j] {
211 continue search
212 }
213 }
214 break search
215 }
216 }
217
218 return translations
219}
220
221type parseError struct {
222 p *Statement
223 max token32
224}
225
226func (e *parseError) Error() string {
227 tokens, error := []token32{e.max}, "\n"
228 positions, p := make([]int, 2*len(tokens)), 0
229 for _, token := range tokens {
230 positions[p], p = int(token.begin), p+1
231 positions[p], p = int(token.end), p+1
232 }
233 translations := translatePositions(e.p.buffer, positions)
234 format := "parse error near %v (line %v symbol %v - line %v symbol %v):\n%v\n"
235 if e.p.Pretty {
236 format = "parse error near \x1B[34m%v\x1B[m (line %v symbol %v - line %v symbol %v):\n%v\n"
237 }
238 for _, token := range tokens {
239 begin, end := int(token.begin), int(token.end)
240 error += fmt.Sprintf(format,
241 rul3s[token.pegRule],
242 translations[begin].line, translations[begin].symbol,
243 translations[end].line, translations[end].symbol,
244 strconv.Quote(string(e.p.buffer[begin:end])))
245 }
246
247 return error
248}
249
250func (p *Statement) PrintSyntaxTree() {
251 if p.Pretty {
252 p.tokens32.PrettyPrintSyntaxTree(p.Buffer)
253 } else {
254 p.tokens32.PrintSyntaxTree(p.Buffer)
255 }
256}
257
258func (p *Statement) Init() {
259 var (
260 max token32
261 position, tokenIndex uint32
262 buffer []rune
263 )
264 p.reset = func() {
265 max = token32{}
266 position, tokenIndex = 0, 0
267
268 p.buffer = []rune(p.Buffer)
269 if len(p.buffer) == 0 || p.buffer[len(p.buffer)-1] != endSymbol {
270 p.buffer = append(p.buffer, endSymbol)
271 }
272 buffer = p.buffer
273 }
274 p.reset()
275
276 _rules := p.rules
277 tree := tokens32{tree: make([]token32, math.MaxInt16)}
278 p.parse = func(rule ...int) error {
279 r := 1
280 if len(rule) > 0 {
281 r = rule[0]
282 }
283 matches := p.rules[r]()
284 p.tokens32 = tree
285 if matches {
286 p.Trim(tokenIndex)
287 return nil
288 }
289 return &parseError{p, max}
290 }
291
292 add := func(rule pegRule, begin uint32) {
293 tree.Add(rule, begin, position, tokenIndex)
294 tokenIndex++
295 if begin != position && position > max.end {
296 max = token32{rule, begin, position}
297 }
298 }
299
300 matchDot := func() bool {
301 if buffer[position] != endSymbol {
302 position++
303 return true
304 }
305 return false
306 }
307
308 /*matchChar := func(c byte) bool {
309 if buffer[position] == c {
310 position++
311 return true
312 }
313 return false
314 }*/
315
316 /*matchRange := func(lower byte, upper byte) bool {
317 if c := buffer[position]; c >= lower && c <= upper {
318 position++
319 return true
320 }
321 return false
322 }*/
323
324 _rules = [...]func() bool{
325 nil,
326 /* 0 Statement <- <(WS? (Assignment / Action / Expression) WS? !.)> */
327 func() bool {
328 position0, tokenIndex0 := position, tokenIndex
329 {
330 position1 := position
331 {
332 position2, tokenIndex2 := position, tokenIndex
333 if !_rules[ruleWS]() {
334 goto l2
335 }
336 goto l3
337 l2:
338 position, tokenIndex = position2, tokenIndex2
339 }
340 l3:
341 {
342 position4, tokenIndex4 := position, tokenIndex
343 if !_rules[ruleAssignment]() {
344 goto l5
345 }
346 goto l4
347 l5:
348 position, tokenIndex = position4, tokenIndex4
349 if !_rules[ruleAction]() {
350 goto l6
351 }
352 goto l4
353 l6:
354 position, tokenIndex = position4, tokenIndex4
355 if !_rules[ruleExpression]() {
356 goto l0
357 }
358 }
359 l4:
360 {
361 position7, tokenIndex7 := position, tokenIndex
362 if !_rules[ruleWS]() {
363 goto l7
364 }
365 goto l8
366 l7:
367 position, tokenIndex = position7, tokenIndex7
368 }
369 l8:
370 {
371 position9, tokenIndex9 := position, tokenIndex
372 if !matchDot() {
373 goto l9
374 }
375 goto l0
376 l9:
377 position, tokenIndex = position9, tokenIndex9
378 }
379 add(ruleStatement, position1)
380 }
381 return true
382 l0:
383 position, tokenIndex = position0, tokenIndex0
384 return false
385 },
386 /* 1 Assignment <- <(Variable WS? '=' WS? Expression)> */
387 func() bool {
388 position10, tokenIndex10 := position, tokenIndex
389 {
390 position11 := position
391 if !_rules[ruleVariable]() {
392 goto l10
393 }
394 {
395 position12, tokenIndex12 := position, tokenIndex
396 if !_rules[ruleWS]() {
397 goto l12
398 }
399 goto l13
400 l12:
401 position, tokenIndex = position12, tokenIndex12
402 }
403 l13:
404 if buffer[position] != rune('=') {
405 goto l10
406 }
407 position++
408 {
409 position14, tokenIndex14 := position, tokenIndex
410 if !_rules[ruleWS]() {
411 goto l14
412 }
413 goto l15
414 l14:
415 position, tokenIndex = position14, tokenIndex14
416 }
417 l15:
418 if !_rules[ruleExpression]() {
419 goto l10
420 }
421 add(ruleAssignment, position11)
422 }
423 return true
424 l10:
425 position, tokenIndex = position10, tokenIndex10
426 return false
427 },
428 /* 2 Variable <- <(([a-z] / [A-Z] / '_') ([a-z] / [A-Z] / [0-9] / '_')*)> */
429 func() bool {
430 position16, tokenIndex16 := position, tokenIndex
431 {
432 position17 := position
433 {
434 position18, tokenIndex18 := position, tokenIndex
435 if c := buffer[position]; c < rune('a') || c > rune('z') {
436 goto l19
437 }
438 position++
439 goto l18
440 l19:
441 position, tokenIndex = position18, tokenIndex18
442 if c := buffer[position]; c < rune('A') || c > rune('Z') {
443 goto l20
444 }
445 position++
446 goto l18
447 l20:
448 position, tokenIndex = position18, tokenIndex18
449 if buffer[position] != rune('_') {
450 goto l16
451 }
452 position++
453 }
454 l18:
455 l21:
456 {
457 position22, tokenIndex22 := position, tokenIndex
458 {
459 position23, tokenIndex23 := position, tokenIndex
460 if c := buffer[position]; c < rune('a') || c > rune('z') {
461 goto l24
462 }
463 position++
464 goto l23
465 l24:
466 position, tokenIndex = position23, tokenIndex23
467 if c := buffer[position]; c < rune('A') || c > rune('Z') {
468 goto l25
469 }
470 position++
471 goto l23
472 l25:
473 position, tokenIndex = position23, tokenIndex23
474 if c := buffer[position]; c < rune('0') || c > rune('9') {
475 goto l26
476 }
477 position++
478 goto l23
479 l26:
480 position, tokenIndex = position23, tokenIndex23
481 if buffer[position] != rune('_') {
482 goto l22
483 }
484 position++
485 }
486 l23:
487 goto l21
488 l22:
489 position, tokenIndex = position22, tokenIndex22
490 }
491 add(ruleVariable, position17)
492 }
493 return true
494 l16:
495 position, tokenIndex = position16, tokenIndex16
496 return false
497 },
498 /* 3 Expression <- <(StringLiteral / Indexing / Search / Variable)> */
499 func() bool {
500 position27, tokenIndex27 := position, tokenIndex
501 {
502 position28 := position
503 {
504 position29, tokenIndex29 := position, tokenIndex
505 if !_rules[ruleStringLiteral]() {
506 goto l30
507 }
508 goto l29
509 l30:
510 position, tokenIndex = position29, tokenIndex29
511 if !_rules[ruleIndexing]() {
512 goto l31
513 }
514 goto l29
515 l31:
516 position, tokenIndex = position29, tokenIndex29
517 if !_rules[ruleSearch]() {
518 goto l32
519 }
520 goto l29
521 l32:
522 position, tokenIndex = position29, tokenIndex29
523 if !_rules[ruleVariable]() {
524 goto l27
525 }
526 }
527 l29:
528 add(ruleExpression, position28)
529 }
530 return true
531 l27:
532 position, tokenIndex = position27, tokenIndex27
533 return false
534 },
535 /* 4 StringLiteral <- <('"' QuotedText '"')> */
536 func() bool {
537 position33, tokenIndex33 := position, tokenIndex
538 {
539 position34 := position
540 if buffer[position] != rune('"') {
541 goto l33
542 }
543 position++
544 if !_rules[ruleQuotedText]() {
545 goto l33
546 }
547 if buffer[position] != rune('"') {
548 goto l33
549 }
550 position++
551 add(ruleStringLiteral, position34)
552 }
553 return true
554 l33:
555 position, tokenIndex = position33, tokenIndex33
556 return false
557 },
558 /* 5 QuotedText <- <(EscapedChar / (!('\\' / '"') .))*> */
559 func() bool {
560 {
561 position36 := position
562 l37:
563 {
564 position38, tokenIndex38 := position, tokenIndex
565 {
566 position39, tokenIndex39 := position, tokenIndex
567 if !_rules[ruleEscapedChar]() {
568 goto l40
569 }
570 goto l39
571 l40:
572 position, tokenIndex = position39, tokenIndex39
573 {
574 position41, tokenIndex41 := position, tokenIndex
575 {
576 position42, tokenIndex42 := position, tokenIndex
577 if buffer[position] != rune('\\') {
578 goto l43
579 }
580 position++
581 goto l42
582 l43:
583 position, tokenIndex = position42, tokenIndex42
584 if buffer[position] != rune('"') {
585 goto l41
586 }
587 position++
588 }
589 l42:
590 goto l38
591 l41:
592 position, tokenIndex = position41, tokenIndex41
593 }
594 if !matchDot() {
595 goto l38
596 }
597 }
598 l39:
599 goto l37
600 l38:
601 position, tokenIndex = position38, tokenIndex38
602 }
603 add(ruleQuotedText, position36)
604 }
605 return true
606 },
607 /* 6 EscapedChar <- <('\\' ('\\' / 'n' / '"'))> */
608 func() bool {
609 position44, tokenIndex44 := position, tokenIndex
610 {
611 position45 := position
612 if buffer[position] != rune('\\') {
613 goto l44
614 }
615 position++
616 {
617 position46, tokenIndex46 := position, tokenIndex
618 if buffer[position] != rune('\\') {
619 goto l47
620 }
621 position++
622 goto l46
623 l47:
624 position, tokenIndex = position46, tokenIndex46
625 if buffer[position] != rune('n') {
626 goto l48
627 }
628 position++
629 goto l46
630 l48:
631 position, tokenIndex = position46, tokenIndex46
632 if buffer[position] != rune('"') {
633 goto l44
634 }
635 position++
636 }
637 l46:
638 add(ruleEscapedChar, position45)
639 }
640 return true
641 l44:
642 position, tokenIndex = position44, tokenIndex44
643 return false
644 },
645 /* 7 Indexing <- <(Variable ('[' Index ']')+)> */
646 func() bool {
647 position49, tokenIndex49 := position, tokenIndex
648 {
649 position50 := position
650 if !_rules[ruleVariable]() {
651 goto l49
652 }
653 if buffer[position] != rune('[') {
654 goto l49
655 }
656 position++
657 if !_rules[ruleIndex]() {
658 goto l49
659 }
660 if buffer[position] != rune(']') {
661 goto l49
662 }
663 position++
664 l51:
665 {
666 position52, tokenIndex52 := position, tokenIndex
667 if buffer[position] != rune('[') {
668 goto l52
669 }
670 position++
671 if !_rules[ruleIndex]() {
672 goto l52
673 }
674 if buffer[position] != rune(']') {
675 goto l52
676 }
677 position++
678 goto l51
679 l52:
680 position, tokenIndex = position52, tokenIndex52
681 }
682 add(ruleIndexing, position50)
683 }
684 return true
685 l49:
686 position, tokenIndex = position49, tokenIndex49
687 return false
688 },
689 /* 8 Index <- <([0-9] / [a-z])+> */
690 func() bool {
691 position53, tokenIndex53 := position, tokenIndex
692 {
693 position54 := position
694 {
695 position57, tokenIndex57 := position, tokenIndex
696 if c := buffer[position]; c < rune('0') || c > rune('9') {
697 goto l58
698 }
699 position++
700 goto l57
701 l58:
702 position, tokenIndex = position57, tokenIndex57
703 if c := buffer[position]; c < rune('a') || c > rune('z') {
704 goto l53
705 }
706 position++
707 }
708 l57:
709 l55:
710 {
711 position56, tokenIndex56 := position, tokenIndex
712 {
713 position59, tokenIndex59 := position, tokenIndex
714 if c := buffer[position]; c < rune('0') || c > rune('9') {
715 goto l60
716 }
717 position++
718 goto l59
719 l60:
720 position, tokenIndex = position59, tokenIndex59
721 if c := buffer[position]; c < rune('a') || c > rune('z') {
722 goto l56
723 }
724 position++
725 }
726 l59:
727 goto l55
728 l56:
729 position, tokenIndex = position56, tokenIndex56
730 }
731 add(ruleIndex, position54)
732 }
733 return true
734 l53:
735 position, tokenIndex = position53, tokenIndex53
736 return false
737 },
738 /* 9 Search <- <(Variable '[' WS? ('w' 'h' 'e' 'r' 'e') WS Query ']')> */
739 func() bool {
740 position61, tokenIndex61 := position, tokenIndex
741 {
742 position62 := position
743 if !_rules[ruleVariable]() {
744 goto l61
745 }
746 if buffer[position] != rune('[') {
747 goto l61
748 }
749 position++
750 {
751 position63, tokenIndex63 := position, tokenIndex
752 if !_rules[ruleWS]() {
753 goto l63
754 }
755 goto l64
756 l63:
757 position, tokenIndex = position63, tokenIndex63
758 }
759 l64:
760 if buffer[position] != rune('w') {
761 goto l61
762 }
763 position++
764 if buffer[position] != rune('h') {
765 goto l61
766 }
767 position++
768 if buffer[position] != rune('e') {
769 goto l61
770 }
771 position++
772 if buffer[position] != rune('r') {
773 goto l61
774 }
775 position++
776 if buffer[position] != rune('e') {
777 goto l61
778 }
779 position++
780 if !_rules[ruleWS]() {
781 goto l61
782 }
783 if !_rules[ruleQuery]() {
784 goto l61
785 }
786 if buffer[position] != rune(']') {
787 goto l61
788 }
789 position++
790 add(ruleSearch, position62)
791 }
792 return true
793 l61:
794 position, tokenIndex = position61, tokenIndex61
795 return false
796 },
797 /* 10 Action <- <(Expression '.' Command)> */
798 func() bool {
799 position65, tokenIndex65 := position, tokenIndex
800 {
801 position66 := position
802 if !_rules[ruleExpression]() {
803 goto l65
804 }
805 if buffer[position] != rune('.') {
806 goto l65
807 }
808 position++
809 if !_rules[ruleCommand]() {
810 goto l65
811 }
812 add(ruleAction, position66)
813 }
814 return true
815 l65:
816 position, tokenIndex = position65, tokenIndex65
817 return false
818 },
819 /* 11 Command <- <(Function '(' Args? ')')> */
820 func() bool {
821 position67, tokenIndex67 := position, tokenIndex
822 {
823 position68 := position
824 if !_rules[ruleFunction]() {
825 goto l67
826 }
827 if buffer[position] != rune('(') {
828 goto l67
829 }
830 position++
831 {
832 position69, tokenIndex69 := position, tokenIndex
833 if !_rules[ruleArgs]() {
834 goto l69
835 }
836 goto l70
837 l69:
838 position, tokenIndex = position69, tokenIndex69
839 }
840 l70:
841 if buffer[position] != rune(')') {
842 goto l67
843 }
844 position++
845 add(ruleCommand, position68)
846 }
847 return true
848 l67:
849 position, tokenIndex = position67, tokenIndex67
850 return false
851 },
852 /* 12 Function <- <([a-z] / [A-Z])+> */
853 func() bool {
854 position71, tokenIndex71 := position, tokenIndex
855 {
856 position72 := position
857 {
858 position75, tokenIndex75 := position, tokenIndex
859 if c := buffer[position]; c < rune('a') || c > rune('z') {
860 goto l76
861 }
862 position++
863 goto l75
864 l76:
865 position, tokenIndex = position75, tokenIndex75
866 if c := buffer[position]; c < rune('A') || c > rune('Z') {
867 goto l71
868 }
869 position++
870 }
871 l75:
872 l73:
873 {
874 position74, tokenIndex74 := position, tokenIndex
875 {
876 position77, tokenIndex77 := position, tokenIndex
877 if c := buffer[position]; c < rune('a') || c > rune('z') {
878 goto l78
879 }
880 position++
881 goto l77
882 l78:
883 position, tokenIndex = position77, tokenIndex77
884 if c := buffer[position]; c < rune('A') || c > rune('Z') {
885 goto l74
886 }
887 position++
888 }
889 l77:
890 goto l73
891 l74:
892 position, tokenIndex = position74, tokenIndex74
893 }
894 add(ruleFunction, position72)
895 }
896 return true
897 l71:
898 position, tokenIndex = position71, tokenIndex71
899 return false
900 },
901 /* 13 Args <- <(StringLiteral (WS? ',' WS? Args))> */
902 func() bool {
903 position79, tokenIndex79 := position, tokenIndex
904 {
905 position80 := position
906 if !_rules[ruleStringLiteral]() {
907 goto l79
908 }
909 {
910 position81, tokenIndex81 := position, tokenIndex
911 if !_rules[ruleWS]() {
912 goto l81
913 }
914 goto l82
915 l81:
916 position, tokenIndex = position81, tokenIndex81
917 }
918 l82:
919 if buffer[position] != rune(',') {
920 goto l79
921 }
922 position++
923 {
924 position83, tokenIndex83 := position, tokenIndex
925 if !_rules[ruleWS]() {
926 goto l83
927 }
928 goto l84
929 l83:
930 position, tokenIndex = position83, tokenIndex83
931 }
932 l84:
933 if !_rules[ruleArgs]() {
934 goto l79
935 }
936 add(ruleArgs, position80)
937 }
938 return true
939 l79:
940 position, tokenIndex = position79, tokenIndex79
941 return false
942 },
943 /* 14 Query <- <(Conjunctions (WS? ('|' '|') WS? Conjunctions)?)> */
944 func() bool {
945 position85, tokenIndex85 := position, tokenIndex
946 {
947 position86 := position
948 if !_rules[ruleConjunctions]() {
949 goto l85
950 }
951 {
952 position87, tokenIndex87 := position, tokenIndex
953 {
954 position89, tokenIndex89 := position, tokenIndex
955 if !_rules[ruleWS]() {
956 goto l89
957 }
958 goto l90
959 l89:
960 position, tokenIndex = position89, tokenIndex89
961 }
962 l90:
963 if buffer[position] != rune('|') {
964 goto l87
965 }
966 position++
967 if buffer[position] != rune('|') {
968 goto l87
969 }
970 position++
971 {
972 position91, tokenIndex91 := position, tokenIndex
973 if !_rules[ruleWS]() {
974 goto l91
975 }
976 goto l92
977 l91:
978 position, tokenIndex = position91, tokenIndex91
979 }
980 l92:
981 if !_rules[ruleConjunctions]() {
982 goto l87
983 }
984 goto l88
985 l87:
986 position, tokenIndex = position87, tokenIndex87
987 }
988 l88:
989 add(ruleQuery, position86)
990 }
991 return true
992 l85:
993 position, tokenIndex = position85, tokenIndex85
994 return false
995 },
996 /* 15 Conjunctions <- <(Conjunction (WS? ('&' '&') WS? Conjunctions)?)> */
997 func() bool {
998 position93, tokenIndex93 := position, tokenIndex
999 {
1000 position94 := position
1001 if !_rules[ruleConjunction]() {
1002 goto l93
1003 }
1004 {
1005 position95, tokenIndex95 := position, tokenIndex
1006 {
1007 position97, tokenIndex97 := position, tokenIndex
1008 if !_rules[ruleWS]() {
1009 goto l97
1010 }
1011 goto l98
1012 l97:
1013 position, tokenIndex = position97, tokenIndex97
1014 }
1015 l98:
1016 if buffer[position] != rune('&') {
1017 goto l95
1018 }
1019 position++
1020 if buffer[position] != rune('&') {
1021 goto l95
1022 }
1023 position++
1024 {
1025 position99, tokenIndex99 := position, tokenIndex
1026 if !_rules[ruleWS]() {
1027 goto l99
1028 }
1029 goto l100
1030 l99:
1031 position, tokenIndex = position99, tokenIndex99
1032 }
1033 l100:
1034 if !_rules[ruleConjunctions]() {
1035 goto l95
1036 }
1037 goto l96
1038 l95:
1039 position, tokenIndex = position95, tokenIndex95
1040 }
1041 l96:
1042 add(ruleConjunctions, position94)
1043 }
1044 return true
1045 l93:
1046 position, tokenIndex = position93, tokenIndex93
1047 return false
1048 },
1049 /* 16 Conjunction <- <(Field WS? Relation WS? StringLiteral)> */
1050 func() bool {
1051 position101, tokenIndex101 := position, tokenIndex
1052 {
1053 position102 := position
1054 if !_rules[ruleField]() {
1055 goto l101
1056 }
1057 {
1058 position103, tokenIndex103 := position, tokenIndex
1059 if !_rules[ruleWS]() {
1060 goto l103
1061 }
1062 goto l104
1063 l103:
1064 position, tokenIndex = position103, tokenIndex103
1065 }
1066 l104:
1067 if !_rules[ruleRelation]() {
1068 goto l101
1069 }
1070 {
1071 position105, tokenIndex105 := position, tokenIndex
1072 if !_rules[ruleWS]() {
1073 goto l105
1074 }
1075 goto l106
1076 l105:
1077 position, tokenIndex = position105, tokenIndex105
1078 }
1079 l106:
1080 if !_rules[ruleStringLiteral]() {
1081 goto l101
1082 }
1083 add(ruleConjunction, position102)
1084 }
1085 return true
1086 l101:
1087 position, tokenIndex = position101, tokenIndex101
1088 return false
1089 },
1090 /* 17 Field <- <([a-z] ([a-z] / [A-Z] / [0-9])*)> */
1091 func() bool {
1092 position107, tokenIndex107 := position, tokenIndex
1093 {
1094 position108 := position
1095 if c := buffer[position]; c < rune('a') || c > rune('z') {
1096 goto l107
1097 }
1098 position++
1099 l109:
1100 {
1101 position110, tokenIndex110 := position, tokenIndex
1102 {
1103 position111, tokenIndex111 := position, tokenIndex
1104 if c := buffer[position]; c < rune('a') || c > rune('z') {
1105 goto l112
1106 }
1107 position++
1108 goto l111
1109 l112:
1110 position, tokenIndex = position111, tokenIndex111
1111 if c := buffer[position]; c < rune('A') || c > rune('Z') {
1112 goto l113
1113 }
1114 position++
1115 goto l111
1116 l113:
1117 position, tokenIndex = position111, tokenIndex111
1118 if c := buffer[position]; c < rune('0') || c > rune('9') {
1119 goto l110
1120 }
1121 position++
1122 }
1123 l111:
1124 goto l109
1125 l110:
1126 position, tokenIndex = position110, tokenIndex110
1127 }
1128 add(ruleField, position108)
1129 }
1130 return true
1131 l107:
1132 position, tokenIndex = position107, tokenIndex107
1133 return false
1134 },
1135 /* 18 Relation <- <(('=' '=') / ('!' '=') / ('c' 'o' 'n' 't' 'a' 'i' 'n' 's') / ('s' 't' 'a' 'r' 't' 's' 'W' 'i' 't' 'h') / ('e' 'n' 'd' 's' 'W' 'i' 't' 'h'))> */
1136 func() bool {
1137 position114, tokenIndex114 := position, tokenIndex
1138 {
1139 position115 := position
1140 {
1141 position116, tokenIndex116 := position, tokenIndex
1142 if buffer[position] != rune('=') {
1143 goto l117
1144 }
1145 position++
1146 if buffer[position] != rune('=') {
1147 goto l117
1148 }
1149 position++
1150 goto l116
1151 l117:
1152 position, tokenIndex = position116, tokenIndex116
1153 if buffer[position] != rune('!') {
1154 goto l118
1155 }
1156 position++
1157 if buffer[position] != rune('=') {
1158 goto l118
1159 }
1160 position++
1161 goto l116
1162 l118:
1163 position, tokenIndex = position116, tokenIndex116
1164 if buffer[position] != rune('c') {
1165 goto l119
1166 }
1167 position++
1168 if buffer[position] != rune('o') {
1169 goto l119
1170 }
1171 position++
1172 if buffer[position] != rune('n') {
1173 goto l119
1174 }
1175 position++
1176 if buffer[position] != rune('t') {
1177 goto l119
1178 }
1179 position++
1180 if buffer[position] != rune('a') {
1181 goto l119
1182 }
1183 position++
1184 if buffer[position] != rune('i') {
1185 goto l119
1186 }
1187 position++
1188 if buffer[position] != rune('n') {
1189 goto l119
1190 }
1191 position++
1192 if buffer[position] != rune('s') {
1193 goto l119
1194 }
1195 position++
1196 goto l116
1197 l119:
1198 position, tokenIndex = position116, tokenIndex116
1199 if buffer[position] != rune('s') {
1200 goto l120
1201 }
1202 position++
1203 if buffer[position] != rune('t') {
1204 goto l120
1205 }
1206 position++
1207 if buffer[position] != rune('a') {
1208 goto l120
1209 }
1210 position++
1211 if buffer[position] != rune('r') {
1212 goto l120
1213 }
1214 position++
1215 if buffer[position] != rune('t') {
1216 goto l120
1217 }
1218 position++
1219 if buffer[position] != rune('s') {
1220 goto l120
1221 }
1222 position++
1223 if buffer[position] != rune('W') {
1224 goto l120
1225 }
1226 position++
1227 if buffer[position] != rune('i') {
1228 goto l120
1229 }
1230 position++
1231 if buffer[position] != rune('t') {
1232 goto l120
1233 }
1234 position++
1235 if buffer[position] != rune('h') {
1236 goto l120
1237 }
1238 position++
1239 goto l116
1240 l120:
1241 position, tokenIndex = position116, tokenIndex116
1242 if buffer[position] != rune('e') {
1243 goto l114
1244 }
1245 position++
1246 if buffer[position] != rune('n') {
1247 goto l114
1248 }
1249 position++
1250 if buffer[position] != rune('d') {
1251 goto l114
1252 }
1253 position++
1254 if buffer[position] != rune('s') {
1255 goto l114
1256 }
1257 position++
1258 if buffer[position] != rune('W') {
1259 goto l114
1260 }
1261 position++
1262 if buffer[position] != rune('i') {
1263 goto l114
1264 }
1265 position++
1266 if buffer[position] != rune('t') {
1267 goto l114
1268 }
1269 position++
1270 if buffer[position] != rune('h') {
1271 goto l114
1272 }
1273 position++
1274 }
1275 l116:
1276 add(ruleRelation, position115)
1277 }
1278 return true
1279 l114:
1280 position, tokenIndex = position114, tokenIndex114
1281 return false
1282 },
1283 /* 19 WS <- <(' ' / '\t')+> */
1284 func() bool {
1285 position121, tokenIndex121 := position, tokenIndex
1286 {
1287 position122 := position
1288 {
1289 position125, tokenIndex125 := position, tokenIndex
1290 if buffer[position] != rune(' ') {
1291 goto l126
1292 }
1293 position++
1294 goto l125
1295 l126:
1296 position, tokenIndex = position125, tokenIndex125
1297 if buffer[position] != rune('\t') {
1298 goto l121
1299 }
1300 position++
1301 }
1302 l125:
1303 l123:
1304 {
1305 position124, tokenIndex124 := position, tokenIndex
1306 {
1307 position127, tokenIndex127 := position, tokenIndex
1308 if buffer[position] != rune(' ') {
1309 goto l128
1310 }
1311 position++
1312 goto l127
1313 l128:
1314 position, tokenIndex = position127, tokenIndex127
1315 if buffer[position] != rune('\t') {
1316 goto l124
1317 }
1318 position++
1319 }
1320 l127:
1321 goto l123
1322 l124:
1323 position, tokenIndex = position124, tokenIndex124
1324 }
1325 add(ruleWS, position122)
1326 }
1327 return true
1328 l121:
1329 position, tokenIndex = position121, tokenIndex121
1330 return false
1331 },
1332 }
1333 p.rules = _rules
1334}