View Javadoc
1   /* Generated By:JavaCC: Do not edit this line. ExpressionParser.java */
2   package com.randomnoun.common.jexl.parser;
3   
4   import java.io.*;
5   import com.randomnoun.common.jexl.ast.*;
6   import java.util.Vector;
7   
8   
9   public class ExpressionParser implements ExpressionParserConstants {
10     public ExpressionParser(String fileName)
11     {
12        this(System.in);
13        try
14        {
15           ReInit(new FileInputStream(new File(fileName)));
16        }
17        catch (Exception e)
18        {
19           e.printStackTrace();
20        }
21     }
22     public static void main(String args[])
23     {
24        ExpressionParser parser;
25        if ( args.length == 0 )
26        {
27           System.out.println("Expression Parser:  Reading from standard input . . .");
28           parser = new ExpressionParser(System.in);
29        }
30        else
31           if ( args.length == 1 )
32           {
33              System.out.println("Expression Parser:  Reading from file " + args[0]+ " . . .");
34              try
35              {
36                 parser = new ExpressionParser(new java.io.FileInputStream(args[0]));
37              }
38              catch (java.io.FileNotFoundException e)
39              {
40                 System.out.println("Expression Parser:  File " + args[0]+ " not found.");
41                 return;
42              }
43           }
44           else
45           {
46              System.out.println("Expression Parser1:  Usage is one of:");
47              System.out.println("         java JavaParser < inputfile");
48              System.out.println("OR");
49              System.out.println("         java JavaParser inputfile");
50              return;
51           }
52        try
53        {
54           parser.Expression();
55           System.out.println("Expression Parser:  Expression parsed successfully.");
56        }
57        catch (ParseException e)
58        {
59           System.out.println(e.getMessage());
60           System.out.println("Expression Parser:  Encountered errors during parse.");
61        }
62     }
63  
64    final public TopLevelExpression TopLevelExpression() throws ParseException {
65     Expression n0;
66     NodeToken n1;
67     Token n2;
68      n0 = Expression();
69      n2 = jj_consume_token(0);
70        n2.beginColumn++; n2.endColumn++;
71        n1 = JTBToolkit.makeNodeToken(n2);
72       {if (true) return new TopLevelExpression(n0,n1);}
73      throw new Error("Missing return statement in function");
74    }
75  
76    final public Expression Expression() throws ParseException {
77     ConditionalAndExpression n0;
78     NodeListOptional n1 = new NodeListOptional();
79     NodeSequence n2;
80     NodeToken n3;
81     Token n4;
82     ConditionalAndExpression n5;
83      n0 = ConditionalAndExpression();
84      label_1:
85      while (true) {
86        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
87        case 19:
88          ;
89          break;
90        default:
91          break label_1;
92        }
93          n2 = new NodeSequence(2);
94        n4 = jj_consume_token(19);
95                  n3 = JTBToolkit.makeNodeToken(n4);
96          n2.addNode(n3);
97        n5 = ConditionalAndExpression();
98          n2.addNode(n5);
99          n1.addNode(n2);
100     }
101      n1.nodes.trimToSize();
102      {if (true) return new Expression(n0,n1);}
103     throw new Error("Missing return statement in function");
104   }
105 
106   final public ConditionalAndExpression ConditionalAndExpression() throws ParseException {
107    EqualityExpression n0;
108    NodeListOptional n1 = new NodeListOptional();
109    NodeSequence n2;
110    NodeToken n3;
111    Token n4;
112    EqualityExpression n5;
113     n0 = EqualityExpression();
114     label_2:
115     while (true) {
116       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
117       case 20:
118         ;
119         break;
120       default:
121         break label_2;
122       }
123         n2 = new NodeSequence(2);
124       n4 = jj_consume_token(20);
125                 n3 = JTBToolkit.makeNodeToken(n4);
126         n2.addNode(n3);
127       n5 = EqualityExpression();
128         n2.addNode(n5);
129         n1.addNode(n2);
130     }
131      n1.nodes.trimToSize();
132      {if (true) return new ConditionalAndExpression(n0,n1);}
133     throw new Error("Missing return statement in function");
134   }
135 
136   final public EqualityExpression EqualityExpression() throws ParseException {
137    RelationalExpression n0;
138    NodeListOptional n1 = new NodeListOptional();
139    NodeSequence n2;
140    NodeChoice n3;
141    NodeToken n4;
142    Token n5;
143    NodeToken n6;
144    Token n7;
145    RelationalExpression n8;
146     n0 = RelationalExpression();
147     label_3:
148     while (true) {
149       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
150       case 21:
151       case 22:
152         ;
153         break;
154       default:
155         break label_3;
156       }
157         n2 = new NodeSequence(2);
158       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
159       case 21:
160         n5 = jj_consume_token(21);
161                       n4 = JTBToolkit.makeNodeToken(n5);
162               n3 = new NodeChoice(n4, 0);
163         break;
164       case 22:
165         n7 = jj_consume_token(22);
166                       n6 = JTBToolkit.makeNodeToken(n7);
167               n3 = new NodeChoice(n6, 1);
168         break;
169       default:
170         jj_consume_token(-1);
171         throw new ParseException();
172       }
173         n2.addNode(n3);
174       n8 = RelationalExpression();
175         n2.addNode(n8);
176         n1.addNode(n2);
177     }
178      n1.nodes.trimToSize();
179      {if (true) return new EqualityExpression(n0,n1);}
180     throw new Error("Missing return statement in function");
181   }
182 
183   final public RelationalExpression RelationalExpression() throws ParseException {
184    AdditiveExpression n0;
185    NodeListOptional n1 = new NodeListOptional();
186    NodeSequence n2;
187    NodeChoice n3;
188    NodeToken n4;
189    Token n5;
190    NodeToken n6;
191    Token n7;
192    NodeToken n8;
193    Token n9;
194    NodeToken n10;
195    Token n11;
196    AdditiveExpression n12;
197     n0 = AdditiveExpression();
198     label_4:
199     while (true) {
200       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
201       case 23:
202       case 24:
203       case 25:
204       case 26:
205         ;
206         break;
207       default:
208         break label_4;
209       }
210         n2 = new NodeSequence(2);
211       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
212       case 23:
213         n5 = jj_consume_token(23);
214                      n4 = JTBToolkit.makeNodeToken(n5);
215               n3 = new NodeChoice(n4, 0);
216         break;
217       case 24:
218         n7 = jj_consume_token(24);
219                      n6 = JTBToolkit.makeNodeToken(n7);
220               n3 = new NodeChoice(n6, 1);
221         break;
222       case 25:
223         n9 = jj_consume_token(25);
224                       n8 = JTBToolkit.makeNodeToken(n9);
225               n3 = new NodeChoice(n8, 2);
226         break;
227       case 26:
228         n11 = jj_consume_token(26);
229                        n10 = JTBToolkit.makeNodeToken(n11);
230               n3 = new NodeChoice(n10, 3);
231         break;
232       default:
233         jj_consume_token(-1);
234         throw new ParseException();
235       }
236         n2.addNode(n3);
237       n12 = AdditiveExpression();
238         n2.addNode(n12);
239         n1.addNode(n2);
240     }
241      n1.nodes.trimToSize();
242      {if (true) return new RelationalExpression(n0,n1);}
243     throw new Error("Missing return statement in function");
244   }
245 
246   final public AdditiveExpression AdditiveExpression() throws ParseException {
247    MultiplicativeExpression n0;
248    NodeListOptional n1 = new NodeListOptional();
249    NodeSequence n2;
250    NodeChoice n3;
251    NodeToken n4;
252    Token n5;
253    NodeToken n6;
254    Token n7;
255    MultiplicativeExpression n8;
256     n0 = MultiplicativeExpression();
257     label_5:
258     while (true) {
259       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
260       case 27:
261       case 28:
262         ;
263         break;
264       default:
265         break label_5;
266       }
267         n2 = new NodeSequence(2);
268       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
269       case 27:
270         n5 = jj_consume_token(27);
271                      n4 = JTBToolkit.makeNodeToken(n5);
272               n3 = new NodeChoice(n4, 0);
273         break;
274       case 28:
275         n7 = jj_consume_token(28);
276                      n6 = JTBToolkit.makeNodeToken(n7);
277               n3 = new NodeChoice(n6, 1);
278         break;
279       default:
280         jj_consume_token(-1);
281         throw new ParseException();
282       }
283         n2.addNode(n3);
284       n8 = MultiplicativeExpression();
285         n2.addNode(n8);
286         n1.addNode(n2);
287     }
288      n1.nodes.trimToSize();
289      {if (true) return new AdditiveExpression(n0,n1);}
290     throw new Error("Missing return statement in function");
291   }
292 
293   final public MultiplicativeExpression MultiplicativeExpression() throws ParseException {
294    UnaryExpression n0;
295    NodeListOptional n1 = new NodeListOptional();
296    NodeSequence n2;
297    NodeChoice n3;
298    NodeToken n4;
299    Token n5;
300    NodeToken n6;
301    Token n7;
302    NodeToken n8;
303    Token n9;
304    UnaryExpression n10;
305     n0 = UnaryExpression();
306     label_6:
307     while (true) {
308       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
309       case 29:
310       case 30:
311       case 31:
312         ;
313         break;
314       default:
315         break label_6;
316       }
317         n2 = new NodeSequence(2);
318       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
319       case 29:
320         n5 = jj_consume_token(29);
321                      n4 = JTBToolkit.makeNodeToken(n5);
322               n3 = new NodeChoice(n4, 0);
323         break;
324       case 30:
325         n7 = jj_consume_token(30);
326                      n6 = JTBToolkit.makeNodeToken(n7);
327               n3 = new NodeChoice(n6, 1);
328         break;
329       case 31:
330         n9 = jj_consume_token(31);
331                      n8 = JTBToolkit.makeNodeToken(n9);
332               n3 = new NodeChoice(n8, 2);
333         break;
334       default:
335         jj_consume_token(-1);
336         throw new ParseException();
337       }
338         n2.addNode(n3);
339       n10 = UnaryExpression();
340         n2.addNode(n10);
341         n1.addNode(n2);
342     }
343      n1.nodes.trimToSize();
344      {if (true) return new MultiplicativeExpression(n0,n1);}
345     throw new Error("Missing return statement in function");
346   }
347 
348   final public UnaryExpression UnaryExpression() throws ParseException {
349    NodeChoice n0;
350    NodeSequence n1;
351    NodeChoice n2;
352    NodeToken n3;
353    Token n4;
354    NodeToken n5;
355    Token n6;
356    NodeToken n7;
357    Token n8;
358    UnaryExpression n9;
359    PrimaryExpression n10;
360     switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
361     case 28:
362     case 32:
363     case 33:
364         n1 = new NodeSequence(2);
365       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
366       case 32:
367         n4 = jj_consume_token(32);
368                      n3 = JTBToolkit.makeNodeToken(n4);
369               n2 = new NodeChoice(n3, 0);
370         break;
371       case 33:
372         n6 = jj_consume_token(33);
373                      n5 = JTBToolkit.makeNodeToken(n6);
374               n2 = new NodeChoice(n5, 1);
375         break;
376       case 28:
377         n8 = jj_consume_token(28);
378                      n7 = JTBToolkit.makeNodeToken(n8);
379               n2 = new NodeChoice(n7, 2);
380         break;
381       default:
382         jj_consume_token(-1);
383         throw new ParseException();
384       }
385         n1.addNode(n2);
386       n9 = UnaryExpression();
387         n1.addNode(n9);
388         n0 = new NodeChoice(n1, 0);
389       break;
390     case INTEGER_LITERAL:
391     case FLOATING_POINT_LITERAL:
392     case CHARACTER_LITERAL:
393     case STRING_LITERAL:
394     case TRUE:
395     case NULL:
396     case FALSE:
397     case IDENTIFIER:
398     case 34:
399       n10 = PrimaryExpression();
400         n0 = new NodeChoice(n10, 1);
401       break;
402     default:
403       jj_consume_token(-1);
404       throw new ParseException();
405     }
406      {if (true) return new UnaryExpression(n0);}
407     throw new Error("Missing return statement in function");
408   }
409 
410   final public PrimaryExpression PrimaryExpression() throws ParseException {
411    NodeChoice n0;
412    FunctionCall n1;
413    Name n2;
414    Literal n3;
415    NodeSequence n4;
416    NodeToken n5;
417    Token n6;
418    Expression n7;
419    NodeToken n8;
420    Token n9;
421     if (jj_2_1(2)) {
422       n1 = FunctionCall();
423         n0 = new NodeChoice(n1, 0);
424     } else if (jj_2_2(2)) {
425       n2 = Name();
426         n0 = new NodeChoice(n2, 1);
427     } else {
428       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
429       case INTEGER_LITERAL:
430       case FLOATING_POINT_LITERAL:
431       case CHARACTER_LITERAL:
432       case STRING_LITERAL:
433       case TRUE:
434       case NULL:
435       case FALSE:
436         n3 = Literal();
437         n0 = new NodeChoice(n3, 2);
438         break;
439       case 34:
440         n4 = new NodeSequence(3);
441         n6 = jj_consume_token(34);
442                n5 = JTBToolkit.makeNodeToken(n6);
443         n4.addNode(n5);
444         n7 = Expression();
445         n4.addNode(n7);
446         n9 = jj_consume_token(35);
447                n8 = JTBToolkit.makeNodeToken(n9);
448         n4.addNode(n8);
449         n0 = new NodeChoice(n4, 3);
450         break;
451       default:
452         jj_consume_token(-1);
453         throw new ParseException();
454       }
455     }
456      {if (true) return new PrimaryExpression(n0);}
457     throw new Error("Missing return statement in function");
458   }
459 
460   final public Name Name() throws ParseException {
461    NodeToken n0;
462    Token n1;
463    NodeListOptional n2 = new NodeListOptional();
464    NodeSequence n3;
465    NodeToken n4;
466    Token n5;
467    NodeToken n6;
468    Token n7;
469     n1 = jj_consume_token(IDENTIFIER);
470                      n0 = JTBToolkit.makeNodeToken(n1);
471     label_7:
472     while (true) {
473       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
474       case 36:
475         ;
476         break;
477       default:
478         break label_7;
479       }
480         n3 = new NodeSequence(2);
481       n5 = jj_consume_token(36);
482                n4 = JTBToolkit.makeNodeToken(n5);
483         n3.addNode(n4);
484       n7 = jj_consume_token(IDENTIFIER);
485                         n6 = JTBToolkit.makeNodeToken(n7);
486         n3.addNode(n6);
487         n2.addNode(n3);
488     }
489      n2.nodes.trimToSize();
490      {if (true) return new Name(n0,n2);}
491     throw new Error("Missing return statement in function");
492   }
493 
494   final public FunctionCall FunctionCall() throws ParseException {
495    NodeToken n0;
496    Token n1;
497    Arguments n2;
498     n1 = jj_consume_token(IDENTIFIER);
499                      n0 = JTBToolkit.makeNodeToken(n1);
500     n2 = Arguments();
501      {if (true) return new FunctionCall(n0,n2);}
502     throw new Error("Missing return statement in function");
503   }
504 
505   final public Arguments Arguments() throws ParseException {
506    NodeToken n0;
507    Token n1;
508    NodeOptional n2 = new NodeOptional();
509    ArgumentList n3;
510    NodeToken n4;
511    Token n5;
512     n1 = jj_consume_token(34);
513             n0 = JTBToolkit.makeNodeToken(n1);
514     switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
515     case INTEGER_LITERAL:
516     case FLOATING_POINT_LITERAL:
517     case CHARACTER_LITERAL:
518     case STRING_LITERAL:
519     case TRUE:
520     case NULL:
521     case FALSE:
522     case IDENTIFIER:
523     case 28:
524     case 32:
525     case 33:
526     case 34:
527       n3 = ArgumentList();
528         n2.addNode(n3);
529       break;
530     default:
531       ;
532     }
533     n5 = jj_consume_token(35);
534             n4 = JTBToolkit.makeNodeToken(n5);
535      {if (true) return new Arguments(n0,n2,n4);}
536     throw new Error("Missing return statement in function");
537   }
538 
539   final public ArgumentList ArgumentList() throws ParseException {
540    Expression n0;
541    NodeListOptional n1 = new NodeListOptional();
542    NodeSequence n2;
543    NodeToken n3;
544    Token n4;
545    Expression n5;
546     n0 = Expression();
547     label_8:
548     while (true) {
549       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
550       case 37:
551         ;
552         break;
553       default:
554         break label_8;
555       }
556         n2 = new NodeSequence(2);
557       n4 = jj_consume_token(37);
558                n3 = JTBToolkit.makeNodeToken(n4);
559         n2.addNode(n3);
560       n5 = Expression();
561         n2.addNode(n5);
562         n1.addNode(n2);
563     }
564      n1.nodes.trimToSize();
565      {if (true) return new ArgumentList(n0,n1);}
566     throw new Error("Missing return statement in function");
567   }
568 
569   final public Literal Literal() throws ParseException {
570    NodeChoice n0;
571    NodeToken n1;
572    Token n2;
573    NodeToken n3;
574    Token n4;
575    NodeToken n5;
576    Token n6;
577    NodeToken n7;
578    Token n8;
579    BooleanLiteral n9;
580    NullLiteral n10;
581     switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
582     case INTEGER_LITERAL:
583       n2 = jj_consume_token(INTEGER_LITERAL);
584                              n1 = JTBToolkit.makeNodeToken(n2);
585         n0 = new NodeChoice(n1, 0);
586       break;
587     case FLOATING_POINT_LITERAL:
588       n4 = jj_consume_token(FLOATING_POINT_LITERAL);
589                                     n3 = JTBToolkit.makeNodeToken(n4);
590         n0 = new NodeChoice(n3, 1);
591       break;
592     case CHARACTER_LITERAL:
593       n6 = jj_consume_token(CHARACTER_LITERAL);
594                                n5 = JTBToolkit.makeNodeToken(n6);
595         n0 = new NodeChoice(n5, 2);
596       break;
597     case STRING_LITERAL:
598       n8 = jj_consume_token(STRING_LITERAL);
599                             n7 = JTBToolkit.makeNodeToken(n8);
600         n0 = new NodeChoice(n7, 3);
601       break;
602     case TRUE:
603     case FALSE:
604       n9 = BooleanLiteral();
605         n0 = new NodeChoice(n9, 4);
606       break;
607     case NULL:
608       n10 = NullLiteral();
609         n0 = new NodeChoice(n10, 5);
610       break;
611     default:
612       jj_consume_token(-1);
613       throw new ParseException();
614     }
615      {if (true) return new Literal(n0);}
616     throw new Error("Missing return statement in function");
617   }
618 
619   final public BooleanLiteral BooleanLiteral() throws ParseException {
620    NodeChoice n0;
621    NodeToken n1;
622    Token n2;
623    NodeToken n3;
624    Token n4;
625     switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
626     case TRUE:
627       n2 = jj_consume_token(TRUE);
628                   n1 = JTBToolkit.makeNodeToken(n2);
629         n0 = new NodeChoice(n1, 0);
630       break;
631     case FALSE:
632       n4 = jj_consume_token(FALSE);
633                    n3 = JTBToolkit.makeNodeToken(n4);
634         n0 = new NodeChoice(n3, 1);
635       break;
636     default:
637       jj_consume_token(-1);
638       throw new ParseException();
639     }
640      {if (true) return new BooleanLiteral(n0);}
641     throw new Error("Missing return statement in function");
642   }
643 
644   final public NullLiteral NullLiteral() throws ParseException {
645    NodeToken n0;
646    Token n1;
647     n1 = jj_consume_token(NULL);
648                n0 = JTBToolkit.makeNodeToken(n1);
649      {if (true) return new NullLiteral(n0);}
650     throw new Error("Missing return statement in function");
651   }
652 
653   private boolean jj_2_1(int xla) {
654     jj_la = xla; jj_lastpos = jj_scanpos = token;
655     try { return !jj_3_1(); }
656     catch(LookaheadSuccess ls) { return true; }
657   }
658 
659   private boolean jj_2_2(int xla) {
660     jj_la = xla; jj_lastpos = jj_scanpos = token;
661     try { return !jj_3_2(); }
662     catch(LookaheadSuccess ls) { return true; }
663   }
664 
665   private boolean jj_3_2() {
666     if (jj_3R_10()) return true;
667     return false;
668   }
669 
670   private boolean jj_3R_9() {
671     if (jj_scan_token(IDENTIFIER)) return true;
672     if (jj_3R_11()) return true;
673     return false;
674   }
675 
676   private boolean jj_3R_10() {
677     if (jj_scan_token(IDENTIFIER)) return true;
678     Token xsp;
679     while (true) {
680       xsp = jj_scanpos;
681       if (jj_3R_12()) { jj_scanpos = xsp; break; }
682     }
683     return false;
684   }
685 
686   private boolean jj_3_1() {
687     if (jj_3R_9()) return true;
688     return false;
689   }
690 
691   private boolean jj_3R_11() {
692     if (jj_scan_token(34)) return true;
693     return false;
694   }
695 
696   private boolean jj_3R_12() {
697     if (jj_scan_token(36)) return true;
698     return false;
699   }
700 
701   /** Generated Token Manager. */
702   public ExpressionParserTokenManager token_source;
703   JavaCharStream jj_input_stream;
704   /** Current token. */
705   public Token token;
706   /** Next token. */
707   public Token jj_nt;
708   private int jj_ntk;
709   private Token jj_scanpos, jj_lastpos;
710   private int jj_la;
711 
712   /** Constructor with InputStream. */
713   public ExpressionParser(java.io.InputStream stream) {
714      this(stream, null);
715   }
716   /** Constructor with InputStream and supplied encoding */
717   public ExpressionParser(java.io.InputStream stream, String encoding) {
718     try { jj_input_stream = new JavaCharStream(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); }
719     token_source = new ExpressionParserTokenManager(jj_input_stream);
720     token = new Token();
721     jj_ntk = -1;
722   }
723 
724   /** Reinitialise. */
725   public void ReInit(java.io.InputStream stream) {
726      ReInit(stream, null);
727   }
728   /** Reinitialise. */
729   public void ReInit(java.io.InputStream stream, String encoding) {
730     try { jj_input_stream.ReInit(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); }
731     token_source.ReInit(jj_input_stream);
732     token = new Token();
733     jj_ntk = -1;
734   }
735 
736   /** Constructor. */
737   public ExpressionParser(java.io.Reader stream) {
738     jj_input_stream = new JavaCharStream(stream, 1, 1);
739     token_source = new ExpressionParserTokenManager(jj_input_stream);
740     token = new Token();
741     jj_ntk = -1;
742   }
743 
744   /** Reinitialise. */
745   public void ReInit(java.io.Reader stream) {
746     jj_input_stream.ReInit(stream, 1, 1);
747     token_source.ReInit(jj_input_stream);
748     token = new Token();
749     jj_ntk = -1;
750   }
751 
752   /** Constructor with generated Token Manager. */
753   public ExpressionParser(ExpressionParserTokenManager tm) {
754     token_source = tm;
755     token = new Token();
756     jj_ntk = -1;
757   }
758 
759   /** Reinitialise. */
760   public void ReInit(ExpressionParserTokenManager tm) {
761     token_source = tm;
762     token = new Token();
763     jj_ntk = -1;
764   }
765 
766   private Token jj_consume_token(int kind) throws ParseException {
767     Token oldToken;
768     if ((oldToken = token).next != null) token = token.next;
769     else token = token.next = token_source.getNextToken();
770     jj_ntk = -1;
771     if (token.kind == kind) {
772       return token;
773     }
774     token = oldToken;
775     throw generateParseException();
776   }
777 
778   static private final class LookaheadSuccess extends java.lang.Error { }
779   final private LookaheadSuccess jj_ls = new LookaheadSuccess();
780   private boolean jj_scan_token(int kind) {
781     if (jj_scanpos == jj_lastpos) {
782       jj_la--;
783       if (jj_scanpos.next == null) {
784         jj_lastpos = jj_scanpos = jj_scanpos.next = token_source.getNextToken();
785       } else {
786         jj_lastpos = jj_scanpos = jj_scanpos.next;
787       }
788     } else {
789       jj_scanpos = jj_scanpos.next;
790     }
791     if (jj_scanpos.kind != kind) return true;
792     if (jj_la == 0 && jj_scanpos == jj_lastpos) throw jj_ls;
793     return false;
794   }
795 
796 
797 /** Get the next Token. */
798   final public Token getNextToken() {
799     if (token.next != null) token = token.next;
800     else token = token.next = token_source.getNextToken();
801     jj_ntk = -1;
802     return token;
803   }
804 
805 /** Get the specific Token. */
806   final public Token getToken(int index) {
807     Token t = token;
808     for (int i = 0; i < index; i++) {
809       if (t.next != null) t = t.next;
810       else t = t.next = token_source.getNextToken();
811     }
812     return t;
813   }
814 
815   private int jj_ntk() {
816     if ((jj_nt=token.next) == null)
817       return (jj_ntk = (token.next=token_source.getNextToken()).kind);
818     else
819       return (jj_ntk = jj_nt.kind);
820   }
821 
822   /** Generate ParseException. */
823   public ParseException generateParseException() {
824     Token errortok = token.next;
825     int line = errortok.beginLine, column = errortok.beginColumn;
826     String mess = (errortok.kind == 0) ? tokenImage[0] : errortok.image;
827     return new ParseException("Parse error at line " + line + ", column " + column + ".  Encountered: " + mess);
828   }
829 
830   /** Enable tracing. */
831   final public void enable_tracing() {
832   }
833 
834   /** Disable tracing. */
835   final public void disable_tracing() {
836   }
837 
838 }
839 
840 class JTBToolkit {
841    static NodeToken makeNodeToken(Token t) {
842       return new NodeToken(t.image.intern(), t.kind, t.beginLine, t.beginColumn, t.endLine, t.endColumn);
843    }
844 }