github.com/Finschia/ostracon@v1.1.5/libs/pubsub/query/query.peg.go (about) 1 package query 2 3 // Code generated by 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 if buffer[position] != rune('\\') { 1129 goto l91 1130 } 1131 position++ 1132 if !matchDot() { 1133 goto l91 1134 } 1135 goto l90 1136 l91: 1137 position, tokenIndex = position90, tokenIndex90 1138 { 1139 position92, tokenIndex92 := position, tokenIndex 1140 if buffer[position] != rune('\'') { 1141 goto l92 1142 } 1143 position++ 1144 goto l89 1145 l92: 1146 position, tokenIndex = position92, tokenIndex92 1147 } 1148 if !matchDot() { 1149 goto l89 1150 } 1151 } 1152 l90: 1153 goto l88 1154 l89: 1155 position, tokenIndex = position89, tokenIndex89 1156 } 1157 if buffer[position] != rune('\'') { 1158 goto l85 1159 } 1160 position++ 1161 add(rulePegText, position87) 1162 } 1163 add(rulevalue, position86) 1164 } 1165 return true 1166 l85: 1167 position, tokenIndex = position85, tokenIndex85 1168 return false 1169 }, 1170 /* 4 number <- <<('0' / ([1-9] digit* ('.' digit*)?))>> */ 1171 func() bool { 1172 position93, tokenIndex93 := position, tokenIndex 1173 { 1174 position94 := position 1175 { 1176 position95 := position 1177 { 1178 position96, tokenIndex96 := position, tokenIndex 1179 if buffer[position] != rune('0') { 1180 goto l97 1181 } 1182 position++ 1183 goto l96 1184 l97: 1185 position, tokenIndex = position96, tokenIndex96 1186 if c := buffer[position]; c < rune('1') || c > rune('9') { 1187 goto l93 1188 } 1189 position++ 1190 l98: 1191 { 1192 position99, tokenIndex99 := position, tokenIndex 1193 if !_rules[ruledigit]() { 1194 goto l99 1195 } 1196 goto l98 1197 l99: 1198 position, tokenIndex = position99, tokenIndex99 1199 } 1200 { 1201 position100, tokenIndex100 := position, tokenIndex 1202 if buffer[position] != rune('.') { 1203 goto l100 1204 } 1205 position++ 1206 l102: 1207 { 1208 position103, tokenIndex103 := position, tokenIndex 1209 if !_rules[ruledigit]() { 1210 goto l103 1211 } 1212 goto l102 1213 l103: 1214 position, tokenIndex = position103, tokenIndex103 1215 } 1216 goto l101 1217 l100: 1218 position, tokenIndex = position100, tokenIndex100 1219 } 1220 l101: 1221 } 1222 l96: 1223 add(rulePegText, position95) 1224 } 1225 add(rulenumber, position94) 1226 } 1227 return true 1228 l93: 1229 position, tokenIndex = position93, tokenIndex93 1230 return false 1231 }, 1232 /* 5 digit <- <[0-9]> */ 1233 func() bool { 1234 position104, tokenIndex104 := position, tokenIndex 1235 { 1236 position105 := position 1237 if c := buffer[position]; c < rune('0') || c > rune('9') { 1238 goto l104 1239 } 1240 position++ 1241 add(ruledigit, position105) 1242 } 1243 return true 1244 l104: 1245 position, tokenIndex = position104, tokenIndex104 1246 return false 1247 }, 1248 /* 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'))>)> */ 1249 func() bool { 1250 position106, tokenIndex106 := position, tokenIndex 1251 { 1252 position107 := position 1253 { 1254 position108, tokenIndex108 := position, tokenIndex 1255 if buffer[position] != rune('t') { 1256 goto l109 1257 } 1258 position++ 1259 goto l108 1260 l109: 1261 position, tokenIndex = position108, tokenIndex108 1262 if buffer[position] != rune('T') { 1263 goto l106 1264 } 1265 position++ 1266 } 1267 l108: 1268 { 1269 position110, tokenIndex110 := position, tokenIndex 1270 if buffer[position] != rune('i') { 1271 goto l111 1272 } 1273 position++ 1274 goto l110 1275 l111: 1276 position, tokenIndex = position110, tokenIndex110 1277 if buffer[position] != rune('I') { 1278 goto l106 1279 } 1280 position++ 1281 } 1282 l110: 1283 { 1284 position112, tokenIndex112 := position, tokenIndex 1285 if buffer[position] != rune('m') { 1286 goto l113 1287 } 1288 position++ 1289 goto l112 1290 l113: 1291 position, tokenIndex = position112, tokenIndex112 1292 if buffer[position] != rune('M') { 1293 goto l106 1294 } 1295 position++ 1296 } 1297 l112: 1298 { 1299 position114, tokenIndex114 := position, tokenIndex 1300 if buffer[position] != rune('e') { 1301 goto l115 1302 } 1303 position++ 1304 goto l114 1305 l115: 1306 position, tokenIndex = position114, tokenIndex114 1307 if buffer[position] != rune('E') { 1308 goto l106 1309 } 1310 position++ 1311 } 1312 l114: 1313 if buffer[position] != rune(' ') { 1314 goto l106 1315 } 1316 position++ 1317 { 1318 position116 := position 1319 if !_rules[ruleyear]() { 1320 goto l106 1321 } 1322 if buffer[position] != rune('-') { 1323 goto l106 1324 } 1325 position++ 1326 if !_rules[rulemonth]() { 1327 goto l106 1328 } 1329 if buffer[position] != rune('-') { 1330 goto l106 1331 } 1332 position++ 1333 if !_rules[ruleday]() { 1334 goto l106 1335 } 1336 if buffer[position] != rune('T') { 1337 goto l106 1338 } 1339 position++ 1340 if !_rules[ruledigit]() { 1341 goto l106 1342 } 1343 if !_rules[ruledigit]() { 1344 goto l106 1345 } 1346 if buffer[position] != rune(':') { 1347 goto l106 1348 } 1349 position++ 1350 if !_rules[ruledigit]() { 1351 goto l106 1352 } 1353 if !_rules[ruledigit]() { 1354 goto l106 1355 } 1356 if buffer[position] != rune(':') { 1357 goto l106 1358 } 1359 position++ 1360 if !_rules[ruledigit]() { 1361 goto l106 1362 } 1363 if !_rules[ruledigit]() { 1364 goto l106 1365 } 1366 { 1367 position117, tokenIndex117 := position, tokenIndex 1368 { 1369 position119, tokenIndex119 := position, tokenIndex 1370 if buffer[position] != rune('-') { 1371 goto l120 1372 } 1373 position++ 1374 goto l119 1375 l120: 1376 position, tokenIndex = position119, tokenIndex119 1377 if buffer[position] != rune('+') { 1378 goto l118 1379 } 1380 position++ 1381 } 1382 l119: 1383 if !_rules[ruledigit]() { 1384 goto l118 1385 } 1386 if !_rules[ruledigit]() { 1387 goto l118 1388 } 1389 if buffer[position] != rune(':') { 1390 goto l118 1391 } 1392 position++ 1393 if !_rules[ruledigit]() { 1394 goto l118 1395 } 1396 if !_rules[ruledigit]() { 1397 goto l118 1398 } 1399 goto l117 1400 l118: 1401 position, tokenIndex = position117, tokenIndex117 1402 if buffer[position] != rune('Z') { 1403 goto l106 1404 } 1405 position++ 1406 } 1407 l117: 1408 add(rulePegText, position116) 1409 } 1410 add(ruletime, position107) 1411 } 1412 return true 1413 l106: 1414 position, tokenIndex = position106, tokenIndex106 1415 return false 1416 }, 1417 /* 7 date <- <(('d' / 'D') ('a' / 'A') ('t' / 'T') ('e' / 'E') ' ' <(year '-' month '-' day)>)> */ 1418 func() bool { 1419 position121, tokenIndex121 := position, tokenIndex 1420 { 1421 position122 := position 1422 { 1423 position123, tokenIndex123 := position, tokenIndex 1424 if buffer[position] != rune('d') { 1425 goto l124 1426 } 1427 position++ 1428 goto l123 1429 l124: 1430 position, tokenIndex = position123, tokenIndex123 1431 if buffer[position] != rune('D') { 1432 goto l121 1433 } 1434 position++ 1435 } 1436 l123: 1437 { 1438 position125, tokenIndex125 := position, tokenIndex 1439 if buffer[position] != rune('a') { 1440 goto l126 1441 } 1442 position++ 1443 goto l125 1444 l126: 1445 position, tokenIndex = position125, tokenIndex125 1446 if buffer[position] != rune('A') { 1447 goto l121 1448 } 1449 position++ 1450 } 1451 l125: 1452 { 1453 position127, tokenIndex127 := position, tokenIndex 1454 if buffer[position] != rune('t') { 1455 goto l128 1456 } 1457 position++ 1458 goto l127 1459 l128: 1460 position, tokenIndex = position127, tokenIndex127 1461 if buffer[position] != rune('T') { 1462 goto l121 1463 } 1464 position++ 1465 } 1466 l127: 1467 { 1468 position129, tokenIndex129 := position, tokenIndex 1469 if buffer[position] != rune('e') { 1470 goto l130 1471 } 1472 position++ 1473 goto l129 1474 l130: 1475 position, tokenIndex = position129, tokenIndex129 1476 if buffer[position] != rune('E') { 1477 goto l121 1478 } 1479 position++ 1480 } 1481 l129: 1482 if buffer[position] != rune(' ') { 1483 goto l121 1484 } 1485 position++ 1486 { 1487 position131 := position 1488 if !_rules[ruleyear]() { 1489 goto l121 1490 } 1491 if buffer[position] != rune('-') { 1492 goto l121 1493 } 1494 position++ 1495 if !_rules[rulemonth]() { 1496 goto l121 1497 } 1498 if buffer[position] != rune('-') { 1499 goto l121 1500 } 1501 position++ 1502 if !_rules[ruleday]() { 1503 goto l121 1504 } 1505 add(rulePegText, position131) 1506 } 1507 add(ruledate, position122) 1508 } 1509 return true 1510 l121: 1511 position, tokenIndex = position121, tokenIndex121 1512 return false 1513 }, 1514 /* 8 year <- <(('1' / '2') digit digit digit)> */ 1515 func() bool { 1516 position132, tokenIndex132 := position, tokenIndex 1517 { 1518 position133 := position 1519 { 1520 position134, tokenIndex134 := position, tokenIndex 1521 if buffer[position] != rune('1') { 1522 goto l135 1523 } 1524 position++ 1525 goto l134 1526 l135: 1527 position, tokenIndex = position134, tokenIndex134 1528 if buffer[position] != rune('2') { 1529 goto l132 1530 } 1531 position++ 1532 } 1533 l134: 1534 if !_rules[ruledigit]() { 1535 goto l132 1536 } 1537 if !_rules[ruledigit]() { 1538 goto l132 1539 } 1540 if !_rules[ruledigit]() { 1541 goto l132 1542 } 1543 add(ruleyear, position133) 1544 } 1545 return true 1546 l132: 1547 position, tokenIndex = position132, tokenIndex132 1548 return false 1549 }, 1550 /* 9 month <- <(('0' / '1') digit)> */ 1551 func() bool { 1552 position136, tokenIndex136 := position, tokenIndex 1553 { 1554 position137 := position 1555 { 1556 position138, tokenIndex138 := position, tokenIndex 1557 if buffer[position] != rune('0') { 1558 goto l139 1559 } 1560 position++ 1561 goto l138 1562 l139: 1563 position, tokenIndex = position138, tokenIndex138 1564 if buffer[position] != rune('1') { 1565 goto l136 1566 } 1567 position++ 1568 } 1569 l138: 1570 if !_rules[ruledigit]() { 1571 goto l136 1572 } 1573 add(rulemonth, position137) 1574 } 1575 return true 1576 l136: 1577 position, tokenIndex = position136, tokenIndex136 1578 return false 1579 }, 1580 /* 10 day <- <(((&('3') '3') | (&('2') '2') | (&('1') '1') | (&('0') '0')) digit)> */ 1581 func() bool { 1582 position140, tokenIndex140 := position, tokenIndex 1583 { 1584 position141 := position 1585 { 1586 switch buffer[position] { 1587 case '3': 1588 if buffer[position] != rune('3') { 1589 goto l140 1590 } 1591 position++ 1592 case '2': 1593 if buffer[position] != rune('2') { 1594 goto l140 1595 } 1596 position++ 1597 case '1': 1598 if buffer[position] != rune('1') { 1599 goto l140 1600 } 1601 position++ 1602 default: 1603 if buffer[position] != rune('0') { 1604 goto l140 1605 } 1606 position++ 1607 } 1608 } 1609 1610 if !_rules[ruledigit]() { 1611 goto l140 1612 } 1613 add(ruleday, position141) 1614 } 1615 return true 1616 l140: 1617 position, tokenIndex = position140, tokenIndex140 1618 return false 1619 }, 1620 /* 11 and <- <(('a' / 'A') ('n' / 'N') ('d' / 'D'))> */ 1621 nil, 1622 /* 12 equal <- <'='> */ 1623 nil, 1624 /* 13 contains <- <(('c' / 'C') ('o' / 'O') ('n' / 'N') ('t' / 'T') ('a' / 'A') ('i' / 'I') ('n' / 'N') ('s' / 'S'))> */ 1625 nil, 1626 /* 14 exists <- <(('e' / 'E') ('x' / 'X') ('i' / 'I') ('s' / 'S') ('t' / 'T') ('s' / 'S'))> */ 1627 nil, 1628 /* 15 le <- <('<' '=')> */ 1629 nil, 1630 /* 16 ge <- <('>' '=')> */ 1631 nil, 1632 /* 17 l <- <'<'> */ 1633 nil, 1634 /* 18 g <- <'>'> */ 1635 nil, 1636 nil, 1637 } 1638 p.rules = _rules 1639 return nil 1640 }