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.

1553 lines
32 KiB

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