KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > nfunk > jep > Parser


1 /* Generated By:JJTree&JavaCC: Do not edit this line. Parser.java */
2 package org.nfunk.jep;
3
4 import java.util.Vector JavaDoc;
5 import org.nfunk.jep.function.*;
6 import org.nfunk.jep.type.*;
7
8 public class Parser/*@bgen(jjtree)*/implements ParserTreeConstants, ParserConstants {/*@bgen(jjtree)*/
9   protected JJTParserState jjtree = new JJTParserState();private JEP jep;
10         private SymbolTable symTab;
11         private OperatorSet opSet;
12         private int initialTokenManagerState = DEFAULT;
13
14         public Node parseStream(java.io.Reader JavaDoc stream, JEP jep_in)
15                                                         throws ParseException {
16                 restart(stream,jep_in);
17                 // Parse the expression, and return the
18
enable_tracing();
19                 Node node = Start();
20                 if (node == null) throw new ParseException("No expression entered");
21                 return node.jjtGetChild(0);
22         }
23
24         /**
25      * Restart the parse with the given stream.
26      * @since 2.3.0 beta 1
27      */

28         public void restart(java.io.Reader JavaDoc stream, JEP jep_in)
29         {
30                 ReInit(stream);
31                 this.token_source.SwitchTo(initialTokenManagerState);
32                 jep = jep_in;
33                 symTab = jep.getSymbolTable();
34                 opSet = jep.getOperatorSet();
35         }
36         /**
37      * Continue parsing without re-initilising stream.
38      * Allows renetrancy of parser so that strings like
39      * "x=1; y=2; z=3;" can be parsed.
40      * When a semi colon is encountered parsing finishes leaving the rest of the string unparsed.
41      * Parsing can be resumed from the current position by using this method.
42      * For example
43      * <pre>
44      * XJep j = new XJep();
45      * Parser parse = j.getParse();
46      * StringReader sr = new StringReader("x=1; y=2; z=3;");
47      * parse.restart(sr,j);
48      * Node node;
49      * try {
50      * while((node = j.continueParse())!=null) {
51      * j.println(node);
52      * } }catch(ParseException e) {}
53      * </pre>
54      */

55         public Node continueParse() throws ParseException
56         {
57                 ASTStart node = Start();
58                 if (node==null) return null;
59                 return node.jjtGetChild(0);
60         }
61
62         private void addToErrorList(String JavaDoc errorStr) {
63                 jep.errorList.addElement(errorStr);
64         }
65
66         /**
67      * Sets the initial state that the token manager is in.
68      * Can be used to change how x.x is interpreted, either as a single
69      * identifier (DEFAULT) or as x <DOT> x (NO_DOT_IN_IDENTIFIERS)
70      * @param state the state to be in. Currently the only legal values are DEFAULT and NO_DOT_IN_IDENTIFIER
71      */

72         public void setInitialTokenManagerState(int state)
73         {
74                 initialTokenManagerState = state;
75         }
76         /**
77      * Translate all escape sequences to characters. Inspired by Rob Millar's
78      * unescape() method in rcm.util.Str fron the Web Sphinx project.
79      *
80      * @param inputStr String containing escape characters.
81      * @return String with all escape sequences replaced.
82      */

83         private String JavaDoc replaceEscape(String JavaDoc inputStr) {
84                 int len = inputStr.length();
85                 int p = 0;
86                 int i;
87                 String JavaDoc metachars = "tnrbf\\\"'";
88                 String JavaDoc chars = "\t\n\r\b\f\\\"'";
89
90                 StringBuffer JavaDoc output = new StringBuffer JavaDoc();
91
92                 while ((i = inputStr.indexOf('\\', p)) != -1) {
93                         output.append(inputStr.substring(p, i));
94
95                         if (i+1 == len) break;
96
97                         // find metacharacter
98
char metac = inputStr.charAt(i+1);
99
100             // find the index of the metac
101
int k = metachars.indexOf(metac);
102             if (k == -1) {
103                 // didn't find the metachar, leave sequence as found.
104
// This code should be unreachable if the parser
105
// is functioning properly because strings containing
106
// unknown escape characters should not be accepted.
107
output.append('\\');
108                 output.append(metac);
109             } else {
110                 // its corresponding true char
111
output.append(chars.charAt(k));
112             }
113
114                         // skip over both escape character & metacharacter
115
p = i + 2;
116                 }
117
118                 // add the end of the input string to the output
119
if (p < len)
120             output.append(inputStr.substring(p));
121
122         return output.toString();
123         }
124
125 /***************************************************************
126 GRAMMAR START
127 ***************************************************************/

128   final public ASTStart Start() throws ParseException {
129  /*@bgen(jjtree) Start */
130   ASTStart jjtn000 = new ASTStart(JJTSTART);
131   boolean jjtc000 = true;
132   jjtree.openNodeScope(jjtn000);
133     try {
134       if (jj_2_1(1)) {
135         Expression();
136         switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
137         case 0:
138           jj_consume_token(0);
139           break;
140         case SEMI:
141           jj_consume_token(SEMI);
142           break;
143         default:
144           jj_la1[0] = jj_gen;
145           jj_consume_token(-1);
146           throw new ParseException();
147         }
148                                           jjtree.closeNodeScope(jjtn000, true);
149                                           jjtc000 = false;
150                                           {if (true) return jjtn000;}
151       } else {
152         switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
153         case 0:
154         case SEMI:
155           switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
156           case 0:
157             jj_consume_token(0);
158             break;
159           case SEMI:
160             jj_consume_token(SEMI);
161             break;
162           default:
163             jj_la1[1] = jj_gen;
164             jj_consume_token(-1);
165             throw new ParseException();
166           }
167           jjtree.closeNodeScope(jjtn000, true);
168           jjtc000 = false;
169                 // njf - The next line is commented out in 2.3.0 since
170
// two "No expression entered" errors are reported
171
// in EvaluatorVisitor and Console (one from here
172
// the other from ParseStream() )
173
// Decided to just return null, and handle the error
174
// in ParseStream.
175
// addToErrorList("No expression entered");
176
{if (true) return null;}
177           break;
178         default:
179           jj_la1[2] = jj_gen;
180           jj_consume_token(-1);
181           throw new ParseException();
182         }
183       }
184     } catch (Throwable JavaDoc jjte000) {
185           if (jjtc000) {
186             jjtree.clearNodeScope(jjtn000);
187             jjtc000 = false;
188           } else {
189             jjtree.popNode();
190           }
191           if (jjte000 instanceof RuntimeException JavaDoc) {
192             {if (true) throw (RuntimeException JavaDoc)jjte000;}
193           }
194           if (jjte000 instanceof ParseException) {
195             {if (true) throw (ParseException)jjte000;}
196           }
197           {if (true) throw (Error JavaDoc)jjte000;}
198     } finally {
199           if (jjtc000) {
200             jjtree.closeNodeScope(jjtn000, true);
201           }
202     }
203     throw new Error JavaDoc("Missing return statement in function");
204   }
205
206 // Expresions can be like
207
// x=3
208
// x=y=3 parsed as x=(y=3)
209
final public void Expression() throws ParseException {
210     if (jj_2_2(3)) {
211       AssignExpression();
212     } else if (jj_2_3(1)) {
213       OrExpression();
214     } else {
215       jj_consume_token(-1);
216       throw new ParseException();
217     }
218   }
219
220   final public void AssignExpression() throws ParseException {
221           ASTFunNode jjtn001 = new ASTFunNode(JJTFUNNODE);
222           boolean jjtc001 = true;
223           jjtree.openNodeScope(jjtn001);
224     try {
225       Variable();
226       jj_consume_token(ASSIGN);
227       Expression();
228                   jjtree.closeNodeScope(jjtn001, 2);
229                   jjtc001 = false;
230                         if (!jep.getAllowAssignment()) {if (true) throw new ParseException(
231                 "Syntax Error (assignment not enabled)");}
232
233                         jjtn001.setOperator(opSet.getAssign());
234     } catch (Throwable JavaDoc jjte001) {
235           if (jjtc001) {
236             jjtree.clearNodeScope(jjtn001);
237             jjtc001 = false;
238           } else {
239             jjtree.popNode();
240           }
241           if (jjte001 instanceof RuntimeException JavaDoc) {
242             {if (true) throw (RuntimeException JavaDoc)jjte001;}
243           }
244           if (jjte001 instanceof ParseException) {
245             {if (true) throw (ParseException)jjte001;}
246           }
247           {if (true) throw (Error JavaDoc)jjte001;}
248     } finally {
249           if (jjtc001) {
250             jjtree.closeNodeScope(jjtn001, 2);
251           }
252     }
253   }
254
255   final public void OrExpression() throws ParseException {
256     AndExpression();
257     label_1:
258     while (true) {
259       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
260       case OR:
261         ;
262         break;
263       default:
264         jj_la1[3] = jj_gen;
265         break label_1;
266       }
267             ASTFunNode jjtn001 = new ASTFunNode(JJTFUNNODE);
268             boolean jjtc001 = true;
269             jjtree.openNodeScope(jjtn001);
270       try {
271         jj_consume_token(OR);
272         AndExpression();
273                   jjtree.closeNodeScope(jjtn001, 2);
274                   jjtc001 = false;
275                         jjtn001.setOperator(opSet.getOr());
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     }
296   }
297
298   final public void AndExpression() throws ParseException {
299     EqualExpression();
300     label_2:
301     while (true) {
302       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
303       case AND:
304         ;
305         break;
306       default:
307         jj_la1[4] = jj_gen;
308         break label_2;
309       }
310             ASTFunNode jjtn001 = new ASTFunNode(JJTFUNNODE);
311             boolean jjtc001 = true;
312             jjtree.openNodeScope(jjtn001);
313       try {
314         jj_consume_token(AND);
315         EqualExpression();
316                   jjtree.closeNodeScope(jjtn001, 2);
317                   jjtc001 = false;
318                         jjtn001.setOperator(opSet.getAnd());
319       } catch (Throwable JavaDoc jjte001) {
320             if (jjtc001) {
321               jjtree.clearNodeScope(jjtn001);
322               jjtc001 = false;
323             } else {
324               jjtree.popNode();
325             }
326             if (jjte001 instanceof RuntimeException JavaDoc) {
327               {if (true) throw (RuntimeException JavaDoc)jjte001;}
328             }
329             if (jjte001 instanceof ParseException) {
330               {if (true) throw (ParseException)jjte001;}
331             }
332             {if (true) throw (Error JavaDoc)jjte001;}
333       } finally {
334             if (jjtc001) {
335               jjtree.closeNodeScope(jjtn001, 2);
336             }
337       }
338     }
339   }
340
341   final public void EqualExpression() throws ParseException {
342     RelationalExpression();
343     label_3:
344     while (true) {
345       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
346       case EQ:
347       case NE:
348         ;
349         break;
350       default:
351         jj_la1[5] = jj_gen;
352         break label_3;
353       }
354       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
355       case NE:
356             ASTFunNode jjtn001 = new ASTFunNode(JJTFUNNODE);
357             boolean jjtc001 = true;
358             jjtree.openNodeScope(jjtn001);
359         try {
360           jj_consume_token(NE);
361           RelationalExpression();
362               jjtree.closeNodeScope(jjtn001, 2);
363               jjtc001 = false;
364             jjtn001.setOperator(opSet.getNE());
365         } catch (Throwable JavaDoc jjte001) {
366             if (jjtc001) {
367               jjtree.clearNodeScope(jjtn001);
368               jjtc001 = false;
369             } else {
370               jjtree.popNode();
371             }
372             if (jjte001 instanceof RuntimeException JavaDoc) {
373               {if (true) throw (RuntimeException JavaDoc)jjte001;}
374             }
375             if (jjte001 instanceof ParseException) {
376               {if (true) throw (ParseException)jjte001;}
377             }
378             {if (true) throw (Error JavaDoc)jjte001;}
379         } finally {
380             if (jjtc001) {
381               jjtree.closeNodeScope(jjtn001, 2);
382             }
383         }
384         break;
385       case EQ:
386             ASTFunNode jjtn002 = new ASTFunNode(JJTFUNNODE);
387             boolean jjtc002 = true;
388             jjtree.openNodeScope(jjtn002);
389         try {
390           jj_consume_token(EQ);
391           RelationalExpression();
392               jjtree.closeNodeScope(jjtn002, 2);
393               jjtc002 = false;
394               jjtn002.setOperator(opSet.getEQ());
395         } catch (Throwable JavaDoc jjte002) {
396             if (jjtc002) {
397               jjtree.clearNodeScope(jjtn002);
398               jjtc002 = false;
399             } else {
400               jjtree.popNode();
401             }
402             if (jjte002 instanceof RuntimeException JavaDoc) {
403               {if (true) throw (RuntimeException JavaDoc)jjte002;}
404             }
405             if (jjte002 instanceof ParseException) {
406               {if (true) throw (ParseException)jjte002;}
407             }
408             {if (true) throw (Error JavaDoc)jjte002;}
409         } finally {
410             if (jjtc002) {
411               jjtree.closeNodeScope(jjtn002, 2);
412             }
413         }
414         break;
415       default:
416         jj_la1[6] = jj_gen;
417         jj_consume_token(-1);
418         throw new ParseException();
419       }
420     }
421   }
422
423   final public void RelationalExpression() throws ParseException {
424     AdditiveExpression();
425     label_4:
426     while (true) {
427       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
428       case GT:
429       case LT:
430       case LE:
431       case GE:
432         ;
433         break;
434       default:
435         jj_la1[7] = jj_gen;
436         break label_4;
437       }
438       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
439       case LT:
440       ASTFunNode jjtn001 = new ASTFunNode(JJTFUNNODE);
441       boolean jjtc001 = true;
442       jjtree.openNodeScope(jjtn001);
443         try {
444           jj_consume_token(LT);
445           AdditiveExpression();
446         jjtree.closeNodeScope(jjtn001, 2);
447         jjtc001 = false;
448             jjtn001.setOperator(opSet.getLT());
449         } catch (Throwable JavaDoc jjte001) {
450       if (jjtc001) {
451         jjtree.clearNodeScope(jjtn001);
452         jjtc001 = false;
453       } else {
454         jjtree.popNode();
455       }
456       if (jjte001 instanceof RuntimeException JavaDoc) {
457         {if (true) throw (RuntimeException JavaDoc)jjte001;}
458       }
459       if (jjte001 instanceof ParseException) {
460         {if (true) throw (ParseException)jjte001;}
461       }
462       {if (true) throw (Error JavaDoc)jjte001;}
463         } finally {
464       if (jjtc001) {
465         jjtree.closeNodeScope(jjtn001, 2);
466       }
467         }
468         break;
469       case GT:
470       ASTFunNode jjtn002 = new ASTFunNode(JJTFUNNODE);
471       boolean jjtc002 = true;
472       jjtree.openNodeScope(jjtn002);
473         try {
474           jj_consume_token(GT);
475           AdditiveExpression();
476         jjtree.closeNodeScope(jjtn002, 2);
477         jjtc002 = false;
478         jjtn002.setOperator(opSet.getGT());
479         } catch (Throwable JavaDoc jjte002) {
480       if (jjtc002) {
481         jjtree.clearNodeScope(jjtn002);
482         jjtc002 = false;
483       } else {
484         jjtree.popNode();
485       }
486       if (jjte002 instanceof RuntimeException JavaDoc) {
487         {if (true) throw (RuntimeException JavaDoc)jjte002;}
488       }
489       if (jjte002 instanceof ParseException) {
490         {if (true) throw (ParseException)jjte002;}
491       }
492       {if (true) throw (Error JavaDoc)jjte002;}
493         } finally {
494       if (jjtc002) {
495         jjtree.closeNodeScope(jjtn002, 2);
496       }
497         }
498         break;
499       case LE:
500       ASTFunNode jjtn003 = new ASTFunNode(JJTFUNNODE);
501       boolean jjtc003 = true;
502       jjtree.openNodeScope(jjtn003);
503         try {
504           jj_consume_token(LE);
505           AdditiveExpression();
506         jjtree.closeNodeScope(jjtn003, 2);
507         jjtc003 = false;
508             jjtn003.setOperator(opSet.getLE());
509         } catch (Throwable JavaDoc jjte003) {
510       if (jjtc003) {
511         jjtree.clearNodeScope(jjtn003);
512         jjtc003 = false;
513       } else {
514         jjtree.popNode();
515       }
516       if (jjte003 instanceof RuntimeException JavaDoc) {
517         {if (true) throw (RuntimeException JavaDoc)jjte003;}
518       }
519       if (jjte003 instanceof ParseException) {
520         {if (true) throw (ParseException)jjte003;}
521       }
522       {if (true) throw (Error JavaDoc)jjte003;}
523         } finally {
524       if (jjtc003) {
525         jjtree.closeNodeScope(jjtn003, 2);
526       }
527         }
528         break;
529       case GE:
530       ASTFunNode jjtn004 = new ASTFunNode(JJTFUNNODE);
531       boolean jjtc004 = true;
532       jjtree.openNodeScope(jjtn004);
533         try {
534           jj_consume_token(GE);
535           AdditiveExpression();
536         jjtree.closeNodeScope(jjtn004, 2);
537         jjtc004 = false;
538         jjtn004.setOperator(opSet.getGE());
539         } catch (Throwable JavaDoc jjte004) {
540       if (jjtc004) {
541         jjtree.clearNodeScope(jjtn004);
542         jjtc004 = false;
543       } else {
544         jjtree.popNode();
545       }
546       if (jjte004 instanceof RuntimeException JavaDoc) {
547         {if (true) throw (RuntimeException JavaDoc)jjte004;}
548       }
549       if (jjte004 instanceof ParseException) {
550         {if (true) throw (ParseException)jjte004;}
551       }
552       {if (true) throw (Error JavaDoc)jjte004;}
553         } finally {
554       if (jjtc004) {
555         jjtree.closeNodeScope(jjtn004, 2);
556       }
557         }
558         break;
559       default:
560         jj_la1[8] = jj_gen;
561         jj_consume_token(-1);
562         throw new ParseException();
563       }
564     }
565   }
566
567   final public void AdditiveExpression() throws ParseException {
568     MultiplicativeExpression();
569     label_5:
570     while (true) {
571       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
572       case PLUS:
573       case MINUS:
574         ;
575         break;
576       default:
577         jj_la1[9] = jj_gen;
578         break label_5;
579       }
580       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
581       case PLUS:
582       ASTFunNode jjtn001 = new ASTFunNode(JJTFUNNODE);
583       boolean jjtc001 = true;
584       jjtree.openNodeScope(jjtn001);
585         try {
586           jj_consume_token(PLUS);
587           MultiplicativeExpression();
588         jjtree.closeNodeScope(jjtn001, 2);
589         jjtc001 = false;
590         jjtn001.setOperator(opSet.getAdd());
591         } catch (Throwable JavaDoc jjte001) {
592       if (jjtc001) {
593         jjtree.clearNodeScope(jjtn001);
594         jjtc001 = false;
595       } else {
596         jjtree.popNode();
597       }
598       if (jjte001 instanceof RuntimeException JavaDoc) {
599         {if (true) throw (RuntimeException JavaDoc)jjte001;}
600       }
601       if (jjte001 instanceof ParseException) {
602         {if (true) throw (ParseException)jjte001;}
603       }
604       {if (true) throw (Error JavaDoc)jjte001;}
605         } finally {
606       if (jjtc001) {
607         jjtree.closeNodeScope(jjtn001, 2);
608       }
609         }
610         break;
611       case MINUS:
612       ASTFunNode jjtn002 = new ASTFunNode(JJTFUNNODE);
613       boolean jjtc002 = true;
614       jjtree.openNodeScope(jjtn002);
615         try {
616           jj_consume_token(MINUS);
617           MultiplicativeExpression();
618         jjtree.closeNodeScope(jjtn002, 2);
619         jjtc002 = false;
620         jjtn002.setOperator(opSet.getSubtract());
621         } catch (Throwable JavaDoc jjte002) {
622       if (jjtc002) {
623         jjtree.clearNodeScope(jjtn002);
624         jjtc002 = false;
625       } else {
626         jjtree.popNode();
627       }
628       if (jjte002 instanceof RuntimeException JavaDoc) {
629         {if (true) throw (RuntimeException JavaDoc)jjte002;}
630       }
631       if (jjte002 instanceof ParseException) {
632         {if (true) throw (ParseException)jjte002;}
633       }
634       {if (true) throw (Error JavaDoc)jjte002;}
635         } finally {
636       if (jjtc002) {
637         jjtree.closeNodeScope(jjtn002, 2);
638       }
639         }
640         break;
641       default:
642         jj_la1[10] = jj_gen;
643         jj_consume_token(-1);
644         throw new ParseException();
645       }
646     }
647   }
648
649   final public void MultiplicativeExpression() throws ParseException {
650     UnaryExpression();
651     label_6:
652     while (true) {
653       if (jj_2_4(1)) {
654         ;
655       } else {
656         break label_6;
657       }
658       if (jj_2_5(1)) {
659       ASTFunNode jjtn001 = new ASTFunNode(JJTFUNNODE);
660       boolean jjtc001 = true;
661       jjtree.openNodeScope(jjtn001);
662         try {
663           PowerExpression();
664         jjtree.closeNodeScope(jjtn001, 2);
665         jjtc001 = false;
666         if (!jep.implicitMul) {if (true) throw new ParseException(
667                 "Syntax Error (implicit multiplication not enabled)");}
668
669         jjtn001.setOperator(opSet.getMultiply());
670         } catch (Throwable JavaDoc jjte001) {
671       if (jjtc001) {
672         jjtree.clearNodeScope(jjtn001);
673         jjtc001 = false;
674       } else {
675         jjtree.popNode();
676       }
677       if (jjte001 instanceof RuntimeException JavaDoc) {
678         {if (true) throw (RuntimeException JavaDoc)jjte001;}
679       }
680       if (jjte001 instanceof ParseException) {
681         {if (true) throw (ParseException)jjte001;}
682       }
683       {if (true) throw (Error JavaDoc)jjte001;}
684         } finally {
685       if (jjtc001) {
686         jjtree.closeNodeScope(jjtn001, 2);
687       }
688         }
689       } else {
690         switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
691         case MUL:
692       ASTFunNode jjtn002 = new ASTFunNode(JJTFUNNODE);
693       boolean jjtc002 = true;
694       jjtree.openNodeScope(jjtn002);
695           try {
696             jj_consume_token(MUL);
697             UnaryExpression();
698         jjtree.closeNodeScope(jjtn002, 2);
699         jjtc002 = false;
700         jjtn002.setOperator(opSet.getMultiply());
701           } catch (Throwable JavaDoc jjte002) {
702       if (jjtc002) {
703         jjtree.clearNodeScope(jjtn002);
704         jjtc002 = false;
705       } else {
706         jjtree.popNode();
707       }
708       if (jjte002 instanceof RuntimeException JavaDoc) {
709         {if (true) throw (RuntimeException JavaDoc)jjte002;}
710       }
711       if (jjte002 instanceof ParseException) {
712         {if (true) throw (ParseException)jjte002;}
713       }
714       {if (true) throw (Error JavaDoc)jjte002;}
715           } finally {
716       if (jjtc002) {
717         jjtree.closeNodeScope(jjtn002, 2);
718       }
719           }
720           break;
721         case DOT:
722       ASTFunNode jjtn003 = new ASTFunNode(JJTFUNNODE);
723       boolean jjtc003 = true;
724       jjtree.openNodeScope(jjtn003);
725           try {
726             jj_consume_token(DOT);
727             UnaryExpression();
728         jjtree.closeNodeScope(jjtn003, 2);
729         jjtc003 = false;
730         jjtn003.setOperator(opSet.getDot());
731           } catch (Throwable JavaDoc jjte003) {
732       if (jjtc003) {
733         jjtree.clearNodeScope(jjtn003);
734         jjtc003 = false;
735       } else {
736         jjtree.popNode();
737       }
738       if (jjte003 instanceof RuntimeException JavaDoc) {
739         {if (true) throw (RuntimeException JavaDoc)jjte003;}
740       }
741       if (jjte003 instanceof ParseException) {
742         {if (true) throw (ParseException)jjte003;}
743       }
744       {if (true) throw (Error JavaDoc)jjte003;}
745           } finally {
746       if (jjtc003) {
747         jjtree.closeNodeScope(jjtn003, 2);
748       }
749           }
750           break;
751         case CROSS:
752       ASTFunNode jjtn004 = new ASTFunNode(JJTFUNNODE);
753       boolean jjtc004 = true;
754       jjtree.openNodeScope(jjtn004);
755           try {
756             jj_consume_token(CROSS);
757             UnaryExpression();
758         jjtree.closeNodeScope(jjtn004, 2);
759         jjtc004 = false;
760         jjtn004.setOperator(opSet.getCross());
761           } catch (Throwable JavaDoc jjte004) {
762       if (jjtc004) {
763         jjtree.clearNodeScope(jjtn004);
764         jjtc004 = false;
765       } else {
766         jjtree.popNode();
767       }
768       if (jjte004 instanceof RuntimeException JavaDoc) {
769         {if (true) throw (RuntimeException JavaDoc)jjte004;}
770       }
771       if (jjte004 instanceof ParseException) {
772         {if (true) throw (ParseException)jjte004;}
773       }
774       {if (true) throw (Error JavaDoc)jjte004;}
775           } finally {
776       if (jjtc004) {
777         jjtree.closeNodeScope(jjtn004, 2);
778       }
779           }
780           break;
781         case DIV:
782       ASTFunNode jjtn005 = new ASTFunNode(JJTFUNNODE);
783       boolean jjtc005 = true;
784       jjtree.openNodeScope(jjtn005);
785           try {
786             jj_consume_token(DIV);
787             UnaryExpression();
788         jjtree.closeNodeScope(jjtn005, 2);
789         jjtc005 = false;
790         jjtn005.setOperator(opSet.getDivide());
791           } catch (Throwable JavaDoc jjte005) {
792       if (jjtc005) {
793         jjtree.clearNodeScope(jjtn005);
794         jjtc005 = false;
795       } else {
796         jjtree.popNode();
797       }
798       if (jjte005 instanceof RuntimeException JavaDoc) {
799         {if (true) throw (RuntimeException JavaDoc)jjte005;}
800       }
801       if (jjte005 instanceof ParseException) {
802         {if (true) throw (ParseException)jjte005;}
803       }
804       {if (true) throw (Error JavaDoc)jjte005;}
805           } finally {
806       if (jjtc005) {
807         jjtree.closeNodeScope(jjtn005, 2);
808       }
809           }
810           break;
811         case MOD:
812       ASTFunNode jjtn006 = new ASTFunNode(JJTFUNNODE);
813       boolean jjtc006 = true;
814       jjtree.openNodeScope(jjtn006);
815           try {
816             jj_consume_token(MOD);
817             UnaryExpression();
818         jjtree.closeNodeScope(jjtn006, 2);
819         jjtc006 = false;
820         jjtn006.setOperator(opSet.getMod());
821           } catch (Throwable JavaDoc jjte006) {
822       if (jjtc006) {
823         jjtree.clearNodeScope(jjtn006);
824         jjtc006 = false;
825       } else {
826         jjtree.popNode();
827       }
828       if (jjte006 instanceof RuntimeException JavaDoc) {
829         {if (true) throw (RuntimeException JavaDoc)jjte006;}
830       }
831       if (jjte006 instanceof ParseException) {
832         {if (true) throw (ParseException)jjte006;}
833       }
834       {if (true) throw (Error JavaDoc)jjte006;}
835           } finally {
836       if (jjtc006) {
837         jjtree.closeNodeScope(jjtn006, 2);
838       }
839           }
840           break;
841         default:
842           jj_la1[11] = jj_gen;
843           jj_consume_token(-1);
844           throw new ParseException();
845         }
846       }
847     }
848   }
849
850   final public void UnaryExpression() throws ParseException {
851     switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
852     case PLUS:
853       jj_consume_token(PLUS);
854       UnaryExpression();
855       break;
856     case MINUS:
857     ASTFunNode jjtn001 = new ASTFunNode(JJTFUNNODE);
858     boolean jjtc001 = true;
859     jjtree.openNodeScope(jjtn001);
860       try {
861         jj_consume_token(MINUS);
862         UnaryExpression();
863       jjtree.closeNodeScope(jjtn001, 1);
864       jjtc001 = false;
865           jjtn001.setOperator(opSet.getUMinus());
866       } catch (Throwable JavaDoc jjte001) {
867     if (jjtc001) {
868       jjtree.clearNodeScope(jjtn001);
869       jjtc001 = false;
870     } else {
871       jjtree.popNode();
872     }
873     if (jjte001 instanceof RuntimeException JavaDoc) {
874       {if (true) throw (RuntimeException JavaDoc)jjte001;}
875     }
876     if (jjte001 instanceof ParseException) {
877       {if (true) throw (ParseException)jjte001;}
878     }
879     {if (true) throw (Error JavaDoc)jjte001;}
880       } finally {
881     if (jjtc001) {
882       jjtree.closeNodeScope(jjtn001, 1);
883     }
884       }
885       break;
886     case NOT:
887     ASTFunNode jjtn002 = new ASTFunNode(JJTFUNNODE);
888     boolean jjtc002 = true;
889     jjtree.openNodeScope(jjtn002);
890       try {
891         jj_consume_token(NOT);
892         UnaryExpression();
893       jjtree.closeNodeScope(jjtn002, 1);
894       jjtc002 = false;
895           jjtn002.setOperator(opSet.getNot());
896       } catch (Throwable JavaDoc jjte002) {
897     if (jjtc002) {
898       jjtree.clearNodeScope(jjtn002);
899       jjtc002 = false;
900     } else {
901       jjtree.popNode();
902     }
903     if (jjte002 instanceof RuntimeException JavaDoc) {
904       {if (true) throw (RuntimeException JavaDoc)jjte002;}
905     }
906     if (jjte002 instanceof ParseException) {
907       {if (true) throw (ParseException)jjte002;}
908     }
909     {if (true) throw (Error JavaDoc)jjte002;}
910       } finally {
911     if (jjtc002) {
912       jjtree.closeNodeScope(jjtn002, 1);
913     }
914       }
915       break;
916     default:
917       jj_la1[12] = jj_gen;
918       if (jj_2_6(1)) {
919         PowerExpression();
920       } else {
921         jj_consume_token(-1);
922         throw new ParseException();
923       }
924     }
925   }
926
927   final public void PowerExpression() throws ParseException {
928     UnaryExpressionNotPlusMinus();
929     switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
930     case POWER:
931     ASTFunNode jjtn001 = new ASTFunNode(JJTFUNNODE);
932     boolean jjtc001 = true;
933     jjtree.openNodeScope(jjtn001);
934       try {
935         jj_consume_token(POWER);
936         UnaryExpression();
937       jjtree.closeNodeScope(jjtn001, 2);
938       jjtc001 = false;
939       jjtn001.setOperator(opSet.getPower());
940       } catch (Throwable JavaDoc jjte001) {
941     if (jjtc001) {
942       jjtree.clearNodeScope(jjtn001);
943       jjtc001 = false;
944     } else {
945       jjtree.popNode();
946     }
947     if (jjte001 instanceof RuntimeException JavaDoc) {
948       {if (true) throw (RuntimeException JavaDoc)jjte001;}
949     }
950     if (jjte001 instanceof ParseException) {
951       {if (true) throw (ParseException)jjte001;}
952     }
953     {if (true) throw (Error JavaDoc)jjte001;}
954       } finally {
955     if (jjtc001) {
956       jjtree.closeNodeScope(jjtn001, 2);
957     }
958       }
959       break;
960     default:
961       jj_la1[13] = jj_gen;
962       ;
963     }
964   }
965
966   final public void UnaryExpressionNotPlusMinus() throws ParseException {
967         String JavaDoc identString = "";
968         int type;
969     switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
970     case INTEGER_LITERAL:
971     case FLOATING_POINT_LITERAL:
972     case STRING_LITERAL:
973       AnyConstant();
974       break;
975     default:
976       jj_la1[15] = jj_gen;
977       if (jj_2_7(1)) {
978         if ((getToken(1).kind == INDENTIFIER1 || getToken(1).kind == INDENTIFIER2) &&
979                                           jep.funTab.containsKey(getToken(1).image)) {
980           Function();
981         } else {
982           switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
983           case INDENTIFIER1:
984           case INDENTIFIER2:
985             Variable();
986             break;
987           default:
988             jj_la1[14] = jj_gen;
989             jj_consume_token(-1);
990             throw new ParseException();
991           }
992         }
993       } else {
994         switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
995         case LRND:
996           jj_consume_token(LRND);
997           Expression();
998           jj_consume_token(RRND);
999           break;
1000        case LSQ:
1001          ListExpression();
1002          break;
1003        default:
1004          jj_la1[16] = jj_gen;
1005          jj_consume_token(-1);
1006          throw new ParseException();
1007        }
1008      }
1009    }
1010  }
1011
1012  final public void ListExpression() throws ParseException {
1013 /*@bgen(jjtree) FunNode */
1014        ASTFunNode jjtn000 = new ASTFunNode(JJTFUNNODE);
1015        boolean jjtc000 = true;
1016        jjtree.openNodeScope(jjtn000);jjtn000.setOperator(opSet.getList());
1017    try {
1018      jj_consume_token(LSQ);
1019      Expression();
1020      label_7:
1021      while (true) {
1022        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
1023        case COMMA:
1024          ;
1025          break;
1026        default:
1027          jj_la1[17] = jj_gen;
1028          break label_7;
1029        }
1030        jj_consume_token(COMMA);
1031        Expression();
1032      }
1033      jj_consume_token(RSQ);
1034    } catch (Throwable JavaDoc jjte000) {
1035          if (jjtc000) {
1036            jjtree.clearNodeScope(jjtn000);
1037            jjtc000 = false;
1038          } else {
1039            jjtree.popNode();
1040          }
1041          if (jjte000 instanceof RuntimeException JavaDoc) {
1042            {if (true) throw (RuntimeException JavaDoc)jjte000;}
1043          }
1044          if (jjte000 instanceof ParseException) {
1045            {if (true) throw (ParseException)jjte000;}
1046          }
1047          {if (true) throw (Error JavaDoc)jjte000;}
1048    } finally {
1049          if (jjtc000) {
1050            jjtree.closeNodeScope(jjtn000, true);
1051          }
1052    }
1053  }
1054
1055  final public void Variable() throws ParseException {
1056        String JavaDoc identString = "";
1057          ASTVarNode jjtn001 = new ASTVarNode(JJTVARNODE);
1058          boolean jjtc001 = true;
1059          jjtree.openNodeScope(jjtn001);
1060    try {
1061      identString = Identifier();
1062          jjtree.closeNodeScope(jjtn001, true);
1063          jjtc001 = false;
1064                if (symTab.containsKey(identString)) {
1065                        jjtn001.setVar(symTab.getVar(identString));
1066                } else {
1067                        if (jep.allowUndeclared) {
1068                                jjtn001.setVar(symTab.makeVarIfNeeded(identString));
1069                        } else {
1070                                addToErrorList("Unrecognized symbol \"" + identString +"\"");
1071                        }
1072                }
1073    } catch (Throwable JavaDoc jjte001) {
1074          if (jjtc001) {
1075            jjtree.clearNodeScope(jjtn001);
1076            jjtc001 = false;
1077          } else {
1078            jjtree.popNode();
1079          }
1080          if (jjte001 instanceof RuntimeException JavaDoc) {
1081            {if (true) throw (RuntimeException JavaDoc)jjte001;}
1082          }
1083          if (jjte001 instanceof ParseException) {
1084            {if (true) throw (ParseException)jjte001;}
1085          }
1086          {if (true) throw (Error JavaDoc)jjte001;}
1087    } finally {
1088          if (jjtc001) {
1089            jjtree.closeNodeScope(jjtn001, true);
1090          }
1091    }
1092  }
1093
1094  final public void Function() throws ParseException {
1095        int reqArguments = 0;
1096        String JavaDoc identString = "";
1097          ASTFunNode jjtn001 = new ASTFunNode(JJTFUNNODE);
1098          boolean jjtc001 = true;
1099          jjtree.openNodeScope(jjtn001);
1100    try {
1101      identString = Identifier();
1102                        if (jep.funTab.containsKey(identString)) {
1103                                //Set number of required arguments
1104
reqArguments =
1105                                        ((PostfixMathCommandI)jep.funTab.get(identString)).getNumberOfParameters();
1106                                jjtn001.setFunction(identString,
1107                                        (PostfixMathCommandI)jep.funTab.get(identString));
1108                        } else {
1109                                addToErrorList("!!! Unrecognized function \"" + identString +"\"");
1110                        }
1111      jj_consume_token(LRND);
1112      ArgumentList(reqArguments, identString);
1113      jj_consume_token(RRND);
1114    } catch (Throwable JavaDoc jjte001) {
1115          if (jjtc001) {
1116            jjtree.clearNodeScope(jjtn001);
1117            jjtc001 = false;
1118          } else {
1119            jjtree.popNode();
1120          }
1121          if (jjte001 instanceof RuntimeException JavaDoc) {
1122            {if (true) throw (RuntimeException JavaDoc)jjte001;}
1123          }
1124          if (jjte001 instanceof ParseException) {
1125            {if (true) throw (ParseException)jjte001;}
1126          }
1127          {if (true) throw (Error JavaDoc)jjte001;}
1128    } finally {
1129          if (jjtc001) {
1130            jjtree.closeNodeScope(jjtn001, true);
1131          }
1132    }
1133  }
1134
1135  final public void ArgumentList(int reqArguments, String JavaDoc functionName) throws ParseException {
1136        int count = 0;
1137        String JavaDoc errorStr = "";
1138    if (jj_2_8(1)) {
1139      Expression();
1140                       count++;
1141      label_8:
1142      while (true) {
1143        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
1144        case COMMA:
1145          ;
1146          break;
1147        default:
1148          jj_la1[18] = jj_gen;
1149          break label_8;
1150        }
1151        jj_consume_token(COMMA);
1152        Expression();
1153                               count++;
1154      }
1155    } else {
1156      ;
1157    }
1158        if (reqArguments != count && reqArguments != -1) {
1159                        errorStr = "Function \"" + functionName +"\" requires "
1160                                   + reqArguments + " parameter";
1161                        if (reqArguments!=1) errorStr += "s";
1162                        addToErrorList(errorStr);
1163                }
1164  }
1165
1166  final public String JavaDoc Identifier() throws ParseException {
1167  Token t;
1168    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
1169    case INDENTIFIER1:
1170      t = jj_consume_token(INDENTIFIER1);
1171      break;
1172    case INDENTIFIER2:
1173      t = jj_consume_token(INDENTIFIER2);
1174      break;
1175    default:
1176      jj_la1[19] = jj_gen;
1177      jj_consume_token(-1);
1178      throw new ParseException();
1179    }
1180                                                       {if (true) return t.image;}
1181    throw new Error JavaDoc("Missing return statement in function");
1182  }
1183
1184  final public void AnyConstant() throws ParseException {
1185 /*@bgen(jjtree) Constant */
1186        ASTConstant jjtn000 = new ASTConstant(JJTCONSTANT);
1187        boolean jjtc000 = true;
1188        jjtree.openNodeScope(jjtn000);Token t;
1189        Object JavaDoc value;
1190    try {
1191      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
1192      case STRING_LITERAL:
1193        t = jj_consume_token(STRING_LITERAL);
1194                             jjtree.closeNodeScope(jjtn000, true);
1195                             jjtc000 = false;
1196                // strip away double quotes at end of string
1197
String JavaDoc temp = (t.image).substring(1,t.image.length()-1);
1198
1199                // replace escape characters
1200
temp = replaceEscape(temp);
1201
1202                jjtn000.setValue(temp);
1203        break;
1204      case INTEGER_LITERAL:
1205      case FLOATING_POINT_LITERAL:
1206        value = RealConstant();
1207                                 jjtree.closeNodeScope(jjtn000, true);
1208                                 jjtc000 = false;
1209                jjtn000.setValue(value);
1210// }
1211
// |
1212
// value = Array() {
1213
// jjtThis.setValue(value);
1214

1215        break;
1216      default:
1217        jj_la1[20] = jj_gen;
1218        jj_consume_token(-1);
1219        throw new ParseException();
1220      }
1221    } catch (Throwable JavaDoc jjte000) {
1222          if (jjtc000) {
1223            jjtree.clearNodeScope(jjtn000);
1224            jjtc000 = false;
1225          } else {
1226            jjtree.popNode();
1227          }
1228          if (jjte000 instanceof RuntimeException JavaDoc) {
1229            {if (true) throw (RuntimeException JavaDoc)jjte000;}
1230          }
1231          if (jjte000 instanceof ParseException) {
1232            {if (true) throw (ParseException)jjte000;}
1233          }
1234          {if (true) throw (Error JavaDoc)jjte000;}
1235    } finally {
1236          if (jjtc000) {
1237            jjtree.closeNodeScope(jjtn000, true);
1238          }
1239    }
1240  }
1241
1242/*
1243Vector Array() :
1244{
1245    Object value;
1246    Vector result = new Vector();
1247}
1248{
1249    <LSQ>
1250    value = RealConstant()
1251    {
1252        result.addElement(value);
1253    }
1254    (
1255        <COMMA>
1256        value = RealConstant()
1257        {
1258            result.addElement(value);
1259        }
1260    )*
1261    <RSQ>
1262    {
1263        return result;
1264    }
1265}
1266*/

