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