summaryrefslogtreecommitdiff
path: root/src/kanga/KangaParser.java
blob: a476c1c518fcd8fb293343ebfea36663044b8e2d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
package kanga;
/* Generated By:JavaCC: Do not edit this line. KangaParser.java */
import kanga.syntaxtree.ALoadStmt;
import kanga.syntaxtree.AStoreStmt;
import kanga.syntaxtree.BinOp;
import kanga.syntaxtree.CJumpStmt;
import kanga.syntaxtree.CallStmt;
import kanga.syntaxtree.ErrorStmt;
import kanga.syntaxtree.Exp;
import kanga.syntaxtree.Goal;
import kanga.syntaxtree.HAllocate;
import kanga.syntaxtree.HLoadStmt;
import kanga.syntaxtree.HStoreStmt;
import kanga.syntaxtree.IntegerLiteral;
import kanga.syntaxtree.JumpStmt;
import kanga.syntaxtree.Label;
import kanga.syntaxtree.MoveStmt;
import kanga.syntaxtree.NoOpStmt;
import kanga.syntaxtree.NodeChoice;
import kanga.syntaxtree.NodeListOptional;
import kanga.syntaxtree.NodeOptional;
import kanga.syntaxtree.NodeSequence;
import kanga.syntaxtree.NodeToken;
import kanga.syntaxtree.Operator;
import kanga.syntaxtree.PassArgStmt;
import kanga.syntaxtree.PrintStmt;
import kanga.syntaxtree.Procedure;
import kanga.syntaxtree.Reg;
import kanga.syntaxtree.SimpleExp;
import kanga.syntaxtree.SpilledArg;
import kanga.syntaxtree.Stmt;
import kanga.syntaxtree.StmtList;


public class KangaParser implements KangaParserConstants {