1267  final public Object JavaDoc RealConstant() throws ParseException {
1268  Token t;
1269  Object JavaDoc value;
1270    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
1271    case INTEGER_LITERAL:
1272      t = jj_consume_token(INTEGER_LITERAL);
1273      break;
1274    case FLOATING_POINT_LITERAL:
1275      t = jj_consume_token(FLOATING_POINT_LITERAL);
1276      break;
1277    default:
1278      jj_la1[21] = jj_gen;
1279      jj_consume_token(-1);
1280      throw new ParseException();
1281    }
1282                try {
1283                        value = jep.getNumberFactory().createNumber(t.image);
1284                } catch (Exception JavaDoc e) {
1285                        value = null;
1286                        addToErrorList("Can't parse \"" + t.image + "\"");
1287                }
1288
1289                {if (true) return value;}
1290    throw new Error JavaDoc("Missing return statement in function");
1291  }
1292
1293  final private boolean jj_2_1(int xla) {
1294    jj_la = xla; jj_lastpos = jj_scanpos = token;
1295    try { return !jj_3_1(); }
1296    catch(LookaheadSuccess ls) { return true; }
1297    finally { jj_save(0, xla); }
1298  }
1299
1300  final private boolean jj_2_2(int xla) {
1301    jj_la = xla; jj_lastpos = jj_scanpos = token;
1302    try { return !jj_3_2(); }
1303    catch(LookaheadSuccess ls) { return true; }
1304    finally { jj_save(1, xla); }
1305  }
1306
1307  final private boolean jj_2_3(int xla) {
1308    jj_la = xla; jj_lastpos = jj_scanpos = token;
1309    try { return !jj_3_3(); }
1310    catch(LookaheadSuccess ls) { return true; }
1311    finally { jj_save(2, xla); }
1312  }
1313
1314  final private boolean jj_2_4(int xla) {
1315    jj_la = xla; jj_lastpos = jj_scanpos = token;
1316    try { return !jj_3_4(); }
1317    catch(LookaheadSuccess ls) { return true; }
1318    finally { jj_save(3, xla); }
1319  }
1320
1321  final private boolean jj_2_5(int xla) {
1322    jj_la = xla; jj_lastpos = jj_scanpos = token;
1323    try { return !jj_3_5(); }
1324    catch(LookaheadSuccess ls) { return true; }
1325    finally { jj_save(4, xla); }
1326  }
1327
1328  final private boolean jj_2_6(int xla) {
1329    jj_la = xla; jj_lastpos = jj_scanpos = token;
1330    try { return !jj_3_6(); }
1331    catch(LookaheadSuccess ls) { return true; }
1332    finally { jj_save(5, xla); }
1333  }
1334
1335  final private boolean jj_2_7(int xla) {
1336    jj_la = xla; jj_lastpos = jj_scanpos = token;
1337    try { return !jj_3_7(); }
1338    catch(LookaheadSuccess ls) { return true; }
1339    finally { jj_save(6, xla); }
1340  }
1341
1342  final private boolean jj_2_8(int xla) {
1343    jj_la = xla; jj_lastpos = jj_scanpos = token;
1344    try { return !jj_3_8(); }
1345    catch(LookaheadSuccess ls) { return true; }
1346    finally { jj_save(7, xla); }
1347  }
1348
1349  final private boolean jj_3R_10() {
1350    if (jj_3R_20()) return true;
1351    if (jj_scan_token(ASSIGN)) return true;
1352    if (jj_3R_9()) return true;
1353    return false;
1354  }
1355
1356  final private boolean jj_3_8() {
1357    if (jj_3R_9()) return true;
1358    return false;
1359  }
1360
1361  final private boolean jj_3R_32() {
1362    if (jj_3R_35()) return true;
1363    return false;
1364  }
1365
1366  final private boolean jj_3R_17() {
1367    if (jj_3R_22()) return true;
1368    return false;
1369  }
1370
1371  final private boolean jj_3_3() {
1372    if (jj_3R_11()) return true;
1373    return false;
1374  }
1375
1376  final private boolean jj_3R_36() {
1377    Token xsp;
1378    xsp = jj_scanpos;
1379    if (jj_scan_token(7)) {
1380    jj_scanpos = xsp;
1381    if (jj_scan_token(9)) return true;
1382    }
1383    return false;
1384  }
1385
1386  final private boolean jj_3R_9() {
1387    Token xsp;
1388    xsp = jj_scanpos;
1389    if (jj_3_2()) {
1390    jj_scanpos = xsp;
1391    if (jj_3_3()) return true;
1392    }
1393    return false;
1394  }
1395
1396  final private boolean jj_3_2() {
1397    if (jj_3R_10()) return true;
1398    return false;
1399  }
1400
1401  final private boolean jj_3_6() {
1402    if (jj_3R_17()) return true;
1403    return false;
1404  }
1405
1406  final private boolean jj_3R_40() {
1407    if (jj_scan_token(NOT)) return true;
1408    return false;
1409  }
1410
1411  final private boolean jj_3R_39() {
1412    if (jj_scan_token(MINUS)) return true;
1413    return false;
1414  }
1415
1416  final private boolean jj_3R_23() {
1417    if (jj_3R_24()) return true;
1418    return false;
1419  }
1420
1421  final private boolean jj_3R_38() {
1422    if (jj_scan_token(PLUS)) return true;
1423    return false;
1424  }
1425
1426  final private boolean jj_3R_37() {
1427    Token xsp;
1428    xsp = jj_scanpos;
1429    if (jj_3R_38()) {
1430    jj_scanpos = xsp;
1431    if (jj_3R_39()) {
1432    jj_scanpos = xsp;
1433    if (jj_3R_40()) {
1434    jj_scanpos = xsp;
1435    if (jj_3_6()) return true;
1436    }
1437    }
1438    }
1439    return false;
1440  }
1441
1442  final private boolean jj_3_1() {
1443    if (jj_3R_9()) return true;
1444    return false;
1445  }
1446
1447  final private boolean jj_3R_29() {
1448    if (jj_3R_32()) return true;
1449    return false;
1450  }
1451
1452  final private boolean jj_3R_16() {
1453    if (jj_scan_token(MOD)) return true;
1454    return false;
1455  }
1456
1457  final private boolean jj_3R_15() {
1458    if (jj_scan_token(DIV)) return true;
1459    return false;
1460  }
1461
1462  final private boolean jj_3R_20() {
1463    if (jj_3R_24()) return true;
1464    return false;
1465  }
1466
1467  final private boolean jj_3R_14() {
1468    if (jj_scan_token(CROSS)) return true;
1469    return false;
1470  }
1471
1472  final private boolean jj_3R_25() {
1473    if (jj_3R_29()) return true;
1474    return false;
1475  }
1476
1477  final private boolean jj_3R_34() {
1478    if (jj_3R_36()) return true;
1479    return false;
1480  }
1481
1482  final private boolean jj_3R_13() {
1483    if (jj_scan_token(DOT)) return true;
1484    return false;
1485  }
1486
1487  final private boolean jj_3R_31() {
1488    if (jj_scan_token(LSQ)) return true;
1489    return false;
1490  }
1491
1492  final private boolean jj_3R_12() {
1493    if (jj_scan_token(MUL)) return true;
1494    return false;
1495  }
1496
1497  final private boolean jj_3R_19() {
1498    if (jj_3R_20()) return true;
1499    return false;
1500  }
1501
1502  final private boolean jj_3R_30() {
1503    Token xsp;
1504    xsp = jj_scanpos;
1505    if (jj_3R_33()) {
1506    jj_scanpos = xsp;
1507    if (jj_3R_34()) return true;
1508    }
1509    return false;
1510  }
1511
1512  final private boolean jj_3R_33() {
1513    if (jj_scan_token(STRING_LITERAL)) return true;
1514    return false;
1515  }
1516
1517  final private boolean jj_3R_28() {
1518    if (jj_3R_31()) return true;
1519    return false;
1520  }
1521
1522  final private boolean jj_3R_21() {
1523    if (jj_3R_25()) return true;
1524    return false;
1525  }
1526
1527  final private boolean jj_3R_27() {
1528    if (jj_scan_token(LRND)) return true;
1529    return false;
1530  }
1531
1532  final private boolean jj_3_4() {
1533    Token xsp;
1534    xsp = jj_scanpos;
1535    if (jj_3_5()) {
1536    jj_scanpos = xsp;
1537    if (jj_3R_12()) {
1538    jj_scanpos = xsp;
1539    if (jj_3R_13()) {
1540    jj_scanpos = xsp;
1541    if (jj_3R_14()) {
1542    jj_scanpos = xsp;
1543    if (jj_3R_15()) {
1544    jj_scanpos = xsp;
1545    if (jj_3R_16()) return true;
1546    }
1547    }
1548    }
1549    }
1550    }
1551    return false;
1552  }
1553
1554  final private boolean jj_3_5() {
1555    if (jj_3R_17()) return true;
1556    return false;
1557  }
1558
1559  final private boolean jj_3R_18() {
1560    if (jj_3R_23()) return true;
1561    return false;
1562  }
1563
1564  final private boolean jj_3R_24() {
1565    Token xsp;
1566    xsp = jj_scanpos;
1567    if (jj_scan_token(12)) {
1568    jj_scanpos = xsp;
1569    if (jj_scan_token(15)) return true;
1570    }
1571    return false;
1572  }
1573
1574  final private boolean jj_3_7() {
1575    Token xsp;
1576    xsp = jj_scanpos;
1577    lookingAhead = true;
1578    jj_semLA = (getToken(1).kind == INDENTIFIER1 || getToken(1).kind == INDENTIFIER2) &&
1579                                  jep.funTab.containsKey(getToken(1).image);
1580    lookingAhead = false;
1581    if (!jj_semLA || jj_3R_18()) {
1582    jj_scanpos = xsp;
1583    if (jj_3R_19()) return true;
1584    }
1585    return false;
1586  }
1587
1588  final private boolean jj_3R_35() {
1589    if (jj_3R_37()) return true;
1590    return false;
1591  }
1592
1593  final private boolean jj_3R_22() {
1594    Token xsp;
1595    xsp = jj_scanpos;
1596    if (jj_3R_26()) {
1597    jj_scanpos = xsp;
1598    if (jj_3_7()) {
1599    jj_scanpos = xsp;
1600    if (jj_3R_27()) {
1601    jj_scanpos = xsp;
1602    if (jj_3R_28()) return true;
1603    }
1604    }
1605    }
1606    return false;
1607  }
1608
1609  final private boolean jj_3R_26() {
1610    if (jj_3R_30()) return true;
1611    return false;
1612  }
1613
1614  final private boolean jj_3R_11() {
1615    if (jj_3R_21()) return true;
1616    return false;
1617  }
1618
1619  public ParserTokenManager token_source;
1620  JavaCharStream jj_input_stream;
1621  public Token token, jj_nt;
1622  private int jj_ntk;
1623  private Token jj_scanpos, jj_lastpos;
1624  private int jj_la;
1625  public boolean lookingAhead = false;
1626  private boolean jj_semLA;
1627  private int jj_gen;
1628  final private int[] jj_la1 = new int[22];
1629  static private int[] jj_la1_0;
1630  static private int[] jj_la1_1;
1631  static {
1632      jj_la1_0();
1633      jj_la1_1();
1634   }
1635   private static void jj_la1_0() {
1636      jj_la1_0 = new int[] {0x80001,0x80001,0x80001,0x10000000,0x8000000,0x4800000,0x4800000,0x3600000,0x3600000,0x60000000,0x60000000,0x80000000,0x60000000,0x0,0x9000,0xa80,0x0,0x100000,0x100000,0x9000,0xa80,0x280,};
1637   }
1638   private static void jj_la1_1() {
1639      jj_la1_1 = new int[] {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x27,0x8,0x10,0x0,0x0,0x140,0x0,0x0,0x0,0x0,0x0,};
1640   }
1641  final private JJCalls[] jj_2_rtns = new JJCalls[8];
1642  private boolean jj_rescan = false;
1643  private int jj_gc = 0;
1644
1645  public Parser(java.io.InputStream JavaDoc stream) {
1646    jj_input_stream = new JavaCharStream(stream, 1, 1);
1647    token_source = new ParserTokenManager(jj_input_stream);
1648    token = new Token();
1649    jj_ntk = -1;
1650    jj_gen = 0;
1651    for (int i = 0; i < 22; i++) jj_la1[i] = -1;
1652    for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
1653  }
1654
1655  public void ReInit(java.io.InputStream JavaDoc stream) {
1656    jj_input_stream.ReInit(stream, 1, 1);
1657    token_source.ReInit(jj_input_stream);
1658    token = new Token();
1659    jj_ntk = -1;
1660    jjtree.reset();
1661    jj_gen = 0;
1662    for (int i = 0; i < 22; i++) jj_la1[i] = -1;
1663    for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
1664  }
1665
1666  public Parser(java.io.Reader JavaDoc stream) {
1667    jj_input_stream = new JavaCharStream(stream, 1, 1);
1668    token_source = new ParserTokenManager(jj_input_stream);
1669    token = new Token();
1670    jj_ntk = -1;
1671    jj_gen = 0;
1672    for (int i = 0; i < 22; i++) jj_la1[i] = -1;
1673    for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
1674  }
1675
1676  public void ReInit(java.io.Reader JavaDoc stream) {
1677    jj_input_stream.ReInit(stream, 1, 1);
1678    token_source.ReInit(jj_input_stream);
1679    token = new Token();
1680    jj_ntk = -1;
1681    jjtree.reset();
1682    jj_gen = 0;
1683    for (int i = 0; i < 22; i++) jj_la1[i] = -1;
1684    for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
1685  }
1686
1687  public Parser(ParserTokenManager tm) {
1688    token_source = tm;
1689    token = new Token();
1690    jj_ntk = -1;
1691    jj_gen = 0;
1692    for (int i = 0; i < 22; i++) jj_la1[i] = -1;
1693    for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
1694  }
1695
1696  public void ReInit(ParserTokenManager tm) {
1697    token_source = tm;
1698    token = new Token();
1699    jj_ntk = -1;
1700    jjtree.reset();
1701    jj_gen = 0;
1702    for (int i = 0; i < 22; i++) jj_la1[i] = -1;
1703    for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
1704  }
1705
1706  final private Token jj_consume_token(int kind) throws ParseException {
1707    Token oldToken;
1708    if ((oldToken = token).next != null) token = token.next;
1709    else token = token.next = token_source.getNextToken();
1710    jj_ntk = -1;
1711    if (token.kind == kind) {
1712      jj_gen++;
1713      if (++jj_gc > 100) {
1714        jj_gc = 0;
1715        for (int i = 0; i < jj_2_rtns.length; i++) {
1716          JJCalls c = jj_2_rtns[i];
1717          while (c != null) {
1718            if (c.gen < jj_gen) c.first = null;
1719            c = c.next;
1720          }
1721        }
1722      }
1723      return token;
1724    }
1725    token = oldToken;
1726    jj_kind = kind;
1727    throw generateParseException();
1728  }
1729
1730  static private final class LookaheadSuccess extends java.lang.Error JavaDoc { }
1731  final private LookaheadSuccess jj_ls = new LookaheadSuccess();
1732  final private boolean jj_scan_token(int kind) {
1733    if (jj_scanpos == jj_lastpos) {
1734      jj_la--;
1735      if (jj_scanpos.next == null) {
1736        jj_lastpos = jj_scanpos = jj_scanpos.next = token_source.getNextToken();
1737      } else {
1738        jj_lastpos = jj_scanpos = jj_scanpos.next;
1739      }
1740    } else {
1741      jj_scanpos = jj_scanpos.next;
1742    }
1743    if (jj_rescan) {
1744      int i = 0; Token tok = token;
1745      while (tok != null && tok != jj_scanpos) { i++; tok = tok.next; }
1746      if (tok != null) jj_add_error_token(kind, i);
1747    }
1748    if (jj_scanpos.kind != kind) return true;
1749    if (jj_la == 0 && jj_scanpos == jj_lastpos) throw jj_ls;
1750    return false;
1751  }
1752
1753  final public Token getNextToken() {
1754    if (token.next != null) token = token.next;
1755    else token = token.next = token_source.getNextToken();
1756    jj_ntk = -1;
1757    jj_gen++;
1758    return token;
1759  }
1760
1761  final public Token getToken(int index) {
1762    Token t = lookingAhead ? jj_scanpos : token;
1763    for (int i = 0; i < index; i++) {
1764      if (t.next != null) t = t.next;
1765      else t = t.next = token_source.getNextToken();
1766    }
1767    return t;
1768  }
1769
1770  final private int jj_ntk() {
1771    if ((jj_nt=token.next) == null)
1772      return (jj_ntk = (token.next=token_source.getNextToken()).kind);
1773    else
1774      return (jj_ntk = jj_nt.kind);
1775  }
1776
1777  private java.util.Vector JavaDoc jj_expentries = new java.util.Vector JavaDoc();
1778  private int[] jj_expentry;
1779  private int jj_kind = -1;
1780  private int[] jj_lasttokens = new int[100];
1781  private int jj_endpos;
1782
1783  private void jj_add_error_token(int kind, int pos) {
1784    if (pos >= 100) return;
1785    if (pos == jj_endpos + 1) {
1786      jj_lasttokens[jj_endpos++] = kind;
1787    } else if (jj_endpos != 0) {
1788      jj_expentry = new int[jj_endpos];
1789      for (int i = 0; i < jj_endpos; i++) {
1790        jj_expentry[i] = jj_lasttokens[i];
1791      }
1792      boolean exists = false;
1793      for (java.util.Enumeration JavaDoc e = jj_expentries.elements(); e.hasMoreElements();) {
1794        int[] oldentry = (int[])(e.nextElement());
1795        if (oldentry.length == jj_expentry.length) {
1796          exists = true;
1797          for (int i = 0; i < jj_expentry.length; i++) {
1798            if (oldentry[i] != jj_expentry[i]) {
1799              exists = false;
1800              break;
1801            }
1802          }
1803          if (exists) break;
1804        }
1805      }
1806      if (!exists) jj_expentries.addElement(jj_expentry);
1807      if (pos != 0) jj_lasttokens[(jj_endpos = pos) - 1] = kind;
1808    }
1809  }
1810
1811  public ParseException generateParseException() {
1812    jj_expentries.removeAllElements();
1813    boolean[] la1tokens = new boolean[42];
1814    for (int i = 0; i < 42; i++) {
1815      la1tokens[i] = false;
1816    }
1817    if (jj_kind >= 0) {
1818      la1tokens[jj_kind] = true;
1819      jj_kind = -1;
1820    }
1821    for (int i = 0; i < 22; i++) {
1822      if (jj_la1[i] == jj_gen) {
1823        for (int j = 0; j < 32; j++) {
1824          if ((jj_la1_0[i] & (1<<j)) != 0) {
1825            la1tokens[j] = true;
1826          }
1827          if ((jj_la1_1[i] & (1<<j)) != 0) {
1828            la1tokens[32+j] = true;
1829          }
1830        }
1831      }
1832    }
1833    for (int i = 0; i < 42; i++) {
1834      if (la1tokens[i]) {
1835        jj_expentry = new int[1];
1836        jj_expentry[0] = i;
1837        jj_expentries.addElement(jj_expentry);
1838      }
1839    }
1840    jj_endpos = 0;
1841    jj_rescan_token();
1842    jj_add_error_token(0, 0);
1843    int[][] exptokseq = new int[jj_expentries.size()][];
1844    for (int i = 0; i < jj_expentries.size(); i++) {
1845      exptokseq[i] = (int[])jj_expentries.elementAt(i);
1846    }
1847    return new ParseException(token, exptokseq, tokenImage);
1848  }
1849
1850  final public void enable_tracing() {
1851  }
1852
1853  final public void disable_tracing() {
1854  }
1855
1856  final private void jj_rescan_token() {
1857    jj_rescan = true;
1858    for (int i = 0; i < 8; i++) {
1859      JJCalls p = jj_2_rtns[i];
1860      do {
1861        if (p.gen > jj_gen) {
1862          jj_la = p.arg; jj_lastpos = jj_scanpos = p.first;
1863          switch (i) {
1864            case 0: jj_3_1(); break;
1865            case 1: jj_3_2(); break;
1866            case 2: jj_3_3(); break;
1867            case 3: jj_3_4(); break;
1868            case 4: jj_3_5(); break;
1869            case 5: jj_3_6(); break;
1870            case 6: jj_3_7(); break;
1871            case 7: jj_3_8(); break;
1872          }
1873        }
1874        p = p.next;
1875      } while (p != null);
1876    }
1877    jj_rescan = false;
1878  }
1879
1880  final private void jj_save(int index, int xla) {
1881    JJCalls p = jj_2_rtns[index];
1882    while (p.gen > jj_gen) {
1883      if (p.next == null) { p = p.next = new JJCalls(); break; }
1884      p = p.next;
1885    }
1886    p.gen = jj_gen + xla - jj_la; p.first = token; p.arg = xla;
1887  }
1888
1889  static final class JJCalls {
1890    int gen;
1891    Token first;
1892    int arg;
1893    JJCalls next;
1894  }
1895
1896}
1897
Popular Tags