001    /* Generated By:JavaCC: Do not edit this line. SelectorParser.java */
002    /**
003     * Licensed to the Apache Software Foundation (ASF) under one or more
004     * contributor license agreements.  See the NOTICE file distributed with
005     * this work for additional information regarding copyright ownership.
006     * The ASF licenses this file to You under the Apache License, Version 2.0
007     * (the "License"); you may not use this file except in compliance with
008     * the License.  You may obtain a copy of the License at
009     *
010     *      http://www.apache.org/licenses/LICENSE-2.0
011     *
012     * Unless required by applicable law or agreed to in writing, software
013     * distributed under the License is distributed on an "AS IS" BASIS,
014     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015     * See the License for the specific language governing permissions and
016     * limitations under the License.
017     */
018    
019    package org.apache.activemq.selector;
020    
021    import java.io.*;
022    import java.util.*;
023    
024    import javax.jms.InvalidSelectorException;
025    
026    import org.apache.activemq.filter.*;
027    import org.apache.activemq.util.LRUCache;
028    
029    /** 
030     * JMS Selector Parser generated by JavaCC
031     * 
032     * Do not edit this .java file directly - it is autogenerated from SelectorParser.jj
033     */
034    public class SelectorParser implements SelectorParserConstants {
035    
036        private static final Map cache = Collections.synchronizedMap(new LRUCache(100));
037        private static final String CONVERT_STRING_EXPRESSIONS_PREFIX = "convert_string_expressions:";
038    
039        public static BooleanExpression parse(String sql) throws InvalidSelectorException {
040            Object result = cache.get(sql);
041            if (result instanceof InvalidSelectorException) {
042                throw (InvalidSelectorException) result;
043            } else if (result instanceof BooleanExpression) {
044                return (BooleanExpression) result;
045            } else {
046    
047                boolean convertStringExpressions = false;
048                if( sql.startsWith(CONVERT_STRING_EXPRESSIONS_PREFIX)) {
049                    convertStringExpressions = true;
050                    sql = sql.substring(CONVERT_STRING_EXPRESSIONS_PREFIX.length());
051                }
052    
053                if( convertStringExpressions ) {
054                    ComparisonExpression.CONVERT_STRING_EXPRESSIONS.set(true);
055                }
056                try {
057                    BooleanExpression e = new SelectorParser(sql).parse();
058                    cache.put(sql, e);
059                    return e;
060                } catch (InvalidSelectorException t) {
061                    cache.put(sql, t);
062                    throw t;
063                } finally {
064                    if( convertStringExpressions ) {
065                        ComparisonExpression.CONVERT_STRING_EXPRESSIONS.remove();
066                    }
067                }
068            }
069        }
070    
071        public static void clearCache() {
072            cache.clear();
073        }
074    
075        private String sql;
076    
077        protected SelectorParser(String sql) {
078            this(new StringReader(sql));
079            this.sql = sql;
080        }
081    
082        protected BooleanExpression parse() throws InvalidSelectorException {
083            try {
084                return this.JmsSelector();
085            }
086            catch (Throwable e) {
087                throw (InvalidSelectorException) new InvalidSelectorException(sql).initCause(e);
088            }
089        }
090    
091        private BooleanExpression asBooleanExpression(Expression value) throws ParseException  {
092            if (value instanceof BooleanExpression) {
093                return (BooleanExpression) value;
094            }
095            if (value instanceof PropertyExpression) {
096                return UnaryExpression.createBooleanCast( value );
097            }
098            throw new ParseException("Expression will not result in a boolean value: " + value);
099        }
100    
101    // ----------------------------------------------------------------------------
102    // Grammer
103    // ----------------------------------------------------------------------------
104      final public BooleanExpression JmsSelector() throws ParseException {
105        Expression left=null;
106        left = orExpression();
107            {if (true) return asBooleanExpression(left);}
108        throw new Error("Missing return statement in function");
109      }
110    
111      final public Expression orExpression() throws ParseException {
112        Expression left;
113        Expression right;
114        left = andExpression();
115        label_1:
116        while (true) {
117          switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
118          case OR:
119            ;
120            break;
121          default:
122            break label_1;
123          }
124          jj_consume_token(OR);
125          right = andExpression();
126                    left = LogicExpression.createOR(asBooleanExpression(left), asBooleanExpression(right));
127        }
128            {if (true) return left;}
129        throw new Error("Missing return statement in function");
130      }
131    
132      final public Expression andExpression() throws ParseException {
133        Expression left;
134        Expression right;
135        left = equalityExpression();
136        label_2:
137        while (true) {
138          switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
139          case AND:
140            ;
141            break;
142          default:
143            break label_2;
144          }
145          jj_consume_token(AND);
146          right = equalityExpression();
147                    left = LogicExpression.createAND(asBooleanExpression(left), asBooleanExpression(right));
148        }
149            {if (true) return left;}
150        throw new Error("Missing return statement in function");
151      }
152    
153      final public Expression equalityExpression() throws ParseException {
154        Expression left;
155        Expression right;
156        left = comparisonExpression();
157        label_3:
158        while (true) {
159          switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
160          case IS:
161          case 28:
162          case 29:
163            ;
164            break;
165          default:
166            break label_3;
167          }
168          switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
169          case 28:
170            jj_consume_token(28);
171            right = comparisonExpression();
172                    left = ComparisonExpression.createEqual(left, right);
173            break;
174          case 29:
175            jj_consume_token(29);
176            right = comparisonExpression();
177                    left = ComparisonExpression.createNotEqual(left, right);
178            break;
179          default:
180            if (jj_2_1(2)) {
181              jj_consume_token(IS);
182              jj_consume_token(NULL);
183                    left = ComparisonExpression.createIsNull(left);
184            } else {
185              switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
186              case IS:
187                jj_consume_token(IS);
188                jj_consume_token(NOT);
189                jj_consume_token(NULL);
190                    left = ComparisonExpression.createIsNotNull(left);
191                break;
192              default:
193                jj_consume_token(-1);
194                throw new ParseException();
195              }
196            }
197          }
198        }
199            {if (true) return left;}
200        throw new Error("Missing return statement in function");
201      }
202    
203      final public Expression comparisonExpression() throws ParseException {
204        Expression left;
205        Expression right;
206        Expression low;
207        Expression high;
208        String t, u;
209            boolean not;
210            ArrayList list;
211        left = addExpression();
212        label_4:
213        while (true) {
214          switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
215          case NOT:
216          case BETWEEN:
217          case LIKE:
218          case IN:
219          case 30:
220          case 31:
221          case 32:
222          case 33:
223            ;
224            break;
225          default:
226            break label_4;
227          }
228          switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
229          case 30:
230            jj_consume_token(30);
231            right = addExpression();
232                        left = ComparisonExpression.createGreaterThan(left, right);
233            break;
234          case 31:
235            jj_consume_token(31);
236            right = addExpression();
237                        left = ComparisonExpression.createGreaterThanEqual(left, right);
238            break;
239          case 32:
240            jj_consume_token(32);
241            right = addExpression();
242                        left = ComparisonExpression.createLessThan(left, right);
243            break;
244          case 33:
245            jj_consume_token(33);
246            right = addExpression();
247                        left = ComparisonExpression.createLessThanEqual(left, right);
248            break;
249          case LIKE:
250                                            u=null;
251            jj_consume_token(LIKE);
252            t = stringLitteral();
253            switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
254            case ESCAPE:
255              jj_consume_token(ESCAPE);
256              u = stringLitteral();
257              break;
258            default:
259              ;
260            }
261                        left = ComparisonExpression.createLike(left, t, u);
262            break;
263          default:
264            if (jj_2_2(2)) {
265                                            u=null;
266              jj_consume_token(NOT);
267              jj_consume_token(LIKE);
268              t = stringLitteral();
269              switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
270              case ESCAPE:
271                jj_consume_token(ESCAPE);
272                u = stringLitteral();
273                break;
274              default:
275                ;
276              }
277                        left = ComparisonExpression.createNotLike(left, t, u);
278            } else {
279              switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
280              case BETWEEN:
281                jj_consume_token(BETWEEN);
282                low = addExpression();
283                jj_consume_token(AND);
284                high = addExpression();
285                                            left = ComparisonExpression.createBetween(left, low, high);
286                break;
287              default:
288                if (jj_2_3(2)) {
289                  jj_consume_token(NOT);
290                  jj_consume_token(BETWEEN);
291                  low = addExpression();
292                  jj_consume_token(AND);
293                  high = addExpression();
294                                            left = ComparisonExpression.createNotBetween(left, low, high);
295                } else {
296                  switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
297                  case IN:
298                    jj_consume_token(IN);
299                    jj_consume_token(34);
300                    t = stringLitteral();
301                                        list = new ArrayList();
302                                        list.add( t );
303                    label_5:
304                    while (true) {
305                      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
306                      case 35:
307                        ;
308                        break;
309                      default:
310                        break label_5;
311                      }
312                      jj_consume_token(35);
313                      t = stringLitteral();
314                                                list.add( t );
315                    }
316                    jj_consume_token(36);
317                               left = ComparisonExpression.createInFilter(left, list);
318                    break;
319                  default:
320                    if (jj_2_4(2)) {
321                      jj_consume_token(NOT);
322                      jj_consume_token(IN);
323                      jj_consume_token(34);
324                      t = stringLitteral();
325                                        list = new ArrayList();
326                                        list.add( t );
327                      label_6:
328                      while (true) {
329                        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
330                        case 35:
331                          ;
332                          break;
333                        default:
334                          break label_6;
335                        }
336                        jj_consume_token(35);
337                        t = stringLitteral();
338                                                list.add( t );
339                      }
340                      jj_consume_token(36);
341                               left = ComparisonExpression.createNotInFilter(left, list);
342                    } else {
343                      jj_consume_token(-1);
344                      throw new ParseException();
345                    }
346                  }
347                }
348              }
349            }
350          }
351        }
352            {if (true) return left;}
353        throw new Error("Missing return statement in function");
354      }
355    
356      final public Expression addExpression() throws ParseException {
357        Expression left;
358        Expression right;
359        left = multExpr();
360        label_7:
361        while (true) {
362          if (jj_2_5(2147483647)) {
363            ;
364          } else {
365            break label_7;
366          }
367          switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
368          case 37:
369            jj_consume_token(37);
370            right = multExpr();
371                        left = ArithmeticExpression.createPlus(left, right);
372            break;
373          case 38:
374            jj_consume_token(38);
375            right = multExpr();
376                        left = ArithmeticExpression.createMinus(left, right);
377            break;
378          default:
379            jj_consume_token(-1);
380            throw new ParseException();
381          }
382        }
383            {if (true) return left;}
384        throw new Error("Missing return statement in function");
385      }
386    
387      final public Expression multExpr() throws ParseException {
388        Expression left;
389        Expression right;
390        left = unaryExpr();
391        label_8:
392        while (true) {
393          switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
394          case 39:
395          case 40:
396          case 41:
397            ;
398            break;
399          default:
400            break label_8;
401          }
402          switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
403          case 39:
404            jj_consume_token(39);
405            right = unaryExpr();
406                    left = ArithmeticExpression.createMultiply(left, right);
407            break;
408          case 40:
409            jj_consume_token(40);
410            right = unaryExpr();
411                    left = ArithmeticExpression.createDivide(left, right);
412            break;
413          case 41:
414            jj_consume_token(41);
415            right = unaryExpr();
416                    left = ArithmeticExpression.createMod(left, right);
417            break;
418          default:
419            jj_consume_token(-1);
420            throw new ParseException();
421          }
422        }
423            {if (true) return left;}
424        throw new Error("Missing return statement in function");
425      }
426    
427      final public Expression unaryExpr() throws ParseException {
428        String s=null;
429        Expression left=null;
430        if (jj_2_6(2147483647)) {
431          jj_consume_token(37);
432          left = unaryExpr();
433        } else {
434          switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
435          case 38:
436            jj_consume_token(38);
437            left = unaryExpr();
438                    left = UnaryExpression.createNegate(left);
439            break;
440          case NOT:
441            jj_consume_token(NOT);
442            left = unaryExpr();
443                        left = UnaryExpression.createNOT( asBooleanExpression(left) );
444            break;
445          case XPATH:
446            jj_consume_token(XPATH);
447            s = stringLitteral();
448                        left = UnaryExpression.createXPath( s );
449            break;
450          case XQUERY:
451            jj_consume_token(XQUERY);
452            s = stringLitteral();
453                        left = UnaryExpression.createXQuery( s );
454            break;
455          case TRUE:
456          case FALSE:
457          case NULL:
458          case DECIMAL_LITERAL:
459          case HEX_LITERAL:
460          case OCTAL_LITERAL:
461          case FLOATING_POINT_LITERAL:
462          case STRING_LITERAL:
463          case ID:
464          case 34:
465            left = primaryExpr();
466            break;
467          default:
468            jj_consume_token(-1);
469            throw new ParseException();
470          }
471        }
472            {if (true) return left;}
473        throw new Error("Missing return statement in function");
474      }
475    
476      final public Expression primaryExpr() throws ParseException {
477        Expression left=null;
478        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
479        case TRUE:
480        case FALSE:
481        case NULL:
482        case DECIMAL_LITERAL:
483        case HEX_LITERAL:
484        case OCTAL_LITERAL:
485        case FLOATING_POINT_LITERAL:
486        case STRING_LITERAL:
487          left = literal();
488          break;
489        case ID:
490          left = variable();
491          break;
492        case 34:
493          jj_consume_token(34);
494          left = orExpression();
495          jj_consume_token(36);
496          break;
497        default:
498          jj_consume_token(-1);
499          throw new ParseException();
500        }
501            {if (true) return left;}
502        throw new Error("Missing return statement in function");
503      }
504    
505      final public ConstantExpression literal() throws ParseException {
506        Token t;
507        String s;
508        ConstantExpression left=null;
509        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
510        case STRING_LITERAL:
511          s = stringLitteral();
512                    left = new ConstantExpression(s);
513          break;
514        case DECIMAL_LITERAL:
515          t = jj_consume_token(DECIMAL_LITERAL);
516                    left = ConstantExpression.createFromDecimal(t.image);
517          break;
518        case HEX_LITERAL:
519          t = jj_consume_token(HEX_LITERAL);
520                    left = ConstantExpression.createFromHex(t.image);
521          break;
522        case OCTAL_LITERAL:
523          t = jj_consume_token(OCTAL_LITERAL);
524                    left = ConstantExpression.createFromOctal(t.image);
525          break;
526        case FLOATING_POINT_LITERAL:
527          t = jj_consume_token(FLOATING_POINT_LITERAL);
528                    left = ConstantExpression.createFloat(t.image);
529          break;
530        case TRUE:
531          jj_consume_token(TRUE);
532                    left = ConstantExpression.TRUE;
533          break;
534        case FALSE:
535          jj_consume_token(FALSE);
536                    left = ConstantExpression.FALSE;
537          break;
538        case NULL:
539          jj_consume_token(NULL);
540                    left = ConstantExpression.NULL;
541          break;
542        default:
543          jj_consume_token(-1);
544          throw new ParseException();
545        }
546            {if (true) return left;}
547        throw new Error("Missing return statement in function");
548      }
549    
550      final public String stringLitteral() throws ParseException {
551        Token t;
552        StringBuffer rc = new StringBuffer();
553        boolean first=true;
554        t = jj_consume_token(STRING_LITERAL);
555            // Decode the sting value.
556            String image = t.image;
557            for( int i=1; i < image.length()-1; i++ ) {
558                    char c = image.charAt(i);
559                    if( c == '\u005c'' )
560                            i++;
561                            rc.append(c);
562            }
563                {if (true) return rc.toString();}
564        throw new Error("Missing return statement in function");
565      }
566    
567      final public PropertyExpression variable() throws ParseException {
568        Token t;
569        PropertyExpression left=null;
570        t = jj_consume_token(ID);
571                left = new PropertyExpression(t.image);
572            {if (true) return left;}
573        throw new Error("Missing return statement in function");
574      }
575    
576      private boolean jj_2_1(int xla) {
577        jj_la = xla; jj_lastpos = jj_scanpos = token;
578        try { return !jj_3_1(); }
579        catch(LookaheadSuccess ls) { return true; }
580      }
581    
582      private boolean jj_2_2(int xla) {
583        jj_la = xla; jj_lastpos = jj_scanpos = token;
584        try { return !jj_3_2(); }
585        catch(LookaheadSuccess ls) { return true; }
586      }
587    
588      private boolean jj_2_3(int xla) {
589        jj_la = xla; jj_lastpos = jj_scanpos = token;
590        try { return !jj_3_3(); }
591        catch(LookaheadSuccess ls) { return true; }
592      }
593    
594      private boolean jj_2_4(int xla) {
595        jj_la = xla; jj_lastpos = jj_scanpos = token;
596        try { return !jj_3_4(); }
597        catch(LookaheadSuccess ls) { return true; }
598      }
599    
600      private boolean jj_2_5(int xla) {
601        jj_la = xla; jj_lastpos = jj_scanpos = token;
602        try { return !jj_3_5(); }
603        catch(LookaheadSuccess ls) { return true; }
604      }
605    
606      private boolean jj_2_6(int xla) {
607        jj_la = xla; jj_lastpos = jj_scanpos = token;
608        try { return !jj_3_6(); }
609        catch(LookaheadSuccess ls) { return true; }
610      }
611    
612      private boolean jj_3_3() {
613        if (jj_scan_token(NOT)) return true;
614        if (jj_scan_token(BETWEEN)) return true;
615        if (jj_3R_43()) return true;
616        if (jj_scan_token(AND)) return true;
617        if (jj_3R_43()) return true;
618        return false;
619      }
620    
621      private boolean jj_3R_45() {
622        if (jj_scan_token(28)) return true;
623        if (jj_3R_41()) return true;
624        return false;
625      }
626    
627      private boolean jj_3R_42() {
628        Token xsp;
629        xsp = jj_scanpos;
630        if (jj_3R_45()) {
631        jj_scanpos = xsp;
632        if (jj_3R_46()) {
633        jj_scanpos = xsp;
634        if (jj_3_1()) {
635        jj_scanpos = xsp;
636        if (jj_3R_47()) return true;
637        }
638        }
639        }
640        return false;
641      }
642    
643      private boolean jj_3R_33() {
644        if (jj_scan_token(FLOATING_POINT_LITERAL)) return true;
645        return false;
646      }
647    
648      private boolean jj_3R_54() {
649        if (jj_scan_token(BETWEEN)) return true;
650        if (jj_3R_43()) return true;
651        if (jj_scan_token(AND)) return true;
652        if (jj_3R_43()) return true;
653        return false;
654      }
655    
656      private boolean jj_3R_58() {
657        if (jj_scan_token(ESCAPE)) return true;
658        if (jj_3R_21()) return true;
659        return false;
660      }
661    
662      private boolean jj_3R_32() {
663        if (jj_scan_token(OCTAL_LITERAL)) return true;
664        return false;
665      }
666    
667      private boolean jj_3R_20() {
668        if (jj_scan_token(41)) return true;
669        if (jj_3R_10()) return true;
670        return false;
671      }
672    
673      private boolean jj_3R_39() {
674        if (jj_3R_41()) return true;
675        Token xsp;
676        while (true) {
677          xsp = jj_scanpos;
678          if (jj_3R_42()) { jj_scanpos = xsp; break; }
679        }
680        return false;
681      }
682    
683      private boolean jj_3_2() {
684        if (jj_scan_token(NOT)) return true;
685        if (jj_scan_token(LIKE)) return true;
686        if (jj_3R_21()) return true;
687        Token xsp;
688        xsp = jj_scanpos;
689        if (jj_3R_59()) jj_scanpos = xsp;
690        return false;
691      }
692    
693      private boolean jj_3R_53() {
694        if (jj_scan_token(LIKE)) return true;
695        if (jj_3R_21()) return true;
696        Token xsp;
697        xsp = jj_scanpos;
698        if (jj_3R_58()) jj_scanpos = xsp;
699        return false;
700      }
701    
702      private boolean jj_3R_31() {
703        if (jj_scan_token(HEX_LITERAL)) return true;
704        return false;
705      }
706    
707      private boolean jj_3R_19() {
708        if (jj_scan_token(40)) return true;
709        if (jj_3R_10()) return true;
710        return false;
711      }
712    
713      private boolean jj_3R_18() {
714        if (jj_scan_token(39)) return true;
715        if (jj_3R_10()) return true;
716        return false;
717      }
718    
719      private boolean jj_3R_11() {
720        Token xsp;
721        xsp = jj_scanpos;
722        if (jj_3R_18()) {
723        jj_scanpos = xsp;
724        if (jj_3R_19()) {
725        jj_scanpos = xsp;
726        if (jj_3R_20()) return true;
727        }
728        }
729        return false;
730      }
731    
732      private boolean jj_3R_40() {
733        if (jj_scan_token(AND)) return true;
734        if (jj_3R_39()) return true;
735        return false;
736      }
737    
738      private boolean jj_3R_30() {
739        if (jj_scan_token(DECIMAL_LITERAL)) return true;
740        return false;
741      }
742    
743      private boolean jj_3R_9() {
744        if (jj_3R_10()) return true;
745        Token xsp;
746        while (true) {
747          xsp = jj_scanpos;
748          if (jj_3R_11()) { jj_scanpos = xsp; break; }
749        }
750        return false;
751      }
752    
753      private boolean jj_3R_29() {
754        if (jj_3R_21()) return true;
755        return false;
756      }
757    
758      private boolean jj_3R_57() {
759        if (jj_scan_token(38)) return true;
760        if (jj_3R_9()) return true;
761        return false;
762      }
763    
764      private boolean jj_3R_37() {
765        if (jj_3R_39()) return true;
766        Token xsp;
767        while (true) {
768          xsp = jj_scanpos;
769          if (jj_3R_40()) { jj_scanpos = xsp; break; }
770        }
771        return false;
772      }
773    
774      private boolean jj_3_5() {
775        Token xsp;
776        xsp = jj_scanpos;
777        if (jj_scan_token(37)) {
778        jj_scanpos = xsp;
779        if (jj_scan_token(38)) return true;
780        }
781        if (jj_3R_9()) return true;
782        return false;
783      }
784    
785      private boolean jj_3R_26() {
786        Token xsp;
787        xsp = jj_scanpos;
788        if (jj_3R_29()) {
789        jj_scanpos = xsp;
790        if (jj_3R_30()) {
791        jj_scanpos = xsp;
792        if (jj_3R_31()) {
793        jj_scanpos = xsp;
794        if (jj_3R_32()) {
795        jj_scanpos = xsp;
796        if (jj_3R_33()) {
797        jj_scanpos = xsp;
798        if (jj_3R_34()) {
799        jj_scanpos = xsp;
800        if (jj_3R_35()) {
801        jj_scanpos = xsp;
802        if (jj_3R_36()) return true;
803        }
804        }
805        }
806        }
807        }
808        }
809        }
810        return false;
811      }
812    
813      private boolean jj_3R_52() {
814        if (jj_scan_token(33)) return true;
815        if (jj_3R_43()) return true;
816        return false;
817      }
818    
819      private boolean jj_3R_56() {
820        if (jj_scan_token(37)) return true;
821        if (jj_3R_9()) return true;
822        return false;
823      }
824    
825      private boolean jj_3R_51() {
826        if (jj_scan_token(32)) return true;
827        if (jj_3R_43()) return true;
828        return false;
829      }
830    
831      private boolean jj_3R_27() {
832        if (jj_scan_token(ID)) return true;
833        return false;
834      }
835    
836      private boolean jj_3R_61() {
837        if (jj_scan_token(35)) return true;
838        if (jj_3R_21()) return true;
839        return false;
840      }
841    
842      private boolean jj_3R_48() {
843        Token xsp;
844        xsp = jj_scanpos;
845        if (jj_3R_56()) {
846        jj_scanpos = xsp;
847        if (jj_3R_57()) return true;
848        }
849        return false;
850      }
851    
852      private boolean jj_3R_38() {
853        if (jj_scan_token(OR)) return true;
854        if (jj_3R_37()) return true;
855        return false;
856      }
857    
858      private boolean jj_3R_50() {
859        if (jj_scan_token(31)) return true;
860        if (jj_3R_43()) return true;
861        return false;
862      }
863    
864      private boolean jj_3R_25() {
865        if (jj_scan_token(34)) return true;
866        if (jj_3R_28()) return true;
867        if (jj_scan_token(36)) return true;
868        return false;
869      }
870    
871      private boolean jj_3R_24() {
872        if (jj_3R_27()) return true;
873        return false;
874      }
875    
876      private boolean jj_3R_49() {
877        if (jj_scan_token(30)) return true;
878        if (jj_3R_43()) return true;
879        return false;
880      }
881    
882      private boolean jj_3R_44() {
883        Token xsp;
884        xsp = jj_scanpos;
885        if (jj_3R_49()) {
886        jj_scanpos = xsp;
887        if (jj_3R_50()) {
888        jj_scanpos = xsp;
889        if (jj_3R_51()) {
890        jj_scanpos = xsp;
891        if (jj_3R_52()) {
892        jj_scanpos = xsp;
893        if (jj_3R_53()) {
894        jj_scanpos = xsp;
895        if (jj_3_2()) {
896        jj_scanpos = xsp;
897        if (jj_3R_54()) {
898        jj_scanpos = xsp;
899        if (jj_3_3()) {
900        jj_scanpos = xsp;
901        if (jj_3R_55()) {
902        jj_scanpos = xsp;
903        if (jj_3_4()) return true;
904        }
905        }
906        }
907        }
908        }
909        }
910        }
911        }
912        }
913        return false;
914      }
915    
916      private boolean jj_3R_23() {
917        if (jj_3R_26()) return true;
918        return false;
919      }
920    
921      private boolean jj_3R_43() {
922        if (jj_3R_9()) return true;
923        Token xsp;
924        while (true) {
925          xsp = jj_scanpos;
926          if (jj_3R_48()) { jj_scanpos = xsp; break; }
927        }
928        return false;
929      }
930    
931      private boolean jj_3R_28() {
932        if (jj_3R_37()) return true;
933        Token xsp;
934        while (true) {
935          xsp = jj_scanpos;
936          if (jj_3R_38()) { jj_scanpos = xsp; break; }
937        }
938        return false;
939      }
940    
941      private boolean jj_3R_22() {
942        Token xsp;
943        xsp = jj_scanpos;
944        if (jj_3R_23()) {
945        jj_scanpos = xsp;
946        if (jj_3R_24()) {
947        jj_scanpos = xsp;
948        if (jj_3R_25()) return true;
949        }
950        }
951        return false;
952      }
953    
954      private boolean jj_3R_17() {
955        if (jj_3R_22()) return true;
956        return false;
957      }
958    
959      private boolean jj_3R_21() {
960        if (jj_scan_token(STRING_LITERAL)) return true;
961        return false;
962      }
963    
964      private boolean jj_3R_60() {
965        if (jj_scan_token(35)) return true;
966        if (jj_3R_21()) return true;
967        return false;
968      }
969    
970      private boolean jj_3R_16() {
971        if (jj_scan_token(XQUERY)) return true;
972        if (jj_3R_21()) return true;
973        return false;
974      }
975    
976      private boolean jj_3R_41() {
977        if (jj_3R_43()) return true;
978        Token xsp;
979        while (true) {
980          xsp = jj_scanpos;
981          if (jj_3R_44()) { jj_scanpos = xsp; break; }
982        }
983        return false;
984      }
985    
986      private boolean jj_3R_59() {
987        if (jj_scan_token(ESCAPE)) return true;
988        if (jj_3R_21()) return true;
989        return false;
990      }
991    
992      private boolean jj_3_4() {
993        if (jj_scan_token(NOT)) return true;
994        if (jj_scan_token(IN)) return true;
995        if (jj_scan_token(34)) return true;
996        if (jj_3R_21()) return true;
997        Token xsp;
998        while (true) {
999          xsp = jj_scanpos;
1000          if (jj_3R_61()) { jj_scanpos = xsp; break; }
1001        }
1002        if (jj_scan_token(36)) return true;
1003        return false;
1004      }
1005    
1006      private boolean jj_3_6() {
1007        if (jj_scan_token(37)) return true;
1008        if (jj_3R_10()) return true;
1009        return false;
1010      }
1011    
1012      private boolean jj_3R_15() {
1013        if (jj_scan_token(XPATH)) return true;
1014        if (jj_3R_21()) return true;
1015        return false;
1016      }
1017    
1018      private boolean jj_3R_14() {
1019        if (jj_scan_token(NOT)) return true;
1020        if (jj_3R_10()) return true;
1021        return false;
1022      }
1023    
1024      private boolean jj_3R_36() {
1025        if (jj_scan_token(NULL)) return true;
1026        return false;
1027      }
1028    
1029      private boolean jj_3R_12() {
1030        if (jj_scan_token(37)) return true;
1031        if (jj_3R_10()) return true;
1032        return false;
1033      }
1034    
1035      private boolean jj_3R_55() {
1036        if (jj_scan_token(IN)) return true;
1037        if (jj_scan_token(34)) return true;
1038        if (jj_3R_21()) return true;
1039        Token xsp;
1040        while (true) {
1041          xsp = jj_scanpos;
1042          if (jj_3R_60()) { jj_scanpos = xsp; break; }
1043        }
1044        if (jj_scan_token(36)) return true;
1045        return false;
1046      }
1047    
1048      private boolean jj_3R_47() {
1049        if (jj_scan_token(IS)) return true;
1050        if (jj_scan_token(NOT)) return true;
1051        if (jj_scan_token(NULL)) return true;
1052        return false;
1053      }
1054    
1055      private boolean jj_3R_13() {
1056        if (jj_scan_token(38)) return true;
1057        if (jj_3R_10()) return true;
1058        return false;
1059      }
1060    
1061      private boolean jj_3R_35() {
1062        if (jj_scan_token(FALSE)) return true;
1063        return false;
1064      }
1065    
1066      private boolean jj_3_1() {
1067        if (jj_scan_token(IS)) return true;
1068        if (jj_scan_token(NULL)) return true;
1069        return false;
1070      }
1071    
1072      private boolean jj_3R_10() {
1073        Token xsp;
1074        xsp = jj_scanpos;
1075        if (jj_3R_12()) {
1076        jj_scanpos = xsp;
1077        if (jj_3R_13()) {
1078        jj_scanpos = xsp;
1079        if (jj_3R_14()) {
1080        jj_scanpos = xsp;
1081        if (jj_3R_15()) {
1082        jj_scanpos = xsp;
1083        if (jj_3R_16()) {
1084        jj_scanpos = xsp;
1085        if (jj_3R_17()) return true;
1086        }
1087        }
1088        }
1089        }
1090        }
1091        return false;
1092      }
1093    
1094      private boolean jj_3R_34() {
1095        if (jj_scan_token(TRUE)) return true;
1096        return false;
1097      }
1098    
1099      private boolean jj_3R_46() {
1100        if (jj_scan_token(29)) return true;
1101        if (jj_3R_41()) return true;
1102        return false;
1103      }
1104    
1105      /** Generated Token Manager. */
1106      public SelectorParserTokenManager token_source;
1107      SimpleCharStream jj_input_stream;
1108      /** Current token. */
1109      public Token token;
1110      /** Next token. */
1111      public Token jj_nt;
1112      private int jj_ntk;
1113      private Token jj_scanpos, jj_lastpos;
1114      private int jj_la;
1115    
1116      /** Constructor with InputStream. */
1117      public SelectorParser(java.io.InputStream stream) {
1118         this(stream, null);
1119      }
1120      /** Constructor with InputStream and supplied encoding */
1121      public SelectorParser(java.io.InputStream stream, String encoding) {
1122        try { jj_input_stream = new SimpleCharStream(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); }
1123        token_source = new SelectorParserTokenManager(jj_input_stream);
1124        token = new Token();
1125        jj_ntk = -1;
1126      }
1127    
1128      /** Reinitialise. */
1129      public void ReInit(java.io.InputStream stream) {
1130         ReInit(stream, null);
1131      }
1132      /** Reinitialise. */
1133      public void ReInit(java.io.InputStream stream, String encoding) {
1134        try { jj_input_stream.ReInit(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); }
1135        token_source.ReInit(jj_input_stream);
1136        token = new Token();
1137        jj_ntk = -1;
1138      }
1139    
1140      /** Constructor. */
1141      public SelectorParser(java.io.Reader stream) {
1142        jj_input_stream = new SimpleCharStream(stream, 1, 1);
1143        token_source = new SelectorParserTokenManager(jj_input_stream);
1144        token = new Token();
1145        jj_ntk = -1;
1146      }
1147    
1148      /** Reinitialise. */
1149      public void ReInit(java.io.Reader stream) {
1150        jj_input_stream.ReInit(stream, 1, 1);
1151        token_source.ReInit(jj_input_stream);
1152        token = new Token();
1153        jj_ntk = -1;
1154      }
1155    
1156      /** Constructor with generated Token Manager. */
1157      public SelectorParser(SelectorParserTokenManager tm) {
1158        token_source = tm;
1159        token = new Token();
1160        jj_ntk = -1;
1161      }
1162    
1163      /** Reinitialise. */
1164      public void ReInit(SelectorParserTokenManager tm) {
1165        token_source = tm;
1166        token = new Token();
1167        jj_ntk = -1;
1168      }
1169    
1170      private Token jj_consume_token(int kind) throws ParseException {
1171        Token oldToken;
1172        if ((oldToken = token).next != null) token = token.next;
1173        else token = token.next = token_source.getNextToken();
1174        jj_ntk = -1;
1175        if (token.kind == kind) {
1176          return token;
1177        }
1178        token = oldToken;
1179        throw generateParseException();
1180      }
1181    
1182      static private final class LookaheadSuccess extends java.lang.Error { }
1183      final private LookaheadSuccess jj_ls = new LookaheadSuccess();
1184      private boolean jj_scan_token(int kind) {
1185        if (jj_scanpos == jj_lastpos) {
1186          jj_la--;
1187          if (jj_scanpos.next == null) {
1188            jj_lastpos = jj_scanpos = jj_scanpos.next = token_source.getNextToken();
1189          } else {
1190            jj_lastpos = jj_scanpos = jj_scanpos.next;
1191          }
1192        } else {
1193          jj_scanpos = jj_scanpos.next;
1194        }
1195        if (jj_scanpos.kind != kind) return true;
1196        if (jj_la == 0 && jj_scanpos == jj_lastpos) throw jj_ls;
1197        return false;
1198      }
1199    
1200    
1201    /** Get the next Token. */
1202      final public Token getNextToken() {
1203        if (token.next != null) token = token.next;
1204        else token = token.next = token_source.getNextToken();
1205        jj_ntk = -1;
1206        return token;
1207      }
1208    
1209    /** Get the specific Token. */
1210      final public Token getToken(int index) {
1211        Token t = token;
1212        for (int i = 0; i < index; i++) {
1213          if (t.next != null) t = t.next;
1214          else t = t.next = token_source.getNextToken();
1215        }
1216        return t;
1217      }
1218    
1219      private int jj_ntk() {
1220        if ((jj_nt=token.next) == null)
1221          return (jj_ntk = (token.next=token_source.getNextToken()).kind);
1222        else
1223          return (jj_ntk = jj_nt.kind);
1224      }
1225    
1226      /** Generate ParseException. */
1227      public ParseException generateParseException() {
1228        Token errortok = token.next;
1229        int line = errortok.beginLine, column = errortok.beginColumn;
1230        String mess = (errortok.kind == 0) ? tokenImage[0] : errortok.image;
1231        return new ParseException("Parse error at line " + line + ", column " + column + ".  Encountered: " + mess);
1232      }
1233    
1234      /** Enable tracing. */
1235      final public void enable_tracing() {
1236      }
1237    
1238      /** Disable tracing. */
1239      final public void disable_tracing() {
1240      }
1241    
1242    }