KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectstyle > cayenne > exp > parser > ExpressionParser


1 /* Generated By:JJTree&JavaCC: Do not edit this line. ExpressionParser.java */
2 /* ====================================================================
3  *
4  * The ObjectStyle Group Software License, version 1.1
5  * ObjectStyle Group - http://objectstyle.org/
6  *
7  * Copyright (c) 2002-2005, Andrei (Andrus) Adamchik and individual authors
8  * of the software. All rights reserved.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  *
14  * 1. Redistributions of source code must retain the above copyright
15  * notice, this list of conditions and the following disclaimer.
16  *
17  * 2. Redistributions in binary form must reproduce the above copyright
18  * notice, this list of conditions and the following disclaimer in
19  * the documentation and/or other materials provided with the
20  * distribution.
21  *
22  * 3. The end-user documentation included with the redistribution, if any,
23  * must include the following acknowlegement:
24  * "This product includes software developed by independent contributors
25  * and hosted on ObjectStyle Group web site (http://objectstyle.org/)."
26  * Alternately, this acknowlegement may appear in the software itself,
27  * if and wherever such third-party acknowlegements normally appear.
28  *
29  * 4. The names "ObjectStyle Group" and "Cayenne" must not be used to endorse
30  * or promote products derived from this software without prior written
31  * permission. For written permission, email
32  * "andrus at objectstyle dot org".
33  *
34  * 5. Products derived from this software may not be called "ObjectStyle"
35  * or "Cayenne", nor may "ObjectStyle" or "Cayenne" appear in their
36  * names without prior written permission.
37  *
38  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
39  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
40  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
41  * DISCLAIMED. IN NO EVENT SHALL THE OBJECTSTYLE GROUP OR
42  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
44  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
45  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
46  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
47  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
48  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
49  * SUCH DAMAGE.
50  * ====================================================================
51  *
52  * This software consists of voluntary contributions made by many
53  * individuals and hosted on ObjectStyle Group web site. For more
54  * information on the ObjectStyle Group, please see
55  * <http://objectstyle.org/>.
56  *
57  * Some parts of the parser are based on OGNL parser,
58  * copyright (c) 2002, Drew Davidson and Luke Blanshard
59  */

60 package org.objectstyle.cayenne.exp.parser;
61
62 import java.io.*;
63 import java.util.*;
64 import java.math.*;
65 import org.objectstyle.cayenne.exp.*;
66
67 /**
68   * Parser of Cayenne Expressions.
69   *
70   * @since 1.1
71   */

