-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathParser.java
More file actions
1226 lines (1187 loc) · 29.6 KB
/
Copy pathParser.java
File metadata and controls
1226 lines (1187 loc) · 29.6 KB
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
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* Parser.java */
/* Generated By:JavaCC: Do not edit this line. Parser.java */
import java.util.*;
public class Parser implements ParserConstants {
static final public ASTNode Start() throws ParseException, InterpreterError {ASTNode t;
switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
case 0:{
jj_consume_token(0);
{if ("" != null) return null;}
break;
}
case LET:
case TYPE:
case TRUE:
case FALSE:
case MINUS:
case LPAR:
case LBRA:
case BAR:
case OR:
case NOT:
case NONE:
case CELL:
case DEREF:
case MATCH:
case IF:
case WHILE:
case PRINT:
case PRINTLN:
case TAG:
case AMPERSAND:
case String:
case Id:
case Num:{
t = Let();
jj_consume_token(TERM);
{if ("" != null) return t;}
break;
}
default:
jj_la1[0] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
throw new Error("Missing return statement in function");
}
static final public ASTNode Let() throws ParseException, InterpreterError {Token n;
ASTNode t=null, e1, e2;
ASTType t1, typ=null;
int mode = 0;
List<Bind> decls = new ArrayList<Bind>();
HashMap<String,ASTType> lbl = new HashMap<String,ASTType>();
ASTNode last=null;
boolean mut = false;
switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
case TRUE:
case FALSE:
case MINUS:
case LPAR:
case LBRA:
case BAR:
case OR:
case NOT:
case NONE:
case CELL:
case DEREF:
case MATCH:
case IF:
case WHILE:
case PRINT:
case PRINTLN:
case TAG:
case AMPERSAND:
case String:
case Id:
case Num:{
t = Seq();
break;
}
case LET:
case TYPE:{
label_1:
while (true) {
switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
case LET:{
jj_consume_token(LET);
mut = false;
switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
case MUT:{
jj_consume_token(MUT);
mut=true;
break;
}
default:
jj_la1[1] = jj_gen;
;
}
n = jj_consume_token(Id);
typ = null;
switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
case COLON:{
jj_consume_token(COLON);
typ = Type();
break;
}
default:
jj_la1[2] = jj_gen;
;
}
jj_consume_token(EQUAL);
e1 = BA();
jj_consume_token(SEMIC);
if (mode == 1) {
ASTTypeDef lasttdef = (ASTTypeDef)last;
lasttdef.body = new ASTLet(decls,null);
last = lasttdef.body;
lbl = new HashMap<String,ASTType>();
} else if (t==null) {
t = new ASTLet(decls,null);
last = t;
}
Bind b = new Bind(n.image,typ,e1);
b.mut = mut;
decls.add(b);
mode = 2;
break;
}
case TYPE:{
jj_consume_token(TYPE);
n = jj_consume_token(Id);
jj_consume_token(EQUAL);
t1 = Type();
jj_consume_token(SEMIC);
if (mode == 2) {
ASTLet lastlet = (ASTLet)last;
lastlet.body = new ASTTypeDef(lbl,null);
last = lastlet.body;
decls = new ArrayList<Bind>();
} else if (t==null) {
t = new ASTTypeDef(lbl,null);
last = t;
}
lbl.put(n.image, t1);
mode = 1;
break;
}
default:
jj_la1[3] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
case LET:
case TYPE:{
;
break;
}
default:
jj_la1[4] = jj_gen;
break label_1;
}
}
e2 = Seq();
if (mode == 1) {
ASTTypeDef lasttdef = (ASTTypeDef)last;
lasttdef.body = e2;
}
else if (mode == 2) {
ASTLet lastlet = (ASTLet)last;
lastlet.body = e2;
}
break;
}
default:
jj_la1[5] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
{if ("" != null) return t;}
throw new Error("Missing return statement in function");
}
static final public ASTNode Seq() throws ParseException, InterpreterError {Token op;
ASTNode t1, t2;
t1 = SeqExp();
label_2:
while (true) {
switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
case SEMIC:{
;
break;
}
default:
jj_la1[6] = jj_gen;
break label_2;
}
op = jj_consume_token(SEMIC);
t2 = SeqExp();
t1 = new ASTSeq(t1,t2);
}
{if ("" != null) return t1;}
throw new Error("Missing return statement in function");
}
static final public ASTNode SeqExp() throws ParseException, InterpreterError {Token op;
ASTNode t1, t2;
t1 = BA();
label_3:
while (true) {
switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
case ASSIGN:
case CASSIGN:{
;
break;
}
default:
jj_la1[7] = jj_gen;
break label_3;
}
switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
case ASSIGN:{
op = jj_consume_token(ASSIGN);
t2 = BA();
t1 = new ASTAssign(t1,t2);
break;
}
case CASSIGN:{
op = jj_consume_token(CASSIGN);
t2 = BA();
t1 = new ASTCAssign(t1,t2);
break;
}
default:
jj_la1[8] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
}
{if ("" != null) return t1;}
throw new Error("Missing return statement in function");
}
static final public ASTNode BA() throws ParseException, InterpreterError {Token op;
ASTNode t1, t2;
t1 = BM();
label_4:
while (true) {
switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
case OR:{
;
break;
}
default:
jj_la1[9] = jj_gen;
break label_4;
}
op = jj_consume_token(OR);
t2 = BM();
t1 = new ASTOr(t1, t2);
}
{if ("" != null) return t1;}
throw new Error("Missing return statement in function");
}
static final public ASTNode BM() throws ParseException, InterpreterError {Token op;
ASTNode t1, t2;
t1 = Rel();
label_5:
while (true) {
switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
case AND:{
;
break;
}
default:
jj_la1[10] = jj_gen;
break label_5;
}
op = jj_consume_token(AND);
t2 = Rel();
t1 = new ASTAnd(t1, t2);
}
{if ("" != null) return t1;}
throw new Error("Missing return statement in function");
}
static final public ASTNode Rel() throws ParseException, InterpreterError {Token op;
ASTNode t1, t2;
t1 = Exp();
switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
case EQ:
case GT:
case GE:
case LT:
case LE:
case NEQ:{
switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
case EQ:{
op = jj_consume_token(EQ);
break;
}
case GT:{
op = jj_consume_token(GT);
break;
}
case LT:{
op = jj_consume_token(LT);
break;
}
case GE:{
op = jj_consume_token(GE);
break;
}
case LE:{
op = jj_consume_token(LE);
break;
}
case NEQ:{
op = jj_consume_token(NEQ);
break;
}
default:
jj_la1[11] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
t2 = Exp();
if (op.kind == EQ) t1 = new ASTEq(t1, t2);
else if (op.kind == GT) t1 = new ASTGt(t1, t2);
else if (op.kind == LT) t1 = new ASTLt(t1, t2);
else if (op.kind == GE) t1 = new ASTGe(t1, t2);
else if (op.kind == LE) t1 = new ASTLe(t1, t2);
else if (op.kind == NEQ) t1 = new ASTNeq(t1, t2);
break;
}
default:
jj_la1[12] = jj_gen;
;
}
{if ("" != null) return t1;}
throw new Error("Missing return statement in function");
}
static final public ASTNode Exp() throws ParseException, InterpreterError {Token op;
ASTNode t1, t2;
t1 = Term();
label_6:
while (true) {
switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
case PLUS:
case MINUS:{
;
break;
}
default:
jj_la1[13] = jj_gen;
break label_6;
}
switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
case PLUS:{
op = jj_consume_token(PLUS);
break;
}
case MINUS:{
op = jj_consume_token(MINUS);
break;
}
default:
jj_la1[14] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
t2 = Term();
if (op.kind == PLUS)
t1 = new ASTPlus(t1,t2);
else t1 = new ASTSub(t1,t2);
}
{if ("" != null) return t1;}
throw new Error("Missing return statement in function");
}
static final public ASTNode Term() throws ParseException, InterpreterError {Token op;
ASTNode t1, t2;
t1 = Fact();
label_7:
while (true) {
switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
case MUL:
case DIV:{
;
break;
}
default:
jj_la1[15] = jj_gen;
break label_7;
}
switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
case MUL:{
op = jj_consume_token(MUL);
t2 = Fact();
t1 = new ASTMult(t1,t2);
break;
}
case DIV:{
op = jj_consume_token(DIV);
t2 = Fact();
t1 = new ASTDiv(t1,t2);
break;
}
default:
jj_la1[16] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
}
{if ("" != null) return t1;}
throw new Error("Missing return statement in function");
}
static final public ASTNode StructTuple() throws ParseException, InterpreterError {Token tag;
ASTNode t;
List<ASTNode> pv = new ArrayList<ASTNode>();
tag = jj_consume_token(TAG);
switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
case LPAR:{
jj_consume_token(LPAR);
t = Let();
pv.add(t);
label_8:
while (true) {
switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
case COMMA:{
;
break;
}
default:
jj_la1[17] = jj_gen;
break label_8;
}
jj_consume_token(COMMA);
t = Let();
pv.add(t);
}
jj_consume_token(RPAR);
break;
}
case NONE:{
jj_consume_token(NONE);
pv.add(new ASTUnit());
break;
}
default:
jj_la1[18] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
{if ("" != null) return new ASTStructTuple(tag.image,pv);}
throw new Error("Missing return statement in function");
}
static final public ASTNode Function() throws ParseException, InterpreterError {Token n;
ASTNode t, e1=null, e2;
ASTType typ = null;
switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
case BAR:{
jj_consume_token(BAR);
n = jj_consume_token(Id);
switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
case COLON:{
jj_consume_token(COLON);
typ = Type();
break;
}
default:
jj_la1[19] = jj_gen;
;
}
t = new ASTFun(n.image, typ, null); e1 = t;
label_9:
while (true) {
switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
case COMMA:{
;
break;
}
default:
jj_la1[20] = jj_gen;
break label_9;
}
jj_consume_token(COMMA);
n = jj_consume_token(Id);
switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
case COLON:{
jj_consume_token(COLON);
typ = Type();
break;
}
default:
jj_la1[21] = jj_gen;
;
}
e2 = new ASTFun(n.image, typ, null);
((ASTFun)e1).setBody(e2); e1 = e2;
}
jj_consume_token(BAR);
e2 = Fact();
((ASTFun)e1).setBody(e2);
break;
}
case OR:{
jj_consume_token(OR);
e2 = Fact();
t = new ASTFun("_", ASTTUnit.tunit,e2);
break;
}
default:
jj_la1[22] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
{if ("" != null) return t;}
throw new Error("Missing return statement in function");
}
static final public ASTPattern Pattern() throws ParseException {Token tag,id;
List<String> pv = new ArrayList<String>();
tag = jj_consume_token(TAG);
switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
case LPAR:{
jj_consume_token(LPAR);
id = jj_consume_token(Id);
pv.add(id.image);
label_10:
while (true) {
switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
case COMMA:{
;
break;
}
default:
jj_la1[23] = jj_gen;
break label_10;
}
jj_consume_token(COMMA);
id = jj_consume_token(Id);
pv.add(id.image);
}
jj_consume_token(RPAR);
break;
}
case NONE:{
jj_consume_token(NONE);
pv.add("_");
break;
}
default:
jj_la1[24] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
{if ("" != null) return new ASTPattern(tag.image,pv);}
throw new Error("Missing return statement in function");
}
static final public ASTNode Match() throws ParseException, InterpreterError {ASTNode t, t1;
ASTPattern p;
List<ASTPattern> patterns = new ArrayList<ASTPattern>();
List<ASTNode> bodies = new ArrayList<ASTNode>();
jj_consume_token(MATCH);
t = Let();
jj_consume_token(LBRA);
p = Pattern();
jj_consume_token(ARROW);
t1 = Let();
patterns.add(p); bodies.add(t1);
label_11:
while (true) {
switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
case BAR:{
;
break;
}
default:
jj_la1[25] = jj_gen;
break label_11;
}
jj_consume_token(BAR);
p = Pattern();
jj_consume_token(ARROW);
t1 = Let();
patterns.add(p); bodies.add(t1);
}
jj_consume_token(RBRA);
t = new ASTMatch(t, patterns, bodies);
{if ("" != null) return t;}
throw new Error("Missing return statement in function");
}
static final public ASTNode Fact() throws ParseException, InterpreterError {Token n;
ASTNode t, e1, e2;
List<Bind> decls;
ASTNode body, alt;
switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
case Num:{
n = jj_consume_token(Num);
t = new ASTInt(Integer.parseInt(n.image));
break;
}
case TRUE:{
n = jj_consume_token(TRUE);
t = new ASTBool(true);
break;
}
case FALSE:{
n = jj_consume_token(FALSE);
t = new ASTBool(false);
break;
}
case NONE:{
n = jj_consume_token(NONE);
t = new ASTUnit();
break;
}
case Id:{
n = jj_consume_token(Id);
t = new ASTId(n.image);
label_12:
while (true) {
switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
case LPAR:
case NONE:{
;
break;
}
default:
jj_la1[26] = jj_gen;
break label_12;
}
switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
case LPAR:{
jj_consume_token(LPAR);
e1 = Let();
switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
case RPAR:{
jj_consume_token(RPAR);
t = new ASTApp(t, e1);
break;
}
case COMMA:{
label_13:
while (true) {
jj_consume_token(COMMA);
t = new ASTApp(t, e1);
e1 = Let();
switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
case COMMA:{
;
break;
}
default:
jj_la1[27] = jj_gen;
break label_13;
}
}
jj_consume_token(RPAR);
t = new ASTApp(t, e1);
break;
}
default:
jj_la1[28] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
break;
}
case NONE:{
jj_consume_token(NONE);
t = new ASTApp(t, new ASTUnit());
break;
}
default:
jj_la1[29] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
}
break;
}
case String:{
n = jj_consume_token(String);
t = new ASTString(n.image.substring(1, n.image.length()-1));
break;
}
case MINUS:{
jj_consume_token(MINUS);
t = Fact();
t = new ASTNeg(t);
break;
}
case NOT:{
jj_consume_token(NOT);
t = Fact();
t = new ASTNot(t);
break;
}
case BAR:
case OR:{
t = Function();
break;
}
case IF:{
jj_consume_token(IF);
t = BA();
jj_consume_token(LBRA);
e1 = Let();
jj_consume_token(RBRA);
jj_consume_token(ELSE);
jj_consume_token(LBRA);
e2 = Let();
jj_consume_token(RBRA);
t = new ASTIf(t, e1, e2);
break;
}
case LPAR:{
jj_consume_token(LPAR);
t = Let();
jj_consume_token(RPAR);
label_14:
while (true) {
switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
case LPAR:
case NONE:{
;
break;
}
default:
jj_la1[30] = jj_gen;
break label_14;
}
switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
case LPAR:{
jj_consume_token(LPAR);
e1 = Let();
switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
case RPAR:{
jj_consume_token(RPAR);
t = new ASTApp(t, e1);
break;
}
case COMMA:{
label_15:
while (true) {
jj_consume_token(COMMA);
t = new ASTApp(t, e1);
e1 = Let();
switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
case COMMA:{
;
break;
}
default:
jj_la1[31] = jj_gen;
break label_15;
}
}
jj_consume_token(RPAR);
t = new ASTApp(t, e1);
break;
}
default:
jj_la1[32] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
break;
}
case NONE:{
jj_consume_token(NONE);
t = new ASTApp(t, new ASTUnit());
break;
}
default:
jj_la1[33] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
}
break;
}
case LBRA:{
jj_consume_token(LBRA);
t = Let();
jj_consume_token(RBRA);
break;
}
case PRINT:{
jj_consume_token(PRINT);
t = Fact();
t = new ASTPrint(t);
break;
}
case PRINTLN:{
jj_consume_token(PRINTLN);
t = Fact();
t = new ASTPrintln(t);
break;
}
case WHILE:{
jj_consume_token(WHILE);
t = BA();
jj_consume_token(LBRA);
body = Let();
jj_consume_token(RBRA);
t = new ASTWhile(t, body);
break;
}
case CELL:{
jj_consume_token(CELL);
t = Fact();
t = new ASTCell(t);
break;
}
case DEREF:{
jj_consume_token(DEREF);
t = Fact();
t = new ASTDeref(t);
break;
}
case AMPERSAND:{
jj_consume_token(AMPERSAND);
n = jj_consume_token(Id);
t = new ASTAddr(n.image);
break;
}
case TAG:{
t = StructTuple();
break;
}
case MATCH:{
t = Match();
break;
}
default:
jj_la1[34] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
{if ("" != null) return t;}
throw new Error("Missing return statement in function");
}
static final public ASTType Type() throws ParseException {ASTType t1, t2;
t1 = TypeF();
switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
case SARROW:{
jj_consume_token(SARROW);
t2 = Type();
t1 = new ASTTArrow(t1,t2);
break;
}
default:
jj_la1[35] = jj_gen;
;
}
{if ("" != null) return t1;}
throw new Error("Missing return statement in function");
}
static final public ArrayList<ASTType> LabelList() throws ParseException {ASTType t;
ArrayList<ASTType> ll;
Token n;
ll = new ArrayList<ASTType>() ;
switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
case NONE:
case INT:
case BOOL:
case STRING:
case REF:
case ENUM:
case AMPERSAND:
case Id:{
t = Type();
ll.add(t);
label_16:
while (true) {
switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
case COMMA:{
;
break;
}
default:
jj_la1[36] = jj_gen;
break label_16;
}
jj_consume_token(COMMA);
t = Type();
ll.add(t);
}
break;
}
default:
jj_la1[37] = jj_gen;
;
}
{if ("" != null) return ll;}
throw new Error("Missing return statement in function");
}
static final public ASTType EnumT() throws ParseException {Token n;
ArrayList<ASTType> ll;
List<Map.Entry<String, List<ASTType>>> options = new ArrayList<>();
jj_consume_token(ENUM);
jj_consume_token(LBRA);
switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
case TAG:{
n = jj_consume_token(TAG);
jj_consume_token(COLON);
jj_consume_token(LPAR);
ll = LabelList();
jj_consume_token(RPAR);
options.add(new AbstractMap.SimpleEntry<>(n.image, new ArrayList<>(ll)));
label_17:
while (true) {
switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
case COMMA:{
;
break;
}
default:
jj_la1[38] = jj_gen;
break label_17;
}
jj_consume_token(COMMA);
n = jj_consume_token(TAG);
jj_consume_token(COLON);
jj_consume_token(LPAR);
ll = LabelList();
jj_consume_token(RPAR);
options.add(new AbstractMap.SimpleEntry<>(n.image, new ArrayList<>(ll)));
}
break;
}
default:
jj_la1[39] = jj_gen;
;
}
jj_consume_token(RBRA);
{if ("" != null) return new ASTTEnum(options);}
throw new Error("Missing return statement in function");
}
static final public ASTType TypeF() throws ParseException {ASTType t;
ArrayList<ASTType> ll;
Token n;
switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
case INT:{
jj_consume_token(INT);
t = new ASTTInt();
break;
}
case Id:{
n = jj_consume_token(Id);
t = new ASTTId(n.image);
break;
}
case BOOL:{
jj_consume_token(BOOL);
t = new ASTTBool();
break;
}
case NONE:{
jj_consume_token(NONE);
t = new ASTTUnit();
break;
}
case STRING:{
jj_consume_token(STRING);
t = new ASTTString();
break;
}
case REF:{
jj_consume_token(REF);
jj_consume_token(LPAR);
t = Type();
jj_consume_token(RPAR);
t = new ASTTRef(t);
break;
}
case AMPERSAND:{
jj_consume_token(AMPERSAND);
jj_consume_token(LPAR);
t = Type();
jj_consume_token(RPAR);
t = new ASTTAddr(t, 0);
break;
}
case ENUM:{