You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1555 lines
32 KiB

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