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