  static final public Goal Goal() throws ParseException {
   NodeToken n0;
   Token n1;
   NodeToken n2;
   Token n3;
   IntegerLiteral n4;
   NodeToken n5;
   Token n6;
   NodeToken n7;
   Token n8;
   IntegerLiteral n9;
   NodeToken n10;
   Token n11;
   NodeToken n12;
   Token n13;
   IntegerLiteral n14;
   NodeToken n15;
   Token n16;
   StmtList n17;
   NodeToken n18;
   Token n19;
   NodeListOptional n20 = new NodeListOptional();
   Procedure n21;
   NodeToken n22;
   Token n23;
    n1 = jj_consume_token(MAIN);
               n0 = JTBToolkit.makeNodeToken(n1);
    n3 = jj_consume_token(LSQPAREN);
            n2 = JTBToolkit.makeNodeToken(n3);
    n4 = IntegerLiteral();
    n6 = jj_consume_token(RSQPAREN);
            n5 = JTBToolkit.makeNodeToken(n6);
    n8 = jj_consume_token(LSQPAREN);
            n7 = JTBToolkit.makeNodeToken(n8);
    n9 = IntegerLiteral();
    n11 = jj_consume_token(RSQPAREN);
             n10 = JTBToolkit.makeNodeToken(n11);
    n13 = jj_consume_token(LSQPAREN);
             n12 = JTBToolkit.makeNodeToken(n13);
    n14 = IntegerLiteral();
    n16 = jj_consume_token(RSQPAREN);
             n15 = JTBToolkit.makeNodeToken(n16);
    n17 = StmtList();
    n19 = jj_consume_token(END);
               n18 = JTBToolkit.makeNodeToken(n19);
    label_1:
    while (true) {
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case IDENTIFIER:
        ;
        break;
      default:
        jj_la1[0] = jj_gen;
        break label_1;
      }
      n21 = Procedure();
        n20.addNode(n21);
    }
     n20.nodes.trimToSize();
    n23 = jj_consume_token(0);
      n23.beginColumn++; n23.endColumn++;
      n22 = JTBToolkit.makeNodeToken(n23);
     {if (true) return new Goal(n0,n2,n4,n5,n7,n9,n10,n12,n14,n15,n17,n18,n20,n22);}
    throw new Error("Missing return statement in function");
  }

  static final public StmtList StmtList() throws ParseException {
   NodeListOptional n0 = new NodeListOptional();
   NodeSequence n1;
   NodeOptional n2;
   Label n3;
   Stmt n4;
    label_2:
    while (true) {
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case NOOP:
      case MOVE:
      case CALL:
      case ERROR:
      case PRINT:
      case JUMP:
      case CJUMP:
      case HSTORE:
      case HLOAD:
      case ALOAD:
      case ASTORE:
      case PASSARG:
      case IDENTIFIER:
        ;
        break;
      default:
        jj_la1[1] = jj_gen;
        break label_2;
      }
        n2 = new NodeOptional();
        n1 = new NodeSequence(2);
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case IDENTIFIER:
        n3 = Label();
           n2.addNode(n3);
        break;
      default:
        jj_la1[2] = jj_gen;
        ;
      }
        n1.addNode(n2);
      n4 = Stmt();
        n1.addNode(n4);
        n0.addNode(n1);
    }
     n0.nodes.trimToSize();
     {if (true) return new StmtList(n0);}
    throw new Error("Missing return statement in function");
  }

  static final public Procedure Procedure() throws ParseException {
   Label n0;
   NodeToken n1;
   Token n2;
   IntegerLiteral n3;
   NodeToken n4;
   Token n5;
   NodeToken n6;
   Token n7;
   IntegerLiteral n8;
   NodeToken n9;
   Token n10;
   NodeToken n11;
   Token n12;
   IntegerLiteral n13;
   NodeToken n14;
   Token n15;
   StmtList n16;
   NodeToken n17;
   Token n18;
    n0 = Label();
    n2 = jj_consume_token(LSQPAREN);
            n1 = JTBToolkit.makeNodeToken(n2);
    n3 = IntegerLiteral();
    n5 = jj_consume_token(RSQPAREN);
            n4 = JTBToolkit.makeNodeToken(n5);
    n7 = jj_consume_token(LSQPAREN);
            n6 = JTBToolkit.makeNodeToken(n7);
    n8 = IntegerLiteral();
    n10 = jj_consume_token(RSQPAREN);
             n9 = JTBToolkit.makeNodeToken(n10);
    n12 = jj_consume_token(LSQPAREN);
             n11 = JTBToolkit.makeNodeToken(n12);
    n13 = IntegerLiteral();
    n15 = jj_consume_token(RSQPAREN);
             n14 = JTBToolkit.makeNodeToken(n15);
    n16 = StmtList();
    n18 = jj_consume_token(END);
               n17 = JTBToolkit.makeNodeToken(n18);
     {if (true) return new Procedure(n0,n1,n3,n4,n6,n8,n9,n11,n13,n14,n16,n17);}
    throw new Error("Missing return statement in function");
  }

  static final public Stmt Stmt() throws ParseException {
   NodeChoice n0;
   NoOpStmt n1;
   ErrorStmt n2;
   CJumpStmt n3;
   JumpStmt n4;
   HStoreStmt n5;
   HLoadStmt n6;
   MoveStmt n7;
   PrintStmt n8;
   ALoadStmt n9;
   AStoreStmt n10;
   PassArgStmt n11;
   CallStmt n12;
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case NOOP:
      n1 = NoOpStmt();
        n0 = new NodeChoice(n1, 0);
      break;
    case ERROR:
      n2 = ErrorStmt();
        n0 = new NodeChoice(n2, 1);
      break;
    case CJUMP:
      n3 = CJumpStmt();
        n0 = new NodeChoice(n3, 2);
      break;
    case JUMP:
      n4 = JumpStmt();
        n0 = new NodeChoice(n4, 3);
      break;
    case HSTORE:
      n5 = HStoreStmt();
        n0 = new NodeChoice(n5, 4);
      break;
    case HLOAD:
      n6 = HLoadStmt();
        n0 = new NodeChoice(n6, 5);
      break;
    case MOVE:
      n7 = MoveStmt();
        n0 = new NodeChoice(n7, 6);
      break;
    case PRINT:
      n8 = PrintStmt();
        n0 = new NodeChoice(n8, 7);
      break;
    case ALOAD:
      n9 = ALoadStmt();
        n0 = new NodeChoice(n9, 8);
      break;
    case ASTORE:
      n10 = AStoreStmt();
        n0 = new NodeChoice(n10, 9);
      break;
    case PASSARG:
      n11 = PassArgStmt();
        n0 = new NodeChoice(n11, 10);
      break;
    case CALL:
      n12 = CallStmt();
        n0 = new NodeChoice(n12, 11);
      break;
    default:
      jj_la1[3] = jj_gen;
      jj_consume_token(-1);
      throw new ParseException();
    }
     {if (true) return new Stmt(n0);}
    throw new Error("Missing return statement in function");
  }

  static final public NoOpStmt NoOpStmt() throws ParseException {
   NodeToken n0;
   Token n1;
    n1 = jj_consume_token(NOOP);
               n0 = JTBToolkit.makeNodeToken(n1);
     {if (true) return new NoOpStmt(n0);}
    throw new Error("Missing return statement in function");
  }

  static final public ErrorStmt ErrorStmt() throws ParseException {
   NodeToken n0;
   Token n1;
    n1 = jj_consume_token(ERROR);
                n0 = JTBToolkit.makeNodeToken(n1);
     {if (true) return new ErrorStmt(n0);}
    throw new Error("Missing return statement in function");
  }

  static final public CJumpStmt CJumpStmt() throws ParseException {
   NodeToken n0;
   Token n1;
   Reg n2;
   Label n3;
    n1 = jj_consume_token(CJUMP);
                n0 = JTBToolkit.makeNodeToken(n1);
    n2 = Reg();
    n3 = Label();
     {if (true) return new CJumpStmt(n0,n2,n3);}
    throw new Error("Missing return statement in function");
  }

  static final public JumpStmt JumpStmt() throws ParseException {
   NodeToken n0;
   Token n1;
   Label n2;
    n1 = jj_consume_token(JUMP);
               n0 = JTBToolkit.makeNodeToken(n1);
    n2 = Label();
     {if (true) return new JumpStmt(n0,n2);}
    throw new Error("Missing return statement in function");
  }

  static final public HStoreStmt HStoreStmt() throws ParseException {
   NodeToken n0;
   Token n1;
   Reg n2;
   IntegerLiteral n3;
   Reg n4;
    n1 = jj_consume_token(HSTORE);
                 n0 = JTBToolkit.makeNodeToken(n1);
    n2 = Reg();
    n3 = IntegerLiteral();
    n4 = Reg();
     {if (true) return new HStoreStmt(n0,n2,n3,n4);}
    throw new Error("Missing return statement in function");
  }

  static final public HLoadStmt HLoadStmt() throws ParseException {
   NodeToken n0;
   Token n1;
   Reg n2;
   Reg n3;
   IntegerLiteral n4;
    n1 = jj_consume_token(HLOAD);
                n0 = JTBToolkit.makeNodeToken(n1);
    n2 = Reg();
    n3 = Reg();
    n4 = IntegerLiteral();
     {if (true) return new HLoadStmt(n0,n2,n3,n4);}
    throw new Error("Missing return statement in function");
  }

  static final public MoveStmt MoveStmt() throws ParseException {
   NodeToken n0;
   Token n1;
   Reg n2;
   Exp n3;
    n1 = jj_consume_token(MOVE);
               n0 = JTBToolkit.makeNodeToken(n1);
    n2 = Reg();
    n3 = Exp();
     {if (true) return new MoveStmt(n0,n2,n3);}
    throw new Error("Missing return statement in function");
  }

  static final public PrintStmt PrintStmt() throws ParseException {
   NodeToken n0;
   Token n1;
   SimpleExp n2;
    n1 = jj_consume_token(PRINT);
                n0 = JTBToolkit.makeNodeToken(n1);
    n2 = SimpleExp();
     {if (true) return new PrintStmt(n0,n2);}
    throw new Error("Missing return statement in function");
  }

  static final public ALoadStmt ALoadStmt() throws ParseException {
   NodeToken n0;
   Token n1;
   Reg n2;
   SpilledArg n3;
    n1 = jj_consume_token(ALOAD);
                n0 = JTBToolkit.makeNodeToken(n1);
    n2 = Reg();
    n3 = SpilledArg();
     {if (true) return new ALoadStmt(n0,n2,n3);}
    throw new Error("Missing return statement in function");
  }

  static final public AStoreStmt AStoreStmt() throws ParseException {
   NodeToken n0;
   Token n1;
   SpilledArg n2;
   Reg n3;
    n1 = jj_consume_token(ASTORE);
                 n0 = JTBToolkit.makeNodeToken(n1);
    n2 = SpilledArg();
    n3 = Reg();
     {if (true) return new AStoreStmt(n0,n2,n3);}
    throw new Error("Missing return statement in function");
  }

  static final public PassArgStmt PassArgStmt() throws ParseException {
   NodeToken n0;
   Token n1;
   IntegerLiteral n2;
   Reg n3;
    n1 = jj_consume_token(PASSARG);
                  n0 = JTBToolkit.makeNodeToken(n1);
    n2 = IntegerLiteral();
    n3 = Reg();
     {if (true) return new PassArgStmt(n0,n2,n3);}
    throw new Error("Missing return statement in function");
  }

  static final public CallStmt CallStmt() throws ParseException {
   NodeToken n0;
   Token n1;
   SimpleExp n2;
    n1 = jj_consume_token(CALL);
               n0 = JTBToolkit.makeNodeToken(n1);
    n2 = SimpleExp();
     {if (true) return new CallStmt(n0,n2);}
    throw new Error("Missing return statement in function");
  }

  static final public Exp Exp() throws ParseException {
   NodeChoice n0;
   HAllocate n1;
   BinOp n2;
   SimpleExp n3;
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case HALLOCATE:
      n1 = HAllocate();
        n0 = new NodeChoice(n1, 0);
      break;
    case LT:
    case PLUS:
    case MINUS:
    case TIMES:
      n2 = BinOp();
        n0 = new NodeChoice(n2, 1);
      break;
    case v0:
    case v1:
    case a0:
    case a1:
    case a2:
    case a3:
    case t0:
    case t1:
    case t2:
    case t3:
    case t4:
    case t5:
    case t6:
    case t7:
    case s0:
    case s1:
    case s2:
    case s3:
    case s4:
    case s5:
    case s6:
    case s7:
    case t8:
    case t9:
    case INTEGER_LITERAL:
    case IDENTIFIER:
      n3 = SimpleExp();
        n0 = new NodeChoice(n3, 2);
      break;
    default:
      jj_la1[4] = jj_gen;
      jj_consume_token(-1);
      throw new ParseException();
    }
     {if (true) return new Exp(n0);}
    throw new Error("Missing return statement in function");
  }

  static final public HAllocate HAllocate() throws ParseException {
   NodeToken n0;
   Token n1;
   SimpleExp n2;
    n1 = jj_consume_token(HALLOCATE);
                    n0 = JTBToolkit.makeNodeToken(n1);
    n2 = SimpleExp();
     {if (true) return new HAllocate(n0,n2);}
    throw new Error("Missing return statement in function");
  }

  static final public BinOp BinOp() throws ParseException {
   Operator n0;
   Reg n1;
   SimpleExp n2;
    n0 = Operator();
    n1 = Reg();
    n2 = SimpleExp();
     {if (true) return new BinOp(n0,n1,n2);}
    throw new Error("Missing return statement in function");
  }

  static final public Operator Operator() throws ParseException {
   NodeChoice n0;
   NodeToken n1;
   Token n2;
   NodeToken n3;
   Token n4;
   NodeToken n5;
   Token n6;
   NodeToken n7;
   Token n8;
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case LT:
      n2 = jj_consume_token(LT);
                n1 = JTBToolkit.makeNodeToken(n2);
        n0 = new NodeChoice(n1, 0);
      break;
    case PLUS:
      n4 = jj_consume_token(PLUS);
                  n3 = JTBToolkit.makeNodeToken(n4);
        n0 = new NodeChoice(n3, 1);
      break;
    case MINUS:
      n6 = jj_consume_token(MINUS);
                   n5 = JTBToolkit.makeNodeToken(n6);
        n0 = new NodeChoice(n5, 2);
      break;
    case TIMES:
      n8 = jj_consume_token(TIMES);
                   n7 = JTBToolkit.makeNodeToken(n8);
        n0 = new NodeChoice(n7, 3);
      break;
    default:
      jj_la1[5] = jj_gen;
      jj_consume_token(-1);
      throw new ParseException();
    }
     {if (true) return new Operator(n0);}
    throw new Error("Missing return statement in function");
  }

  static final public SpilledArg SpilledArg() throws ParseException {
   NodeToken n0;
   Token n1;
   IntegerLiteral n2;
    n1 = jj_consume_token(SPILLEDARG);
                     n0 = JTBToolkit.makeNodeToken(n1);
    n2 = IntegerLiteral();
     {if (true) return new SpilledArg(n0,n2);}
    throw new Error("Missing return statement in function");
  }

  static final public SimpleExp SimpleExp() throws ParseException {
   NodeChoice n0;
   Reg n1;
   IntegerLiteral n2;
   Label n3;
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case v0:
    case v1:
    case a0:
    case a1:
    case a2:
    case a3:
    case t0:
    case t1:
    case t2:
    case t3:
    case t4:
    case t5:
    case t6:
    case t7:
    case s0:
    case s1:
    case s2:
    case s3:
    case s4:
    case s5:
    case s6:
    case s7:
    case t8:
    case t9:
      n1 = Reg();
        n0 = new NodeChoice(n1, 0);
      break;
    case INTEGER_LITERAL:
      n2 = IntegerLiteral();
        n0 = new NodeChoice(n2, 1);
      break;
    case IDENTIFIER:
      n3 = Label();
        n0 = new NodeChoice(n3, 2);
      break;
    default:
      jj_la1[6] = jj_gen;
      jj_consume_token(-1);
      throw new ParseException();
    }
     {if (true) return new SimpleExp(n0);}
    throw new Error("Missing return statement in function");
  }

  static final public Reg Reg() throws ParseException {
   NodeChoice n0;
   NodeToken n1;
   Token n2;
   NodeToken n3;
   Token n4;
   NodeToken n5;
   Token n6;
   NodeToken n7;
   Token n8;
   NodeToken n9;
   Token n10;
   NodeToken n11;
   Token n12;
   NodeToken n13;
   Token n14;
   NodeToken n15;
   Token n16;
   NodeToken n17;
   Token n18;
   NodeToken n19;
   Token n20;
   NodeToken n21;
   Token n22;
   NodeToken n23;
   Token n24;
   NodeToken n25;
   Token n26;
   NodeToken n27;
   Token n28;
   NodeToken n29;
   Token n30;
   NodeToken n31;
   Token n32;
   NodeToken n33;
   Token n34;
   NodeToken n35;
   Token n36;
   NodeToken n37;
   Token n38;
   NodeToken n39;
   Token n40;
   NodeToken n41;
   Token n42;
   NodeToken n43;
   Token n44;
   NodeToken n45;
   Token n46;
   NodeToken n47;
   Token n48;
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case a0:
      n2 = jj_consume_token(a0);
                n1 = JTBToolkit.makeNodeToken(n2);
        n0 = new NodeChoice(n1, 0);
      break;
    case a1:
      n4 = jj_consume_token(a1);
                n3 = JTBToolkit.makeNodeToken(n4);
        n0 = new NodeChoice(n3, 1);
      break;
    case a2:
      n6 = jj_consume_token(a2);
                n5 = JTBToolkit.makeNodeToken(n6);
        n0 = new NodeChoice(n5, 2);
      break;
    case a3:
      n8 = jj_consume_token(a3);
                n7 = JTBToolkit.makeNodeToken(n8);
        n0 = new NodeChoice(n7, 3);
      break;
    case t0:
      n10 = jj_consume_token(t0);
                 n9 = JTBToolkit.makeNodeToken(n10);
        n0 = new NodeChoice(n9, 4);
      break;
    case t1:
      n12 = jj_consume_token(t1);
                 n11 = JTBToolkit.makeNodeToken(n12);
        n0 = new NodeChoice(n11, 5);
      break;
    case t2:
      n14 = jj_consume_token(t2);
                 n13 = JTBToolkit.makeNodeToken(n14);
        n0 = new NodeChoice(n13, 6);
      break;
    case t3:
      n16 = jj_consume_token(t3);
                 n15 = JTBToolkit.makeNodeToken(n16);
        n0 = new NodeChoice(n15, 7);
      break;
    case t4:
      n18 = jj_consume_token(t4);
                 n17 = JTBToolkit.makeNodeToken(n18);
        n0 = new NodeChoice(n17, 8);
      break;
    case t5:
      n20 = jj_consume_token(t5);
                 n19 = JTBToolkit.makeNodeToken(n20);
        n0 = new NodeChoice(n19, 9);
      break;
    case t6:
      n22 = jj_consume_token(t6);
                 n21 = JTBToolkit.makeNodeToken(n22);
        n0 = new NodeChoice(n21, 10);
      break;
    case t7:
      n24 = jj_consume_token(t7);
                 n23 = JTBToolkit.makeNodeToken(n24);
        n0 = new NodeChoice(n23, 11);
      break;
    case s0:
      n26 = jj_consume_token(s0);
                 n25 = JTBToolkit.makeNodeToken(n26);
        n0 = new NodeChoice(n25, 12);
      break;
    case s1:
      n28 = jj_consume_token(s1);
                 n27 = JTBToolkit.makeNodeToken(n28);
        n0 = new NodeChoice(n27, 13);
      break;
    case s2:
      n30 = jj_consume_token(s2);
                 n29 = JTBToolkit.makeNodeToken(n30);
        n0 = new NodeChoice(n29, 14);
      break;
    case s3:
      n32 = jj_consume_token(s3);
                 n31 = JTBToolkit.makeNodeToken(n32);
        n0 = new NodeChoice(n31, 15);
      break;
    case s4:
      n34 = jj_consume_token(s4);
                 n33 = JTBToolkit.makeNodeToken(n34);
        n0 = new NodeChoice(n33, 16);
      break;
    case s5:
      n36 = jj_consume_token(s5);
                 n35 = JTBToolkit.makeNodeToken(n36);
        n0 = new NodeChoice(n35, 17);
      break;
    case s6:
      n38 = jj_consume_token(s6);
                 n37 = JTBToolkit.makeNodeToken(n38);
        n0 = new NodeChoice(n37, 18);
      break;
    case s7:
      n40 = jj_consume_token(s7);
                 n39 = JTBToolkit.makeNodeToken(n40);
        n0 = new NodeChoice(n39, 19);
      break;
    case t8:
      n42 = jj_consume_token(t8);
                 n41 = JTBToolkit.makeNodeToken(n42);
        n0 = new NodeChoice(n41, 20);
      break;
    case t9:
      n44 = jj_consume_token(t9);
                 n43 = JTBToolkit.makeNodeToken(n44);
        n0 = new NodeChoice(n43, 21);
      break;
    case v0:
      n46 = jj_consume_token(v0);
                 n45 = JTBToolkit.makeNodeToken(n46);
        n0 = new NodeChoice(n45, 22);
      break;
    case v1:
      n48 = jj_consume_token(v1);
                 n47 = JTBToolkit.makeNodeToken(n48);
        n0 = new NodeChoice(n47, 23);
      break;
    default:
      jj_la1[7] = jj_gen;
      jj_consume_token(-1);
      throw new ParseException();
    }
     {if (true) return new Reg(n0);}
    throw new Error("Missing return statement in function");
  }

  static final public IntegerLiteral IntegerLiteral() throws ParseException {
   NodeToken n0;
   Token n1;
    n1 = jj_consume_token(INTEGER_LITERAL);
                          n0 = JTBToolkit.makeNodeToken(n1);
     {if (true) return new IntegerLiteral(n0);}
    throw new Error("Missing return statement in function");
  }

  static final public Label Label() throws ParseException {
   NodeToken n0;
   Token n1;
    n1 = jj_consume_token(IDENTIFIER);
                     n0 = JTBToolkit.makeNodeToken(n1);
     {if (true) return new Label(n0);}
    throw new Error("Missing return statement in function");
  }

  static private boolean jj_initialized_once = false;
  static public KangaParserTokenManager token_source;
  static JavaCharStream jj_input_stream;
  static public Token token, jj_nt;
  static private int jj_ntk;
  static private int jj_gen;
  static final private int[] jj_la1 = new int[8];
  static private int[] jj_la1_0;
  static private int[] jj_la1_1;
  static private int[] jj_la1_2;
  static {
      jj_la1_0();
      jj_la1_1();
      jj_la1_2();
   }
   private static void jj_la1_0() {
      jj_la1_0 = new int[] {0x0,0x0,0x0,0x0,0x48c10000,0x8c10000,0x0,0x0,};
   }
   private static void jj_la1_1() {
      jj_la1_1 = new int[] {0x0,0x7f3e,0x0,0x7f3e,0xfff00000,0x0,0xfff00000,0xfff00000,};
   }
   private static void jj_la1_2() {
      jj_la1_2 = new int[] {0x80000,0x80000,0x80000,0x0,0xc0fff,0x0,0xc0fff,0xfff,};
   }

  public KangaParser(java.io.InputStream stream) {
     this(stream, null);
  }
  public KangaParser(java.io.InputStream stream, String encoding) {
    if (jj_initialized_once) {
      System.out.println("ERROR: Second call to constructor of static parser.  You must");
      System.out.println("       either use ReInit() or set the JavaCC option STATIC to false");
      System.out.println("       during parser generation.");
      throw new Error();
    }
    jj_initialized_once = true;
    try { jj_input_stream = new JavaCharStream(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); }
    token_source = new KangaParserTokenManager(jj_input_stream);
    token = new Token();
    jj_ntk = -1;
    jj_gen = 0;
    for (int i = 0; i < 8; i++) jj_la1[i] = -1;
  }

  static public void ReInit(java.io.InputStream stream) {
     ReInit(stream, null);
  }
  static public void ReInit(java.io.InputStream stream, String encoding) {
    try { jj_input_stream.ReInit(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); }
    token_source.ReInit(jj_input_stream);
    token = new Token();
    jj_ntk = -1;
    jj_gen = 0;
    for (int i = 0; i < 8; i++) jj_la1[i] = -1;
  }

  public KangaParser(java.io.Reader stream) {
    if (jj_initialized_once) {
      System.out.println("ERROR: Second call to constructor of static parser.  You must");
      System.out.println("       either use ReInit() or set the JavaCC option STATIC to false");
      System.out.println("       during parser generation.");
      throw new Error();
    }
    jj_initialized_once = true;
    jj_input_stream = new JavaCharStream(stream, 1, 1);
    token_source = new KangaParserTokenManager(jj_input_stream);
    token = new Token();
    jj_ntk = -1;
    jj_gen = 0;
    for (int i = 0; i < 8; i++) jj_la1[i] = -1;
  }

  static public void ReInit(java.io.Reader stream) {
    jj_input_stream.ReInit(stream, 1, 1);
    token_source.ReInit(jj_input_stream);
    token = new Token();
    jj_ntk = -1;
    jj_gen = 0;
    for (int i = 0; i < 8; i++) jj_la1[i] = -1;
  }

  public KangaParser(KangaParserTokenManager tm) {
    if (jj_initialized_once) {
      System.out.println("ERROR: Second call to constructor of static parser.  You must");
      System.out.println("       either use ReInit() or set the JavaCC option STATIC to false");
      System.out.println("       during parser generation.");
      throw new Error();
    }
    jj_initialized_once = true;
    token_source = tm;
    token = new Token();
    jj_ntk = -1;
    jj_gen = 0;
    for (int i = 0; i < 8; i++) jj_la1[i] = -1;
  }

  public void ReInit(KangaParserTokenManager tm) {
    token_source = tm;
    token = new Token();
    jj_ntk = -1;
    jj_gen = 0;
    for (int i = 0; i < 8; i++) jj_la1[i] = -1;
  }

  static final private Token jj_consume_token(int kind) throws ParseException {
    Token oldToken;
    if ((oldToken = token).next != null) token = token.next;
    else token = token.next = token_source.getNextToken();
    jj_ntk = -1;
    if (token.kind == kind) {
      jj_gen++;
      return token;
    }
    token = oldToken;
    jj_kind = kind;
    throw generateParseException();
  }

  static final public Token getNextToken() {
    if (token.next != null) token = token.next;
    else token = token.next = token_source.getNextToken();
    jj_ntk = -1;
    jj_gen++;
    return token;
  }

  static final public Token getToken(int index) {
    Token t = token;
    for (int i = 0; i < index; i++) {
      if (t.next != null) t = t.next;
      else t = t.next = token_source.getNextToken();
    }
    return t;
  }

  static final private int jj_ntk() {
    if ((jj_nt=token.next) == null)
      return (jj_ntk = (token.next=token_source.getNextToken()).kind);
    else
      return (jj_ntk = jj_nt.kind);
  }

  static private java.util.Vector jj_expentries = new java.util.Vector();
  static private int[] jj_expentry;
  static private int jj_kind = -1;

  static public ParseException generateParseException() {
    jj_expentries.removeAllElements();
    boolean[] la1tokens = new boolean[86];
    for (int i = 0; i < 86; i++) {
      la1tokens[i] = false;
    }
    if (jj_kind >= 0) {
      la1tokens[jj_kind] = true;
      jj_kind = -1;
    }
    for (int i = 0; i < 8; i++) {
      if (jj_la1[i] == jj_gen) {
        for (int j = 0; j < 32; j++) {
          if ((jj_la1_0[i] & (1<<j)) != 0) {
            la1tokens[j] = true;
          }
          if ((jj_la1_1[i] & (1<<j)) != 0) {
            la1tokens[32+j] = true;
          }
          if ((jj_la1_2[i] & (1<<j)) != 0) {
            la1tokens[64+j] = true;
          }
        }
      }
    }
    for (int i = 0; i < 86; i++) {
      if (la1tokens[i]) {
        jj_expentry = new int[1];
        jj_expentry[0] = i;
        jj_expentries.addElement(jj_expentry);
      }
    }
    int[][] exptokseq = new int[jj_expentries.size()][];
    for (int i = 0; i < jj_expentries.size(); i++) {
      exptokseq[i] = (int[])jj_expentries.elementAt(i);
    }
    return new ParseException(token, exptokseq, tokenImage);
  }

  static final public void enable_tracing() {
  }

  static final public void disable_tracing() {
  }

}

class JTBToolkit {
   static NodeToken makeNodeToken(Token t) {
      return new NodeToken(t.image.intern(), t.kind, t.beginLine, t.beginColumn, t.endLine, t.endColumn);
   }
}