001 // $ANTLR 2.7.5 (20050128): "oql-ojb.g" -> "OQLParser.java"$
002
003 /* Copyright 2003-2005 The Apache Software Foundation
004 *
005 * Licensed under the Apache License, Version 2.0 (the "License");
006 * you may not use this file except in compliance with the License.
007 * You may obtain a copy of the License at
008 *
009 * http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017
018 package org.apache.ojb.odmg.oql;
019
020
021 import antlr.TokenBuffer;
022 import antlr.TokenStreamException;
023 import antlr.TokenStreamIOException;
024 import antlr.ANTLRException;
025 import antlr.LLkParser;
026 import antlr.Token;
027 import antlr.TokenStream;
028 import antlr.RecognitionException;
029 import antlr.NoViableAltException;
030 import antlr.MismatchedTokenException;
031 import antlr.SemanticException;
032 import antlr.ParserSharedInputState;
033 import antlr.collections.impl.BitSet;
034
035 import java.util.ArrayList;
036 import java.util.Collection;
037 import java.util.Vector;
038
039 import org.apache.ojb.broker.metadata.ClassDescriptor;
040 import org.apache.ojb.broker.metadata.MetadataManager;
041 import org.apache.ojb.broker.metadata.ObjectReferenceDescriptor;
042 import org.apache.ojb.broker.util.ClassHelper;
043 import org.apache.ojb.broker.query.Criteria;
044 import org.apache.ojb.broker.query.Query;
045 import org.apache.ojb.broker.query.QueryByCriteria;
046 import org.apache.ojb.broker.query.QueryFactory;
047
048 public class OQLParser extends antlr.LLkParser implements OQLLexerTokenTypes
049 {
050
051 protected OQLParser(TokenBuffer tokenBuf, int k) {
052 super(tokenBuf,k);
053 tokenNames = _tokenNames;
054 }
055
056 public OQLParser(TokenBuffer tokenBuf) {
057 this(tokenBuf,3);
058 }
059
060 protected OQLParser(TokenStream lexer, int k) {
061 super(lexer,k);
062 tokenNames = _tokenNames;
063 }
064
065 public OQLParser(TokenStream lexer) {
066 this(lexer,3);
067 }
068
069 public OQLParser(ParserSharedInputState state) {
070 super(state,3);
071 tokenNames = _tokenNames;
072 }
073
074 public final Query buildQuery() throws RecognitionException, TokenStreamException {
075 Query query = null;
076
077
078 try { // for error handling
079 query=selectQuery();
080 {
081 if ((LA(1)==TOK_SEMIC)) {
082 match(TOK_SEMIC);
083 }
084 else if ((LA(1)==EOF)) {
085 }
086 else {
087 throw new NoViableAltException(LT(1), getFilename());
088 }
089
090 }
091 }
092 catch (RecognitionException ex) {
093 reportError(ex);
094 recover(ex,_tokenSet_0);
095 }
096 return query;
097 }
098
099 public final QueryByCriteria selectQuery() throws RecognitionException, TokenStreamException {
100 QueryByCriteria query = null;
101
102
103 try { // for error handling
104
105 Class clazz = null;
106 Criteria criteria = new Criteria();
107 String[] projectionAttrs;
108 boolean distinct = false;
109
110 match(LITERAL_select);
111 {
112 if ((LA(1)==LITERAL_distinct)) {
113 match(LITERAL_distinct);
114
115 distinct = true;
116
117 }
118 else if ((LA(1)==TOK_STAR||LA(1)==Identifier)) {
119 }
120 else {
121 throw new NoViableAltException(LT(1), getFilename());
122 }
123
124 }
125 projectionAttrs=projectionAttributes();
126 match(LITERAL_from);
127 clazz=fromClause();
128 {
129 if ((LA(1)==LITERAL_where)) {
130 match(LITERAL_where);
131 whereClause(criteria);
132 }
133 else if ((_tokenSet_1.member(LA(1)))) {
134 }
135 else {
136 throw new NoViableAltException(LT(1), getFilename());
137 }
138
139 }
140
141 if (clazz != null)
142 {
143 if (projectionAttrs[0].indexOf('.') < 0)
144 {
145 query = QueryFactory.newQuery(clazz, criteria, distinct);
146 }
147 else
148 {
149 ClassDescriptor cld = MetadataManager.getInstance().getRepository().getDescriptorFor(clazz);
150 for (int i = 0; i < projectionAttrs.length; i++)
151 {
152 projectionAttrs[i] = projectionAttrs[i].substring(projectionAttrs[i].indexOf('.') + 1);
153 }
154
155 ArrayList descs = cld.getAttributeDescriptorsForPath(projectionAttrs[0]);
156 int pathLen = descs.size();
157
158 if ((pathLen > 0) && (descs.get(pathLen - 1) instanceof ObjectReferenceDescriptor))
159 {
160 ObjectReferenceDescriptor ord =
161 ((ObjectReferenceDescriptor) descs.get(pathLen - 1));
162 query = QueryFactory.newQuery(clazz, criteria, distinct);
163 query.setObjectProjectionAttribute(projectionAttrs[0],
164 ord.getItemClass());
165 }
166 else
167 {
168 query = QueryFactory.newReportQuery(clazz, projectionAttrs, criteria, distinct);
169 }
170 }
171 }
172
173 {
174 if ((LA(1)==LITERAL_order)) {
175 match(LITERAL_order);
176 match(LITERAL_by);
177 orderClause(query);
178 }
179 else if ((_tokenSet_2.member(LA(1)))) {
180 }
181 else {
182 throw new NoViableAltException(LT(1), getFilename());
183 }
184
185 }
186 {
187 if ((LA(1)==LITERAL_group)) {
188 match(LITERAL_group);
189 match(LITERAL_by);
190 groupClause(query);
191 }
192 else if ((_tokenSet_3.member(LA(1)))) {
193 }
194 else {
195 throw new NoViableAltException(LT(1), getFilename());
196 }
197
198 }
199 {
200 if ((LA(1)==LITERAL_prefetch)) {
201 match(LITERAL_prefetch);
202 prefetchClause(query);
203 }
204 else if ((LA(1)==EOF||LA(1)==TOK_RPAREN||LA(1)==TOK_SEMIC)) {
205 }
206 else {
207 throw new NoViableAltException(LT(1), getFilename());
208 }
209
210 }
211 }
212 catch (RecognitionException ex) {
213 reportError(ex);
214 recover(ex,_tokenSet_4);
215 }
216 return query;
217 }
218
219 public final String[] projectionAttributes() throws RecognitionException, TokenStreamException {
220 String[] projectionAttrs = null;
221
222 Token id = null;
223 Token id1 = null;
224
225 try { // for error handling
226
227 String first = null;
228 ArrayList list = null;
229
230 {
231 if ((LA(1)==Identifier)) {
232 id = LT(1);
233 match(Identifier);
234 {
235
236 first = id.getText();
237
238 }
239 {
240 _loop80:
241 do {
242 if ((LA(1)==TOK_COMMA)) {
243 match(TOK_COMMA);
244 id1 = LT(1);
245 match(Identifier);
246 {
247
248 if (list == null)
249 {
250 list = new ArrayList();
251 list.add(first);
252 }
253 list.add(id1.getText());
254
255 }
256 }
257 else {
258 break _loop80;
259 }
260
261 } while (true);
262 }
263 }
264 else if ((LA(1)==TOK_STAR)) {
265 match(TOK_STAR);
266 }
267 else {
268 throw new NoViableAltException(LT(1), getFilename());
269 }
270
271 }
272
273 if (list == null)
274 {
275 projectionAttrs = new String[] {first};
276 }
277 else
278 {
279 projectionAttrs = (String[]) list.toArray(new String[list.size()]);
280 }
281
282
283 }
284 catch (RecognitionException ex) {
285 reportError(ex);
286 recover(ex,_tokenSet_5);
287 }
288 return projectionAttrs;
289 }
290
291 public final Class fromClause() throws RecognitionException, TokenStreamException {
292 Class clazz = null;
293
294 Token id = null;
295
296 try { // for error handling
297 id = LT(1);
298 match(Identifier);
299
300 try {
301 clazz = ClassHelper.getClass(id.getText());
302 } catch (Exception e) {
303 }
304
305 }
306 catch (RecognitionException ex) {
307 reportError(ex);
308 recover(ex,_tokenSet_6);
309 }
310 return clazz;
311 }
312
313 public final void whereClause(
314 Criteria criteria
315 ) throws RecognitionException, TokenStreamException {
316
317
318 try { // for error handling
319 orExpr(criteria);
320 }
321 catch (RecognitionException ex) {
322 reportError(ex);
323 recover(ex,_tokenSet_7);
324 }
325 }
326
327 public final void orderClause(
328 QueryByCriteria query
329 ) throws RecognitionException, TokenStreamException {
330
331
332 try { // for error handling
333 sortCriterion(query);
334 {
335 _loop83:
336 do {
337 if ((LA(1)==TOK_COMMA)) {
338 match(TOK_COMMA);
339 sortCriterion(query);
340 }
341 else {
342 break _loop83;
343 }
344
345 } while (true);
346 }
347 }
348 catch (RecognitionException ex) {
349 reportError(ex);
350 recover(ex,_tokenSet_2);
351 }
352 }
353
354 public final void groupClause(
355 QueryByCriteria query
356 ) throws RecognitionException, TokenStreamException {
357
358
359 try { // for error handling
360 groupCriterion(query);
361 {
362 _loop89:
363 do {
364 if ((LA(1)==TOK_COMMA)) {
365 match(TOK_COMMA);
366 groupCriterion(query);
367 }
368 else {
369 break _loop89;
370 }
371
372 } while (true);
373 }
374 }
375 catch (RecognitionException ex) {
376 reportError(ex);
377 recover(ex,_tokenSet_3);
378 }
379 }
380
381 public final void prefetchClause(
382 QueryByCriteria query
383 ) throws RecognitionException, TokenStreamException {
384
385
386 try { // for error handling
387 prefetchCriterion(query);
388 {
389 _loop93:
390 do {
391 if ((LA(1)==TOK_COMMA)) {
392 match(TOK_COMMA);
393 prefetchCriterion(query);
394 }
395 else {
396 break _loop93;
397 }
398
399 } while (true);
400 }
401 }
402 catch (RecognitionException ex) {
403 reportError(ex);
404 recover(ex,_tokenSet_4);
405 }
406 }
407
408 public final Query existsQuery() throws RecognitionException, TokenStreamException {
409 Query query = null;
410
411
412 try { // for error handling
413
414 Class clazz = null;
415 Criteria criteria = new Criteria();
416
417 match(LITERAL_exists);
418 projectionAttributes();
419 match(LITERAL_in);
420 clazz=fromClause();
421 {
422 if ((LA(1)==TOK_COLON)) {
423 match(TOK_COLON);
424 whereClause(criteria);
425 }
426 else if ((_tokenSet_7.member(LA(1)))) {
427 }
428 else {
429 throw new NoViableAltException(LT(1), getFilename());
430 }
431
432 }
433
434 if (clazz != null) {
435 query = QueryFactory.newQuery(clazz, criteria);
436 }
437
438 }
439 catch (RecognitionException ex) {
440 reportError(ex);
441 recover(ex,_tokenSet_7);
442 }
443 return query;
444 }
445
446 public final void orExpr(
447 Criteria criteria
448 ) throws RecognitionException, TokenStreamException {
449
450
451 try { // for error handling
452 andExpr(criteria);
453 {
454 _loop97:
455 do {
456 if ((LA(1)==LITERAL_or) && (_tokenSet_8.member(LA(2))) && (_tokenSet_9.member(LA(3)))) {
457 match(LITERAL_or);
458 Criteria orCriteria = new Criteria();
459 andExpr(orCriteria);
460 criteria.addOrCriteria(orCriteria);
461 }
462 else {
463 break _loop97;
464 }
465
466 } while (true);
467 }
468 }
469 catch (RecognitionException ex) {
470 reportError(ex);
471 recover(ex,_tokenSet_7);
472 }
473 }
474
475 public final void sortCriterion(
476 QueryByCriteria query
477 ) throws RecognitionException, TokenStreamException {
478
479 Token id = null;
480
481 try { // for error handling
482 boolean descending = false;
483 id = LT(1);
484 match(Identifier);
485 {
486 if ((LA(1)==LITERAL_asc||LA(1)==LITERAL_desc)) {
487 {
488 if ((LA(1)==LITERAL_asc)) {
489 match(LITERAL_asc);
490 descending = false;
491 }
492 else if ((LA(1)==LITERAL_desc)) {
493 match(LITERAL_desc);
494 descending = true;
495 }
496 else {
497 throw new NoViableAltException(LT(1), getFilename());
498 }
499
500 }
501 }
502 else if ((_tokenSet_10.member(LA(1)))) {
503 }
504 else {
505 throw new NoViableAltException(LT(1), getFilename());
506 }
507
508 }
509
510 if (descending) {
511 query.addOrderByDescending(id.getText());
512 } else {
513 query.addOrderByAscending(id.getText());
514 }
515
516 }
517 catch (RecognitionException ex) {
518 reportError(ex);
519 recover(ex,_tokenSet_10);
520 }
521 }
522
523 public final void groupCriterion(
524 QueryByCriteria query
525 ) throws RecognitionException, TokenStreamException {
526
527 Token id = null;
528
529 try { // for error handling
530 id = LT(1);
531 match(Identifier);
532
533 query.addGroupBy(id.getText());
534
535 }
536 catch (RecognitionException ex) {
537 reportError(ex);
538 recover(ex,_tokenSet_11);
539 }
540 }
541
542 public final void prefetchCriterion(
543 QueryByCriteria query
544 ) throws RecognitionException, TokenStreamException {
545
546 Token id = null;
547
548 try { // for error handling
549 id = LT(1);
550 match(Identifier);
551
552 query.addPrefetchedRelationship(id.getText());
553
554 }
555 catch (RecognitionException ex) {
556 reportError(ex);
557 recover(ex,_tokenSet_12);
558 }
559 }
560
561 public final void andExpr(
562 Criteria criteria
563 ) throws RecognitionException, TokenStreamException {
564
565
566 try { // for error handling
567 quantifierExpr(criteria);
568 {
569 _loop100:
570 do {
571 if ((LA(1)==LITERAL_and) && (_tokenSet_8.member(LA(2))) && (_tokenSet_9.member(LA(3)))) {
572 match(LITERAL_and);
573 Criteria andCriteria = new Criteria();
574 quantifierExpr(andCriteria);
575 criteria.addAndCriteria(andCriteria);
576 }
577 else {
578 break _loop100;
579 }
580
581 } while (true);
582 }
583 }
584 catch (RecognitionException ex) {
585 reportError(ex);
586 recover(ex,_tokenSet_7);
587 }
588 }
589
590 public final void quantifierExpr(
591 Criteria criteria
592 ) throws RecognitionException, TokenStreamException {
593
594
595 try { // for error handling
596 switch ( LA(1)) {
597 case TOK_LPAREN:
598 {
599 match(TOK_LPAREN);
600 orExpr(criteria);
601 match(TOK_RPAREN);
602 break;
603 }
604 case LITERAL_is_undefined:
605 case LITERAL_is_defined:
606 {
607 undefinedExpr(criteria);
608 break;
609 }
610 case LITERAL_exists:
611 case LITERAL_not:
612 {
613 existsExpr(criteria);
614 break;
615 }
616 default:
617 if ((LA(1)==Identifier) && (_tokenSet_13.member(LA(2)))) {
618 equalityExpr(criteria);
619 }
620 else if ((LA(1)==Identifier) && (LA(2)==LITERAL_not||LA(2)==LITERAL_like) && (_tokenSet_14.member(LA(3)))) {
621 likeExpr(criteria);
622 }
623 else if ((LA(1)==Identifier) && (LA(2)==LITERAL_not||LA(2)==LITERAL_between) && (_tokenSet_15.member(LA(3)))) {
624 betweenExpr(criteria);
625 }
626 else if ((LA(1)==Identifier) && (LA(2)==LITERAL_in||LA(2)==LITERAL_not) && (LA(3)==TOK_LPAREN||LA(3)==LITERAL_in||LA(3)==LITERAL_list)) {
627 inExpr(criteria);
628 }
629 else {
630 throw new NoViableAltException(LT(1), getFilename());
631 }
632 }
633 }
634 catch (RecognitionException ex) {
635 reportError(ex);
636 recover(ex,_tokenSet_7);
637 }
638 }
639
640 public final void equalityExpr(
641 Criteria criteria
642 ) throws RecognitionException, TokenStreamException {
643
644 Token id = null;
645
646 try { // for error handling
647
648 Object value = null;
649
650 id = LT(1);
651 match(Identifier);
652 {
653 {
654 switch ( LA(1)) {
655 case TOK_EQ:
656 {
657 match(TOK_EQ);
658 {
659 if ((LA(1)==LITERAL_nil)) {
660 match(LITERAL_nil);
661 criteria.addIsNull(id.getText());
662 }
663 else if ((_tokenSet_16.member(LA(1)))) {
664 value=literal();
665 criteria.addEqualTo(id.getText(), value);
666 }
667 else {
668 throw new NoViableAltException(LT(1), getFilename());
669 }
670
671 }
672 break;
673 }
674 case TOK_NE:
675 {
676 match(TOK_NE);
677 {
678 if ((LA(1)==LITERAL_nil)) {
679 match(LITERAL_nil);
680 criteria.addNotNull(id.getText());
681 }
682 else if ((_tokenSet_16.member(LA(1)))) {
683 value=literal();
684 criteria.addNotEqualTo(id.getText(), value);
685 }
686 else {
687 throw new NoViableAltException(LT(1), getFilename());
688 }
689
690 }
691 break;
692 }
693 case TOK_NE2:
694 {
695 match(TOK_NE2);
696 {
697 if ((LA(1)==LITERAL_nil)) {
698 match(LITERAL_nil);
699 criteria.addNotNull(id.getText());
700 }
701 else if ((_tokenSet_16.member(LA(1)))) {
702 value=literal();
703 criteria.addNotEqualTo(id.getText(), value);
704 }
705 else {
706 throw new NoViableAltException(LT(1), getFilename());
707 }
708
709 }
710 break;
711 }
712 case TOK_LT:
713 {
714 match(TOK_LT);
715 value=literal();
716 criteria.addLessThan(id.getText(), value);
717 break;
718 }
719 case TOK_GT:
720 {
721 match(TOK_GT);
722 value=literal();
723 criteria.addGreaterThan(id.getText(), value);
724 break;
725 }
726 case TOK_LE:
727 {
728 match(TOK_LE);
729 value=literal();
730 criteria.addLessOrEqualThan(id.getText(), value);
731 break;
732 }
733 case TOK_GE:
734 {
735 match(TOK_GE);
736 value=literal();
737 criteria.addGreaterOrEqualThan(id.getText(), value);
738 break;
739 }
740 default:
741 {
742 throw new NoViableAltException(LT(1), getFilename());
743 }
744 }
745 }
746 }
747 }
748 catch (RecognitionException ex) {
749 reportError(ex);
750 recover(ex,_tokenSet_7);
751 }
752 }
753
754 public final void likeExpr(
755 Criteria criteria
756 ) throws RecognitionException, TokenStreamException {
757
758 Token id = null;
759
760 try { // for error handling
761
762 boolean negative = false;
763 Object value = null;
764
765 id = LT(1);
766 match(Identifier);
767 {
768 if ((LA(1)==LITERAL_not)) {
769 match(LITERAL_not);
770 negative = true;
771 }
772 else if ((LA(1)==LITERAL_like)) {
773 }
774 else {
775 throw new NoViableAltException(LT(1), getFilename());
776 }
777
778 }
779 match(LITERAL_like);
780 value=literal();
781
782 if (negative) {
783 criteria.addNotLike(id.getText(), value);
784 } else {
785 criteria.addLike(id.getText(), value);
786 }
787
788 }
789 catch (RecognitionException ex) {
790 reportError(ex);
791 recover(ex,_tokenSet_7);
792 }
793 }
794
795 public final void undefinedExpr(
796 Criteria criteria
797 ) throws RecognitionException, TokenStreamException {
798
799 Token id = null;
800
801 try { // for error handling
802 boolean negative = false;
803 {
804 if ((LA(1)==LITERAL_is_undefined)) {
805 match(LITERAL_is_undefined);
806 negative = false;
807 }
808 else if ((LA(1)==LITERAL_is_defined)) {
809 match(LITERAL_is_defined);
810 negative = true;
811 }
812 else {
813 throw new NoViableAltException(LT(1), getFilename());
814 }
815
816 }
817 match(TOK_LPAREN);
818 id = LT(1);
819 match(Identifier);
820 match(TOK_RPAREN);
821
822 if (negative) {
823 criteria.addNotNull(id.getText());
824 } else {
825 criteria.addIsNull(id.getText());
826 }
827
828 }
829 catch (RecognitionException ex) {
830 reportError(ex);
831 recover(ex,_tokenSet_7);
832 }
833 }
834
835 public final void betweenExpr(
836 Criteria criteria
837 ) throws RecognitionException, TokenStreamException {
838
839 Token id = null;
840
841 try { // for error handling
842
843 boolean negative = false;
844 Object lower = null;
845 Object upper = null;
846
847 id = LT(1);
848 match(Identifier);
849 {
850 if ((LA(1)==LITERAL_not)) {
851 match(LITERAL_not);
852 negative = true;
853 }
854 else if ((LA(1)==LITERAL_between)) {
855 }
856 else {
857 throw new NoViableAltException(LT(1), getFilename());
858 }
859
860 }
861 match(LITERAL_between);
862 lower=literal();
863 match(LITERAL_and);
864 upper=literal();
865
866 if (negative) {
867 criteria.addNotBetween(id.getText(), lower, upper);
868 } else {
869 criteria.addBetween(id.getText(), lower, upper);
870 }
871
872 }
873 catch (RecognitionException ex) {
874 reportError(ex);
875 recover(ex,_tokenSet_7);
876 }
877 }
878
879 public final void inExpr(
880 Criteria criteria
881 ) throws RecognitionException, TokenStreamException {
882
883 Token id = null;
884
885 try { // for error handling
886
887 boolean negative = false;
888 Collection coll;
889
890 id = LT(1);
891 match(Identifier);
892 {
893 if ((LA(1)==LITERAL_not)) {
894 match(LITERAL_not);
895 negative = true;
896 }
897 else if ((LA(1)==LITERAL_in)) {
898 }
899 else {
900 throw new NoViableAltException(LT(1), getFilename());
901 }
902
903 }
904 match(LITERAL_in);
905 {
906 if ((LA(1)==LITERAL_list)) {
907 match(LITERAL_list);
908 }
909 else if ((LA(1)==TOK_LPAREN)) {
910 }
911 else {
912 throw new NoViableAltException(LT(1), getFilename());
913 }
914
915 }
916 coll=argList();
917
918 if (negative) {
919 criteria.addNotIn(id.getText(), coll);
920 } else {
921 criteria.addIn(id.getText(), coll);
922 }
923
924 }
925 catch (RecognitionException ex) {
926 reportError(ex);
927 recover(ex,_tokenSet_7);
928 }
929 }
930
931 public final void existsExpr(
932 Criteria criteria
933 ) throws RecognitionException, TokenStreamException {
934
935
936 try { // for error handling
937
938 Query subQuery = null;
939 boolean negative = false;
940
941 {
942 if ((LA(1)==LITERAL_not)) {
943 match(LITERAL_not);
944 negative = true;
945 }
946 else if ((LA(1)==LITERAL_exists)) {
947 }
948 else {
949 throw new NoViableAltException(LT(1), getFilename());
950 }
951
952 }
953 {
954 if ((LA(1)==LITERAL_exists) && (LA(2)==TOK_LPAREN)) {
955 match(LITERAL_exists);
956 match(TOK_LPAREN);
957 subQuery=selectQuery();
958 match(TOK_RPAREN);
959 }
960 else if ((LA(1)==LITERAL_exists) && (LA(2)==TOK_STAR||LA(2)==Identifier)) {
961 subQuery=existsQuery();
962 }
963 else {
964 throw new NoViableAltException(LT(1), getFilename());
965 }
966
967 }
968
969 if (negative) {
970 criteria.addNotExists(subQuery);
971 } else {
972 criteria.addExists(subQuery);
973 }
974
975 }
976 catch (RecognitionException ex) {
977 reportError(ex);
978 recover(ex,_tokenSet_7);
979 }
980 }
981
982 public final Object literal() throws RecognitionException, TokenStreamException {
983 Object value = null;
984
985 Token tokInt = null;
986 Token tokADbl = null;
987 Token tokEDbl = null;
988 Token tokChar = null;
989 Token tokStr = null;
990 Token tokDate = null;
991 Token tokTime = null;
992 Token tokTs = null;
993
994 try { // for error handling
995 switch ( LA(1)) {
996 case TOK_DOLLAR:
997 {
998 match(TOK_DOLLAR);
999 match(TOK_UNSIGNED_INTEGER);
1000 value = null;
1001 break;
1002 }
1003 case LITERAL_true:
1004 {
1005 match(LITERAL_true);
1006 value = Boolean.TRUE;
1007 break;
1008 }
1009 case LITERAL_false:
1010 {
1011 match(LITERAL_false);
1012 value = Boolean.FALSE;
1013 break;
1014 }
1015 case TOK_UNSIGNED_INTEGER:
1016 {
1017 tokInt = LT(1);
1018 match(TOK_UNSIGNED_INTEGER);
1019
1020 try
1021 {
1022 value = Integer.valueOf(tokInt.getText());
1023 }
1024 catch (NumberFormatException ignored)
1025 {
1026 value = Long.valueOf(tokInt.getText());
1027 }
1028
1029 break;
1030 }
1031 case TOK_APPROXIMATE_NUMERIC_LITERAL:
1032 {
1033 tokADbl = LT(1);
1034 match(TOK_APPROXIMATE_NUMERIC_LITERAL);
1035 value = Double.valueOf(tokADbl.getText());
1036 break;
1037 }
1038 case TOK_EXACT_NUMERIC_LITERAL:
1039 {
1040 tokEDbl = LT(1);
1041 match(TOK_EXACT_NUMERIC_LITERAL);
1042 value = Double.valueOf(tokEDbl.getText());
1043 break;
1044 }
1045 case CharLiteral:
1046 {
1047 tokChar = LT(1);
1048 match(CharLiteral);
1049 value = new Character(tokChar.getText().charAt(0));
1050 break;
1051 }
1052 case StringLiteral:
1053 {
1054 tokStr = LT(1);
1055 match(StringLiteral);
1056 value = tokStr.getText();
1057 break;
1058 }
1059 case LITERAL_date:
1060 {
1061 match(LITERAL_date);
1062 tokDate = LT(1);
1063 match(StringLiteral);
1064 value = java.sql.Date.valueOf(tokDate.getText());
1065 break;
1066 }
1067 case LITERAL_time:
1068 {
1069 match(LITERAL_time);
1070 tokTime = LT(1);
1071 match(StringLiteral);
1072 value = java.sql.Time.valueOf(tokTime.getText());
1073 break;
1074 }
1075 case LITERAL_timestamp:
1076 {
1077 match(LITERAL_timestamp);
1078 tokTs = LT(1);
1079 match(StringLiteral);
1080 value = java.sql.Timestamp.valueOf(tokTs.getText());
1081 break;
1082 }
1083 default:
1084 {
1085 throw new NoViableAltException(LT(1), getFilename());
1086 }
1087 }
1088 }
1089 catch (RecognitionException ex) {
1090 reportError(ex);
1091 recover(ex,_tokenSet_17);
1092 }
1093 return value;
1094 }
1095
1096 public final Collection argList() throws RecognitionException, TokenStreamException {
1097 Collection coll = null;
1098
1099
1100 try { // for error handling
1101
1102 Collection temp = new Vector();
1103 Object val;
1104
1105 match(TOK_LPAREN);
1106 {
1107 if ((_tokenSet_16.member(LA(1)))) {
1108 val=literal();
1109 if (val != null) {temp.add(val);}
1110 {
1111 _loop124:
1112 do {
1113 if ((LA(1)==TOK_COMMA)) {
1114 match(TOK_COMMA);
1115 val=literal();
1116 if (val != null) {temp.add(val);}
1117 }
1118 else {
1119 break _loop124;
1120 }
1121
1122 } while (true);
1123 }
1124 }
1125 else if ((LA(1)==TOK_RPAREN)) {
1126 }
1127 else {
1128 throw new NoViableAltException(LT(1), getFilename());
1129 }
1130
1131 }
1132 match(TOK_RPAREN);
1133
1134 if (!temp.isEmpty()) {coll = temp;}
1135
1136 }
1137 catch (RecognitionException ex) {
1138 reportError(ex);
1139 recover(ex,_tokenSet_7);
1140 }
1141 return coll;
1142 }
1143
1144
1145 public static final String[] _tokenNames = {
1146 "<0>",
1147 "EOF",
1148 "<2>",
1149 "NULL_TREE_LOOKAHEAD",
1150 "right parenthesis",
1151 "left parenthesis",
1152 "comma",
1153 "semicolon",
1154 "TOK_COLON",
1155 "dot",
1156 "dot",
1157 "operator",
1158 "comparison operator",
1159 "operator",
1160 "operator",
1161 "operator",
1162 "operator",
1163 "comparison operator",
1164 "comparison operator",
1165 "comparison operator",
1166 "comparison operator",
1167 "comparison operator",
1168 "comparison operator",
1169 "left bracket",
1170 "right bracket",
1171 "TOK_DOLLAR",
1172 "NameFirstCharacter",
1173 "NameCharacter",
1174 "Identifier",
1175 "TOK_UNSIGNED_INTEGER",
1176 "TOK_APPROXIMATE_NUMERIC_LITERAL",
1177 "numeric value",
1178 "character string",
1179 "character string",
1180 "WhiteSpace",
1181 "NewLine",
1182 "CommentLine",
1183 "MultiLineComment",
1184 "\"select\"",
1185 "\"distinct\"",
1186 "\"from\"",
1187 "\"where\"",
1188 "\"order\"",
1189 "\"by\"",
1190 "\"group\"",
1191 "\"prefetch\"",
1192 "\"exists\"",
1193 "\"in\"",
1194 "\"asc\"",
1195 "\"desc\"",
1196 "\"or\"",
1197 "\"and\"",
1198 "\"nil\"",
1199 "\"not\"",
1200 "\"list\"",
1201 "\"between\"",
1202 "\"is_undefined\"",
1203 "\"is_defined\"",
1204 "\"like\"",
1205 "\"true\"",
1206 "\"false\"",
1207 "\"date\"",
1208 "\"time\"",
1209 "\"timestamp\""
1210 };
1211
1212 private static final long[] mk_tokenSet_0() {
1213 long[] data = { 2L, 0L};
1214 return data;
1215 }
1216 public static final BitSet _tokenSet_0 = new BitSet(mk_tokenSet_0());
1217 private static final long[] mk_tokenSet_1() {
1218 long[] data = { 57174604644498L, 0L};
1219 return data;
1220 }
1221 public static final BitSet _tokenSet_1 = new BitSet(mk_tokenSet_1());
1222 private static final long[] mk_tokenSet_2() {
1223 long[] data = { 52776558133394L, 0L};
1224 return data;
1225 }
1226 public static final BitSet _tokenSet_2 = new BitSet(mk_tokenSet_2());
1227 private static final long[] mk_tokenSet_3() {
1228 long[] data = { 35184372088978L, 0L};
1229 return data;
1230 }
1231 public static final BitSet _tokenSet_3 = new BitSet(mk_tokenSet_3());
1232 private static final long[] mk_tokenSet_4() {
1233 long[] data = { 146L, 0L};
1234 return data;
1235 }
1236 public static final BitSet _tokenSet_4 = new BitSet(mk_tokenSet_4());
1237 private static final long[] mk_tokenSet_5() {
1238 long[] data = { 141836999983104L, 0L};
1239 return data;
1240 }
1241 public static final BitSet _tokenSet_5 = new BitSet(mk_tokenSet_5());
1242 private static final long[] mk_tokenSet_6() {
1243 long[] data = { 3437073348428178L, 0L};
1244 return data;
1245 }
1246 public static final BitSet _tokenSet_6 = new BitSet(mk_tokenSet_6());
1247 private static final long[] mk_tokenSet_7() {
1248 long[] data = { 3434874325172370L, 0L};
1249 return data;
1250 }
1251 public static final BitSet _tokenSet_7 = new BitSet(mk_tokenSet_7());
1252 private static final long[] mk_tokenSet_8() {
1253 long[] data = { 225250350381137952L, 0L};
1254 return data;
1255 }
1256 public static final BitSet _tokenSet_8 = new BitSet(mk_tokenSet_8());
1257 private static final long[] mk_tokenSet_9() {
1258 long[] data = { 549650261048496160L, 0L};
1259 return data;
1260 }
1261 public static final BitSet _tokenSet_9 = new BitSet(mk_tokenSet_9());
1262 private static final long[] mk_tokenSet_10() {
1263 long[] data = { 52776558133458L, 0L};
1264 return data;
1265 }
1266 public static final BitSet _tokenSet_10 = new BitSet(mk_tokenSet_10());
1267 private static final long[] mk_tokenSet_11() {
1268 long[] data = { 35184372089042L, 0L};
1269 return data;
1270 }
1271 public static final BitSet _tokenSet_11 = new BitSet(mk_tokenSet_11());
1272 private static final long[] mk_tokenSet_12() {
1273 long[] data = { 210L, 0L};
1274 return data;
1275 }
1276 public static final BitSet _tokenSet_12 = new BitSet(mk_tokenSet_12());
1277 private static final long[] mk_tokenSet_13() {
1278 long[] data = { 8261632L, 0L};
1279 return data;
1280 }
1281 public static final BitSet _tokenSet_13 = new BitSet(mk_tokenSet_13());
1282 private static final long[] mk_tokenSet_14() {
1283 long[] data = { -288230359475159040L, 0L};
1284 return data;
1285 }
1286 public static final BitSet _tokenSet_14 = new BitSet(mk_tokenSet_14());
1287 private static final long[] mk_tokenSet_15() {
1288 long[] data = { -540431938607906816L, 0L};
1289 return data;
1290 }
1291 public static final BitSet _tokenSet_15 = new BitSet(mk_tokenSet_15());
1292 private static final long[] mk_tokenSet_16() {
1293 long[] data = { -576460735626870784L, 0L};
1294 return data;
1295 }
1296 public static final BitSet _tokenSet_16 = new BitSet(mk_tokenSet_16());
1297 private static final long[] mk_tokenSet_17() {
1298 long[] data = { 3434874325172434L, 0L};
1299 return data;
1300 }
1301 public static final BitSet _tokenSet_17 = new BitSet(mk_tokenSet_17());
1302
1303 }