github.com/badrootd/nibiru-cometbft@v0.37.5-0.20240307173500-2a75559eee9b/libs/pubsub/query/query.peg.go (about) 1 package query 2 3 // Code generated by ./.bin/peg -inline -switch query.peg DO NOT EDIT. 4 5 import ( 6 "fmt" 7 "io" 8 "os" 9 "sort" 10 "strconv" 11 "strings" 12 ) 13 14 const endSymbol rune = 1114112 15 16 /* The rule types inferred from the grammar are below. */ 17 type pegRule uint8 18 19 const ( 20 ruleUnknown pegRule = iota 21 rulee 22 rulecondition 23 ruletag 24 rulevalue 25 rulenumber 26 ruledigit 27 ruletime 28 ruledate 29 ruleyear 30 rulemonth 31 ruleday 32 ruleand 33 ruleequal 34 rulecontains 35 ruleexists 36 rulele 37 rulege 38 rulel 39 ruleg 40 rulePegText 41 ) 42 43 var rul3s = [...]string{ 44 "Unknown", 45 "e", 46 "condition", 47 "tag", 48 "value", 49 "number", 50 "digit", 51 "time", 52 "date", 53 "year", 54 "month", 55 "day", 56 "and", 57 "equal", 58 "contains", 59 "exists", 60 "le", 61 "ge", 62 "l", 63 "g", 64 "PegText", 65 } 66 67 type token32 struct { 68 pegRule 69 begin, end uint32 70 } 71 72 func (t *token32) String() string { 73 return fmt.Sprintf("\x1B[34m%v\x1B[m %v %v", rul3s[t.pegRule], t.begin, t.end) 74 } 75 76 type node32 struct { 77 token32 78 up, next *node32 79 } 80 81 func (node *node32) print(w io.Writer, pretty bool, buffer string) { 82 var print func(node *node32, depth int) 83 print = func(node *node32, depth int) { 84 for node != nil { 85 for c := 0; c < depth; c++ { 86 fmt.Fprintf(w, " ") 87 } 88 rule := rul3s[node.pegRule] 89 quote := strconv.Quote(string(([]rune(buffer)[node.begin:node.end]))) 90 if !pretty { 91 fmt.Fprintf(w, "%v %v\n", rule, quote) 92 } else { 93 fmt.Fprintf(w, "\x1B[36m%v\x1B[m %v\n", rule, quote) 94 } 95 if node.up != nil { 96 print(node.up, depth+1) 97 } 98 node = node.next 99 } 100 } 101 print(node, 0) 102 } 103 104 func (node *node32) Print(w io.Writer, buffer string) { 105 node.print(w, false, buffer) 106 } 107 108 func (node *node32) PrettyPrint(w io.Writer, buffer string) { 109 node.print(w, true, buffer) 110 } 111 112 type tokens32 struct { 113 tree []token32 114 } 115 116 func (t *tokens32) Trim(length uint32) { 117 t.tree = t.tree[:length] 118 } 119 120 func (t *tokens32) Print() { 121 for _, token := range t.tree { 122 fmt.Println(token.String()) 123 } 124 } 125 126 func (t *tokens32) AST() *node32 { 127 type element struct { 128 node *node32 129 down *element 130 } 131 tokens := t.Tokens() 132 var stack *element 133 for _, token := range tokens { 134 if token.begin == token.end { 135 continue 136 } 137 node := &node32{token32: token} 138 for stack != nil && stack.node.begin >= token.begin && stack.node.end <= token.end { 139 stack.node.next = node.up 140 node.up = stack.node 141 stack = stack.down 142 } 143 stack = &element{node: node, down: stack} 144 } 145 if stack != nil { 146 return stack.node 147 } 148 return nil 149 } 150 151 func (t *tokens32) PrintSyntaxTree(buffer string) { 152 t.AST().Print(os.Stdout, buffer) 153 } 154 155 func (t *tokens32) WriteSyntaxTree(w io.Writer, buffer string) { 156 t.AST().Print(w, buffer) 157 } 158 159 func (t *tokens32) PrettyPrintSyntaxTree(buffer string) { 160 t.AST().PrettyPrint(os.Stdout, buffer) 161 } 162 163 func (t *tokens32) Add(rule pegRule, begin, end, index uint32) { 164 tree, i := t.tree, int(index) 165 if i >= len(tree) { 166 t.tree = append(tree, token32{pegRule: rule, begin: begin, end: end}) 167 return 168 } 169 tree[i] = token32{pegRule: rule, begin: begin, end: end} 170 } 171 172 func (t *tokens32) Tokens() []token32 { 173 return t.tree 174 } 175 176 type QueryParser struct { 177 Buffer string 178 buffer []rune 179 rules [21]func() bool 180 parse func(rule ...int) error 181 reset func() 182 Pretty bool 183 tokens32 184 } 185 186 func (p *QueryParser) Parse(rule ...int) error { 187 return p.parse(rule...) 188 } 189 190 func (p *QueryParser) Reset() { 191 p.reset() 192 } 193 194 type textPosition struct { 195 line, symbol int 196 } 197 198 type textPositionMap map[int]textPosition 199 200 func translatePositions(buffer []rune, positions []int) textPositionMap { 201 length, translations, j, line, symbol := len(positions), make(textPositionMap, len(positions)), 0, 1, 0 202 sort.Ints(positions) 203 204 search: 205 for i, c := range buffer { 206 if c == '\n' { 207 line, symbol = line+1, 0 208 } else { 209 symbol++ 210 } 211 if i == positions[j] { 212 translations[positions[j]] = textPosition{line, symbol} 213 for j++; j < length; j++ { 214 if i != positions[j] { 215 continue search 216 } 217 } 218 break search 219 } 220 } 221 222 return translations 223 } 224 225 type parseError struct { 226 p *QueryParser 227 max token32 228 } 229 230 func (e *parseError) Error() string { 231 tokens, err := []token32{e.max}, "\n" 232 positions, p := make([]int, 2*len(tokens)), 0 233 for _, token := range tokens { 234 positions[p], p = int(token.begin), p+1 235 positions[p], p = int(token.end), p+1 236 } 237 translations := translatePositions(e.p.buffer, positions) 238 format := "parse error near %v (line %v symbol %v - line %v symbol %v):\n%v\n" 239 if e.p.Pretty { 240 format = "parse error near \x1B[34m%v\x1B[m (line %v symbol %v - line %v symbol %v):\n%v\n" 241 } 242 for _, token := range tokens { 243 begin, end := int(token.begin), int(token.end) 244 err += fmt.Sprintf(format, 245 rul3s[token.pegRule], 246 translations[begin].line, translations[begin].symbol, 247 translations[end].line, translations[end].symbol, 248 strconv.Quote(string(e.p.buffer[begin:end]))) 249 } 250 251 return err 252 } 253 254 func (p *QueryParser) PrintSyntaxTree() { 255 if p.Pretty { 256 p.tokens32.PrettyPrintSyntaxTree(p.Buffer) 257 } else { 258 p.tokens32.PrintSyntaxTree(p.Buffer) 259 } 260 } 261 262 func (p *QueryParser) WriteSyntaxTree(w io.Writer) { 263 p.tokens32.WriteSyntaxTree(w, p.Buffer) 264 } 265 266 func (p *QueryParser) SprintSyntaxTree() string { 267 var bldr strings.Builder 268 p.WriteSyntaxTree(&bldr) 269 return bldr.String() 270 } 271 272 func Pretty(pretty bool) func(*QueryParser) error { 273 return func(p *QueryParser) error { 274 p.Pretty = pretty 275 return nil 276 } 277 } 278 279 func Size(size int) func(*QueryParser) error { 280 return func(p *QueryParser) error { 281 p.tokens32 = tokens32{tree: make([]token32, 0, size)} 282 return nil 283 } 284 } 285 func (p *QueryParser) Init(options ...func(*QueryParser) error) error { 286 var ( 287 max token32 288 position, tokenIndex uint32 289 buffer []rune 290 ) 291 for _, option := range options { 292 err := option(p) 293 if err != nil { 294 return err 295 } 296 } 297 p.reset = func() { 298 max = token32{} 299 position, tokenIndex = 0, 0 300 301 p.buffer = []rune(p.Buffer) 302 if len(p.buffer) == 0 || p.buffer[len(p.buffer)-1] != endSymbol { 303 p.buffer = append(p.buffer, endSymbol) 304 } 305 buffer = p.buffer 306 } 307 p.reset() 308 309 _rules := p.rules 310 tree := p.tokens32 311 p.parse = func(rule ...int) error { 312 r := 1 313 if len(rule) > 0 { 314 r = rule[0] 315 } 316 matches := p.rules[r]() 317 p.tokens32 = tree 318 if matches { 319 p.Trim(tokenIndex) 320 return nil 321 } 322 return &parseError{p, max} 323 } 324 325 add := func(rule pegRule, begin uint32) { 326 tree.Add(rule, begin, position, tokenIndex) 327 tokenIndex++ 328 if begin != position && position > max.end { 329 max = token32{rule, begin, position} 330 } 331 } 332 333 matchDot := func() bool { 334 if buffer[position] != endSymbol { 335 position++ 336 return true 337 } 338 return false 339 } 340 341 /*matchChar := func(c byte) bool { 342 if buffer[position] == c { 343 position++ 344 return true 345 } 346 return false 347 }*/ 348 349 /*matchRange := func(lower byte, upper byte) bool { 350 if c := buffer[position]; c >= lower && c <= upper { 351 position++ 352 return true 353 } 354 return false 355 }*/ 356 357 _rules = [...]func() bool{ 358 nil, 359 /* 0 e <- <('"' condition (' '+ and ' '+ condition)* '"' !.)> */ 360 func() bool { 361 position0, tokenIndex0 := position, tokenIndex 362 { 363 position1 := position 364 if buffer[position] != rune('"') { 365 goto l0 366 } 367 position++ 368 if !_rules[rulecondition]() { 369 goto l0 370 } 371 l2: 372 { 373 position3, tokenIndex3 := position, tokenIndex 374 if buffer[position] != rune(' ') { 375 goto l3 376 } 377 position++ 378 l4: 379 { 380 position5, tokenIndex5 := position, tokenIndex 381 if buffer[position] != rune(' ') { 382 goto l5 383 } 384 position++ 385 goto l4 386 l5: 387 position, tokenIndex = position5, tokenIndex5 388 } 389 { 390 position6 := position 391 { 392 position7, tokenIndex7 := position, tokenIndex 393 if buffer[position] != rune('a') { 394 goto l8 395 } 396 position++ 397 goto l7 398 l8: 399 position, tokenIndex = position7, tokenIndex7 400 if buffer[position] != rune('A') { 401 goto l3 402 } 403 position++ 404 } 405 l7: 406 { 407 position9, tokenIndex9 := position, tokenIndex 408 if buffer[position] != rune('n') { 409 goto l10 410 } 411 position++ 412 goto l9 413 l10: 414 position, tokenIndex = position9, tokenIndex9 415 if buffer[position] != rune('N') { 416 goto l3 417 } 418 position++ 419 } 420 l9: 421 { 422 position11, tokenIndex11 := position, tokenIndex 423 if buffer[position] != rune('d') { 424 goto l12 425 } 426 position++ 427 goto l11 428 l12: 429 position, tokenIndex = position11, tokenIndex11 430 if buffer[position] != rune('D') { 431 goto l3 432 } 433 position++ 434 } 435 l11: 436 add(ruleand, position6) 437 } 438 if buffer[position] != rune(' ') { 439 goto l3 440 } 441 position++ 442 l13: 443 { 444 position14, tokenIndex14 := position, tokenIndex 445 if buffer[position] != rune(' ') { 446 goto l14 447 } 448 position++ 449 goto l13 450 l14: 451 position, tokenIndex = position14, tokenIndex14 452 } 453 if !_rules[rulecondition]() { 454 goto l3 455 } 456 goto l2 457 l3: 458 position, tokenIndex = position3, tokenIndex3 459 } 460 if buffer[position] != rune('"') { 461 goto l0 462 } 463 position++ 464 { 465 position15, tokenIndex15 := position, tokenIndex 466 if !matchDot() { 467 goto l15 468 } 469 goto l0 470 l15: 471 position, tokenIndex = position15, tokenIndex15 472 } 473 add(rulee, position1) 474 } 475 return true 476 l0: 477 position, tokenIndex = position0, tokenIndex0 478 return false 479 }, 480 /* 1 condition <- <(tag ' '* ((le ' '* ((&('D' | 'd') date) | (&('T' | 't') time) | (&('0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9') number))) / (ge ' '* ((&('D' | 'd') date) | (&('T' | 't') time) | (&('0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9') number))) / ((&('E' | 'e') exists) | (&('=') (equal ' '* ((&('\'') value) | (&('D' | 'd') date) | (&('T' | 't') time) | (&('0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9') number)))) | (&('>') (g ' '* ((&('D' | 'd') date) | (&('T' | 't') time) | (&('0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9') number)))) | (&('<') (l ' '* ((&('D' | 'd') date) | (&('T' | 't') time) | (&('0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9') number)))) | (&('C' | 'c') (contains ' '* value)))))> */ 481 func() bool { 482 position16, tokenIndex16 := position, tokenIndex 483 { 484 position17 := position 485 { 486 position18 := position 487 { 488 position19 := position 489 { 490 position22, tokenIndex22 := position, tokenIndex 491 { 492 switch buffer[position] { 493 case '<': 494 if buffer[position] != rune('<') { 495 goto l22 496 } 497 position++ 498 case '>': 499 if buffer[position] != rune('>') { 500 goto l22 501 } 502 position++ 503 case '=': 504 if buffer[position] != rune('=') { 505 goto l22 506 } 507 position++ 508 case '\'': 509 if buffer[position] != rune('\'') { 510 goto l22 511 } 512 position++ 513 case '"': 514 if buffer[position] != rune('"') { 515 goto l22 516 } 517 position++ 518 case ')': 519 if buffer[position] != rune(')') { 520 goto l22 521 } 522 position++ 523 case '(': 524 if buffer[position] != rune('(') { 525 goto l22 526 } 527 position++ 528 case '\\': 529 if buffer[position] != rune('\\') { 530 goto l22 531 } 532 position++ 533 case '\r': 534 if buffer[position] != rune('\r') { 535 goto l22 536 } 537 position++ 538 case '\n': 539 if buffer[position] != rune('\n') { 540 goto l22 541 } 542 position++ 543 case '\t': 544 if buffer[position] != rune('\t') { 545 goto l22 546 } 547 position++ 548 default: 549 if buffer[position] != rune(' ') { 550 goto l22 551 } 552 position++ 553 } 554 } 555 556 goto l16 557 l22: 558 position, tokenIndex = position22, tokenIndex22 559 } 560 if !matchDot() { 561 goto l16 562 } 563 l20: 564 { 565 position21, tokenIndex21 := position, tokenIndex 566 { 567 position24, tokenIndex24 := position, tokenIndex 568 { 569 switch buffer[position] { 570 case '<': 571 if buffer[position] != rune('<') { 572 goto l24 573 } 574 position++ 575 case '>': 576 if buffer[position] != rune('>') { 577 goto l24 578 } 579 position++ 580 case '=': 581 if buffer[position] != rune('=') { 582 goto l24 583 } 584 position++ 585 case '\'': 586 if buffer[position] != rune('\'') { 587 goto l24 588 } 589 position++ 590 case '"': 591 if buffer[position] != rune('"') { 592 goto l24 593 } 594 position++ 595 case ')': 596 if buffer[position] != rune(')') { 597 goto l24 598 } 599 position++ 600 case '(': 601 if buffer[position] != rune('(') { 602 goto l24 603 } 604 position++ 605 case '\\': 606 if buffer[position] != rune('\\') { 607 goto l24 608 } 609 position++ 610 case '\r': 611 if buffer[position] != rune('\r') { 612 goto l24 613 } 614 position++ 615 case '\n': 616 if buffer[position] != rune('\n') { 617 goto l24 618 } 619 position++ 620 case '\t': 621 if buffer[position] != rune('\t') { 622 goto l24 623 } 624 position++ 625 default: 626 if buffer[position] != rune(' ') { 627 goto l24 628 } 629 position++ 630 } 631 } 632 633 goto l21 634 l24: 635 position, tokenIndex = position24, tokenIndex24 636 } 637 if !matchDot() { 638 goto l21 639 } 640 goto l20 641 l21: 642 position, tokenIndex = position21, tokenIndex21 643 } 644 add(rulePegText, position19) 645 } 646 add(ruletag, position18) 647 } 648 l26: 649 { 650 position27, tokenIndex27 := position, tokenIndex 651 if buffer[position] != rune(' ') { 652 goto l27 653 } 654 position++ 655 goto l26 656 l27: 657 position, tokenIndex = position27, tokenIndex27 658 } 659 { 660 position28, tokenIndex28 := position, tokenIndex 661 { 662 position30 := position 663 if buffer[position] != rune('<') { 664 goto l29 665 } 666 position++ 667 if buffer[position] != rune('=') { 668 goto l29 669 } 670 position++ 671 add(rulele, position30) 672 } 673 l31: 674 { 675 position32, tokenIndex32 := position, tokenIndex 676 if buffer[position] != rune(' ') { 677 goto l32 678 } 679 position++ 680 goto l31 681 l32: 682 position, tokenIndex = position32, tokenIndex32 683 } 684 { 685 switch buffer[position] { 686 case 'D', 'd': 687 if !_rules[ruledate]() { 688 goto l29 689 } 690 case 'T', 't': 691 if !_rules[ruletime]() { 692 goto l29 693 } 694 default: 695 if !_rules[rulenumber]() { 696 goto l29 697 } 698 } 699 } 700 701 goto l28 702 l29: 703 position, tokenIndex = position28, tokenIndex28 704 { 705 position35 := position 706 if buffer[position] != rune('>') { 707 goto l34 708 } 709 position++ 710 if buffer[position] != rune('=') { 711 goto l34 712 } 713 position++ 714 add(rulege, position35) 715 } 716 l36: 717 { 718 position37, tokenIndex37 := position, tokenIndex 719 if buffer[position] != rune(' ') { 720 goto l37 721 } 722 position++ 723 goto l36 724 l37: 725 position, tokenIndex = position37, tokenIndex37 726 } 727 { 728 switch buffer[position] { 729 case 'D', 'd': 730 if !_rules[ruledate]() { 731 goto l34 732 } 733 case 'T', 't': 734 if !_rules[ruletime]() { 735 goto l34 736 } 737 default: 738 if !_rules[rulenumber]() { 739 goto l34 740 } 741 } 742 } 743 744 goto l28 745 l34: 746 position, tokenIndex = position28, tokenIndex28 747 { 748 switch buffer[position] { 749 case 'E', 'e': 750 { 751 position40 := position 752 { 753 position41, tokenIndex41 := position, tokenIndex 754 if buffer[position] != rune('e') { 755 goto l42 756 } 757 position++ 758 goto l41 759 l42: 760 position, tokenIndex = position41, tokenIndex41 761 if buffer[position] != rune('E') { 762 goto l16 763 } 764 position++ 765 } 766 l41: 767 { 768 position43, tokenIndex43 := position, tokenIndex 769 if buffer[position] != rune('x') { 770 goto l44 771 } 772 position++ 773 goto l43 774 l44: 775 position, tokenIndex = position43, tokenIndex43 776 if buffer[position] != rune('X') { 777 goto l16 778 } 779 position++ 780 } 781 l43: 782 { 783 position45, tokenIndex45 := position, tokenIndex 784 if buffer[position] != rune('i') { 785 goto l46 786 } 787 position++ 788 goto l45 789 l46: 790 position, tokenIndex = position45, tokenIndex45 791 if buffer[position] != rune('I') { 792 goto l16 793 } 794 position++ 795 } 796 l45: 797 { 798 position47, tokenIndex47 := position, tokenIndex 799 if buffer[position] != rune('s') { 800 goto l48 801 } 802 position++ 803 goto l47 804 l48: 805 position, tokenIndex = position47, tokenIndex47 806 if buffer[position] != rune('S') { 807 goto l16 808 } 809 position++ 810 } 811 l47: 812 { 813 position49, tokenIndex49 := position, tokenIndex 814 if buffer[position] != rune('t') { 815 goto l50 816 } 817 position++ 818 goto l49 819 l50: 820 position, tokenIndex = position49, tokenIndex49 821 if buffer[position] != rune('T') { 822 goto l16 823 } 824 position++ 825 } 826 l49: 827 { 828 position51, tokenIndex51 := position, tokenIndex 829 if buffer[position] != rune('s') { 830 goto l52 831 } 832 position++ 833 goto l51 834 l52: 835 position, tokenIndex = position51, tokenIndex51 836 if buffer[position] != rune('S') { 837 goto l16 838 } 839 position++ 840 } 841 l51: 842 add(ruleexists, position40) 843 } 844 case '=': 845 { 846 position53 := position 847 if buffer[position] != rune('=') { 848 goto l16 849 } 850 position++ 851 add(ruleequal, position53) 852 } 853 l54: 854 { 855 position55, tokenIndex55 := position, tokenIndex 856 if buffer[position] != rune(' ') { 857 goto l55 858 } 859 position++ 860 goto l54 861 l55: 862 position, tokenIndex = position55, tokenIndex55 863 } 864 { 865 switch buffer[position] { 866 case '\'': 867 if !_rules[rulevalue]() { 868 goto l16 869 } 870 case 'D', 'd': 871 if !_rules[ruledate]() { 872 goto l16 873 } 874 case 'T', 't': 875 if !_rules[ruletime]() { 876 goto l16 877 } 878 default: 879 if !_rules[rulenumber]() { 880 goto l16 881 } 882 } 883 } 884 885 case '>': 886 { 887 position57 := position 888 if buffer[position] != rune('>') { 889 goto l16 890 } 891 position++ 892 add(ruleg, position57) 893 } 894 l58: 895 { 896 position59, tokenIndex59 := position, tokenIndex 897 if buffer[position] != rune(' ') { 898 goto l59 899 } 900 position++ 901 goto l58 902 l59: 903 position, tokenIndex = position59, tokenIndex59 904 } 905 { 906 switch buffer[position] { 907 case 'D', 'd': 908 if !_rules[ruledate]() { 909 goto l16 910 } 911 case 'T', 't': 912 if !_rules[ruletime]() { 913 goto l16 914 } 915 default: 916 if !_rules[rulenumber]() { 917 goto l16 918 } 919 } 920 } 921 922 case '<': 923 { 924 position61 := position 925 if buffer[position] != rune('<') { 926 goto l16 927 } 928 position++ 929 add(rulel, position61) 930 } 931 l62: 932 { 933 position63, tokenIndex63 := position, tokenIndex 934 if buffer[position] != rune(' ') { 935 goto l63 936 } 937 position++ 938 goto l62 939 l63: 940 position, tokenIndex = position63, tokenIndex63 941 } 942 { 943 switch buffer[position] { 944 case 'D', 'd': 945 if !_rules[ruledate]() { 946 goto l16 947 } 948 case 'T', 't': 949 if !_rules[ruletime]() { 950 goto l16 951 } 952 default: 953 if !_rules[rulenumber]() { 954 goto l16 955 } 956 } 957 } 958 959 default: 960 { 961 position65 := position 962 { 963 position66, tokenIndex66 := position, tokenIndex 964 if buffer[position] != rune('c') { 965 goto l67 966 } 967 position++ 968 goto l66 969 l67: 970 position, tokenIndex = position66, tokenIndex66 971 if buffer[position] != rune('C') { 972 goto l16 973 } 974 position++ 975 } 976 l66: 977 { 978 position68, tokenIndex68 := position, tokenIndex 979 if buffer[position] != rune('o') { 980 goto l69 981 } 982 position++ 983 goto l68 984 l69: 985 position, tokenIndex = position68, tokenIndex68 986 if buffer[position] != rune('O') { 987 goto l16 988 } 989 position++ 990 } 991 l68: 992 { 993 position70, tokenIndex70 := position, tokenIndex 994 if buffer[position] != rune('n') { 995 goto l71 996 } 997 position++ 998 goto l70 999 l71: 1000 position, tokenIndex = position70, tokenIndex70 1001 if buffer[position] != rune('N') { 1002 goto l16 1003 } 1004 position++ 1005 } 1006 l70: 1007 { 1008 position72, tokenIndex72 := position, tokenIndex 1009 if buffer[position] != rune('t') { 1010 goto l73 1011 } 1012 position++ 1013 goto l72 1014 l73: 1015 position, tokenIndex = position72, tokenIndex72 1016 if buffer[position] != rune('T') { 1017 goto l16 1018 } 1019 position++ 1020 } 1021 l72: 1022 { 1023 position74, tokenIndex74 := position, tokenIndex 1024 if buffer[position] != rune('a') { 1025 goto l75 1026 } 1027 position++ 1028 goto l74 1029 l75: 1030 position, tokenIndex = position74, tokenIndex74 1031 if buffer[position] != rune('A') { 1032 goto l16 1033 } 1034 position++ 1035 } 1036 l74: 1037 { 1038 position76, tokenIndex76 := position, tokenIndex 1039 if buffer[position] != rune('i') { 1040 goto l77 1041 } 1042 position++ 1043 goto l76 1044 l77: 1045 position, tokenIndex = position76, tokenIndex76 1046 if buffer[position] != rune('I') { 1047 goto l16 1048 } 1049 position++ 1050 } 1051 l76: 1052 { 1053 position78, tokenIndex78 := position, tokenIndex 1054 if buffer[position] != rune('n') { 1055 goto l79 1056 } 1057 position++ 1058 goto l78 1059 l79: 1060 position, tokenIndex = position78, tokenIndex78 1061 if buffer[position] != rune('N') { 1062 goto l16 1063 } 1064 position++ 1065 } 1066 l78: 1067 { 1068 position80, tokenIndex80 := position, tokenIndex 1069 if buffer[position] != rune('s') { 1070 goto l81 1071 } 1072 position++ 1073 goto l80 1074 l81: 1075 position, tokenIndex = position80, tokenIndex80 1076 if buffer[position] != rune('S') { 1077 goto l16 1078 } 1079 position++ 1080 } 1081 l80: 1082 add(rulecontains, position65) 1083 } 1084 l82: 1085 { 1086 position83, tokenIndex83 := position, tokenIndex 1087 if buffer[position] != rune(' ') { 1088 goto l83 1089 } 1090 position++ 1091 goto l82 1092 l83: 1093 position, tokenIndex = position83, tokenIndex83 1094 } 1095 if !_rules[rulevalue]() { 1096 goto l16 1097 } 1098 } 1099 } 1100 1101 } 1102 l28: 1103 add(rulecondition, position17) 1104 } 1105 return true 1106 l16: 1107 position, tokenIndex = position16, tokenIndex16 1108 return false 1109 }, 1110 /* 2 tag <- <<(!((&('<') '<') | (&('>') '>') | (&('=') '=') | (&('\'') '\'') | (&('"') '"') | (&(')') ')') | (&('(') '(') | (&('\\') '\\') | (&('\r') '\r') | (&('\n') '\n') | (&('\t') '\t') | (&(' ') ' ')) .)+>> */ 1111 nil, 1112 /* 3 value <- <<('\'' (!('"' / '\'') .)* '\'')>> */ 1113 func() bool { 1114 position85, tokenIndex85 := position, tokenIndex 1115 { 1116 position86 := position 1117 { 1118 position87 := position 1119 if buffer[position] != rune('\'') { 1120 goto l85 1121 } 1122 position++ 1123 l88: 1124 { 1125 position89, tokenIndex89 := position, tokenIndex 1126 { 1127 position90, tokenIndex90 := position, tokenIndex 1128 { 1129 position91, tokenIndex91 := position, tokenIndex 1130 if buffer[position] != rune('"') { 1131 goto l92 1132 } 1133 position++ 1134 goto l91 1135 l92: 1136 position, tokenIndex = position91, tokenIndex91 1137 if buffer[position] != rune('\'') { 1138 goto l90 1139 } 1140 position++ 1141 } 1142 l91: 1143 goto l89 1144 l90: 1145 position, tokenIndex = position90, tokenIndex90 1146 } 1147 if !matchDot() { 1148 goto l89 1149 } 1150 goto l88 1151 l89: 1152 position, tokenIndex = position89, tokenIndex89 1153 } 1154 if buffer[position] != rune('\'') { 1155 goto l85 1156 } 1157 position++ 1158 add(rulePegText, position87) 1159 } 1160 add(rulevalue, position86) 1161 } 1162 return true 1163 l85: 1164 position, tokenIndex = position85, tokenIndex85 1165 return false 1166 }, 1167 /* 4 number <- <<('0' / ([1-9] digit* ('.' digit*)?))>> */ 1168 func() bool { 1169 position93, tokenIndex93 := position, tokenIndex 1170 { 1171 position94 := position 1172 { 1173 position95 := position 1174 { 1175 position96, tokenIndex96 := position, tokenIndex 1176 if buffer[position] != rune('0') { 1177 goto l97 1178 } 1179 position++ 1180 goto l96 1181 l97: 1182 position, tokenIndex = position96, tokenIndex96 1183 if c := buffer[position]; c < rune('1') || c > rune('9') { 1184 goto l93 1185 } 1186 position++ 1187 l98: 1188 { 1189 position99, tokenIndex99 := position, tokenIndex 1190 if !_rules[ruledigit]() { 1191 goto l99 1192 } 1193 goto l98 1194 l99: 1195 position, tokenIndex = position99, tokenIndex99 1196 } 1197 { 1198 position100, tokenIndex100 := position, tokenIndex 1199 if buffer[position] != rune('.') { 1200 goto l100 1201 } 1202 position++ 1203 l102: 1204 { 1205 position103, tokenIndex103 := position, tokenIndex 1206 if !_rules[ruledigit]() { 1207 goto l103 1208 } 1209 goto l102 1210 l103: 1211 position, tokenIndex = position103, tokenIndex103 1212 } 1213 goto l101 1214 l100: 1215 position, tokenIndex = position100, tokenIndex100 1216 } 1217 l101: 1218 } 1219 l96: 1220 add(rulePegText, position95) 1221 } 1222 add(rulenumber, position94) 1223 } 1224 return true 1225 l93: 1226 position, tokenIndex = position93, tokenIndex93 1227 return false 1228 }, 1229 /* 5 digit <- <[0-9]> */ 1230 func() bool { 1231 position104, tokenIndex104 := position, tokenIndex 1232 { 1233 position105 := position 1234 if c := buffer[position]; c < rune('0') || c > rune('9') { 1235 goto l104 1236 } 1237 position++ 1238 add(ruledigit, position105) 1239 } 1240 return true 1241 l104: 1242 position, tokenIndex = position104, tokenIndex104 1243 return false 1244 }, 1245 /* 6 time <- <(('t' / 'T') ('i' / 'I') ('m' / 'M') ('e' / 'E') ' ' <(year '-' month '-' day 'T' digit digit ':' digit digit ':' digit digit ((('-' / '+') digit digit ':' digit digit) / 'Z'))>)> */ 1246 func() bool { 1247 position106, tokenIndex106 := position, tokenIndex 1248 { 1249 position107 := position 1250 { 1251 position108, tokenIndex108 := position, tokenIndex 1252 if buffer[position] != rune('t') { 1253 goto l109 1254 } 1255 position++ 1256 goto l108 1257 l109: 1258 position, tokenIndex = position108, tokenIndex108 1259 if buffer[position] != rune('T') { 1260 goto l106 1261 } 1262 position++ 1263 } 1264 l108: 1265 { 1266 position110, tokenIndex110 := position, tokenIndex 1267 if buffer[position] != rune('i') { 1268 goto l111 1269 } 1270 position++ 1271 goto l110 1272 l111: 1273 position, tokenIndex = position110, tokenIndex110 1274 if buffer[position] != rune('I') { 1275 goto l106 1276 } 1277 position++ 1278 } 1279 l110: 1280 { 1281 position112, tokenIndex112 := position, tokenIndex 1282 if buffer[position] != rune('m') { 1283 goto l113 1284 } 1285 position++ 1286 goto l112 1287 l113: 1288 position, tokenIndex = position112, tokenIndex112 1289 if buffer[position] != rune('M') { 1290 goto l106 1291 } 1292 position++ 1293 } 1294 l112: 1295 { 1296 position114, tokenIndex114 := position, tokenIndex 1297 if buffer[position] != rune('e') { 1298 goto l115 1299 } 1300 position++ 1301 goto l114 1302 l115: 1303 position, tokenIndex = position114, tokenIndex114 1304 if buffer[position] != rune('E') { 1305 goto l106 1306 } 1307 position++ 1308 } 1309 l114: 1310 if buffer[position] != rune(' ') { 1311 goto l106 1312 } 1313 position++ 1314 { 1315 position116 := position 1316 if !_rules[ruleyear]() { 1317 goto l106 1318 } 1319 if buffer[position] != rune('-') { 1320 goto l106 1321 } 1322 position++ 1323 if !_rules[rulemonth]() { 1324 goto l106 1325 } 1326 if buffer[position] != rune('-') { 1327 goto l106 1328 } 1329 position++ 1330 if !_rules[ruleday]() { 1331 goto l106 1332 } 1333 if buffer[position] != rune('T') { 1334 goto l106 1335 } 1336 position++ 1337 if !_rules[ruledigit]() { 1338 goto l106 1339 } 1340 if !_rules[ruledigit]() { 1341 goto l106 1342 } 1343 if buffer[position] != rune(':') { 1344 goto l106 1345 } 1346 position++ 1347 if !_rules[ruledigit]() { 1348 goto l106 1349 } 1350 if !_rules[ruledigit]() { 1351 goto l106 1352 } 1353 if buffer[position] != rune(':') { 1354 goto l106 1355 } 1356 position++ 1357 if !_rules[ruledigit]() { 1358 goto l106 1359 } 1360 if !_rules[ruledigit]() { 1361 goto l106 1362 } 1363 { 1364 position117, tokenIndex117 := position, tokenIndex 1365 { 1366 position119, tokenIndex119 := position, tokenIndex 1367 if buffer[position] != rune('-') { 1368 goto l120 1369 } 1370 position++ 1371 goto l119 1372 l120: 1373 position, tokenIndex = position119, tokenIndex119 1374 if buffer[position] != rune('+') { 1375 goto l118 1376 } 1377 position++ 1378 } 1379 l119: 1380 if !_rules[ruledigit]() { 1381 goto l118 1382 } 1383 if !_rules[ruledigit]() { 1384 goto l118 1385 } 1386 if buffer[position] != rune(':') { 1387 goto l118 1388 } 1389 position++ 1390 if !_rules[ruledigit]() { 1391 goto l118 1392 } 1393 if !_rules[ruledigit]() { 1394 goto l118 1395 } 1396 goto l117 1397 l118: 1398 position, tokenIndex = position117, tokenIndex117 1399 if buffer[position] != rune('Z') { 1400 goto l106 1401 } 1402 position++ 1403 } 1404 l117: 1405 add(rulePegText, position116) 1406 } 1407 add(ruletime, position107) 1408 } 1409 return true 1410 l106: 1411 position, tokenIndex = position106, tokenIndex106 1412 return false 1413 }, 1414 /* 7 date <- <(('d' / 'D') ('a' / 'A') ('t' / 'T') ('e' / 'E') ' ' <(year '-' month '-' day)>)> */ 1415 func() bool { 1416 position121, tokenIndex121 := position, tokenIndex 1417 { 1418 position122 := position 1419 { 1420 position123, tokenIndex123 := position, tokenIndex 1421 if buffer[position] != rune('d') { 1422 goto l124 1423 } 1424 position++ 1425 goto l123 1426 l124: 1427 position, tokenIndex = position123, tokenIndex123 1428 if buffer[position] != rune('D') { 1429 goto l121 1430 } 1431 position++ 1432 } 1433 l123: 1434 { 1435 position125, tokenIndex125 := position, tokenIndex 1436 if buffer[position] != rune('a') { 1437 goto l126 1438 } 1439 position++ 1440 goto l125 1441 l126: 1442 position, tokenIndex = position125, tokenIndex125 1443 if buffer[position] != rune('A') { 1444 goto l121 1445 } 1446 position++ 1447 } 1448 l125: 1449 { 1450 position127, tokenIndex127 := position, tokenIndex 1451 if buffer[position] != rune('t') { 1452 goto l128 1453 } 1454 position++ 1455 goto l127 1456 l128: 1457 position, tokenIndex = position127, tokenIndex127 1458 if buffer[position] != rune('T') { 1459 goto l121 1460 } 1461 position++ 1462 } 1463 l127: 1464 { 1465 position129, tokenIndex129 := position, tokenIndex 1466 if buffer[position] != rune('e') { 1467 goto l130 1468 } 1469 position++ 1470 goto l129 1471 l130: 1472 position, tokenIndex = position129, tokenIndex129 1473 if buffer[position] != rune('E') { 1474 goto l121 1475 } 1476 position++ 1477 } 1478 l129: 1479 if buffer[position] != rune(' ') { 1480 goto l121 1481 } 1482 position++ 1483 { 1484 position131 := position 1485 if !_rules[ruleyear]() { 1486 goto l121 1487 } 1488 if buffer[position] != rune('-') { 1489 goto l121 1490 } 1491 position++ 1492 if !_rules[rulemonth]() { 1493 goto l121 1494 } 1495 if buffer[position] != rune('-') { 1496 goto l121 1497 } 1498 position++ 1499 if !_rules[ruleday]() { 1500 goto l121 1501 } 1502 add(rulePegText, position131) 1503 } 1504 add(ruledate, position122) 1505 } 1506 return true 1507 l121: 1508 position, tokenIndex = position121, tokenIndex121 1509 return false 1510 }, 1511 /* 8 year <- <(('1' / '2') digit digit digit)> */ 1512 func() bool { 1513 position132, tokenIndex132 := position, tokenIndex 1514 { 1515 position133 := position 1516 { 1517 position134, tokenIndex134 := position, tokenIndex 1518 if buffer[position] != rune('1') { 1519 goto l135 1520 } 1521 position++ 1522 goto l134 1523 l135: 1524 position, tokenIndex = position134, tokenIndex134 1525 if buffer[position] != rune('2') { 1526 goto l132 1527 } 1528 position++ 1529 } 1530 l134: 1531 if !_rules[ruledigit]() { 1532 goto l132 1533 } 1534 if !_rules[ruledigit]() { 1535 goto l132 1536 } 1537 if !_rules[ruledigit]() { 1538 goto l132 1539 } 1540 add(ruleyear, position133) 1541 } 1542 return true 1543 l132: 1544 position, tokenIndex = position132, tokenIndex132 1545 return false 1546 }, 1547 /* 9 month <- <(('0' / '1') digit)> */ 1548 func() bool { 1549 position136, tokenIndex136 := position, tokenIndex 1550 { 1551 position137 := position 1552 { 1553 position138, tokenIndex138 := position, tokenIndex 1554 if buffer[position] != rune('0') { 1555 goto l139 1556 } 1557 position++ 1558 goto l138 1559 l139: 1560 position, tokenIndex = position138, tokenIndex138 1561 if buffer[position] != rune('1') { 1562 goto l136 1563 } 1564 position++ 1565 } 1566 l138: 1567 if !_rules[ruledigit]() { 1568 goto l136 1569 } 1570 add(rulemonth, position137) 1571 } 1572 return true 1573 l136: 1574 position, tokenIndex = position136, tokenIndex136 1575 return false 1576 }, 1577 /* 10 day <- <(((&('3') '3') | (&('2') '2') | (&('1') '1') | (&('0') '0')) digit)> */ 1578 func() bool { 1579 position140, tokenIndex140 := position, tokenIndex 1580 { 1581 position141 := position 1582 { 1583 switch buffer[position] { 1584 case '3': 1585 if buffer[position] != rune('3') { 1586 goto l140 1587 } 1588 position++ 1589 case '2': 1590 if buffer[position] != rune('2') { 1591 goto l140 1592 } 1593 position++ 1594 case '1': 1595 if buffer[position] != rune('1') { 1596 goto l140 1597 } 1598 position++ 1599 default: 1600 if buffer[position] != rune('0') { 1601 goto l140 1602 } 1603 position++ 1604 } 1605 } 1606 1607 if !_rules[ruledigit]() { 1608 goto l140 1609 } 1610 add(ruleday, position141) 1611 } 1612 return true 1613 l140: 1614 position, tokenIndex = position140, tokenIndex140 1615 return false 1616 }, 1617 /* 11 and <- <(('a' / 'A') ('n' / 'N') ('d' / 'D'))> */ 1618 nil, 1619 /* 12 equal <- <'='> */ 1620 nil, 1621 /* 13 contains <- <(('c' / 'C') ('o' / 'O') ('n' / 'N') ('t' / 'T') ('a' / 'A') ('i' / 'I') ('n' / 'N') ('s' / 'S'))> */ 1622 nil, 1623 /* 14 exists <- <(('e' / 'E') ('x' / 'X') ('i' / 'I') ('s' / 'S') ('t' / 'T') ('s' / 'S'))> */ 1624 nil, 1625 /* 15 le <- <('<' '=')> */ 1626 nil, 1627 /* 16 ge <- <('>' '=')> */ 1628 nil, 1629 /* 17 l <- <'<'> */ 1630 nil, 1631 /* 18 g <- <'>'> */ 1632 nil, 1633 nil, 1634 } 1635 p.rules = _rules 1636 return nil 1637 }