KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mr > api > jms > selector > parser > SelectorParser


1 /*
2  * Copyright 2002 by
3  * <a HREF="http://www.coridan.com">Coridan</a>
4  * <a HREF="mailto: support@coridan.com ">support@coridan.com</a>
5  *
6  * The contents of this file are subject to the Mozilla Public License Version
7  * 1.1 (the "License"); you may not use this file except in compliance with the
8  * License. You may obtain a copy of the License at
9  * http://www.mozilla.org/MPL/
10  *
11  * Software distributed under the License is distributed on an "AS IS" basis,
12  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13  * for the specific language governing rights and limitations under the
14  * License.
15  *
16  * The Original Code is "MantaRay" (TM).
17  *
18  * The Initial Developer of the Original Code is Coridan.
19  * Portions created by the Initial Developer are Copyright (C) 2006
20  * Coridan Inc. All Rights Reserved.
21  *
22  * Contributor(s): all the names of the contributors are added in the source
23  * code where applicable.
24  *
25  * Alternatively, the contents of this file may be used under the terms of the
26  * LGPL license (the "GNU LESSER GENERAL PUBLIC LICENSE"), in which case the
27  * provisions of LGPL are applicable instead of those above. If you wish to
28  * allow use of your version of this file only under the terms of the LGPL
29  * License and not to allow others to use your version of this file under
30  * the MPL, indicate your decision by deleting the provisions above and
31  * replace them with the notice and other provisions required by the LGPL.
32  * If you do not delete the provisions above, a recipient may use your version
33  * of this file under either the MPL or the GNU LESSER GENERAL PUBLIC LICENSE.
34  
35  *
36  * This library is free software; you can redistribute it and/or modify it
37  * under the terms of the MPL as stated above or under the terms of the GNU
38  * Lesser General Public License as published by the Free Software Foundation;
39  * either version 2.1 of the License, or any later version.
40  *
41  * This library is distributed in the hope that it will be useful, but WITHOUT
42  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
43  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
44  * License for more details.
45  */

46 // $ANTLR 2.7.2: "Selector.g" -> "SelectorParser.java"$
47

