File Coverage

lib/UR/BoolExpr/BxParser.pm
Criterion Covered Total %
statement 97 168 57.7
branch 37 74 50.0
condition 1 12 8.3
subroutine 14 25 56.0
pod 0 1 0.0
total 149 280 53.2


line stmt bran cond sub pod time code
1             ####################################################################
2             #
3             # This file was generated using Parse::Yapp version 1.05.
4             #
5             # Don't edit this file, use source file instead.
6             #
7             # ANY CHANGE MADE HERE WILL BE LOST !
8             #
9             ####################################################################
10             package UR::BoolExpr::BxParser;
11 4     4   121 use vars qw ( @ISA );
  4         4  
  4         187  
12 4     4   14 use strict;
  4         4  
  4         213  
13              
14             @ISA= qw ( UR::BoolExpr::BxParser::Yapp::Driver );
15             #Included Parse/Yapp/Driver.pm file----------------------------------------
16             {
17             #
18             # Module UR::BoolExpr::BxParser::Yapp::Driver
19             #
20             # This module is part of the Parse::Yapp package available on your
21             # nearest CPAN
22             #
23             # Any use of this module in a standalone parser make the included
24             # text under the same copyright as the Parse::Yapp module itself.
25             #
26             # This notice should remain unchanged.
27             #
28             # (c) Copyright 1998-2001 Francois Desarmenien, all rights reserved.
29             # (see the pod text in Parse::Yapp module for use and distribution rights)
30             #
31              
32             package UR::BoolExpr::BxParser::Yapp::Driver;
33              
34             require 5.004;
35              
36 4     4   12 use strict;
  4         4  
  4         72  
37              
38 4     4   11 use vars qw ( $VERSION $COMPATIBLE $FILENAME );
  4         5  
  4         233  
39              
40             $VERSION = '1.05'; # No BumpVersion
41             $COMPATIBLE = '0.07';
42             $FILENAME=__FILE__;
43              
44 4     4   18 use Carp;
  4         6  
  4         3500  
45              
46             #Known parameters, all starting with YY (leading YY will be discarded)
47             my(%params)=(YYLEX => 'CODE', 'YYERROR' => 'CODE', YYVERSION => '',
48             YYRULES => 'ARRAY', YYSTATES => 'ARRAY', YYDEBUG => '');
49             #Mandatory parameters
50             my(@params)=('LEX','RULES','STATES');
51              
52             sub new {
53 125     125   33318 my($class)=shift;
54 125         156 my($errst,$nberr,$token,$value,$check,$dotpos);
55 125         713 my($self)={ ERROR => \&_Error,
56             ERRST => \$errst,
57             NBERR => \$nberr,
58             TOKEN => \$token,
59             VALUE => \$value,
60             DOTPOS => \$dotpos,
61             STACK => [],
62             DEBUG => 0,
63             CHECK => \$check };
64              
65 125         356 _CheckParams( [], \%params, \@_, $self );
66              
67             exists($$self{VERSION})
68 125 50 33     873 and $$self{VERSION} < $COMPATIBLE
69             and croak "Yapp driver version $VERSION ".
70             "incompatible with version $$self{VERSION}:\n".
71             "Please recompile parser module.";
72              
73 125 50       216 ref($class)
74             and $class=ref($class);
75              
76 125         351 bless($self,$class);
77             }
78              
79             sub YYParse {
80 125     125   1059 my($self)=shift;
81 125         107 my($retval);
82              
83 125         227 _CheckParams( \@params, \%params, \@_, $self );
84              
85 125 50       246 if($$self{DEBUG}) {
86 0         0 _DBLoad();
87 0         0 $retval = eval '$self->_DBParse()';#Do not create stab entry on compile
88 0 0       0 $@ and die $@;
89             }
90             else {
91 125         191 $retval = $self->_Parse();
92             }
93 114         414 $retval
94             }
95              
96             sub YYData {
97 4015     4015   530302 my($self)=shift;
98              
99             exists($$self{USER})
100 4015 100       5766 or $$self{USER}={};
101              
102 4015         5002 $$self{USER};
103            
104             }
105              
106             sub YYErrok {
107 0     0   0 my($self)=shift;
108              
109 0         0 ${$$self{ERRST}}=0;
  0         0  
110 0         0 undef;
111             }
112              
113             sub YYNberr {
114 0     0   0 my($self)=shift;
115              
116 0         0 ${$$self{NBERR}};
  0         0  
117             }
118              
119             sub YYRecovering {
120 0     0   0 my($self)=shift;
121              
122 0         0 ${$$self{ERRST}} != 0;
  0         0  
123             }
124              
125             sub YYAbort {
126 0     0   0 my($self)=shift;
127              
128 0         0 ${$$self{CHECK}}='ABORT';
  0         0  
129 0         0 undef;
130             }
131              
132             sub YYAccept {
133 114     114   124 my($self)=shift;
134              
135 114         102 ${$$self{CHECK}}='ACCEPT';
  114         158  
136 114         111 undef;
137             }
138              
139             sub YYError {
140 0     0   0 my($self)=shift;
141              
142 0         0 ${$$self{CHECK}}='ERROR';
  0         0  
143 0         0 undef;
144             }
145              
146             sub YYSemval {
147 0     0   0 my($self)=shift;
148 0         0 my($index)= $_[0] - ${$$self{DOTPOS}} - 1;
  0         0  
149              
150             $index < 0
151 0         0 and -$index <= @{$$self{STACK}}
152 0 0 0     0 and return $$self{STACK}[$index][1];
153              
154 0         0 undef; #Invalid index
155             }
156              
157             sub YYCurtok {
158 0     0   0 my($self)=shift;
159              
160             @_
161 0 0       0 and ${$$self{TOKEN}}=$_[0];
  0         0  
162 0         0 ${$$self{TOKEN}};
  0         0  
163             }
164              
165             sub YYCurval {
166 0     0   0 my($self)=shift;
167              
168             @_
169 0 0       0 and ${$$self{VALUE}}=$_[0];
  0         0  
170 0         0 ${$$self{VALUE}};
  0         0  
171             }
172              
173             sub YYExpect {
174 11     11   43 my($self)=shift;
175              
176 11         12 keys %{$self->{STATES}[$self->{STACK}[-1][0]]{ACTIONS}}
  11         66  
177             }
178              
179             sub YYLexer {
180 0     0   0 my($self)=shift;
181              
182 0         0 $$self{LEX};
183             }
184              
185              
186             #################
187             # Private stuff #
188             #################
189              
190              
191             sub _CheckParams {
192 250     250   299 my($mandatory,$checklist,$inarray,$outhash)=@_;
193 250         175 my($prm,$value);
194 250         271 my($prmlst)={};
195              
196 250         665 while(($prm,$value)=splice(@$inarray,0,2)) {
197 750         663 $prm=uc($prm);
198 750 50       1089 exists($$checklist{$prm})
199             or croak("Unknow parameter '$prm'");
200 750 50       1126 ref($value) eq $$checklist{$prm}
201             or croak("Invalid value for parameter '$prm'");
202 750         1156 $prm=unpack('@2A*',$prm);
203 750         1790 $$outhash{$prm}=$value;
204             }
205 250         426 for (@$mandatory) {
206 375 50       656 exists($$outhash{$_})
207             or croak("Missing mandatory parameter '".lc($_)."'");
208             }
209             }
210              
211             sub _Error {
212 0     0   0 print "Parse error.\n";
213             }
214              
215             sub _DBLoad {
216             {
217 4     4   21 no strict 'refs';
  4     0   4  
  4         12386  
  0         0  
218              
219 0         0 exists(${__PACKAGE__.'::'}{_DBParse})#Already loaded ?
220 0 0       0 and return;
221             }
222 0         0 my($fname)=__FILE__;
223 0         0 my(@drv);
224 0 0       0 open(DRV,"<$fname") or die "Report this as a BUG: Cannot open $fname";
225 0         0 while() {
226             /^\s*sub\s+_Parse\s*{\s*$/ .. /^\s*}\s*#\s*_Parse\s*$/
227 0 0       0 and do {
228 0         0 s/^#DBG>//;
229 0         0 push(@drv,$_);
230             }
231             }
232 0         0 close(DRV);
233              
234 0         0 $drv[0]=~s/_P/_DBP/;
235 0         0 eval join('',@drv);
236             }
237              
238             #Note that for loading debugging version of the driver,
239             #this file will be parsed from 'sub _Parse' up to '}#_Parse' inclusive.
240             #So, DO NOT remove comment at end of sub !!!
241             sub _Parse {
242 125     125   116 my($self)=shift;
243              
244             my($rules,$states,$lex,$error)
245 125         232 = @$self{ 'RULES', 'STATES', 'LEX', 'ERROR' };
246             my($errstatus,$nberror,$token,$value,$stack,$check,$dotpos)
247 125         222 = @$self{ 'ERRST', 'NBERR', 'TOKEN', 'VALUE', 'STACK', 'CHECK', 'DOTPOS' };
248              
249             #DBG> my($debug)=$$self{DEBUG};
250             #DBG> my($dbgerror)=0;
251              
252             #DBG> my($ShowCurToken) = sub {
253             #DBG> my($tok)='>';
254             #DBG> for (split('',$$token)) {
255             #DBG> $tok.= (ord($_) < 32 or ord($_) > 126)
256             #DBG> ? sprintf('<%02X>',ord($_))
257             #DBG> : $_;
258             #DBG> }
259             #DBG> $tok.='<';
260             #DBG> };
261              
262 125         116 $$errstatus=0;
263 125         129 $$nberror=0;
264 125         163 ($$token,$$value)=(undef,undef);
265 125         244 @$stack=( [ 0, undef ] );
266 125         147 $$check='';
267              
268 125         96 while(1) {
269 4060         2491 my($actions,$act,$stateno);
270              
271 4060         3100 $stateno=$$stack[-1][0];
272 4060         2590 $actions=$$states[$stateno];
273              
274             #DBG> print STDERR ('-' x 40),"\n";
275             #DBG> $debug & 0x2
276             #DBG> and print STDERR "In state $stateno:\n";
277             #DBG> $debug & 0x08
278             #DBG> and print STDERR "Stack:[".
279             #DBG> join(',',map { $$_[0] } @$stack).
280             #DBG> "]\n";
281              
282              
283 4060 100       4518 if (exists($$actions{ACTIONS})) {
284              
285             defined($$token)
286 1918 100       2614 or do {
287 1550         1899 ($$token,$$value)=&$lex($self);
288             #DBG> $debug & 0x01
289             #DBG> and print STDERR "Need token. Got ".&$ShowCurToken."\n";
290             };
291              
292             $act= exists($$actions{ACTIONS}{$$token})
293             ? $$actions{ACTIONS}{$$token}
294             : exists($$actions{DEFAULT})
295             ? $$actions{DEFAULT}
296 1918 100       7975 : undef;
    100          
297             }
298             else {
299 2142         1597 $act=$$actions{DEFAULT};
300             #DBG> $debug & 0x01
301             #DBG> and print STDERR "Don't need token.\n";
302             }
303              
304             defined($act)
305 4060 100       5078 and do {
306              
307             $act > 0
308 4049 100       5099 and do { #shift
309              
310             #DBG> $debug & 0x04
311             #DBG> and print STDERR "Shift and go to state $act.\n";
312              
313             $$errstatus
314 1317 50       1819 and do {
315 0         0 --$$errstatus;
316              
317             #DBG> $debug & 0x10
318             #DBG> and $dbgerror
319             #DBG> and $$errstatus == 0
320             #DBG> and do {
321             #DBG> print STDERR "**End of Error recovery.\n";
322             #DBG> $dbgerror=0;
323             #DBG> };
324             };
325              
326              
327 1317         2115 push(@$stack,[ $act, $$value ]);
328              
329 1317 100       2445 $$token ne '' #Don't eat the eof
330             and $$token=$$value=undef;
331 1317         1282 next;
332             };
333              
334             #reduce
335 2732         1714 my($lhs,$len,$code,@sempar,$semval);
336 2732         1713 ($lhs,$len,$code)=@{$$rules[-$act]};
  2732         3350  
337              
338             #DBG> $debug & 0x04
339             #DBG> and $act
340             #DBG> and print STDERR "Reduce using rule ".-$act." ($lhs,$len): ";
341              
342 2732 100       3506 $act
343             or $self->YYAccept();
344              
345 2732         1762 $$dotpos=$len;
346              
347             unpack('A1',$lhs) eq '@' #In line rule
348 2732 50       5282 and do {
349 0 0       0 $lhs =~ /^\@[0-9]+\-([0-9]+)$/
350             or die "In line rule name '$lhs' ill formed: ".
351             "report it as a BUG.\n";
352 0         0 $$dotpos = $1;
353             };
354              
355             @sempar = $$dotpos
356 2732 100       5000 ? map { $$_[1] } @$stack[ -$$dotpos .. -1 ]
  3915         5604  
357             : ();
358              
359 2732 50       5551 $semval = $code ? &$code( $self, @sempar )
    100          
360             : @sempar ? $sempar[0] : undef;
361              
362 2732         7840 splice(@$stack,-$len,$len);
363              
364             $$check eq 'ACCEPT'
365 2732 100       4151 and do {
366              
367             #DBG> $debug & 0x04
368             #DBG> and print STDERR "Accept.\n";
369              
370 114         294 return($semval);
371             };
372              
373             $$check eq 'ABORT'
374 2618 50       3138 and do {
375              
376             #DBG> $debug & 0x04
377             #DBG> and print STDERR "Abort.\n";
378              
379 0         0 return(undef);
380              
381             };
382              
383             #DBG> $debug & 0x04
384             #DBG> and print STDERR "Back to state $$stack[-1][0], then ";
385              
386             $$check eq 'ERROR'
387 2618 50       3400 or do {
388             #DBG> $debug & 0x04
389             #DBG> and print STDERR
390             #DBG> "go to state $$states[$$stack[-1][0]]{GOTOS}{$lhs}.\n";
391              
392             #DBG> $debug & 0x10
393             #DBG> and $dbgerror
394             #DBG> and $$errstatus == 0
395             #DBG> and do {
396             #DBG> print STDERR "**End of Error recovery.\n";
397             #DBG> $dbgerror=0;
398             #DBG> };
399              
400             push(@$stack,
401 2618         4347 [ $$states[$$stack[-1][0]]{GOTOS}{$lhs}, $semval ]);
402 2618         2076 $$check='';
403 2618         2821 next;
404             };
405              
406             #DBG> $debug & 0x04
407             #DBG> and print STDERR "Forced Error recovery.\n";
408              
409 0         0 $$check='';
410              
411             };
412              
413             #Error
414             $$errstatus
415 11 50       22 or do {
416              
417 11         13 $$errstatus = 1;
418 11         24 &$error($self);
419 0 0       0 $$errstatus # if 0, then YYErrok has been called
420             or next; # so continue parsing
421              
422             #DBG> $debug & 0x10
423             #DBG> and do {
424             #DBG> print STDERR "**Entering Error recovery.\n";
425             #DBG> ++$dbgerror;
426             #DBG> };
427              
428 0         0 ++$$nberror;
429              
430             };
431              
432             $$errstatus == 3 #The next token is not valid: discard it
433 0 0       0 and do {
434             $$token eq '' # End of input: no hope
435 0 0       0 and do {
436             #DBG> $debug & 0x10
437             #DBG> and print STDERR "**At eof: aborting.\n";
438 0         0 return(undef);
439             };
440              
441             #DBG> $debug & 0x10
442             #DBG> and print STDERR "**Dicard invalid token ".&$ShowCurToken.".\n";
443              
444 0         0 $$token=$$value=undef;
445             };
446              
447 0         0 $$errstatus=3;
448              
449 0   0     0 while( @$stack
      0        
450             and ( not exists($$states[$$stack[-1][0]]{ACTIONS})
451             or not exists($$states[$$stack[-1][0]]{ACTIONS}{error})
452             or $$states[$$stack[-1][0]]{ACTIONS}{error} <= 0)) {
453              
454             #DBG> $debug & 0x10
455             #DBG> and print STDERR "**Pop state $$stack[-1][0].\n";
456              
457 0         0 pop(@$stack);
458             }
459              
460             @$stack
461 0 0       0 or do {
462              
463             #DBG> $debug & 0x10
464             #DBG> and print STDERR "**No state left on stack: aborting.\n";
465              
466 0         0 return(undef);
467             };
468              
469             #shift the error token
470              
471             #DBG> $debug & 0x10
472             #DBG> and print STDERR "**Shift \$error token and go to state ".
473             #DBG> $$states[$$stack[-1][0]]{ACTIONS}{error}.
474             #DBG> ".\n";
475              
476 0         0 push(@$stack, [ $$states[$$stack[-1][0]]{ACTIONS}{error}, undef ]);
477              
478             }
479              
480             #never reached
481 0         0 croak("Error in driver logic. Please, report it as a BUG");
482              
483             }#_Parse
484             #DO NOT remove comment
485              
486             1;
487              
488             }
489             #End of include--------------------------------------------------
490              
491              
492              
493              
494             sub new {
495 125     125 0 983 my($class)=shift;
496 125 50       247 ref($class)
497             and $class=ref($class);
498              
499             my($self)=$class->SUPER::new( yyversion => '1.05',
500             yystates =>
501             [
502             {#State 0
503             ACTIONS => {
504             'LEFT_PAREN' => 4,
505             'BETWEEN_WORD' => 11,
506             'ASC_WORD' => 1,
507             'DESC_WORD' => 2,
508             'IDENTIFIER' => 3,
509             'NOT_WORD' => 6,
510             'LIKE_WORD' => 8,
511             'FALSE_WORD' => 9,
512             'TRUE_WORD' => 12,
513             'IN_WORD' => 13
514             },
515             DEFAULT => -1,
516             GOTOS => {
517             'boolexpr' => 5,
518             'expr' => 10,
519             'keyword_as_value' => 7,
520             'property' => 15,
521             'condition' => 14
522             }
523             },
524             {#State 1
525             DEFAULT => -66
526             },
527             {#State 2
528             DEFAULT => -65
529             },
530             {#State 3
531             DEFAULT => -29
532             },
533             {#State 4
534             ACTIONS => {
535             'ASC_WORD' => 1,
536             'LEFT_PAREN' => 4,
537             'IDENTIFIER' => 3,
538             'DESC_WORD' => 2,
539             'NOT_WORD' => 6,
540             'LIKE_WORD' => 8,
541             'FALSE_WORD' => 9,
542             'BETWEEN_WORD' => 11,
543             'TRUE_WORD' => 12,
544             'IN_WORD' => 13
545             },
546             GOTOS => {
547             'expr' => 16,
548             'keyword_as_value' => 7,
549             'condition' => 14,
550             'property' => 15
551             }
552             },
553             {#State 5
554             ACTIONS => {
555             '' => 17,
556             'OFFSET' => 18,
557             'ORDER_BY' => 20,
558             'GROUP_BY' => 19,
559             'LIMIT' => 21
560             }
561             },
562             {#State 6
563             DEFAULT => -64
564             },
565             {#State 7
566             DEFAULT => -30
567             },
568             {#State 8
569             DEFAULT => -62
570             },
571             {#State 9
572             DEFAULT => -68
573             },
574             {#State 10
575             ACTIONS => {
576             'AND' => 22,
577             'OR' => 23
578             },
579             DEFAULT => -2
580             },
581             {#State 11
582             DEFAULT => -63
583             },
584             {#State 12
585             DEFAULT => -67
586             },
587             {#State 13
588             DEFAULT => -61
589             },
590             {#State 14
591             DEFAULT => -7
592             },
593             {#State 15
594             ACTIONS => {
595             'DOUBLEEQUAL_SIGN' => 24,
596             'NOT_BANG' => 33,
597             'NOT_WORD' => 34,
598             'COLON' => 25,
599             'LIKE_WORD' => 35,
600             'OPERATORS' => 26,
601             'EQUAL_SIGN' => 36,
602             'FALSE_WORD' => 37,
603             'BETWEEN_WORD' => 29,
604             'TILDE' => 38,
605             'TRUE_WORD' => 40,
606             'IN_WORD' => 41,
607             'IS_NOT_NULL' => 44,
608             'IS_NULL' => 32
609             },
610             GOTOS => {
611             'operator' => 28,
612             'like_operator' => 30,
613             'an_operator' => 31,
614             'in_operator' => 39,
615             'null_op_word' => 27,
616             'boolean_op_word' => 43,
617             'between_operator' => 42,
618             'negation' => 45
619             }
620             },
621             {#State 16
622             ACTIONS => {
623             'AND' => 22,
624             'OR' => 23,
625             'RIGHT_PAREN' => 46
626             }
627             },
628             {#State 17
629             DEFAULT => 0
630             },
631             {#State 18
632             ACTIONS => {
633             'INTEGER' => 47
634             }
635             },
636             {#State 19
637             ACTIONS => {
638             'ASC_WORD' => 1,
639             'IDENTIFIER' => 3,
640             'DESC_WORD' => 2,
641             'NOT_WORD' => 6,
642             'LIKE_WORD' => 8,
643             'FALSE_WORD' => 9,
644             'BETWEEN_WORD' => 11,
645             'TRUE_WORD' => 12,
646             'IN_WORD' => 13
647             },
648             GOTOS => {
649             'keyword_as_value' => 7,
650             'group_by_list' => 48,
651             'property' => 49
652             }
653             },
654             {#State 20
655             ACTIONS => {
656             'ASC_WORD' => 1,
657             'IDENTIFIER' => 3,
658             'DESC_WORD' => 2,
659             'NOT_WORD' => 6,
660             'MINUS' => 50,
661             'LIKE_WORD' => 8,
662             'FALSE_WORD' => 9,
663             'BETWEEN_WORD' => 11,
664             'TRUE_WORD' => 12,
665             'IN_WORD' => 13
666             },
667             GOTOS => {
668             'order_by_list' => 53,
669             'order_by_property' => 51,
670             'keyword_as_value' => 7,
671             'property' => 52
672             }
673             },
674             {#State 21
675             ACTIONS => {
676             'INTEGER' => 54
677             }
678             },
679             {#State 22
680             ACTIONS => {
681             'ASC_WORD' => 1,
682             'IDENTIFIER' => 3,
683             'DESC_WORD' => 2,
684             'LEFT_PAREN' => 4,
685             'NOT_WORD' => 6,
686             'LIKE_WORD' => 8,
687             'FALSE_WORD' => 9,
688             'BETWEEN_WORD' => 11,
689             'TRUE_WORD' => 12,
690             'IN_WORD' => 13
691             },
692             GOTOS => {
693             'expr' => 55,
694             'keyword_as_value' => 7,
695             'condition' => 14,
696             'property' => 15
697             }
698             },
699             {#State 23
700             ACTIONS => {
701             'ASC_WORD' => 1,
702             'IDENTIFIER' => 3,
703             'DESC_WORD' => 2,
704             'LEFT_PAREN' => 4,
705             'NOT_WORD' => 6,
706             'LIKE_WORD' => 8,
707             'FALSE_WORD' => 9,
708             'BETWEEN_WORD' => 11,
709             'TRUE_WORD' => 12,
710             'IN_WORD' => 13
711             },
712             GOTOS => {
713             'expr' => 56,
714             'keyword_as_value' => 7,
715             'condition' => 14,
716             'property' => 15
717             }
718             },
719             {#State 24
720             DEFAULT => -45
721             },
722             {#State 25
723             ACTIONS => {
724             'WHITESPACE' => 58
725             },
726             DEFAULT => -27,
727             GOTOS => {
728             'optional_spaces' => 59,
729             'spaces' => 57
730             }
731             },
732             {#State 26
733             DEFAULT => -43
734             },
735             {#State 27
736             DEFAULT => -20
737             },
738             {#State 28
739             ACTIONS => {
740             'WHITESPACE' => 58
741             },
742             DEFAULT => -27,
743             GOTOS => {
744             'optional_spaces' => 60,
745             'spaces' => 57
746             }
747             },
748             {#State 29
749             DEFAULT => -58
750             },
751             {#State 30
752             ACTIONS => {
753             'WORD' => 61,
754             'DOUBLEQUOTE_STRING' => 62,
755             'MINUS' => 63,
756             'BETWEEN_WORD' => 11,
757             'REAL' => 67,
758             'INTEGER' => 68,
759             'ASC_WORD' => 1,
760             'IDENTIFIER' => 69,
761             'DESC_WORD' => 2,
762             'NOT_WORD' => 6,
763             'LIKE_WORD' => 8,
764             'AND' => 73,
765             'FALSE_WORD' => 9,
766             'TRUE_WORD' => 12,
767             'IN_WORD' => 13,
768             'OR' => 74,
769             'SINGLEQUOTE_STRING' => 75
770             },
771             GOTOS => {
772             'number' => 64,
773             'value' => 71,
774             'keyword_as_value' => 70,
775             'single_value' => 72,
776             'like_value' => 66,
777             'subsequent_value_part' => 65
778             }
779             },
780             {#State 31
781             DEFAULT => -39
782             },
783             {#State 32
784             DEFAULT => -23
785             },
786             {#State 33
787             DEFAULT => -42
788             },
789             {#State 34
790             DEFAULT => -41
791             },
792             {#State 35
793             DEFAULT => -46
794             },
795             {#State 36
796             DEFAULT => -44
797             },
798             {#State 37
799             DEFAULT => -22
800             },
801             {#State 38
802             DEFAULT => -48
803             },
804             {#State 39
805             ACTIONS => {
806             'LEFT_BRACKET' => 76
807             },
808             GOTOS => {
809             'set' => 77
810             }
811             },
812             {#State 40
813             DEFAULT => -21
814             },
815             {#State 41
816             DEFAULT => -51
817             },
818             {#State 42
819             ACTIONS => {
820             'WORD' => 61,
821             'DOUBLEQUOTE_STRING' => 62,
822             'MINUS' => 63,
823             'BETWEEN_WORD' => 11,
824             'REAL' => 67,
825             'INTEGER' => 68,
826             'ASC_WORD' => 1,
827             'IDENTIFIER' => 69,
828             'DESC_WORD' => 2,
829             'NOT_WORD' => 6,
830             'LIKE_WORD' => 8,
831             'AND' => 73,
832             'FALSE_WORD' => 9,
833             'TRUE_WORD' => 12,
834             'IN_WORD' => 13,
835             'OR' => 74,
836             'SINGLEQUOTE_STRING' => 75
837             },
838             GOTOS => {
839             'between_value' => 78,
840             'number' => 64,
841             'keyword_as_value' => 70,
842             'single_value' => 79,
843             'subsequent_value_part' => 65
844             }
845             },
846             {#State 43
847             DEFAULT => -19
848             },
849             {#State 44
850             DEFAULT => -25
851             },
852             {#State 45
853             ACTIONS => {
854             'DOUBLEEQUAL_SIGN' => 24,
855             'COLON' => 80,
856             'LIKE_WORD' => 84,
857             'OPERATORS' => 26,
858             'EQUAL_SIGN' => 36,
859             'BETWEEN_WORD' => 81,
860             'TILDE' => 85,
861             'IN_WORD' => 86,
862             'IS_NULL' => 83
863             },
864             GOTOS => {
865             'an_operator' => 82
866             }
867             },
868             {#State 46
869             DEFAULT => -10
870             },
871             {#State 47
872             DEFAULT => -6
873             },
874             {#State 48
875             DEFAULT => -4
876             },
877             {#State 49
878             ACTIONS => {
879             'AND' => 87
880             },
881             DEFAULT => -37
882             },
883             {#State 50
884             ACTIONS => {
885             'ASC_WORD' => 1,
886             'IDENTIFIER' => 3,
887             'DESC_WORD' => 2,
888             'NOT_WORD' => 6,
889             'LIKE_WORD' => 8,
890             'FALSE_WORD' => 9,
891             'BETWEEN_WORD' => 11,
892             'TRUE_WORD' => 12,
893             'IN_WORD' => 13
894             },
895             GOTOS => {
896             'keyword_as_value' => 7,
897             'property' => 88
898             }
899             },
900             {#State 51
901             ACTIONS => {
902             'AND' => 89
903             },
904             DEFAULT => -35
905             },
906             {#State 52
907             ACTIONS => {
908             'ASC_WORD' => 90,
909             'DESC_WORD' => 91
910             },
911             DEFAULT => -31
912             },
913             {#State 53
914             DEFAULT => -3
915             },
916             {#State 54
917             DEFAULT => -5
918             },
919             {#State 55
920             ACTIONS => {
921             'AND' => 22
922             },
923             DEFAULT => -8
924             },
925             {#State 56
926             ACTIONS => {
927             'AND' => 22,
928             'OR' => 23
929             },
930             DEFAULT => -9
931             },
932             {#State 57
933             DEFAULT => -28
934             },
935             {#State 58
936             DEFAULT => -26
937             },
938             {#State 59
939             ACTIONS => {
940             'WORD' => 61,
941             'DOUBLEQUOTE_STRING' => 62,
942             'MINUS' => 63,
943             'BETWEEN_WORD' => 11,
944             'REAL' => 67,
945             'INTEGER' => 68,
946             'ASC_WORD' => 1,
947             'IDENTIFIER' => 69,
948             'DESC_WORD' => 2,
949             'NOT_WORD' => 6,
950             'LIKE_WORD' => 8,
951             'AND' => 73,
952             'FALSE_WORD' => 9,
953             'TRUE_WORD' => 12,
954             'IN_WORD' => 13,
955             'OR' => 74,
956             'SINGLEQUOTE_STRING' => 75
957             },
958             GOTOS => {
959             'between_value' => 93,
960             'number' => 64,
961             'keyword_as_value' => 70,
962             'old_syntax_in_value' => 92,
963             'single_value' => 94,
964             'subsequent_value_part' => 65
965             }
966             },
967             {#State 60
968             ACTIONS => {
969             'WORD' => 61,
970             'DOUBLEQUOTE_STRING' => 62,
971             'MINUS' => 63,
972             'BETWEEN_WORD' => 11,
973             'REAL' => 67,
974             'INTEGER' => 68,
975             'ASC_WORD' => 1,
976             'IDENTIFIER' => 69,
977             'DESC_WORD' => 2,
978             'NOT_WORD' => 6,
979             'LIKE_WORD' => 8,
980             'AND' => 73,
981             'FALSE_WORD' => 9,
982             'TRUE_WORD' => 12,
983             'IN_WORD' => 13,
984             'OR' => 74,
985             'SINGLEQUOTE_STRING' => 75
986             },
987             GOTOS => {
988             'number' => 64,
989             'value' => 95,
990             'keyword_as_value' => 70,
991             'single_value' => 72,
992             'subsequent_value_part' => 65
993             }
994             },
995             {#State 61
996             DEFAULT => -73
997             },
998             {#State 62
999             DEFAULT => -74
1000             },
1001             {#State 63
1002             ACTIONS => {
1003             'INTEGER' => 97,
1004             'REAL' => 96
1005             }
1006             },
1007             {#State 64
1008             DEFAULT => -72
1009             },
1010             {#State 65
1011             DEFAULT => -81
1012             },
1013             {#State 66
1014             DEFAULT => -12
1015             },
1016             {#State 67
1017             DEFAULT => -85
1018             },
1019             {#State 68
1020             DEFAULT => -84
1021             },
1022             {#State 69
1023             DEFAULT => -71
1024             },
1025             {#State 70
1026             DEFAULT => -76
1027             },
1028             {#State 71
1029             DEFAULT => -50
1030             },
1031             {#State 72
1032             ACTIONS => {
1033             'WORD' => 61,
1034             'DOUBLEQUOTE_STRING' => 62,
1035             'MINUS' => 63,
1036             'BETWEEN_WORD' => 11,
1037             'REAL' => 67,
1038             'INTEGER' => 68,
1039             'ASC_WORD' => 1,
1040             'IDENTIFIER' => 69,
1041             'DESC_WORD' => 2,
1042             'NOT_WORD' => 6,
1043             'LIKE_WORD' => 8,
1044             'WHITESPACE' => 58,
1045             'FALSE_WORD' => 9,
1046             'TRUE_WORD' => 12,
1047             'IN_WORD' => 13,
1048             'SINGLEQUOTE_STRING' => 75
1049             },
1050             DEFAULT => -70,
1051             GOTOS => {
1052             'number' => 64,
1053             'keyword_as_value' => 70,
1054             'subsequent_values_list' => 100,
1055             'spaces' => 99,
1056             'subsequent_value_part' => 98
1057             }
1058             },
1059             {#State 73
1060             DEFAULT => -82
1061             },
1062             {#State 74
1063             DEFAULT => -83
1064             },
1065             {#State 75
1066             DEFAULT => -75
1067             },
1068             {#State 76
1069             ACTIONS => {
1070             'WORD' => 61,
1071             'DOUBLEQUOTE_STRING' => 62,
1072             'MINUS' => 63,
1073             'BETWEEN_WORD' => 11,
1074             'REAL' => 67,
1075             'INTEGER' => 68,
1076             'ASC_WORD' => 1,
1077             'IDENTIFIER' => 69,
1078             'DESC_WORD' => 2,
1079             'NOT_WORD' => 6,
1080             'LIKE_WORD' => 8,
1081             'AND' => 73,
1082             'FALSE_WORD' => 9,
1083             'TRUE_WORD' => 12,
1084             'IN_WORD' => 13,
1085             'OR' => 74,
1086             'SINGLEQUOTE_STRING' => 75
1087             },
1088             GOTOS => {
1089             'set_body' => 101,
1090             'number' => 64,
1091             'value' => 102,
1092             'keyword_as_value' => 70,
1093             'single_value' => 72,
1094             'subsequent_value_part' => 65
1095             }
1096             },
1097             {#State 77
1098             DEFAULT => -13
1099             },
1100             {#State 78
1101             DEFAULT => -16
1102             },
1103             {#State 79
1104             ACTIONS => {
1105             'MINUS' => 103
1106             }
1107             },
1108             {#State 80
1109             ACTIONS => {
1110             'WHITESPACE' => 58
1111             },
1112             DEFAULT => -27,
1113             GOTOS => {
1114             'optional_spaces' => 104,
1115             'spaces' => 57
1116             }
1117             },
1118             {#State 81
1119             DEFAULT => -59
1120             },
1121             {#State 82
1122             DEFAULT => -40
1123             },
1124             {#State 83
1125             DEFAULT => -24
1126             },
1127             {#State 84
1128             DEFAULT => -47
1129             },
1130             {#State 85
1131             DEFAULT => -49
1132             },
1133             {#State 86
1134             DEFAULT => -52
1135             },
1136             {#State 87
1137             ACTIONS => {
1138             'ASC_WORD' => 1,
1139             'IDENTIFIER' => 3,
1140             'DESC_WORD' => 2,
1141             'NOT_WORD' => 6,
1142             'LIKE_WORD' => 8,
1143             'FALSE_WORD' => 9,
1144             'BETWEEN_WORD' => 11,
1145             'TRUE_WORD' => 12,
1146             'IN_WORD' => 13
1147             },
1148             GOTOS => {
1149             'keyword_as_value' => 7,
1150             'group_by_list' => 105,
1151             'property' => 49
1152             }
1153             },
1154             {#State 88
1155             DEFAULT => -32
1156             },
1157             {#State 89
1158             ACTIONS => {
1159             'ASC_WORD' => 1,
1160             'IDENTIFIER' => 3,
1161             'DESC_WORD' => 2,
1162             'NOT_WORD' => 6,
1163             'MINUS' => 50,
1164             'LIKE_WORD' => 8,
1165             'FALSE_WORD' => 9,
1166             'BETWEEN_WORD' => 11,
1167             'TRUE_WORD' => 12,
1168             'IN_WORD' => 13
1169             },
1170             GOTOS => {
1171             'order_by_list' => 106,
1172             'order_by_property' => 51,
1173             'keyword_as_value' => 7,
1174             'property' => 52
1175             }
1176             },
1177             {#State 90
1178             DEFAULT => -34
1179             },
1180             {#State 91
1181             DEFAULT => -33
1182             },
1183             {#State 92
1184             DEFAULT => -14
1185             },
1186             {#State 93
1187             DEFAULT => -17
1188             },
1189             {#State 94
1190             ACTIONS => {
1191             'IN_DIVIDER' => 107,
1192             'MINUS' => 103
1193             }
1194             },
1195             {#State 95
1196             DEFAULT => -11
1197             },
1198             {#State 96
1199             DEFAULT => -87
1200             },
1201             {#State 97
1202             DEFAULT => -86
1203             },
1204             {#State 98
1205             ACTIONS => {
1206             'WORD' => 61,
1207             'DOUBLEQUOTE_STRING' => 62,
1208             'MINUS' => 63,
1209             'BETWEEN_WORD' => 11,
1210             'REAL' => 67,
1211             'INTEGER' => 68,
1212             'ASC_WORD' => 1,
1213             'IDENTIFIER' => 69,
1214             'DESC_WORD' => 2,
1215             'NOT_WORD' => 6,
1216             'LIKE_WORD' => 8,
1217             'WHITESPACE' => 58,
1218             'FALSE_WORD' => 9,
1219             'TRUE_WORD' => 12,
1220             'IN_WORD' => 13,
1221             'SINGLEQUOTE_STRING' => 75
1222             },
1223             DEFAULT => -77,
1224             GOTOS => {
1225             'number' => 64,
1226             'keyword_as_value' => 70,
1227             'subsequent_values_list' => 108,
1228             'spaces' => 99,
1229             'subsequent_value_part' => 98
1230             }
1231             },
1232             {#State 99
1233             ACTIONS => {
1234             'WORD' => 61,
1235             'DOUBLEQUOTE_STRING' => 62,
1236             'MINUS' => 63,
1237             'BETWEEN_WORD' => 11,
1238             'REAL' => 67,
1239             'INTEGER' => 68,
1240             'ASC_WORD' => 1,
1241             'IDENTIFIER' => 69,
1242             'DESC_WORD' => 2,
1243             'NOT_WORD' => 6,
1244             'LIKE_WORD' => 8,
1245             'WHITESPACE' => 58,
1246             'FALSE_WORD' => 9,
1247             'TRUE_WORD' => 12,
1248             'IN_WORD' => 13,
1249             'SINGLEQUOTE_STRING' => 75
1250             },
1251             DEFAULT => -80,
1252             GOTOS => {
1253             'number' => 64,
1254             'keyword_as_value' => 70,
1255             'subsequent_values_list' => 109,
1256             'spaces' => 99,
1257             'subsequent_value_part' => 98
1258             }
1259             },
1260             {#State 100
1261             DEFAULT => -69
1262             },
1263             {#State 101
1264             ACTIONS => {
1265             'RIGHT_BRACKET' => 110
1266             }
1267             },
1268             {#State 102
1269             ACTIONS => {
1270             'SET_SEPARATOR' => 111
1271             },
1272             DEFAULT => -57
1273             },
1274             {#State 103
1275             ACTIONS => {
1276             'WORD' => 61,
1277             'DOUBLEQUOTE_STRING' => 62,
1278             'MINUS' => 63,
1279             'BETWEEN_WORD' => 11,
1280             'REAL' => 67,
1281             'INTEGER' => 68,
1282             'ASC_WORD' => 1,
1283             'IDENTIFIER' => 69,
1284             'DESC_WORD' => 2,
1285             'NOT_WORD' => 6,
1286             'LIKE_WORD' => 8,
1287             'AND' => 73,
1288             'FALSE_WORD' => 9,
1289             'TRUE_WORD' => 12,
1290             'IN_WORD' => 13,
1291             'OR' => 74,
1292             'SINGLEQUOTE_STRING' => 75
1293             },
1294             GOTOS => {
1295             'number' => 64,
1296             'keyword_as_value' => 70,
1297             'single_value' => 112,
1298             'subsequent_value_part' => 65
1299             }
1300             },
1301             {#State 104
1302             ACTIONS => {
1303             'WORD' => 61,
1304             'DOUBLEQUOTE_STRING' => 62,
1305             'MINUS' => 63,
1306             'BETWEEN_WORD' => 11,
1307             'REAL' => 67,
1308             'INTEGER' => 68,
1309             'ASC_WORD' => 1,
1310             'IDENTIFIER' => 69,
1311             'DESC_WORD' => 2,
1312             'NOT_WORD' => 6,
1313             'LIKE_WORD' => 8,
1314             'AND' => 73,
1315             'FALSE_WORD' => 9,
1316             'TRUE_WORD' => 12,
1317             'IN_WORD' => 13,
1318             'OR' => 74,
1319             'SINGLEQUOTE_STRING' => 75
1320             },
1321             GOTOS => {
1322             'between_value' => 114,
1323             'number' => 64,
1324             'keyword_as_value' => 70,
1325             'old_syntax_in_value' => 113,
1326             'single_value' => 94,
1327             'subsequent_value_part' => 65
1328             }
1329             },
1330             {#State 105
1331             DEFAULT => -38
1332             },
1333             {#State 106
1334             DEFAULT => -36
1335             },
1336             {#State 107
1337             ACTIONS => {
1338             'WORD' => 61,
1339             'DOUBLEQUOTE_STRING' => 62,
1340             'MINUS' => 63,
1341             'BETWEEN_WORD' => 11,
1342             'REAL' => 67,
1343             'INTEGER' => 68,
1344             'ASC_WORD' => 1,
1345             'IDENTIFIER' => 69,
1346             'DESC_WORD' => 2,
1347             'NOT_WORD' => 6,
1348             'LIKE_WORD' => 8,
1349             'AND' => 73,
1350             'FALSE_WORD' => 9,
1351             'TRUE_WORD' => 12,
1352             'IN_WORD' => 13,
1353             'OR' => 74,
1354             'SINGLEQUOTE_STRING' => 75
1355             },
1356             GOTOS => {
1357             'number' => 64,
1358             'keyword_as_value' => 70,
1359             'old_syntax_in_value' => 115,
1360             'single_value' => 116,
1361             'subsequent_value_part' => 65
1362             }
1363             },
1364             {#State 108
1365             DEFAULT => -78
1366             },
1367             {#State 109
1368             DEFAULT => -79
1369             },
1370             {#State 110
1371             DEFAULT => -55
1372             },
1373             {#State 111
1374             ACTIONS => {
1375             'WORD' => 61,
1376             'DOUBLEQUOTE_STRING' => 62,
1377             'MINUS' => 63,
1378             'BETWEEN_WORD' => 11,
1379             'REAL' => 67,
1380             'INTEGER' => 68,
1381             'ASC_WORD' => 1,
1382             'IDENTIFIER' => 69,
1383             'DESC_WORD' => 2,
1384             'NOT_WORD' => 6,
1385             'LIKE_WORD' => 8,
1386             'AND' => 73,
1387             'FALSE_WORD' => 9,
1388             'TRUE_WORD' => 12,
1389             'IN_WORD' => 13,
1390             'OR' => 74,
1391             'SINGLEQUOTE_STRING' => 75
1392             },
1393             GOTOS => {
1394             'set_body' => 117,
1395             'number' => 64,
1396             'value' => 102,
1397             'keyword_as_value' => 70,
1398             'single_value' => 72,
1399             'subsequent_value_part' => 65
1400             }
1401             },
1402             {#State 112
1403             DEFAULT => -60
1404             },
1405             {#State 113
1406             DEFAULT => -15
1407             },
1408             {#State 114
1409             DEFAULT => -18
1410             },
1411             {#State 115
1412             DEFAULT => -53
1413             },
1414             {#State 116
1415             ACTIONS => {
1416             'IN_DIVIDER' => 107
1417             },
1418             DEFAULT => -54
1419             },
1420             {#State 117
1421             DEFAULT => -56
1422             }
1423             ],
1424             yyrules =>
1425             [
1426             [#Rule 0
1427             '$start', 2, undef
1428             ],
1429             [#Rule 1
1430             'boolexpr', 0,
1431             sub
1432             #line 10 "BxParser.yp"
1433             { [] }
1434             ],
1435             [#Rule 2
1436             'boolexpr', 1,
1437             sub
1438             #line 11 "BxParser.yp"
1439             { UR::BoolExpr::BxParser->_simplify($_[1]) }
1440             ],
1441             [#Rule 3
1442             'boolexpr', 3,
1443             sub
1444             #line 12 "BxParser.yp"
1445             { [@{$_[1]}, '-order', $_[3]] }
1446             ],
1447             [#Rule 4
1448             'boolexpr', 3,
1449             sub
1450             #line 13 "BxParser.yp"
1451             { [@{$_[1]}, '-group', $_[3]] }
1452             ],
1453             [#Rule 5
1454             'boolexpr', 3,
1455             sub
1456             #line 14 "BxParser.yp"
1457             { [@{$_[1]}, '-limit', $_[3]] }
1458             ],
1459             [#Rule 6
1460             'boolexpr', 3,
1461             sub
1462             #line 15 "BxParser.yp"
1463             { [@{$_[1]}, '-offset', $_[3]] }
1464             ],
1465             [#Rule 7
1466             'expr', 1,
1467             sub
1468             #line 18 "BxParser.yp"
1469             { $_[1] }
1470             ],
1471             [#Rule 8
1472             'expr', 3,
1473             sub
1474             #line 19 "BxParser.yp"
1475             { UR::BoolExpr::BxParser->_and($_[1], $_[3]) }
1476             ],
1477             [#Rule 9
1478             'expr', 3,
1479             sub
1480             #line 20 "BxParser.yp"
1481             { UR::BoolExpr::BxParser->_or($_[1], $_[3]) }
1482             ],
1483             [#Rule 10
1484             'expr', 3,
1485             sub
1486             #line 21 "BxParser.yp"
1487             { $_[2] }
1488             ],
1489             [#Rule 11
1490             'condition', 4,
1491             sub
1492             #line 24 "BxParser.yp"
1493             { [ "$_[1] $_[2]" => $_[4] ] }
1494             ],
1495             [#Rule 12
1496             'condition', 3,
1497             sub
1498             #line 25 "BxParser.yp"
1499             { [ "$_[1] $_[2]" => $_[3] ] }
1500             ],
1501             [#Rule 13
1502             'condition', 3,
1503             sub
1504             #line 26 "BxParser.yp"
1505             { [ "$_[1] $_[2]" => $_[3] ] }
1506             ],
1507             [#Rule 14
1508             'condition', 4,
1509             sub
1510             #line 27 "BxParser.yp"
1511             { [ "$_[1] in" => $_[4] ] }
1512             ],
1513             [#Rule 15
1514             'condition', 5,
1515             sub
1516             #line 28 "BxParser.yp"
1517             { [ "$_[1] $_[2] in" => $_[5] ] }
1518             ],
1519             [#Rule 16
1520             'condition', 3,
1521             sub
1522             #line 29 "BxParser.yp"
1523             { [ "$_[1] $_[2]" => $_[3] ] }
1524             ],
1525             [#Rule 17
1526             'condition', 4,
1527             sub
1528             #line 30 "BxParser.yp"
1529             { [ "$_[1] between" => $_[4] ] }
1530             ],
1531             [#Rule 18
1532             'condition', 5,
1533             sub
1534             #line 31 "BxParser.yp"
1535             { [ "$_[1] $_[2] between" => $_[5] ] }
1536             ],
1537             [#Rule 19
1538             'condition', 2,
1539             sub
1540             #line 32 "BxParser.yp"
1541             { [ "$_[1] $_[2]" => 1 ] }
1542             ],
1543             [#Rule 20
1544             'condition', 2,
1545             sub
1546             #line 33 "BxParser.yp"
1547             { [ "$_[1] $_[2]" => undef ] }
1548             ],
1549             [#Rule 21
1550             'boolean_op_word', 1,
1551             sub
1552             #line 36 "BxParser.yp"
1553             { $_[1] }
1554             ],
1555             [#Rule 22
1556             'boolean_op_word', 1,
1557             sub
1558             #line 37 "BxParser.yp"
1559             { $_[1] }
1560             ],
1561             [#Rule 23
1562             'null_op_word', 1,
1563             sub
1564             #line 40 "BxParser.yp"
1565             { '=' }
1566             ],
1567             [#Rule 24
1568             'null_op_word', 2,
1569             sub
1570             #line 41 "BxParser.yp"
1571             { "!=" }
1572             ],
1573             [#Rule 25
1574             'null_op_word', 1,
1575             sub
1576             #line 42 "BxParser.yp"
1577             { '!=' }
1578             ],
1579             [#Rule 26
1580             'spaces', 1,
1581             sub
1582             #line 45 "BxParser.yp"
1583             { $_[1] }
1584             ],
1585             [#Rule 27
1586             'optional_spaces', 0,
1587             sub
1588             #line 48 "BxParser.yp"
1589             { undef }
1590             ],
1591             [#Rule 28
1592             'optional_spaces', 1,
1593             sub
1594             #line 49 "BxParser.yp"
1595             { undef }
1596             ],
1597             [#Rule 29
1598             'property', 1,
1599             sub
1600             #line 52 "BxParser.yp"
1601             { $_[1] }
1602             ],
1603             [#Rule 30
1604             'property', 1,
1605             sub
1606             #line 53 "BxParser.yp"
1607             { $_[1] }
1608             ],
1609             [#Rule 31
1610             'order_by_property', 1,
1611             sub
1612             #line 56 "BxParser.yp"
1613             { $_[1 ] }
1614             ],
1615             [#Rule 32
1616             'order_by_property', 2,
1617             sub
1618             #line 57 "BxParser.yp"
1619             { '-'.$_[2] }
1620             ],
1621             [#Rule 33
1622             'order_by_property', 2,
1623             sub
1624             #line 58 "BxParser.yp"
1625             { '-'.$_[1] }
1626             ],
1627             [#Rule 34
1628             'order_by_property', 2,
1629             sub
1630             #line 59 "BxParser.yp"
1631             { $_[1] }
1632             ],
1633             [#Rule 35
1634             'order_by_list', 1,
1635             sub
1636             #line 62 "BxParser.yp"
1637             { [ $_[1]] }
1638             ],
1639             [#Rule 36
1640             'order_by_list', 3,
1641             sub
1642             #line 63 "BxParser.yp"
1643             { [$_[1], @{$_[3]}] }
1644             ],
1645             [#Rule 37
1646             'group_by_list', 1,
1647             sub
1648             #line 66 "BxParser.yp"
1649             { [ $_[1] ] }
1650             ],
1651             [#Rule 38
1652             'group_by_list', 3,
1653             sub
1654             #line 67 "BxParser.yp"
1655             { [$_[1], @{$_[3]}] }
1656             ],
1657             [#Rule 39
1658             'operator', 1,
1659             sub
1660             #line 70 "BxParser.yp"
1661             { $_[1] }
1662             ],
1663             [#Rule 40
1664             'operator', 2,
1665             sub
1666             #line 71 "BxParser.yp"
1667             { "$_[1] $_[2]" }
1668             ],
1669             [#Rule 41
1670             'negation', 1,
1671             sub
1672             #line 74 "BxParser.yp"
1673             { 'not' }
1674             ],
1675             [#Rule 42
1676             'negation', 1,
1677             sub
1678             #line 75 "BxParser.yp"
1679             { 'not' }
1680             ],
1681             [#Rule 43
1682             'an_operator', 1,
1683             sub
1684             #line 78 "BxParser.yp"
1685             { $_[1] }
1686             ],
1687             [#Rule 44
1688             'an_operator', 1,
1689             sub
1690             #line 79 "BxParser.yp"
1691             { '=' }
1692             ],
1693             [#Rule 45
1694             'an_operator', 1,
1695             sub
1696             #line 80 "BxParser.yp"
1697             { '=' }
1698             ],
1699             [#Rule 46
1700             'like_operator', 1,
1701             sub
1702             #line 83 "BxParser.yp"
1703             { 'like' }
1704             ],
1705             [#Rule 47
1706             'like_operator', 2,
1707             sub
1708             #line 84 "BxParser.yp"
1709             { "$_[1] like" }
1710             ],
1711             [#Rule 48
1712             'like_operator', 1,
1713             sub
1714             #line 85 "BxParser.yp"
1715             { 'like' }
1716             ],
1717             [#Rule 49
1718             'like_operator', 2,
1719             sub
1720             #line 86 "BxParser.yp"
1721             { "$_[1] like" }
1722             ],
1723             [#Rule 50
1724             'like_value', 1,
1725             sub
1726             #line 89 "BxParser.yp"
1727             { $_[1] =~ m/\%/ ? $_[1] : '%' . $_[1] . '%' }
1728             ],
1729             [#Rule 51
1730             'in_operator', 1,
1731             sub
1732             #line 92 "BxParser.yp"
1733             { 'in' }
1734             ],
1735             [#Rule 52
1736             'in_operator', 2,
1737             sub
1738             #line 93 "BxParser.yp"
1739             { "$_[1] in" }
1740             ],
1741             [#Rule 53
1742             'old_syntax_in_value', 3,
1743             sub
1744             #line 96 "BxParser.yp"
1745             { [ $_[1], @{$_[3]} ] }
1746             ],
1747             [#Rule 54
1748             'old_syntax_in_value', 3,
1749             sub
1750             #line 97 "BxParser.yp"
1751             { [ $_[1], $_[3] ] }
1752             ],
1753             [#Rule 55
1754             'set', 3,
1755             sub
1756             #line 100 "BxParser.yp"
1757             { $_[2] }
1758             ],
1759             [#Rule 56
1760             'set_body', 3,
1761             sub
1762             #line 103 "BxParser.yp"
1763             { [ $_[1], @{$_[3]} ] }
1764             ],
1765             [#Rule 57
1766             'set_body', 1,
1767             sub
1768             #line 104 "BxParser.yp"
1769             { [ $_[1] ] }
1770             ],
1771             [#Rule 58
1772             'between_operator', 1,
1773             sub
1774             #line 107 "BxParser.yp"
1775             { 'between' }
1776             ],
1777             [#Rule 59
1778             'between_operator', 2,
1779             sub
1780             #line 108 "BxParser.yp"
1781             { "$_[1] between" }
1782             ],
1783             [#Rule 60
1784             'between_value', 3,
1785             sub
1786             #line 111 "BxParser.yp"
1787             { [ $_[1], $_[3] ] }
1788             ],
1789             [#Rule 61
1790             'keyword_as_value', 1,
1791             sub
1792             #line 114 "BxParser.yp"
1793             { $_[1] }
1794             ],
1795             [#Rule 62
1796             'keyword_as_value', 1,
1797             sub
1798             #line 115 "BxParser.yp"
1799             { $_[1] }
1800             ],
1801             [#Rule 63
1802             'keyword_as_value', 1,
1803             sub
1804             #line 116 "BxParser.yp"
1805             { $_[1] }
1806             ],
1807             [#Rule 64
1808             'keyword_as_value', 1,
1809             sub
1810             #line 117 "BxParser.yp"
1811             { $_[1] }
1812             ],
1813             [#Rule 65
1814             'keyword_as_value', 1,
1815             sub
1816             #line 118 "BxParser.yp"
1817             { $_[1] }
1818             ],
1819             [#Rule 66
1820             'keyword_as_value', 1,
1821             sub
1822             #line 119 "BxParser.yp"
1823             { $_[1] }
1824             ],
1825             [#Rule 67
1826             'keyword_as_value', 1,
1827             sub
1828             #line 120 "BxParser.yp"
1829             { $_[1] }
1830             ],
1831             [#Rule 68
1832             'keyword_as_value', 1,
1833             sub
1834             #line 121 "BxParser.yp"
1835             { $_[1] }
1836             ],
1837             [#Rule 69
1838             'value', 2,
1839             sub
1840             #line 124 "BxParser.yp"
1841             { $_[1].$_[2] }
1842             ],
1843             [#Rule 70
1844             'value', 1,
1845             sub
1846             #line 125 "BxParser.yp"
1847             { $_[1] }
1848             ],
1849             [#Rule 71
1850             'subsequent_value_part', 1,
1851             sub
1852             #line 128 "BxParser.yp"
1853             { $_[1] }
1854             ],
1855             [#Rule 72
1856             'subsequent_value_part', 1,
1857             sub
1858             #line 129 "BxParser.yp"
1859             { $_[1] }
1860             ],
1861             [#Rule 73
1862             'subsequent_value_part', 1,
1863             sub
1864             #line 130 "BxParser.yp"
1865             { $_[1] }
1866             ],
1867             [#Rule 74
1868             'subsequent_value_part', 1,
1869             sub
1870             #line 131 "BxParser.yp"
1871             { ($_[1] =~ m/^"(.*?)"$/)[0]; }
1872             ],
1873             [#Rule 75
1874             'subsequent_value_part', 1,
1875             sub
1876             #line 132 "BxParser.yp"
1877             { ($_[1] =~ m/^'(.*?)'$/)[0]; }
1878             ],
1879             [#Rule 76
1880             'subsequent_value_part', 1,
1881             sub
1882             #line 133 "BxParser.yp"
1883             { $_[1] }
1884             ],
1885             [#Rule 77
1886             'subsequent_values_list', 1,
1887             sub
1888             #line 136 "BxParser.yp"
1889             { $_[1] }
1890             ],
1891             [#Rule 78
1892             'subsequent_values_list', 2,
1893             sub
1894             #line 137 "BxParser.yp"
1895             { $_[1].$_[2] }
1896             ],
1897             [#Rule 79
1898             'subsequent_values_list', 2,
1899             sub
1900             #line 138 "BxParser.yp"
1901             { $_[1].$_[2] }
1902             ],
1903             [#Rule 80
1904             'subsequent_values_list', 1,
1905             sub
1906             #line 139 "BxParser.yp"
1907             { '' }
1908             ],
1909             [#Rule 81
1910             'single_value', 1,
1911             sub
1912             #line 142 "BxParser.yp"
1913             { $_[1] }
1914             ],
1915             [#Rule 82
1916             'single_value', 1,
1917             sub
1918             #line 143 "BxParser.yp"
1919             { $_[1] }
1920             ],
1921             [#Rule 83
1922             'single_value', 1,
1923             sub
1924             #line 144 "BxParser.yp"
1925             { $_[1] }
1926             ],
1927             [#Rule 84
1928             'number', 1,
1929             sub
1930             #line 148 "BxParser.yp"
1931             { $_[1] + 0 }
1932             ],
1933             [#Rule 85
1934             'number', 1,
1935             sub
1936             #line 149 "BxParser.yp"
1937             { $_[1] + 0 }
1938             ],
1939             [#Rule 86
1940             'number', 2,
1941             sub
1942             #line 150 "BxParser.yp"
1943             { 0 - $_[2] }
1944             ],
1945             [#Rule 87
1946             'number', 2,
1947             sub
1948             #line 151 "BxParser.yp"
1949             { 0 - $_[2] }
1950             ]
1951             ],
1952             @_);
1953             bless($self,$class);
1954             }
1955              
1956             #line 154 "BxParser.yp"
1957              
1958              
1959             package UR::BoolExpr::BxParser;
1960             use strict;
1961             use warnings;
1962              
1963             sub _error {
1964             my @expect = $_[0]->YYExpect;
1965             my $tok = $_[0]->YYData->{INPUT};
1966             my $match = $_[0]->YYData->{MATCH};
1967             my $string = $_[0]->YYData->{STRING};
1968             my $err = qq(Can't parse expression "$string"\n Syntax error near token $tok '$match');
1969             my $rem = $_[0]->YYData->{REMAINING};
1970             $err .= ", remaining text: '$rem'" if $rem;
1971             $err .= "\nExpected one of: " . join(", ", @expect) . "\n";
1972             Carp::croak($err);
1973             }
1974              
1975             my %token_states = (
1976             'DEFAULT' => [
1977             WHITESPACE => qr{\s+},
1978             AND => [ qr{and}i, 'DEFAULT'],
1979             OR => [ qr{or}i, 'DEFAULT' ],
1980             BETWEEN_WORD => qr{between},
1981             LIKE_WORD => qr{like},
1982             IN_WORD => qr{in},
1983             NOT_WORD => qr{not},
1984             DESC_WORD => qr{desc},
1985             ASC_WORD => qr{asc},
1986             TRUE_WORD => qr{true},
1987             FALSE_WORD => qr{false},
1988             LIMIT => qr{limit},
1989             OFFSET => qr{offset},
1990             IDENTIFIER => qr{[a-zA-Z_][a-zA-Z0-9_.]*},
1991             MINUS => qr{-},
1992             INTEGER => qr{\d+},
1993             REAL => qr{\d*\.\d+|\d+\.\d*},
1994             WORD => [ qr{[%\+\.\/\w][\+\-\.%\w\/]*}, # also allow / for pathnames, - for hyphenated names, % for like wildcards
1995             'dont_gobble_spaces' ],
1996             DOUBLEQUOTE_STRING => qr{"(?:\\.|[^"])*"},
1997             SINGLEQUOTE_STRING => qr{'(?:\\.|[^'])*'},
1998             LEFT_PAREN => [ qr{\(}, 'DEFAULT' ],
1999             RIGHT_PAREN => [ qr{\)}, 'DEFAULT' ],
2000             LEFT_BRACKET => [ qr{\[}, 'set_contents'],
2001             RIGHT_BRACKET => [qr{\]}, 'DEFAULT' ],
2002             NOT_BANG => qr{!},
2003             EQUAL_SIGN => [ qr{=}, 'dont_gobble_spaces' ],
2004             DOUBLEEQUAL_SIGN => [ qr{=>}, 'dont_gobble_spaces' ],
2005             OPERATORS => [ qr{<=|>=|<|>}, 'dont_gobble_spaces' ],
2006             AND => [ qr{,}, 'DEFAULT' ],
2007             COLON => [ qr{:}, 'after_colon_value' ],
2008             TILDE => qr{~},
2009             ORDER_BY => qr{order by},
2010             GROUP_BY => qr{group by},
2011             IS_NULL => qr{is null|is undef},
2012             IS_NOT_NULL => qr{is not null|is not undef},
2013             ],
2014             'set_contents' => [
2015             SET_SEPARATOR => qr{,}, # Depending on state, can be either AND or SET_SEPARATOR
2016             WORD => qr{[%\+\.\w\:][\+\.\:%\w]*}, # also allow / for pathnames, - for hyphenated names, % for like wildcards
2017             RIGHT_BRACKET => [qr{\]}, 'DEFAULT' ],
2018             ],
2019             'after_colon_value' => [
2020             INTEGER => qr{\d+},
2021             REAL => qr{\d*\.\d+|\d+\.\d*},
2022             IN_DIVIDER => qr{\/},
2023             #WORD => qr{\w+}, # Override WORD in DEFAULT to disallow /
2024             WORD => qr{[%\+\.\w\:][\+\.\:%\w]*}, # Override WORD in DEFAULT to disallow /
2025             DOUBLEQUOTE_STRING => qr{"(?:\\.|[^"])*"},
2026             SINGLEQUOTE_STRING => qr{'(?:\\.|[^'])*'},
2027             WHITESPACE => [qr{\s+}, 'DEFAULT'],
2028             ],
2029             'dont_gobble_spaces' => [
2030             AND => [ qr{and}, 'DEFAULT'],
2031             OR => [ qr{or}, 'DEFAULT' ],
2032             LIMIT => [qr{limit}, 'DEFAULT'],
2033             OFFSET => [qr{offset}, 'DEFAULT'],
2034             INTEGER => qr{\d+},
2035             REAL => qr{\d*\.\d+|\d+\.\d*},
2036             WORD => qr{[%\+\.\/\w][\+\-\.\:%\w\/]*}, # also allow / for pathnames, - for hyphenated names, % for like wildcards
2037             ORDER_BY => [qr{order by}, 'DEFAULT'],
2038             GROUP_BY => [qr{group by}, 'DEFAULT'],
2039             ],
2040             );
2041              
2042             sub parse {
2043             my $string = shift;
2044             my %params = @_;
2045              
2046             my $debug = $params{'tokdebug'};
2047             my $yydebug = $params{'yydebug'} || 0;
2048              
2049             print "\nStarting parse for string $string\n" if $debug;
2050             my $parser = UR::BoolExpr::BxParser->new();
2051             $parser->YYData->{STRING} = $string;
2052              
2053             my $parser_state = 'DEFAULT';
2054              
2055             my $get_next_token = sub {
2056             if (length($string) == 0) {
2057             print "String is empty, we're done!\n" if $debug;
2058             return (undef, '');
2059             }
2060              
2061             GET_NEXT_TOKEN:
2062             foreach (1) {
2063             my $longest = 0;
2064             my $longest_token = '';
2065             my $longest_match = '';
2066              
2067             for my $token_list ( $parser_state, 'DEFAULT' ) {
2068             print "\nTrying tokens for state $token_list...\n" if $debug;
2069             my $tokens = $token_states{$token_list};
2070             for(my $i = 0; $i < @$tokens; $i += 2) {
2071             my($tok, $re) = @$tokens[$i, $i+1];
2072             print "Trying token $tok... " if $debug;
2073              
2074             my($regex,$next_parser_state);
2075             if (ref($re) eq 'ARRAY') {
2076             ($regex,$next_parser_state) = @$re;
2077             } else {
2078             $regex = $re;
2079             }
2080              
2081             if ($string =~ m/^($regex)/) {
2082             print "Matched >>$1<<" if $debug;
2083             my $match_len = length($1);
2084             if ($match_len > $longest) {
2085             print "\n ** It's now the longest" if $debug;
2086             $longest = $match_len;
2087             $longest_token = $tok;
2088             $longest_match = $1;
2089             if ($next_parser_state) {
2090             $parser_state = $next_parser_state;
2091             }
2092             }
2093             }
2094             print "\n" if $debug;
2095             }
2096              
2097             $string = substr($string, $longest);
2098             print "Consuming up to char pos $longest chars, string is now >>$string<<\n" if $debug;
2099              
2100             if ($longest_token eq 'WHITESPACE' and $parser_state ne 'dont_gobble_spaces') {
2101             print "Redoing token extraction after whitespace\n" if $debug;
2102             redo GET_NEXT_TOKEN;
2103             }
2104              
2105             $parser->YYData->{REMAINING} = $string;
2106             if ($longest) {
2107             print "Returning token $longest_token, match $longest_match\n next state is named $parser_state\n" if $debug;
2108             $parser->YYData->{INPUT} = $longest_token;
2109             $parser->YYData->{MATCH} = $longest_match;
2110             return ($longest_token, $longest_match);
2111             }
2112             last if $token_list eq 'DEFAULT'; # avoid going over it twice if $parser_state is DEFAULT
2113             }
2114             }
2115             print "Didn't match anything, done!\n" if $debug;
2116             return (undef, ''); # Didn't match anything
2117             };
2118              
2119             return ( $parser->YYParse(
2120             yylex => $get_next_token,
2121             yyerror => \&_error,
2122             yydebug => $yydebug),
2123             \$string,
2124             );
2125             }
2126              
2127             # Used by the top-level expr production to turn an or-type parse tree with
2128             # only a single AND condition into a simple AND-type tree (1-level arrayref).
2129             # Or to add the '-or' to the front of a real OR-type tree so it can be passed
2130             # directly to UR::BoolExpr::resolve()
2131             sub _simplify {
2132             my($class, $expr) = @_;
2133              
2134             if (ref($expr->[0])) {
2135             if (@$expr == 1) {
2136             # An or-type parse tree, but with only one AND subrule - use as a simple and-type rule
2137             $expr = $expr->[0];
2138             } else {
2139             $expr = ['-or', $expr]; # an or-type parse tree with multiple subrules
2140             }
2141             }
2142             return $expr;
2143             }
2144              
2145             # Handles the case for "expr AND expr" where one or both exprs can be an
2146             # OR-type expr. In that case, it distributes the AND exprs among all the
2147             # OR conditions. For example:
2148             # (a=1 or b=2) and (c=3 or d=4)
2149             # is the same as
2150             # (a=1 and c=3) or (a=1 and d=4) or (b=2 and c=3) or (b=2 and d=4)
2151             # This is necessary because the BoolExpr resolver can only handle 1-level deep
2152             # AND-type rules, or a 1-level deep OR-type rule composed of any number of
2153             # 1-level deep AND-type rules
2154             sub _and {
2155             my($class,$left, $right) = @_;
2156              
2157             # force them to be [[ "property operator" => value]] instead of just [ "property operator" => value ]
2158             $left = [ $left ] unless (ref($left->[0]));
2159             $right = [ $right ] unless (ref($right->[0]));
2160              
2161             my @and;
2162             foreach my $left_subexpr ( @$left ) {
2163             foreach my $right_subexpr (@$right) {
2164             push @and, [@$left_subexpr, @$right_subexpr];
2165             }
2166             }
2167             \@and;
2168             }
2169              
2170             sub _or {
2171             my($class,$left, $right) = @_;
2172              
2173             # force them to be [[ "property operator" => value]] instead of just [ "property operator" => value ]
2174             $left = [ $left ] unless (ref($left->[0]));
2175             $right = [ $right ] unless (ref($right->[0]));
2176              
2177             [ @$left, @$right ];
2178             }
2179              
2180             1;
2181              
2182              
2183             1;