本站源代码
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.

816 lines
17KB

  1. package query
  2. import __yyfmt__ "fmt"
  3. //line query_string.y:2
  4. import (
  5. "fmt"
  6. "strconv"
  7. "strings"
  8. "time"
  9. )
  10. func logDebugGrammar(format string, v ...interface{}) {
  11. if debugParser {
  12. logger.Printf(format, v...)
  13. }
  14. }
  15. //line query_string.y:17
  16. type yySymType struct {
  17. yys int
  18. s string
  19. n int
  20. f float64
  21. q Query
  22. pf *float64
  23. }
  24. const tSTRING = 57346
  25. const tPHRASE = 57347
  26. const tPLUS = 57348
  27. const tMINUS = 57349
  28. const tCOLON = 57350
  29. const tBOOST = 57351
  30. const tNUMBER = 57352
  31. const tGREATER = 57353
  32. const tLESS = 57354
  33. const tEQUAL = 57355
  34. const tTILDE = 57356
  35. var yyToknames = [...]string{
  36. "$end",
  37. "error",
  38. "$unk",
  39. "tSTRING",
  40. "tPHRASE",
  41. "tPLUS",
  42. "tMINUS",
  43. "tCOLON",
  44. "tBOOST",
  45. "tNUMBER",
  46. "tGREATER",
  47. "tLESS",
  48. "tEQUAL",
  49. "tTILDE",
  50. }
  51. var yyStatenames = [...]string{}
  52. const yyEofCode = 1
  53. const yyErrCode = 2
  54. const yyInitialStackSize = 16
  55. //line yacctab:1
  56. var yyExca = [...]int{
  57. -1, 1,
  58. 1, -1,
  59. -2, 0,
  60. -1, 3,
  61. 1, 3,
  62. -2, 5,
  63. }
  64. const yyNprod = 28
  65. const yyPrivate = 57344
  66. var yyTokenNames []string
  67. var yyStates []string
  68. const yyLast = 42
  69. var yyAct = [...]int{
  70. 17, 16, 18, 23, 22, 30, 3, 21, 19, 20,
  71. 29, 26, 22, 22, 1, 21, 21, 15, 28, 25,
  72. 24, 27, 34, 14, 22, 13, 31, 21, 32, 33,
  73. 22, 9, 11, 21, 5, 6, 2, 10, 4, 12,
  74. 7, 8,
  75. }
  76. var yyPact = [...]int{
  77. 28, -1000, -1000, 28, 27, -1000, -1000, -1000, 16, 9,
  78. -1000, -1000, -1000, -1000, -1000, -3, -11, -1000, -1000, 6,
  79. 5, -1000, -5, -1000, -1000, 23, -1000, -1000, 17, -1000,
  80. -1000, -1000, -1000, -1000, -1000,
  81. }
  82. var yyPgo = [...]int{
  83. 0, 0, 41, 39, 38, 14, 36, 6,
  84. }
  85. var yyR1 = [...]int{
  86. 0, 5, 6, 6, 7, 4, 4, 4, 2, 2,
  87. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  88. 2, 2, 2, 2, 3, 3, 1, 1,
  89. }
  90. var yyR2 = [...]int{
  91. 0, 1, 2, 1, 3, 0, 1, 1, 1, 2,
  92. 4, 1, 1, 3, 3, 3, 4, 5, 4, 5,
  93. 4, 5, 4, 5, 0, 1, 1, 2,
  94. }
  95. var yyChk = [...]int{
  96. -1000, -5, -6, -7, -4, 6, 7, -6, -2, 4,
  97. 10, 5, -3, 9, 14, 8, 4, -1, 5, 11,
  98. 12, 10, 7, 14, -1, 13, 5, -1, 13, 5,
  99. 10, -1, 5, -1, 5,
  100. }
  101. var yyDef = [...]int{
  102. 5, -2, 1, -2, 0, 6, 7, 2, 24, 8,
  103. 11, 12, 4, 25, 9, 0, 13, 14, 15, 0,
  104. 0, 26, 0, 10, 16, 0, 20, 18, 0, 22,
  105. 27, 17, 21, 19, 23,
  106. }
  107. var yyTok1 = [...]int{
  108. 1,
  109. }
  110. var yyTok2 = [...]int{
  111. 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
  112. 12, 13, 14,
  113. }
  114. var yyTok3 = [...]int{
  115. 0,
  116. }
  117. var yyErrorMessages = [...]struct {
  118. state int
  119. token int
  120. msg string
  121. }{}
  122. //line yaccpar:1
  123. /* parser for yacc output */
  124. var (
  125. yyDebug = 0
  126. yyErrorVerbose = false
  127. )
  128. type yyLexer interface {
  129. Lex(lval *yySymType) int
  130. Error(s string)
  131. }
  132. type yyParser interface {
  133. Parse(yyLexer) int
  134. Lookahead() int
  135. }
  136. type yyParserImpl struct {
  137. lval yySymType
  138. stack [yyInitialStackSize]yySymType
  139. char int
  140. }
  141. func (p *yyParserImpl) Lookahead() int {
  142. return p.char
  143. }
  144. func yyNewParser() yyParser {
  145. return &yyParserImpl{}
  146. }
  147. const yyFlag = -1000
  148. func yyTokname(c int) string {
  149. if c >= 1 && c-1 < len(yyToknames) {
  150. if yyToknames[c-1] != "" {
  151. return yyToknames[c-1]
  152. }
  153. }
  154. return __yyfmt__.Sprintf("tok-%v", c)
  155. }
  156. func yyStatname(s int) string {
  157. if s >= 0 && s < len(yyStatenames) {
  158. if yyStatenames[s] != "" {
  159. return yyStatenames[s]
  160. }
  161. }
  162. return __yyfmt__.Sprintf("state-%v", s)
  163. }
  164. func yyErrorMessage(state, lookAhead int) string {
  165. const TOKSTART = 4
  166. if !yyErrorVerbose {
  167. return "syntax error"
  168. }
  169. for _, e := range yyErrorMessages {
  170. if e.state == state && e.token == lookAhead {
  171. return "syntax error: " + e.msg
  172. }
  173. }
  174. res := "syntax error: unexpected " + yyTokname(lookAhead)
  175. // To match Bison, suggest at most four expected tokens.
  176. expected := make([]int, 0, 4)
  177. // Look for shiftable tokens.
  178. base := yyPact[state]
  179. for tok := TOKSTART; tok-1 < len(yyToknames); tok++ {
  180. if n := base + tok; n >= 0 && n < yyLast && yyChk[yyAct[n]] == tok {
  181. if len(expected) == cap(expected) {
  182. return res
  183. }
  184. expected = append(expected, tok)
  185. }
  186. }
  187. if yyDef[state] == -2 {
  188. i := 0
  189. for yyExca[i] != -1 || yyExca[i+1] != state {
  190. i += 2
  191. }
  192. // Look for tokens that we accept or reduce.
  193. for i += 2; yyExca[i] >= 0; i += 2 {
  194. tok := yyExca[i]
  195. if tok < TOKSTART || yyExca[i+1] == 0 {
  196. continue
  197. }
  198. if len(expected) == cap(expected) {
  199. return res
  200. }
  201. expected = append(expected, tok)
  202. }
  203. // If the default action is to accept or reduce, give up.
  204. if yyExca[i+1] != 0 {
  205. return res
  206. }
  207. }
  208. for i, tok := range expected {
  209. if i == 0 {
  210. res += ", expecting "
  211. } else {
  212. res += " or "
  213. }
  214. res += yyTokname(tok)
  215. }
  216. return res
  217. }
  218. func yylex1(lex yyLexer, lval *yySymType) (char, token int) {
  219. token = 0
  220. char = lex.Lex(lval)
  221. if char <= 0 {
  222. token = yyTok1[0]
  223. goto out
  224. }
  225. if char < len(yyTok1) {
  226. token = yyTok1[char]
  227. goto out
  228. }
  229. if char >= yyPrivate {
  230. if char < yyPrivate+len(yyTok2) {
  231. token = yyTok2[char-yyPrivate]
  232. goto out
  233. }
  234. }
  235. for i := 0; i < len(yyTok3); i += 2 {
  236. token = yyTok3[i+0]
  237. if token == char {
  238. token = yyTok3[i+1]
  239. goto out
  240. }
  241. }
  242. out:
  243. if token == 0 {
  244. token = yyTok2[1] /* unknown char */
  245. }
  246. if yyDebug >= 3 {
  247. __yyfmt__.Printf("lex %s(%d)\n", yyTokname(token), uint(char))
  248. }
  249. return char, token
  250. }
  251. func yyParse(yylex yyLexer) int {
  252. return yyNewParser().Parse(yylex)
  253. }
  254. func (yyrcvr *yyParserImpl) Parse(yylex yyLexer) int {
  255. var yyn int
  256. var yyVAL yySymType
  257. var yyDollar []yySymType
  258. _ = yyDollar // silence set and not used
  259. yyS := yyrcvr.stack[:]
  260. Nerrs := 0 /* number of errors */
  261. Errflag := 0 /* error recovery flag */
  262. yystate := 0
  263. yyrcvr.char = -1
  264. yytoken := -1 // yyrcvr.char translated into internal numbering
  265. defer func() {
  266. // Make sure we report no lookahead when not parsing.
  267. yystate = -1
  268. yyrcvr.char = -1
  269. yytoken = -1
  270. }()
  271. yyp := -1
  272. goto yystack
  273. ret0:
  274. return 0
  275. ret1:
  276. return 1
  277. yystack:
  278. /* put a state and value onto the stack */
  279. if yyDebug >= 4 {
  280. __yyfmt__.Printf("char %v in %v\n", yyTokname(yytoken), yyStatname(yystate))
  281. }
  282. yyp++
  283. if yyp >= len(yyS) {
  284. nyys := make([]yySymType, len(yyS)*2)
  285. copy(nyys, yyS)
  286. yyS = nyys
  287. }
  288. yyS[yyp] = yyVAL
  289. yyS[yyp].yys = yystate
  290. yynewstate:
  291. yyn = yyPact[yystate]
  292. if yyn <= yyFlag {
  293. goto yydefault /* simple state */
  294. }
  295. if yyrcvr.char < 0 {
  296. yyrcvr.char, yytoken = yylex1(yylex, &yyrcvr.lval)
  297. }
  298. yyn += yytoken
  299. if yyn < 0 || yyn >= yyLast {
  300. goto yydefault
  301. }
  302. yyn = yyAct[yyn]
  303. if yyChk[yyn] == yytoken { /* valid shift */
  304. yyrcvr.char = -1
  305. yytoken = -1
  306. yyVAL = yyrcvr.lval
  307. yystate = yyn
  308. if Errflag > 0 {
  309. Errflag--
  310. }
  311. goto yystack
  312. }
  313. yydefault:
  314. /* default state action */
  315. yyn = yyDef[yystate]
  316. if yyn == -2 {
  317. if yyrcvr.char < 0 {
  318. yyrcvr.char, yytoken = yylex1(yylex, &yyrcvr.lval)
  319. }
  320. /* look through exception table */
  321. xi := 0
  322. for {
  323. if yyExca[xi+0] == -1 && yyExca[xi+1] == yystate {
  324. break
  325. }
  326. xi += 2
  327. }
  328. for xi += 2; ; xi += 2 {
  329. yyn = yyExca[xi+0]
  330. if yyn < 0 || yyn == yytoken {
  331. break
  332. }
  333. }
  334. yyn = yyExca[xi+1]
  335. if yyn < 0 {
  336. goto ret0
  337. }
  338. }
  339. if yyn == 0 {
  340. /* error ... attempt to resume parsing */
  341. switch Errflag {
  342. case 0: /* brand new error */
  343. yylex.Error(yyErrorMessage(yystate, yytoken))
  344. Nerrs++
  345. if yyDebug >= 1 {
  346. __yyfmt__.Printf("%s", yyStatname(yystate))
  347. __yyfmt__.Printf(" saw %s\n", yyTokname(yytoken))
  348. }
  349. fallthrough
  350. case 1, 2: /* incompletely recovered error ... try again */
  351. Errflag = 3
  352. /* find a state where "error" is a legal shift action */
  353. for yyp >= 0 {
  354. yyn = yyPact[yyS[yyp].yys] + yyErrCode
  355. if yyn >= 0 && yyn < yyLast {
  356. yystate = yyAct[yyn] /* simulate a shift of "error" */
  357. if yyChk[yystate] == yyErrCode {
  358. goto yystack
  359. }
  360. }
  361. /* the current p has no shift on "error", pop stack */
  362. if yyDebug >= 2 {
  363. __yyfmt__.Printf("error recovery pops state %d\n", yyS[yyp].yys)
  364. }
  365. yyp--
  366. }
  367. /* there is no state on the stack with an error shift ... abort */
  368. goto ret1
  369. case 3: /* no shift yet; clobber input char */
  370. if yyDebug >= 2 {
  371. __yyfmt__.Printf("error recovery discards %s\n", yyTokname(yytoken))
  372. }
  373. if yytoken == yyEofCode {
  374. goto ret1
  375. }
  376. yyrcvr.char = -1
  377. yytoken = -1
  378. goto yynewstate /* try again in the same state */
  379. }
  380. }
  381. /* reduction by production yyn */
  382. if yyDebug >= 2 {
  383. __yyfmt__.Printf("reduce %v in:\n\t%v\n", yyn, yyStatname(yystate))
  384. }
  385. yynt := yyn
  386. yypt := yyp
  387. _ = yypt // guard against "declared and not used"
  388. yyp -= yyR2[yyn]
  389. // yyp is now the index of $0. Perform the default action. Iff the
  390. // reduced production is ε, $1 is possibly out of range.
  391. if yyp+1 >= len(yyS) {
  392. nyys := make([]yySymType, len(yyS)*2)
  393. copy(nyys, yyS)
  394. yyS = nyys
  395. }
  396. yyVAL = yyS[yyp+1]
  397. /* consult goto table to find next state */
  398. yyn = yyR1[yyn]
  399. yyg := yyPgo[yyn]
  400. yyj := yyg + yyS[yyp].yys + 1
  401. if yyj >= yyLast {
  402. yystate = yyAct[yyg]
  403. } else {
  404. yystate = yyAct[yyj]
  405. if yyChk[yystate] != -yyn {
  406. yystate = yyAct[yyg]
  407. }
  408. }
  409. // dummy call; replaced with literal code
  410. switch yynt {
  411. case 1:
  412. yyDollar = yyS[yypt-1 : yypt+1]
  413. //line query_string.y:40
  414. {
  415. logDebugGrammar("INPUT")
  416. }
  417. case 2:
  418. yyDollar = yyS[yypt-2 : yypt+1]
  419. //line query_string.y:45
  420. {
  421. logDebugGrammar("SEARCH PARTS")
  422. }
  423. case 3:
  424. yyDollar = yyS[yypt-1 : yypt+1]
  425. //line query_string.y:49
  426. {
  427. logDebugGrammar("SEARCH PART")
  428. }
  429. case 4:
  430. yyDollar = yyS[yypt-3 : yypt+1]
  431. //line query_string.y:54
  432. {
  433. query := yyDollar[2].q
  434. if yyDollar[3].pf != nil {
  435. if query, ok := query.(BoostableQuery); ok {
  436. query.SetBoost(*yyDollar[3].pf)
  437. }
  438. }
  439. switch yyDollar[1].n {
  440. case queryShould:
  441. yylex.(*lexerWrapper).query.AddShould(query)
  442. case queryMust:
  443. yylex.(*lexerWrapper).query.AddMust(query)
  444. case queryMustNot:
  445. yylex.(*lexerWrapper).query.AddMustNot(query)
  446. }
  447. }
  448. case 5:
  449. yyDollar = yyS[yypt-0 : yypt+1]
  450. //line query_string.y:73
  451. {
  452. yyVAL.n = queryShould
  453. }
  454. case 6:
  455. yyDollar = yyS[yypt-1 : yypt+1]
  456. //line query_string.y:77
  457. {
  458. logDebugGrammar("PLUS")
  459. yyVAL.n = queryMust
  460. }
  461. case 7:
  462. yyDollar = yyS[yypt-1 : yypt+1]
  463. //line query_string.y:82
  464. {
  465. logDebugGrammar("MINUS")
  466. yyVAL.n = queryMustNot
  467. }
  468. case 8:
  469. yyDollar = yyS[yypt-1 : yypt+1]
  470. //line query_string.y:88
  471. {
  472. str := yyDollar[1].s
  473. logDebugGrammar("STRING - %s", str)
  474. var q FieldableQuery
  475. if strings.HasPrefix(str, "/") && strings.HasSuffix(str, "/") {
  476. q = NewRegexpQuery(str[1 : len(str)-1])
  477. } else if strings.ContainsAny(str, "*?") {
  478. q = NewWildcardQuery(str)
  479. } else {
  480. q = NewMatchQuery(str)
  481. }
  482. yyVAL.q = q
  483. }
  484. case 9:
  485. yyDollar = yyS[yypt-2 : yypt+1]
  486. //line query_string.y:102
  487. {
  488. str := yyDollar[1].s
  489. fuzziness, err := strconv.ParseFloat(yyDollar[2].s, 64)
  490. if err != nil {
  491. yylex.(*lexerWrapper).lex.Error(fmt.Sprintf("invalid fuzziness value: %v", err))
  492. }
  493. logDebugGrammar("FUZZY STRING - %s %f", str, fuzziness)
  494. q := NewMatchQuery(str)
  495. q.SetFuzziness(int(fuzziness))
  496. yyVAL.q = q
  497. }
  498. case 10:
  499. yyDollar = yyS[yypt-4 : yypt+1]
  500. //line query_string.y:114
  501. {
  502. field := yyDollar[1].s
  503. str := yyDollar[3].s
  504. fuzziness, err := strconv.ParseFloat(yyDollar[4].s, 64)
  505. if err != nil {
  506. yylex.(*lexerWrapper).lex.Error(fmt.Sprintf("invalid fuzziness value: %v", err))
  507. }
  508. logDebugGrammar("FIELD - %s FUZZY STRING - %s %f", field, str, fuzziness)
  509. q := NewMatchQuery(str)
  510. q.SetFuzziness(int(fuzziness))
  511. q.SetField(field)
  512. yyVAL.q = q
  513. }
  514. case 11:
  515. yyDollar = yyS[yypt-1 : yypt+1]
  516. //line query_string.y:128
  517. {
  518. str := yyDollar[1].s
  519. logDebugGrammar("STRING - %s", str)
  520. q1 := NewMatchQuery(str)
  521. val, err := strconv.ParseFloat(yyDollar[1].s, 64)
  522. if err != nil {
  523. yylex.(*lexerWrapper).lex.Error(fmt.Sprintf("error parsing number: %v", err))
  524. }
  525. inclusive := true
  526. q2 := NewNumericRangeInclusiveQuery(&val, &val, &inclusive, &inclusive)
  527. q := NewDisjunctionQuery([]Query{q1, q2})
  528. q.queryStringMode = true
  529. yyVAL.q = q
  530. }
  531. case 12:
  532. yyDollar = yyS[yypt-1 : yypt+1]
  533. //line query_string.y:143
  534. {
  535. phrase := yyDollar[1].s
  536. logDebugGrammar("PHRASE - %s", phrase)
  537. q := NewMatchPhraseQuery(phrase)
  538. yyVAL.q = q
  539. }
  540. case 13:
  541. yyDollar = yyS[yypt-3 : yypt+1]
  542. //line query_string.y:150
  543. {
  544. field := yyDollar[1].s
  545. str := yyDollar[3].s
  546. logDebugGrammar("FIELD - %s STRING - %s", field, str)
  547. var q FieldableQuery
  548. if strings.HasPrefix(str, "/") && strings.HasSuffix(str, "/") {
  549. q = NewRegexpQuery(str[1 : len(str)-1])
  550. } else if strings.ContainsAny(str, "*?") {
  551. q = NewWildcardQuery(str)
  552. } else {
  553. q = NewMatchQuery(str)
  554. }
  555. q.SetField(field)
  556. yyVAL.q = q
  557. }
  558. case 14:
  559. yyDollar = yyS[yypt-3 : yypt+1]
  560. //line query_string.y:166
  561. {
  562. field := yyDollar[1].s
  563. str := yyDollar[3].s
  564. logDebugGrammar("FIELD - %s STRING - %s", field, str)
  565. q1 := NewMatchQuery(str)
  566. q1.SetField(field)
  567. val, err := strconv.ParseFloat(yyDollar[3].s, 64)
  568. if err != nil {
  569. yylex.(*lexerWrapper).lex.Error(fmt.Sprintf("error parsing number: %v", err))
  570. }
  571. inclusive := true
  572. q2 := NewNumericRangeInclusiveQuery(&val, &val, &inclusive, &inclusive)
  573. q2.SetField(field)
  574. q := NewDisjunctionQuery([]Query{q1, q2})
  575. q.queryStringMode = true
  576. yyVAL.q = q
  577. }
  578. case 15:
  579. yyDollar = yyS[yypt-3 : yypt+1]
  580. //line query_string.y:184
  581. {
  582. field := yyDollar[1].s
  583. phrase := yyDollar[3].s
  584. logDebugGrammar("FIELD - %s PHRASE - %s", field, phrase)
  585. q := NewMatchPhraseQuery(phrase)
  586. q.SetField(field)
  587. yyVAL.q = q
  588. }
  589. case 16:
  590. yyDollar = yyS[yypt-4 : yypt+1]
  591. //line query_string.y:193
  592. {
  593. field := yyDollar[1].s
  594. min, err := strconv.ParseFloat(yyDollar[4].s, 64)
  595. if err != nil {
  596. yylex.(*lexerWrapper).lex.Error(fmt.Sprintf("error parsing number: %v", err))
  597. }
  598. minInclusive := false
  599. logDebugGrammar("FIELD - GREATER THAN %f", min)
  600. q := NewNumericRangeInclusiveQuery(&min, nil, &minInclusive, nil)
  601. q.SetField(field)
  602. yyVAL.q = q
  603. }
  604. case 17:
  605. yyDollar = yyS[yypt-5 : yypt+1]
  606. //line query_string.y:206
  607. {
  608. field := yyDollar[1].s
  609. min, err := strconv.ParseFloat(yyDollar[5].s, 64)
  610. if err != nil {
  611. yylex.(*lexerWrapper).lex.Error(fmt.Sprintf("error parsing number: %v", err))
  612. }
  613. minInclusive := true
  614. logDebugGrammar("FIELD - GREATER THAN OR EQUAL %f", min)
  615. q := NewNumericRangeInclusiveQuery(&min, nil, &minInclusive, nil)
  616. q.SetField(field)
  617. yyVAL.q = q
  618. }
  619. case 18:
  620. yyDollar = yyS[yypt-4 : yypt+1]
  621. //line query_string.y:219
  622. {
  623. field := yyDollar[1].s
  624. max, err := strconv.ParseFloat(yyDollar[4].s, 64)
  625. if err != nil {
  626. yylex.(*lexerWrapper).lex.Error(fmt.Sprintf("error parsing number: %v", err))
  627. }
  628. maxInclusive := false
  629. logDebugGrammar("FIELD - LESS THAN %f", max)
  630. q := NewNumericRangeInclusiveQuery(nil, &max, nil, &maxInclusive)
  631. q.SetField(field)
  632. yyVAL.q = q
  633. }
  634. case 19:
  635. yyDollar = yyS[yypt-5 : yypt+1]
  636. //line query_string.y:232
  637. {
  638. field := yyDollar[1].s
  639. max, err := strconv.ParseFloat(yyDollar[5].s, 64)
  640. if err != nil {
  641. yylex.(*lexerWrapper).lex.Error(fmt.Sprintf("error parsing number: %v", err))
  642. }
  643. maxInclusive := true
  644. logDebugGrammar("FIELD - LESS THAN OR EQUAL %f", max)
  645. q := NewNumericRangeInclusiveQuery(nil, &max, nil, &maxInclusive)
  646. q.SetField(field)
  647. yyVAL.q = q
  648. }
  649. case 20:
  650. yyDollar = yyS[yypt-4 : yypt+1]
  651. //line query_string.y:245
  652. {
  653. field := yyDollar[1].s
  654. minInclusive := false
  655. phrase := yyDollar[4].s
  656. logDebugGrammar("FIELD - GREATER THAN DATE %s", phrase)
  657. minTime, err := queryTimeFromString(phrase)
  658. if err != nil {
  659. yylex.(*lexerWrapper).lex.Error(fmt.Sprintf("invalid time: %v", err))
  660. }
  661. q := NewDateRangeInclusiveQuery(minTime, time.Time{}, &minInclusive, nil)
  662. q.SetField(field)
  663. yyVAL.q = q
  664. }
  665. case 21:
  666. yyDollar = yyS[yypt-5 : yypt+1]
  667. //line query_string.y:260
  668. {
  669. field := yyDollar[1].s
  670. minInclusive := true
  671. phrase := yyDollar[5].s
  672. logDebugGrammar("FIELD - GREATER THAN OR EQUAL DATE %s", phrase)
  673. minTime, err := queryTimeFromString(phrase)
  674. if err != nil {
  675. yylex.(*lexerWrapper).lex.Error(fmt.Sprintf("invalid time: %v", err))
  676. }
  677. q := NewDateRangeInclusiveQuery(minTime, time.Time{}, &minInclusive, nil)
  678. q.SetField(field)
  679. yyVAL.q = q
  680. }
  681. case 22:
  682. yyDollar = yyS[yypt-4 : yypt+1]
  683. //line query_string.y:275
  684. {
  685. field := yyDollar[1].s
  686. maxInclusive := false
  687. phrase := yyDollar[4].s
  688. logDebugGrammar("FIELD - LESS THAN DATE %s", phrase)
  689. maxTime, err := queryTimeFromString(phrase)
  690. if err != nil {
  691. yylex.(*lexerWrapper).lex.Error(fmt.Sprintf("invalid time: %v", err))
  692. }
  693. q := NewDateRangeInclusiveQuery(time.Time{}, maxTime, nil, &maxInclusive)
  694. q.SetField(field)
  695. yyVAL.q = q
  696. }
  697. case 23:
  698. yyDollar = yyS[yypt-5 : yypt+1]
  699. //line query_string.y:290
  700. {
  701. field := yyDollar[1].s
  702. maxInclusive := true
  703. phrase := yyDollar[5].s
  704. logDebugGrammar("FIELD - LESS THAN OR EQUAL DATE %s", phrase)
  705. maxTime, err := queryTimeFromString(phrase)
  706. if err != nil {
  707. yylex.(*lexerWrapper).lex.Error(fmt.Sprintf("invalid time: %v", err))
  708. }
  709. q := NewDateRangeInclusiveQuery(time.Time{}, maxTime, nil, &maxInclusive)
  710. q.SetField(field)
  711. yyVAL.q = q
  712. }
  713. case 24:
  714. yyDollar = yyS[yypt-0 : yypt+1]
  715. //line query_string.y:306
  716. {
  717. yyVAL.pf = nil
  718. }
  719. case 25:
  720. yyDollar = yyS[yypt-1 : yypt+1]
  721. //line query_string.y:310
  722. {
  723. yyVAL.pf = nil
  724. boost, err := strconv.ParseFloat(yyDollar[1].s, 64)
  725. if err != nil {
  726. yylex.(*lexerWrapper).lex.Error(fmt.Sprintf("invalid boost value: %v", err))
  727. } else {
  728. yyVAL.pf = &boost
  729. }
  730. logDebugGrammar("BOOST %f", boost)
  731. }
  732. case 26:
  733. yyDollar = yyS[yypt-1 : yypt+1]
  734. //line query_string.y:322
  735. {
  736. yyVAL.s = yyDollar[1].s
  737. }
  738. case 27:
  739. yyDollar = yyS[yypt-2 : yypt+1]
  740. //line query_string.y:326
  741. {
  742. yyVAL.s = "-" + yyDollar[2].s
  743. }
  744. }
  745. goto yystack /* stack new state and value */
  746. }
上海开阖软件有限公司 沪ICP备12045867号-1