48
49
50 package org.mr.api.jms.selector.parser;
51
52
53 import antlr.ASTFactory;
54 import antlr.ASTPair;
55 import antlr.MismatchedTokenException;
56 import antlr.NoViableAltException;
57 import antlr.ParserSharedInputState;
58 import antlr.RecognitionException;
59 import antlr.Token;
60 import antlr.TokenBuffer;
61 import antlr.TokenStream;
62 import antlr.TokenStreamException;
63 import antlr.collections.AST;
64 import antlr.collections.impl.ASTArray;
65
66 import org.mr.api.jms.selector.syntax.Context;
67 import org.mr.api.jms.selector.syntax.Identifiers;
68 import org.mr.api.jms.selector.syntax.SelectorException;
69 import org.mr.api.jms.selector.syntax.Type;
70
71 public class SelectorParser extends antlr.LLkParser implements SelectorTokenTypes
72  {
73
74     public void initialise() {
75         // construct SelectorAST nodes
76
setASTNodeClass(SelectorAST.class.getName());
77     }//initialise
78

79     private void rethrow(String JavaDoc msg, AST node, Token token) throws SelectorException {
80         if (node != null) {
81             throw new SelectorException(((SelectorAST) node).getContext(), msg);
82         } //if
83
else {
84             Context context = new Context(token.getLine(), token.getColumn());
85             throw new SelectorException(context, msg);
86         }//else
87
}//rethrow
88

89 protected SelectorParser(TokenBuffer tokenBuf, int k) {
90   super(tokenBuf,k);
91   tokenNames = _tokenNames;
92   buildTokenTypeASTClassMap();
93   astFactory = new ASTFactory(getTokenTypeToASTClassMap());
94 }
95
96 public SelectorParser(TokenBuffer tokenBuf) {
97   this(tokenBuf,2);
98 }
99
100 protected SelectorParser(TokenStream lexer, int k) {
101   super(lexer,k);
102   tokenNames = _tokenNames;
103   buildTokenTypeASTClassMap();
104   astFactory = new ASTFactory(getTokenTypeToASTClassMap());
105 }
106
107 public SelectorParser(TokenStream lexer) {
108   this(lexer,2);
109 }
110
111 public SelectorParser(ParserSharedInputState state) {
112   super(state,2);
113   tokenNames = _tokenNames;
114   buildTokenTypeASTClassMap();
115   astFactory = new ASTFactory(getTokenTypeToASTClassMap());
116 }
117
118     public final void selector() throws RecognitionException, TokenStreamException {
119         
120         returnAST = null;
121         ASTPair currentAST = new ASTPair();
122         SelectorAST selector_AST = null;
123         
124         try { // for error handling
125
orExpression();
126             astFactory.addASTChild(currentAST, returnAST);
127             match(Token.EOF_TYPE);
128             selector_AST = (SelectorAST)currentAST.root;
129         }
130         catch (NoViableAltException error) {
131             
132             rethrow(error.getMessage(), error.node, error.token);
133             
134         }
135         catch (MismatchedTokenException error) {
136             
137             rethrow(error.getMessage(), error.node, error.token);
138             
139         }
140         returnAST = selector_AST;
141     }
142     
143     public final void orExpression() throws RecognitionException, TokenStreamException {
144         
145         returnAST = null;
146         ASTPair currentAST = new ASTPair();
147         SelectorAST orExpression_AST = null;
148         
149         andExpression();
150         astFactory.addASTChild(currentAST, returnAST);
151         {
152         _loop4:
153         do {
154             if ((LA(1)==LITERAL_or)) {
155                 SelectorAST tmp2_AST = null;
156                 tmp2_AST = (SelectorAST)astFactory.create(LT(1));
157                 astFactory.makeASTRoot(currentAST, tmp2_AST);
158                 match(LITERAL_or);
159                 orExpression_AST = (SelectorAST)currentAST.root;
160                 
161                 orExpression_AST.setReturnType(Type.BOOLEAN);
162                 
163                 andExpression();
164                 astFactory.addASTChild(currentAST, returnAST);
165             }
166             else {
167                 break _loop4;
168             }
169             
170         } while (true);
171         }
172         orExpression_AST = (SelectorAST)currentAST.root;
173         returnAST = orExpression_AST;
174     }
175     
176     public final void andExpression() throws RecognitionException, TokenStreamException {
177         
178         returnAST = null;
179         ASTPair currentAST = new ASTPair();
180         SelectorAST andExpression_AST = null;
181         
182         notExpression();
183         astFactory.addASTChild(currentAST, returnAST);
184         {
185         _loop7:
186         do {
187             if ((LA(1)==LITERAL_and)) {
188                 SelectorAST tmp3_AST = null;
189                 tmp3_AST = (SelectorAST)astFactory.create(LT(1));
190                 astFactory.makeASTRoot(currentAST, tmp3_AST);
191                 match(LITERAL_and);
192                 andExpression_AST = (SelectorAST)currentAST.root;
193                 
194                 andExpression_AST.setReturnType(Type.BOOLEAN);
195                 
196                 notExpression();
197                 astFactory.addASTChild(currentAST, returnAST);
198             }
199             else {
200                 break _loop7;
201             }
202             
203         } while (true);
204         }
205         andExpression_AST = (SelectorAST)currentAST.root;
206         returnAST = andExpression_AST;
207     }
208     
209     public final void notExpression() throws RecognitionException, TokenStreamException {
210         
211         returnAST = null;
212         ASTPair currentAST = new ASTPair();
213         SelectorAST notExpression_AST = null;
214         
215         {
216         switch ( LA(1)) {
217         case LITERAL_not:
218         {
219             SelectorAST tmp4_AST = null;
220             tmp4_AST = (SelectorAST)astFactory.create(LT(1));
221             astFactory.makeASTRoot(currentAST, tmp4_AST);
222             match(LITERAL_not);
223             notExpression_AST = (SelectorAST)currentAST.root;
224             
225             notExpression_AST.setReturnType(Type.BOOLEAN);
226             
227             break;
228         }
229         case PLUS:
230         case MINUS:
231         case LPAREN:
232         case IDENT:
233         case STRING_LITERAL:
234         case NUM_INT:
235         case NUM_FLOAT:
236         case LITERAL_false:
237         case LITERAL_true:
238         {
239             break;
240         }
241         default:
242         {
243             throw new NoViableAltException(LT(1), getFilename());
244         }
245         }
246         }
247         expression();
248         astFactory.addASTChild(currentAST, returnAST);
249         notExpression_AST = (SelectorAST)currentAST.root;
250         returnAST = notExpression_AST;
251     }
252     
253     public final void expression() throws RecognitionException, TokenStreamException {
254         
255         returnAST = null;
256         ASTPair currentAST = new ASTPair();
257         SelectorAST expression_AST = null;
258         SelectorAST expr_AST = null;
259         SelectorAST bool_AST = null;
260         SelectorAST comp_AST = null;
261         
262         sumExpression();
263         expr_AST = (SelectorAST)returnAST;
264         {
265         switch ( LA(1)) {
266         case LITERAL_not:
267         case LITERAL_is:
268         case LITERAL_between:
269         case LITERAL_in:
270         case LITERAL_like:
271         {
272             booleanExpression(expr_AST);
273             bool_AST = (SelectorAST)returnAST;
274             expr_AST = bool_AST;
275             break;
276         }
277         case EQUAL:
278         case NOT_EQUAL:
279         case LT:
280         case GT:
281         case LE:
282         case GE:
283         {
284             comparisonExpression(expr_AST);
285             comp_AST = (SelectorAST)returnAST;
286             expr_AST = comp_AST;
287             break;
288         }
289         case EOF:
290         case LITERAL_or:
291         case LITERAL_and:
292         case RPAREN:
293         {
294             break;
295         }
296         default:
297         {
298             throw new NoViableAltException(LT(1), getFilename());
299         }
300         }
301         }
302         expression_AST = (SelectorAST)currentAST.root;
303         
304         expression_AST = expr_AST;
305         
306         currentAST.root = expression_AST;
307         currentAST.child = expression_AST!=null &&expression_AST.getFirstChild()!=null ?
308             expression_AST.getFirstChild() : expression_AST;
309         currentAST.advanceChildToEnd();
310         returnAST = expression_AST;
311     }
312     
313     public final void sumExpression() throws RecognitionException, TokenStreamException {
314         
315         returnAST = null;
316         ASTPair currentAST = new ASTPair();
317         SelectorAST sumExpression_AST = null;
318         
319         productExpression();
320         astFactory.addASTChild(currentAST, returnAST);
321         {
322         _loop17:
323         do {
324             if ((LA(1)==PLUS||LA(1)==MINUS)) {
325                 {
326                 switch ( LA(1)) {
327                 case PLUS:
328                 {
329                     SelectorAST tmp5_AST = null;
330                     tmp5_AST = (SelectorAST)astFactory.create(LT(1));
331                     astFactory.makeASTRoot(currentAST, tmp5_AST);
332                     match(PLUS);
333                     break;
334                 }
335                 case MINUS:
336                 {
337                     SelectorAST tmp6_AST = null;
338                     tmp6_AST = (SelectorAST)astFactory.create(LT(1));
339                     astFactory.makeASTRoot(currentAST, tmp6_AST);
340                     match(MINUS);
341                     break;
342                 }
343                 default:
344                 {
345                     throw new NoViableAltException(LT(1), getFilename());
346                 }
347                 }
348                 }
349                 sumExpression_AST = (SelectorAST)currentAST.root;
350                 
351                 sumExpression_AST.setReturnType(Type.NUMERIC);
352                 
353                 productExpression();
354                 astFactory.addASTChild(currentAST, returnAST);
355             }
356             else {
357                 break _loop17;
358             }
359             
360         } while (true);
361         }
362         sumExpression_AST = (SelectorAST)currentAST.root;
363         returnAST = sumExpression_AST;
364     }
365     
366     public final void booleanExpression(
367         SelectorAST leftHand
368     ) throws RecognitionException, TokenStreamException {
369         
370         returnAST = null;
371         ASTPair currentAST = new ASTPair();
372         SelectorAST booleanExpression_AST = null;
373         
374         switch ( LA(1)) {
375         case LITERAL_is:
376         {
377             isExpression(leftHand);
378             astFactory.addASTChild(currentAST, returnAST);
379             booleanExpression_AST = (SelectorAST)currentAST.root;
380             break;
381         }
382         case LITERAL_not:
383         case LITERAL_between:
384         case LITERAL_in:
385         case LITERAL_like:
386         {
387             {
388             switch ( LA(1)) {
389             case LITERAL_not:
390             {
391                 SelectorAST tmp7_AST = null;
392                 tmp7_AST = (SelectorAST)astFactory.create(LT(1));
393                 astFactory.makeASTRoot(currentAST, tmp7_AST);
394                 match(LITERAL_not);
395                 break;
396             }
397             case LITERAL_between:
398             case LITERAL_in:
399             case LITERAL_like:
400             {
401                 break;
402             }
403             default:
404             {
405                 throw new NoViableAltException(LT(1), getFilename());
406             }
407             }
408             }
409             {
410             switch ( LA(1)) {
411             case LITERAL_between:
412             {
413                 betweenExpression(leftHand);
414                 astFactory.addASTChild(currentAST, returnAST);
415                 break;
416             }
417             case LITERAL_like:
418             {
419                 likeExpression(leftHand);
420                 astFactory.addASTChild(currentAST, returnAST);
421                 break;
422             }
423             case LITERAL_in:
424             {
425                 inExpression(leftHand);
426                 astFactory.addASTChild(currentAST, returnAST);
427                 break;
428             }
429             default:
430             {
431                 throw new NoViableAltException(LT(1), getFilename());
432             }
433             }
434             }
435             booleanExpression_AST = (SelectorAST)currentAST.root;
436             break;
437         }
438         default:
439         {
440             throw new NoViableAltException(LT(1), getFilename());
441         }
442         }
443         returnAST = booleanExpression_AST;
444     }
445     
446     public final void comparisonExpression(
447         SelectorAST leftHand
448     ) throws RecognitionException, TokenStreamException {
449         
450         returnAST = null;
451         ASTPair currentAST = new ASTPair();
452         SelectorAST comparisonExpression_AST = null;
453         SelectorAST eq_AST = null;
454         SelectorAST ne_AST = null;
455         SelectorAST lt_AST = null;
456         SelectorAST gt_AST = null;
457         SelectorAST le_AST = null;
458         SelectorAST ge_AST = null;
459         
460         {
461         switch ( LA(1)) {
462         case EQUAL:
463         {
464             SelectorAST tmp8_AST = null;
465             tmp8_AST = (SelectorAST)astFactory.create(LT(1));
466             match(EQUAL);
467             sumExpression();
468             eq_AST = (SelectorAST)returnAST;
469             comparisonExpression_AST = (SelectorAST)currentAST.root;
470             
471             comparisonExpression_AST = (SelectorAST)astFactory.make( (new ASTArray(3)).add(tmp8_AST).add(leftHand).add(eq_AST));
472             
473             currentAST.root = comparisonExpression_AST;
474             currentAST.child = comparisonExpression_AST!=null &&comparisonExpression_AST.getFirstChild()!=null ?
475                 comparisonExpression_AST.getFirstChild() : comparisonExpression_AST;
476             currentAST.advanceChildToEnd();
477             break;
478         }
479         case NOT_EQUAL:
480         {
481             SelectorAST tmp9_AST = null;
482             tmp9_AST = (SelectorAST)astFactory.create(LT(1));
483             match(NOT_EQUAL);
484             sumExpression();
485             ne_AST = (SelectorAST)returnAST;
486             comparisonExpression_AST = (SelectorAST)currentAST.root;
487             
488             comparisonExpression_AST = (SelectorAST)astFactory.make( (new ASTArray(3)).add(tmp9_AST).add(leftHand).add(ne_AST));
489             
490             currentAST.root = comparisonExpression_AST;
491             currentAST.child = comparisonExpression_AST!=null &&comparisonExpression_AST.getFirstChild()!=null ?
492                 comparisonExpression_AST.getFirstChild() : comparisonExpression_AST;
493             currentAST.advanceChildToEnd();
494             break;
495         }
496         case LT:
497         {
498             SelectorAST tmp10_AST = null;
499             tmp10_AST = (SelectorAST)astFactory.create(LT(1));
500             match(LT);
501             sumExpression();
502             lt_AST = (SelectorAST)returnAST;
503             comparisonExpression_AST = (SelectorAST)currentAST.root;
504             
505             comparisonExpression_AST = (SelectorAST)astFactory.make( (new ASTArray(3)).add(tmp10_AST).add(leftHand).add(lt_AST));
506             
507             currentAST.root = comparisonExpression_AST;
508             currentAST.child = comparisonExpression_AST!=null &&comparisonExpression_AST.getFirstChild()!=null ?
509                 comparisonExpression_AST.getFirstChild() : comparisonExpression_AST;
510             currentAST.advanceChildToEnd();
511             break;
512         }
513         case GT:
514         {
515             SelectorAST tmp11_AST = null;
516             tmp11_AST = (SelectorAST)astFactory.create(LT(1));
517             match(GT);
518             sumExpression();
519             gt_AST = (SelectorAST)returnAST;
520             comparisonExpression_AST = (SelectorAST)currentAST.root;
521             
522             comparisonExpression_AST = (SelectorAST)astFactory.make( (new ASTArray(3)).add(tmp11_AST).add(leftHand).add(gt_AST));
523             
524             currentAST.root = comparisonExpression_AST;
525             currentAST.child = comparisonExpression_AST!=null &&comparisonExpression_AST.getFirstChild()!=null ?
526                 comparisonExpression_AST.getFirstChild() : comparisonExpression_AST;
527             currentAST.advanceChildToEnd();
528             break;
529         }
530         case LE:
531         {
532             SelectorAST tmp12_AST = null;
533             tmp12_AST = (SelectorAST)astFactory.create(LT(1));
534             match(LE);
535             sumExpression();
536             le_AST = (SelectorAST)returnAST;
537             comparisonExpression_AST = (SelectorAST)currentAST.root;
538             
539             comparisonExpression_AST = (SelectorAST)astFactory.make( (new ASTArray(3)).add(tmp12_AST).add(leftHand).add(le_AST));
540             
541             currentAST.root = comparisonExpression_AST;
542             currentAST.child = comparisonExpression_AST!=null &&comparisonExpression_AST.getFirstChild()!=null ?
543                 comparisonExpression_AST.getFirstChild() : comparisonExpression_AST;
544             currentAST.advanceChildToEnd();
545             break;
546         }
547         case GE:
548         {
549             SelectorAST tmp13_AST = null;
550             tmp13_AST = (SelectorAST)astFactory.create(LT(1));
551             match(GE);
552             sumExpression();
553             ge_AST = (SelectorAST)returnAST;
554             comparisonExpression_AST = (SelectorAST)currentAST.root;
555             
556             comparisonExpression_AST = (SelectorAST)astFactory.make( (new ASTArray(3)).add(tmp13_AST).add(leftHand).add(ge_AST));
557             
558             currentAST.root = comparisonExpression_AST;
559             currentAST.child = comparisonExpression_AST!=null &&comparisonExpression_AST.getFirstChild()!=null ?
560                 comparisonExpression_AST.getFirstChild() : comparisonExpression_AST;
561             currentAST.advanceChildToEnd();
562             break;
563         }
564         default:
565         {
566             throw new NoViableAltException(LT(1), getFilename());
567         }
568         }
569         }
570         comparisonExpression_AST = (SelectorAST)currentAST.root;
571         
572         comparisonExpression_AST.setReturnType(Type.BOOLEAN);
573         
574         returnAST = comparisonExpression_AST;
575     }
576     
577     public final void productExpression() throws RecognitionException, TokenStreamException {
578         
579         returnAST = null;
580         ASTPair currentAST = new ASTPair();
581         SelectorAST productExpression_AST = null;
582         
583         unaryExpression();
584         astFactory.addASTChild(currentAST, returnAST);
585         {
586         _loop21:
587         do {
588             if ((LA(1)==MULTIPLY||LA(1)==DIVIDE)) {
589                 {
590                 switch ( LA(1)) {
591                 case MULTIPLY:
592                 {
593                     SelectorAST tmp14_AST = null;
594                     tmp14_AST = (SelectorAST)astFactory.create(LT(1));
595                     astFactory.makeASTRoot(currentAST, tmp14_AST);
596                     match(MULTIPLY);
597                     break;
598                 }
599                 case DIVIDE:
600                 {
601                     SelectorAST tmp15_AST = null;
602                     tmp15_AST = (SelectorAST)astFactory.create(LT(1));
603                     astFactory.makeASTRoot(currentAST, tmp15_AST);
604                     match(DIVIDE);
605                     break;
606                 }
607                 default:
608                 {
609                     throw new NoViableAltException(LT(1), getFilename());
610                 }
611                 }
612                 }
613                 productExpression_AST = (SelectorAST)currentAST.root;
614                 
615                 productExpression_AST.setReturnType(Type.NUMERIC);
616                 
617                 unaryExpression();
618                 astFactory.addASTChild(currentAST, returnAST);
619             }
620             else {
621                 break _loop21;
622             }
623             
624         } while (true);
625         }
626         productExpression_AST = (SelectorAST)currentAST.root;
627         returnAST = productExpression_AST;
628     }
629     
630     public final void unaryExpression() throws RecognitionException, TokenStreamException {
631         
632         returnAST = null;
633         ASTPair currentAST = new ASTPair();
634         SelectorAST unaryExpression_AST = null;
635         
636         switch ( LA(1)) {
637         case MINUS:
638         {
639             SelectorAST tmp16_AST = null;
640             tmp16_AST = (SelectorAST)astFactory.create(LT(1));
641             astFactory.makeASTRoot(currentAST, tmp16_AST);
642             match(MINUS);
643             unaryExpression_AST = (SelectorAST)currentAST.root;
644             
645             unaryExpression_AST.setType(UNARY_MINUS);
646             unaryExpression_AST.setReturnType(Type.NUMERIC);
647             
648             unaryExpression();
649             astFactory.addASTChild(currentAST, returnAST);
650             unaryExpression_AST = (SelectorAST)currentAST.root;
651             break;
652         }
653         case PLUS:
654         {
655             match(PLUS);
656             unaryExpression();
657             astFactory.addASTChild(currentAST, returnAST);
658             unaryExpression_AST = (SelectorAST)currentAST.root;
659             break;
660         }
661         case LPAREN:
662         case IDENT:
663         case STRING_LITERAL:
664         case NUM_INT:
665         case NUM_FLOAT:
666         case LITERAL_false:
667         case LITERAL_true:
668         {
669             term();
670             astFactory.addASTChild(currentAST, returnAST);
671             unaryExpression_AST = (SelectorAST)currentAST.root;
672             break;
673         }
674         default:
675         {
676             throw new NoViableAltException(LT(1), getFilename());
677         }
678         }
679         returnAST = unaryExpression_AST;
680     }
681     
682     public final void term() throws RecognitionException, TokenStreamException {
683         
684         returnAST = null;
685         ASTPair currentAST = new ASTPair();
686         SelectorAST term_AST = null;
687         Token ident = null;
688         SelectorAST ident_AST = null;
689         
690         switch ( LA(1)) {
691         case LPAREN:
692         {
693             SelectorAST tmp18_AST = null;
694             tmp18_AST = (SelectorAST)astFactory.create(LT(1));
695             astFactory.addASTChild(currentAST, tmp18_AST);
696             match(LPAREN);
697             orExpression();
698             astFactory.addASTChild(currentAST, returnAST);
699             SelectorAST tmp19_AST = null;
700             tmp19_AST = (SelectorAST)astFactory.create(LT(1));
701             astFactory.addASTChild(currentAST, tmp19_AST);
702             match(RPAREN);
703             term_AST = (SelectorAST)currentAST.root;
704             break;
705         }
706         case STRING_LITERAL:
707         case NUM_INT:
708         case NUM_FLOAT:
709         case LITERAL_false:
710         case LITERAL_true:
711         {
712             literal();
713             astFactory.addASTChild(currentAST, returnAST);
714             term_AST = (SelectorAST)currentAST.root;
715             break;
716         }
717         case IDENT:
718         {
719             ident = LT(1);
720             ident_AST = (SelectorAST)astFactory.create(ident);
721             astFactory.addASTChild(currentAST, ident_AST);
722             match(IDENT);
723             
724             String JavaDoc name = ident.getText();
725             if (Identifiers.isJMSIdentifier(name)) {
726             if (Identifiers.isNumeric(name)) {
727             ident_AST.setReturnType(Type.NUMERIC);
728             } else if (Identifiers.isString(name)) {
729             ident_AST.setReturnType(Type.STRING);
730             } else {
731             String JavaDoc msg = "invalid message header identifier: " + name;
732             throw new SelectorException(ident_AST.getContext(), msg);
733             }
734             }
735             
736             term_AST = (SelectorAST)currentAST.root;
737             break;
738         }
739         default:
740         {
741             throw new NoViableAltException(LT(1), getFilename());
742         }
743         }
744         returnAST = term_AST;
745     }
746     
747     public final void literal() throws RecognitionException, TokenStreamException {
748         
749         returnAST = null;
750         ASTPair currentAST = new ASTPair();
751         SelectorAST literal_AST = null;
752         
753         switch ( LA(1)) {
754         case NUM_INT:
755         {
756             SelectorAST tmp20_AST = null;
757             tmp20_AST = (SelectorAST)astFactory.create(LT(1));
758             astFactory.addASTChild(currentAST, tmp20_AST);
759             match(NUM_INT);
760             literal_AST = (SelectorAST)currentAST.root;
761             
762             literal_AST.setReturnType(Type.NUMERIC);
763             
764             literal_AST = (SelectorAST)currentAST.root;
765             break;
766         }
767         case NUM_FLOAT:
768         {
769             SelectorAST tmp21_AST = null;
770             tmp21_AST = (SelectorAST)astFactory.create(LT(1));
771             astFactory.addASTChild(currentAST, tmp21_AST);
772             match(NUM_FLOAT);
773             literal_AST = (SelectorAST)currentAST.root;
774             
775             literal_AST.setReturnType(Type.NUMERIC);
776             
777             literal_AST = (SelectorAST)currentAST.root;
778             break;
779         }
780         case STRING_LITERAL:
781         {
782             SelectorAST tmp22_AST = null;
783             tmp22_AST = (SelectorAST)astFactory.create(LT(1));
784             astFactory.addASTChild(currentAST, tmp22_AST);
785             match(STRING_LITERAL);
786             literal_AST = (SelectorAST)currentAST.root;
787             
788             literal_AST.setReturnType(Type.STRING);
789             
790             literal_AST = (SelectorAST)currentAST.root;
791             break;
792         }
793         case LITERAL_false:
794         case LITERAL_true:
795         {
796             {
797             switch ( LA(1)) {
798             case LITERAL_false:
799             {
800                 SelectorAST tmp23_AST = null;
801                 tmp23_AST = (SelectorAST)astFactory.create(LT(1));
802                 astFactory.addASTChild(currentAST, tmp23_AST);
803                 match(LITERAL_false);
804                 break;
805             }
806             case LITERAL_true:
807             {
808                 SelectorAST tmp24_AST = null;
809                 tmp24_AST = (SelectorAST)astFactory.create(LT(1));
810                 astFactory.addASTChild(currentAST, tmp24_AST);
811                 match(LITERAL_true);
812                 break;
813             }
814             default:
815             {
816                 throw new NoViableAltException(LT(1), getFilename());
817             }
818             }
819             }
820             literal_AST = (SelectorAST)currentAST.root;
821             
822             literal_AST.setReturnType(Type.BOOLEAN);
823             
824             literal_AST = (SelectorAST)currentAST.root;
825             break;
826         }
827         default:
828         {
829             throw new NoViableAltException(LT(1), getFilename());
830         }
831         }
832         returnAST = literal_AST;
833     }
834     
835     public final void isExpression(
836         SelectorAST leftHand
837     ) throws RecognitionException, TokenStreamException {
838         
839         returnAST = null;
840         ASTPair currentAST = new ASTPair();
841         SelectorAST isExpression_AST = null;
842         Token is = null;
843         SelectorAST is_AST = null;
844         Token not = null;
845         SelectorAST not_AST = null;
846         Token nul = null;
847         SelectorAST nul_AST = null;
848         
849         is = LT(1);
850         is_AST = (SelectorAST)astFactory.create(is);
851         match(LITERAL_is);
852         {
853         switch ( LA(1)) {
854         case LITERAL_not:
855         {
856             not = LT(1);
857             not_AST = (SelectorAST)astFactory.create(not);
858             match(LITERAL_not);
859             break;
860         }
861         case LITERAL_null:
862         {
863             break;
864         }
865         default:
866         {
867             throw new NoViableAltException(LT(1), getFilename());
868         }
869         }
870         }
871         nul = LT(1);
872         nul_AST = (SelectorAST)astFactory.create(nul);
873         match(LITERAL_null);
874         isExpression_AST = (SelectorAST)currentAST.root;
875         
876         isExpression_AST = (SelectorAST)astFactory.make( (new ASTArray(3)).add(is_AST).add(leftHand).add(nul_AST));
877         if (not != null)
878         {
879         isExpression_AST = (SelectorAST)astFactory.make( (new ASTArray(2)).add(not_AST).add(isExpression_AST));
880         isExpression_AST.setReturnType(Type.BOOLEAN);
881         }
882         isExpression_AST.setReturnType(Type.BOOLEAN);
883         
884         currentAST.root = isExpression_AST;
885         currentAST.child = isExpression_AST!=null &&isExpression_AST.getFirstChild()!=null ?
886             isExpression_AST.getFirstChild() : isExpression_AST;
887         currentAST.advanceChildToEnd();
888         returnAST = isExpression_AST;
889     }
890     
891     public final void betweenExpression(
892         SelectorAST leftHand
893     ) throws RecognitionException, TokenStreamException {
894         
895         returnAST = null;
896         ASTPair currentAST = new ASTPair();
897         SelectorAST betweenExpression_AST = null;
898         Token btw = null;
899         SelectorAST btw_AST = null;
900         SelectorAST sum1_AST = null;
901         SelectorAST sum2_AST = null;
902         
903         btw = LT(1);
904         btw_AST = (SelectorAST)astFactory.create(btw);
905         match(LITERAL_between);
906         sumExpression();
907         sum1_AST = (SelectorAST)returnAST;
908         match(LITERAL_and);
909         sumExpression();
910         sum2_AST = (SelectorAST)returnAST;
911         betweenExpression_AST = (SelectorAST)currentAST.root;
912         
913         betweenExpression_AST = (SelectorAST)astFactory.make( (new ASTArray(4)).add(btw_AST).add(leftHand).add(sum1_AST).add(sum2_AST));
914         betweenExpression_AST.setReturnType(Type.BOOLEAN);
915         
916         currentAST.root = betweenExpression_AST;
917         currentAST.child = betweenExpression_AST!=null &&betweenExpression_AST.getFirstChild()!=null ?
918             betweenExpression_AST.getFirstChild() : betweenExpression_AST;
919         currentAST.advanceChildToEnd();
920         returnAST = betweenExpression_AST;
921     }
922     
923     public final void likeExpression(
924         SelectorAST leftHand
925     ) throws RecognitionException, TokenStreamException {
926         
927         returnAST = null;
928         ASTPair currentAST = new ASTPair();
929         SelectorAST likeExpression_AST = null;
930         Token like = null;
931         SelectorAST like_AST = null;
932         Token pattern = null;
933         SelectorAST pattern_AST = null;
934         Token esc = null;
935         SelectorAST esc_AST = null;
936         Token escape = null;
937         SelectorAST escape_AST = null;
938         
939         like = LT(1);
940         like_AST = (SelectorAST)astFactory.create(like);
941         match(LITERAL_like);
942         pattern = LT(1);
943         pattern_AST = (SelectorAST)astFactory.create(pattern);
944         match(STRING_LITERAL);
945         {
946         switch ( LA(1)) {
947         case LITERAL_escape:
948         {
949             esc = LT(1);
950             esc_AST = (SelectorAST)astFactory.create(esc);
951             match(LITERAL_escape);
952             escape = LT(1);
953             escape_AST = (SelectorAST)astFactory.create(escape);
954             match(STRING_LITERAL);
955             break;
956         }
957         case EOF:
958         case LITERAL_or:
959         case LITERAL_and:
960         case RPAREN:
961         {
962             break;
963         }
964         default:
965         {
966             throw new NoViableAltException(LT(1), getFilename());
967         }
968         }
969         }
970         likeExpression_AST = (SelectorAST)currentAST.root;
971         
972         likeExpression_AST = (esc != null)
973         ? (SelectorAST)astFactory.make( (new ASTArray(5)).add(like_AST).add(leftHand).add(pattern_AST).add(esc_AST).add(escape_AST))
974         : (SelectorAST)astFactory.make( (new ASTArray(3)).add(like_AST).add(leftHand).add(pattern_AST));
975         likeExpression_AST.setReturnType(Type.BOOLEAN);
976         
977         currentAST.root = likeExpression_AST;
978         currentAST.child = likeExpression_AST!=null &&likeExpression_AST.getFirstChild()!=null ?
979             likeExpression_AST.getFirstChild() : likeExpression_AST;
980         currentAST.advanceChildToEnd();
981         returnAST = likeExpression_AST;
982     }
983     
984     public final void inExpression(
985         SelectorAST leftHand
986     ) throws RecognitionException, TokenStreamException {
987         
988         returnAST = null;
989         ASTPair currentAST = new ASTPair();
990         SelectorAST inExpression_AST = null;
991         Token in = null;
992         SelectorAST in_AST = null;
993         SelectorAST values_AST = null;
994         
995         in = LT(1);
996         in_AST = (SelectorAST)astFactory.create(in);
997         match(LITERAL_in);
998         SelectorAST tmp26_AST = null;
999         tmp26_AST = (SelectorAST)astFactory.create(LT(1));
1000        match(LPAREN);
1001        valueList();
1002        values_AST = (SelectorAST)returnAST;
1003        SelectorAST tmp27_AST = null;
1004        tmp27_AST = (SelectorAST)astFactory.create(LT(1));
1005        match(RPAREN);
1006        inExpression_AST = (SelectorAST)currentAST.root;
1007        
1008        inExpression_AST = (SelectorAST)astFactory.make( (new ASTArray(5)).add(in_AST).add(leftHand).add(tmp26_AST).add(values_AST).add(tmp27_AST));
1009        inExpression_AST.setReturnType(Type.BOOLEAN);
1010        
1011        currentAST.root = inExpression_AST;
1012        currentAST.child = inExpression_AST!=null &&inExpression_AST.getFirstChild()!=null ?
1013            inExpression_AST.getFirstChild() : inExpression_AST;
1014        currentAST.advanceChildToEnd();
1015        returnAST = inExpression_AST;
1016    }
1017    
1018    public final void valueList() throws RecognitionException, TokenStreamException {
1019        
1020        returnAST = null;
1021        ASTPair currentAST = new ASTPair();
1022        SelectorAST valueList_AST = null;
1023        
1024        SelectorAST tmp28_AST = null;
1025        tmp28_AST = (SelectorAST)astFactory.create(LT(1));
1026        astFactory.addASTChild(currentAST, tmp28_AST);
1027        match(STRING_LITERAL);
1028        {
1029        _loop35:
1030        do {
1031            if ((LA(1)==COMMA)) {
1032                match(COMMA);
1033                SelectorAST tmp30_AST = null;
1034                tmp30_AST = (SelectorAST)astFactory.create(LT(1));
1035                astFactory.addASTChild(currentAST, tmp30_AST);
1036                match(STRING_LITERAL);
1037            }
1038            else {
1039                break _loop35;
1040            }
1041            
1042        } while (true);
1043        }
1044        valueList_AST = (SelectorAST)currentAST.root;
1045        returnAST = valueList_AST;
1046    }
1047    
1048    
1049    public static final String JavaDoc[] _tokenNames = {
1050        "<0>",
1051        "EOF",
1052        "<2>",
1053        "NULL_TREE_LOOKAHEAD",
1054        "UNARY_MINUS",
1055        "\"or\"",
1056        "\"and\"",
1057        "\"not\"",
1058        "=",
1059        "<>",
1060        "<",
1061        ">",
1062        "<=",
1063        ">=",
1064        "+",
1065        "-",
1066        "*",
1067        "/",
1068        "(",
1069        ")",
1070        "an identifier",
1071        "\"is\"",
1072        "\"null\"",
1073        "\"between\"",
1074        "\"in\"",
1075        "\"like\"",
1076        "a string literal",
1077        "\"escape\"",
1078        ",",
1079        "an integer",
1080        "NUM_FLOAT",
1081        "\"false\"",
1082        "\"true\"",
1083        "WS",
1084        "HEX_DIGIT",
1085        "EXPONENT",
1086        "FLOAT_SUFFIX",
1087        "IDENT_START",
1088        "IDENT_NON_START",
1089        "IDENT_PART"
1090    };
1091    
1092    protected void buildTokenTypeASTClassMap() {
1093        tokenTypeToASTClassMap=null;
1094    };
1095    
1096    
1097    }
1098
Popular Tags