72 public class ExpressionParser/*@bgen(jjtree)*/implements ExpressionParserTreeConstants, ExpressionParserConstants {/*@bgen(jjtree)*/
73   protected JJTExpressionParserState jjtree = new JJTExpressionParserState();public static void main(String JavaDoc[] arg) {
74         // since Main is used for some basic speed measuring,
75
// lets run it twice to "warm up" the parser
76
Expression.fromString(arg[0]);
77
78         long start = System.currentTimeMillis();
79         Expression exp = Expression.fromString(arg[0]);
80         long end = System.currentTimeMillis();
81
82         System.out.println(exp);
83         System.out.println("Parsed in " + (end - start) + " ms.");
84     }
85
86   final public Expression expression() throws ParseException {
87     orCondition();
88     jj_consume_token(0);
89         {if (true) return (Expression) jjtree.rootNode();}
90     throw new Error JavaDoc("Missing return statement in function");
91   }
92
93   final public void orCondition() throws ParseException {
94     andCondition();
95     label_1:
96     while (true) {
97       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
98       case 1:
99         ;
100         break;
101       default:
102         jj_la1[0] = jj_gen;
103         break label_1;
104       }
105       jj_consume_token(1);
106                                 ASTOr jjtn001 = new ASTOr(JJTOR);
107                                 boolean jjtc001 = true;
108                                 jjtree.openNodeScope(jjtn001);
109       try {
110         andCondition();
111       } catch (Throwable JavaDoc jjte001) {
112                                 if (jjtc001) {
113                                   jjtree.clearNodeScope(jjtn001);
114                                   jjtc001 = false;
115                                 } else {
116                                   jjtree.popNode();
117                                 }
118                                 if (jjte001 instanceof RuntimeException JavaDoc) {
119                                   {if (true) throw (RuntimeException JavaDoc)jjte001;}
120                                 }
121                                 if (jjte001 instanceof ParseException) {
122                                   {if (true) throw (ParseException)jjte001;}
123                                 }
124                                 {if (true) throw (Error JavaDoc)jjte001;}
125       } finally {
126                                 if (jjtc001) {
127                                   jjtree.closeNodeScope(jjtn001, 2);
128                                 }
129       }
130     }
131   }
132
133   final public void andCondition() throws ParseException {
134     notCondition();
135     label_2:
136     while (true) {
137       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
138       case 2:
139         ;
140         break;
141       default:
142         jj_la1[1] = jj_gen;
143         break label_2;
144       }
145       jj_consume_token(2);
146                                  ASTAnd jjtn001 = new ASTAnd(JJTAND);
147                                  boolean jjtc001 = true;
148                                  jjtree.openNodeScope(jjtn001);
149       try {
150         notCondition();
151       } catch (Throwable JavaDoc jjte001) {
152                                  if (jjtc001) {
153                                    jjtree.clearNodeScope(jjtn001);
154                                    jjtc001 = false;
155                                  } else {
156                                    jjtree.popNode();
157                                  }
158                                  if (jjte001 instanceof RuntimeException JavaDoc) {
159                                    {if (true) throw (RuntimeException JavaDoc)jjte001;}
160                                  }
161                                  if (jjte001 instanceof ParseException) {
162                                    {if (true) throw (ParseException)jjte001;}
163                                  }
164                                  {if (true) throw (Error JavaDoc)jjte001;}
165       } finally {
166                                  if (jjtc001) {
167                                    jjtree.closeNodeScope(jjtn001, 2);
168                                  }
169       }
170     }
171   }
172
173   final public void notCondition() throws ParseException {
174     switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
175     case 3:
176     case 4:
177       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
178       case 3:
179         jj_consume_token(3);
180         break;
181       case 4:
182         jj_consume_token(4);
183         break;
184       default:
185         jj_la1[2] = jj_gen;
186         jj_consume_token(-1);
187         throw new ParseException();
188       }
189                                   ASTNot jjtn001 = new ASTNot(JJTNOT);
190                                   boolean jjtc001 = true;
191                                   jjtree.openNodeScope(jjtn001);
192       try {
193         simpleCondition();
194       } catch (Throwable JavaDoc jjte001) {
195                                   if (jjtc001) {
196                                     jjtree.clearNodeScope(jjtn001);
197                                     jjtc001 = false;
198                                   } else {
199                                     jjtree.popNode();
200                                   }
201                                   if (jjte001 instanceof RuntimeException JavaDoc) {
202                                     {if (true) throw (RuntimeException JavaDoc)jjte001;}
203                                   }
204                                   if (jjte001 instanceof ParseException) {
205                                     {if (true) throw (ParseException)jjte001;}
206                                   }
207                                   {if (true) throw (Error JavaDoc)jjte001;}
208       } finally {
209                                   if (jjtc001) {
210                                     jjtree.closeNodeScope(jjtn001, 1);
211                                   }
212       }
213       break;
214     case 16:
215     case 20:
216     case 21:
217     case 24:
218     case 25:
219     case 26:
220     case NULL:
221     case PROPERTY_PATH:
222     case SINGLE_QUOTED_STRING:
223     case DOUBLE_QUOTED_STRING:
224     case INT_LITERAL:
225     case FLOAT_LITERAL:
226       simpleCondition();
227       break;
228     default:
229       jj_la1[3] = jj_gen;
230       jj_consume_token(-1);
231       throw new ParseException();
232     }
233   }
234
235   final public void simpleCondition() throws ParseException {
236     scalarExpression();
237     switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
238     case 3:
239     case 4:
240     case 5:
241     case 6:
242     case 7:
243     case 8:
244     case 9:
245     case 10:
246     case 11:
247     case 12:
248     case 13:
249     case 14:
250     case 15:
251     case 18:
252       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
253       case 3:
254       case 4:
255         simpleNotCondition();
256         break;
257       case 5:
258       case 6:
259         switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
260         case 5:
261           jj_consume_token(5);
262           break;
263         case 6:
264           jj_consume_token(6);
265           break;
266         default:
267           jj_la1[4] = jj_gen;
268           jj_consume_token(-1);
269           throw new ParseException();
270         }
271                           ASTEqual jjtn001 = new ASTEqual(JJTEQUAL);
272                           boolean jjtc001 = true;
273                           jjtree.openNodeScope(jjtn001);
274         try {
275           scalarExpression();
276         } catch (Throwable JavaDoc jjte001) {
277                           if (jjtc001) {
278                             jjtree.clearNodeScope(jjtn001);
279                             jjtc001 = false;
280                           } else {
281                             jjtree.popNode();
282                           }
283                           if (jjte001 instanceof RuntimeException JavaDoc) {
284                             {if (true) throw (RuntimeException JavaDoc)jjte001;}
285                           }
286                           if (jjte001 instanceof ParseException) {
287                             {if (true) throw (ParseException)jjte001;}
288                           }
289                           {if (true) throw (Error JavaDoc)jjte001;}
290         } finally {
291                           if (jjtc001) {
292                             jjtree.closeNodeScope(jjtn001, 2);
293                           }
294         }
295         break;
296       case 7:
297       case 8:
298         switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
299         case 7:
300           jj_consume_token(7);
301           break;
302         case 8:
303           jj_consume_token(8);
304           break;
305         default:
306           jj_la1[5] = jj_gen;
307           jj_consume_token(-1);
308           throw new ParseException();
309         }
310                            ASTNotEqual jjtn002 = new ASTNotEqual(JJTNOTEQUAL);
311                            boolean jjtc002 = true;
312                            jjtree.openNodeScope(jjtn002);
313         try {
314           scalarExpression();
315         } catch (Throwable JavaDoc jjte002) {
316                            if (jjtc002) {
317                              jjtree.clearNodeScope(jjtn002);
318                              jjtc002 = false;
319                            } else {
320                              jjtree.popNode();
321                            }
322                            if (jjte002 instanceof RuntimeException JavaDoc) {
323                              {if (true) throw (RuntimeException JavaDoc)jjte002;}
324                            }
325                            if (jjte002 instanceof ParseException) {
326                              {if (true) throw (ParseException)jjte002;}
327                            }
328                            {if (true) throw (Error JavaDoc)jjte002;}
329         } finally {
330                            if (jjtc002) {
331                              jjtree.closeNodeScope(jjtn002, 2);
332                            }
333         }
334         break;
335       case 9:
336         jj_consume_token(9);
337                  ASTLessOrEqual jjtn003 = new ASTLessOrEqual(JJTLESSOREQUAL);
338                  boolean jjtc003 = true;
339                  jjtree.openNodeScope(jjtn003);
340         try {
341           scalarExpression();
342         } catch (Throwable JavaDoc jjte003) {
343                  if (jjtc003) {
344                    jjtree.clearNodeScope(jjtn003);
345                    jjtc003 = false;
346                  } else {
347                    jjtree.popNode();
348                  }
349                  if (jjte003 instanceof RuntimeException JavaDoc) {
350                    {if (true) throw (RuntimeException JavaDoc)jjte003;}
351                  }
352                  if (jjte003 instanceof ParseException) {
353                    {if (true) throw (ParseException)jjte003;}
354                  }
355                  {if (true) throw (Error JavaDoc)jjte003;}
356         } finally {
357                  if (jjtc003) {
358                    jjtree.closeNodeScope(jjtn003, 2);
359                  }
360         }
361         break;
362       case 10:
363         jj_consume_token(10);
364                 ASTLess jjtn004 = new ASTLess(JJTLESS);
365                 boolean jjtc004 = true;
366                 jjtree.openNodeScope(jjtn004);
367         try {
368           scalarExpression();
369         } catch (Throwable JavaDoc jjte004) {
370                 if (jjtc004) {
371                   jjtree.clearNodeScope(jjtn004);
372                   jjtc004 = false;
373                 } else {
374                   jjtree.popNode();
375                 }
376                 if (jjte004 instanceof RuntimeException JavaDoc) {
377                   {if (true) throw (RuntimeException JavaDoc)jjte004;}
378                 }
379                 if (jjte004 instanceof ParseException) {
380                   {if (true) throw (ParseException)jjte004;}
381                 }
382                 {if (true) throw (Error JavaDoc)jjte004;}
383         } finally {
384                 if (jjtc004) {
385                   jjtree.closeNodeScope(jjtn004, 2);
386                 }
387         }
388         break;
389       case 11:
390         jj_consume_token(11);
391                  ASTGreater jjtn005 = new ASTGreater(JJTGREATER);
392                  boolean jjtc005 = true;
393                  jjtree.openNodeScope(jjtn005);
394         try {
395           scalarExpression();
396         } catch (Throwable JavaDoc jjte005) {
397                  if (jjtc005) {
398                    jjtree.clearNodeScope(jjtn005);
399                    jjtc005 = false;
400                  } else {
401                    jjtree.popNode();
402                  }
403                  if (jjte005 instanceof RuntimeException JavaDoc) {
404                    {if (true) throw (RuntimeException JavaDoc)jjte005;}
405                  }
406                  if (jjte005 instanceof ParseException) {
407                    {if (true) throw (ParseException)jjte005;}
408                  }
409                  {if (true) throw (Error JavaDoc)jjte005;}
410         } finally {
411                  if (jjtc005) {
412                    jjtree.closeNodeScope(jjtn005, 2);
413                  }
414         }
415         break;
416       case 12:
417         jj_consume_token(12);
418                  ASTGreaterOrEqual jjtn006 = new ASTGreaterOrEqual(JJTGREATEROREQUAL);
419                  boolean jjtc006 = true;
420                  jjtree.openNodeScope(jjtn006);
421         try {
422           scalarExpression();
423         } catch (Throwable JavaDoc jjte006) {
424                  if (jjtc006) {
425                    jjtree.clearNodeScope(jjtn006);
426                    jjtc006 = false;
427                  } else {
428                    jjtree.popNode();
429                  }
430                  if (jjte006 instanceof RuntimeException JavaDoc) {
431                    {if (true) throw (RuntimeException JavaDoc)jjte006;}
432                  }
433                  if (jjte006 instanceof ParseException) {
434                    {if (true) throw (ParseException)jjte006;}
435                  }
436                  {if (true) throw (Error JavaDoc)jjte006;}
437         } finally {
438                  if (jjtc006) {
439                    jjtree.closeNodeScope(jjtn006, 2);
440                  }
441         }
442         break;
443       case 13:
444         jj_consume_token(13);
445                          ASTLike jjtn007 = new ASTLike(JJTLIKE);
446                          boolean jjtc007 = true;
447                          jjtree.openNodeScope(jjtn007);
448         try {
449           scalarExpression();
450         } catch (Throwable JavaDoc jjte007) {
451                          if (jjtc007) {
452                            jjtree.clearNodeScope(jjtn007);
453                            jjtc007 = false;
454                          } else {
455                            jjtree.popNode();
456                          }
457                          if (jjte007 instanceof RuntimeException JavaDoc) {
458                            {if (true) throw (RuntimeException JavaDoc)jjte007;}
459                          }
460                          if (jjte007 instanceof ParseException) {
461                            {if (true) throw (ParseException)jjte007;}
462                          }
463                          {if (true) throw (Error JavaDoc)jjte007;}
464         } finally {
465                          if (jjtc007) {
466                            jjtree.closeNodeScope(jjtn007, 2);
467                          }
468         }
469         break;
470       case 14:
471         jj_consume_token(14);
472                                 ASTLikeIgnoreCase jjtn008 = new ASTLikeIgnoreCase(JJTLIKEIGNORECASE);
473                                 boolean jjtc008 = true;
474                                 jjtree.openNodeScope(jjtn008);
475         try {
476           scalarExpression();
477         } catch (Throwable JavaDoc jjte008) {
478                                 if (jjtc008) {
479                                   jjtree.clearNodeScope(jjtn008);
480                                   jjtc008 = false;
481                                 } else {
482                                   jjtree.popNode();
483                                 }
484                                 if (jjte008 instanceof RuntimeException JavaDoc) {
485                                   {if (true) throw (RuntimeException JavaDoc)jjte008;}
486                                 }
487                                 if (jjte008 instanceof ParseException) {
488                                   {if (true) throw (ParseException)jjte008;}
489                                 }
490                                 {if (true) throw (Error JavaDoc)jjte008;}
491         } finally {
492                                 if (jjtc008) {
493                                   jjtree.closeNodeScope(jjtn008, 2);
494                                 }
495         }
496         break;
497       case 15:
498         jj_consume_token(15);
499                   ASTIn jjtn009 = new ASTIn(JJTIN);
500                   boolean jjtc009 = true;
501                   jjtree.openNodeScope(jjtn009);
502         try {
503           switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
504           case 24:
505             namedParameter();
506             break;
507           case 16:
508             jj_consume_token(16);
509             scalarCommaList();
510             jj_consume_token(17);
511             break;
512           default:
513             jj_la1[6] = jj_gen;
514             jj_consume_token(-1);
515             throw new ParseException();
516           }
517         } catch (Throwable JavaDoc jjte009) {
518                   if (jjtc009) {
519                     jjtree.clearNodeScope(jjtn009);
520                     jjtc009 = false;
521                   } else {
522                     jjtree.popNode();
523                   }
524                   if (jjte009 instanceof RuntimeException JavaDoc) {
525                     {if (true) throw (RuntimeException JavaDoc)jjte009;}
526                   }
527                   if (jjte009 instanceof ParseException) {
528                     {if (true) throw (ParseException)jjte009;}
529                   }
530                   {if (true) throw (Error JavaDoc)jjte009;}
531         } finally {
532                   if (jjtc009) {
533                     jjtree.closeNodeScope(jjtn009, 2);
534                   }
535         }
536         break;
537       case 18:
538         jj_consume_token(18);
539         scalarExpression();
540         jj_consume_token(2);
541                                                       ASTBetween jjtn010 = new ASTBetween(JJTBETWEEN);
542                                                       boolean jjtc010 = true;
543                                                       jjtree.openNodeScope(jjtn010);
544         try {
545           scalarExpression();
546         } catch (Throwable JavaDoc jjte010) {
547                                                       if (jjtc010) {
548                                                         jjtree.clearNodeScope(jjtn010);
549                                                         jjtc010 = false;
550                                                       } else {
551                                                         jjtree.popNode();
552                                                       }
553                                                       if (jjte010 instanceof RuntimeException JavaDoc) {
554                                                         {if (true) throw (RuntimeException JavaDoc)jjte010;}
555                                                       }
556                                                       if (jjte010 instanceof ParseException) {
557                                                         {if (true) throw (ParseException)jjte010;}
558                                                       }
559                                                       {if (true) throw (Error JavaDoc)jjte010;}
560         } finally {
561                                                       if (jjtc010) {
562                                                         jjtree.closeNodeScope(jjtn010, 3);
563                                                       }
564         }
565         break;
566       default:
567         jj_la1[7] = jj_gen;
568         jj_consume_token(-1);
569         throw new ParseException();
570       }
571       break;
572     default:
573       jj_la1[8] = jj_gen;
574       ;
575     }
576   }
577
578   final public void simpleNotCondition() throws ParseException {
579     switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
580     case 3:
581       jj_consume_token(3);
582       break;
583     case 4:
584       jj_consume_token(4);
585       break;
586     default:
587       jj_la1[9] = jj_gen;
588       jj_consume_token(-1);
589       throw new ParseException();
590     }
591     switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
592     case 13:
593       jj_consume_token(13);
594                          ASTNotLike jjtn001 = new ASTNotLike(JJTNOTLIKE);
595                          boolean jjtc001 = true;
596                          jjtree.openNodeScope(jjtn001);
597       try {
598         scalarExpression();
599       } catch (Throwable JavaDoc jjte001) {
600                          if (jjtc001) {
601                            jjtree.clearNodeScope(jjtn001);
602                            jjtc001 = false;
603                          } else {
604                            jjtree.popNode();
605                          }
606                          if (jjte001 instanceof RuntimeException JavaDoc) {
607                            {if (true) throw (RuntimeException JavaDoc)jjte001;}
608                          }
609                          if (jjte