-
Notifications
You must be signed in to change notification settings - Fork 0
/
y.output
2561 lines (1783 loc) · 65.3 KB
/
y.output
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
Terminals unused in grammar
STRUCT
UNION
CONTINUE
C_LIT
State 68 conflicts: 1 shift/reduce
State 107 conflicts: 1 shift/reduce
State 130 conflicts: 1 shift/reduce
State 131 conflicts: 1 shift/reduce
State 132 conflicts: 1 shift/reduce
State 137 conflicts: 1 shift/reduce
State 140 conflicts: 1 shift/reduce
State 141 conflicts: 1 shift/reduce
State 148 conflicts: 1 shift/reduce
State 152 conflicts: 1 shift/reduce
Grammar
0 $accept: program $end
1 program: cprogram
2 cprogram: %empty
3 | cprogram declarations
4 | cprogram function
5 declarations: vdeclaration
6 | fdeclaration
7 identifier: IDENTIFIER
8 fdeclaration: datatype identifier OP fparamlist CP
9 function: datatype identifier OP fparamlist CP block
10 statement_list: %empty
11 | statement_list statement
12 | statement_list declarations SEMICOLON
13 conditional: iexp
14 | c_switch
15 statement: expression SEMICOLON
16 | RETURN expression SEMICOLON
17 | BREAK SEMICOLON
18 | assign SEMICOLON
19 | loops
20 | block
21 | conditional
22 block: OB statement_list CB
23 iexp: IF OP expression CP statement eiexp
24 eiexp: %empty
25 | ELSE statement
26 funcall: identifier OP actarguments CP
27 actarguments: expression
28 | expression COMMA actarguments
29 fsdecl: datatype identifier
30 fparamlist: %empty
31 | fsdecl
32 | fsdecl COMMA fparamlist
33 loops: for_loop
34 | while_loop
35 exp_hack: expression
36 | assign
37 for_loop: FOR OP exp_hack SEMICOLON exp_hack SEMICOLON exp_hack CP statement
38 while_loop: WHILE OP expression CP statement
39 c_switch: SWITCH OP expression CP OB switch_body CB
40 switch_body: %empty
41 | switch_body CASE aconst COLON statement_list
42 aconst: NUMBER
43 datatype: INT
44 | CHAR
45 constant: S_LIT
46 | aconst
47 expression: %empty
48 | expression PLUS expression
49 | expression MINUS expression
50 | expression MUL expression
51 | expression DIV expression
52 | expression GT expression
53 | expression LT expression
54 | expression LE expression
55 | expression GE expression
56 | expression EE expression
57 | expression NE expression
58 | expression AND expression
59 | expression OR expression
60 | identifier INCOP
61 | identifier DECOP
62 | NOT expression
63 | AMP identifier
64 | funcall
65 | identifier arrsize
66 | constant
67 | OP expression CP
68 assign: identifier EQ expression
69 | pointer_expression EQ expression
70 pointer_expression: MUL identifier
71 vdeclaration: datatype list
72 list: list COMMA sdecl
73 | sdecl
74 arrsize: %empty
75 | OSB constant CSB
76 sdecl: identifier arrsize
77 | identifier arrsize EQ expression
78 | pointer_expression arrsize
79 | pointer_expression arrsize EQ expression
Terminals, with rules where they appear
$end (0) 0
error (256)
INT (258) 43
CHAR (259) 44
STRUCT (260)
UNION (261)
FOR (262) 37
WHILE (263) 38
IF (264) 23
ELSE (265) 25
SWITCH (266) 39
CASE (267) 41
BREAK (268) 17
CONTINUE (269)
RETURN (270) 16
IDENTIFIER (271) 7
NUMBER (272) 42
PLUS (273) 48
MINUS (274) 49
MUL (275) 50 70
DIV (276) 51
LE (277) 54
GE (278) 55
LT (279) 53
GT (280) 52
EE (281) 56
NE (282) 57
AMP (283) 63
AND (284) 58
OR (285) 59
NOT (286) 62
COLON (287) 41
EQ (288) 68 69 77 79
COMMA (289) 28 32 72
OSB (290) 75
CSB (291) 75
OB (292) 22 39
CB (293) 22 39
OP (294) 8 9 23 26 37 38 39 67
CP (295) 8 9 23 26 37 38 39 67
SEMICOLON (296) 12 15 16 17 18 37
S_LIT (297) 45
C_LIT (298)
INCOP (299) 60
DECOP (300) 61
Nonterminals, with rules where they appear
$accept (46)
on left: 0
program (47)
on left: 1, on right: 0
cprogram (48)
on left: 2 3 4, on right: 1 3 4
declarations (49)
on left: 5 6, on right: 3 12
identifier (50)
on left: 7, on right: 8 9 26 29 60 61 63 65 68 70 76 77
fdeclaration (51)
on left: 8, on right: 6
function (52)
on left: 9, on right: 4
statement_list (53)
on left: 10 11 12, on right: 11 12 22 41
conditional (54)
on left: 13 14, on right: 21
statement (55)
on left: 15 16 17 18 19 20 21, on right: 11 23 25 37 38
block (56)
on left: 22, on right: 9 20
iexp (57)
on left: 23, on right: 13
eiexp (58)
on left: 24 25, on right: 23
funcall (59)
on left: 26, on right: 64
actarguments (60)
on left: 27 28, on right: 26 28
fsdecl (61)
on left: 29, on right: 31 32
fparamlist (62)
on left: 30 31 32, on right: 8 9 32
loops (63)
on left: 33 34, on right: 19
exp_hack (64)
on left: 35 36, on right: 37
for_loop (65)
on left: 37, on right: 33
while_loop (66)
on left: 38, on right: 34
c_switch (67)
on left: 39, on right: 14
switch_body (68)
on left: 40 41, on right: 39 41
aconst (69)
on left: 42, on right: 41 46
datatype (70)
on left: 43 44, on right: 8 9 29 71
constant (71)
on left: 45 46, on right: 66 75
expression (72)
on left: 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
65 66 67, on right: 15 16 23 27 28 35 38 39 48 49 50 51 52 53 54
55 56 57 58 59 62 67 68 69 77 79
assign (73)
on left: 68 69, on right: 18 36
pointer_expression (74)
on left: 70, on right: 69 78 79
vdeclaration (75)
on left: 71, on right: 5
list (76)
on left: 72 73, on right: 71 72
arrsize (77)
on left: 74 75, on right: 65 76 77 78 79
sdecl (78)
on left: 76 77 78 79, on right: 72 73
State 0
0 $accept: . program $end
$default reduce using rule 2 (cprogram)
program go to state 1
cprogram go to state 2
State 1
0 $accept: program . $end
$end shift, and go to state 3
State 2
1 program: cprogram .
3 cprogram: cprogram . declarations
4 | cprogram . function
INT shift, and go to state 4
CHAR shift, and go to state 5
$default reduce using rule 1 (program)
declarations go to state 6
fdeclaration go to state 7
function go to state 8
datatype go to state 9
vdeclaration go to state 10
State 3
0 $accept: program $end .
$default accept
State 4
43 datatype: INT .
$default reduce using rule 43 (datatype)
State 5
44 datatype: CHAR .
$default reduce using rule 44 (datatype)
State 6
3 cprogram: cprogram declarations .
$default reduce using rule 3 (cprogram)
State 7
6 declarations: fdeclaration .
$default reduce using rule 6 (declarations)
State 8
4 cprogram: cprogram function .
$default reduce using rule 4 (cprogram)
State 9
8 fdeclaration: datatype . identifier OP fparamlist CP
9 function: datatype . identifier OP fparamlist CP block
71 vdeclaration: datatype . list
IDENTIFIER shift, and go to state 11
MUL shift, and go to state 12
identifier go to state 13
pointer_expression go to state 14
list go to state 15
sdecl go to state 16
State 10
5 declarations: vdeclaration .
$default reduce using rule 5 (declarations)
State 11
7 identifier: IDENTIFIER .
$default reduce using rule 7 (identifier)
State 12
70 pointer_expression: MUL . identifier
IDENTIFIER shift, and go to state 11
identifier go to state 17
State 13
8 fdeclaration: datatype identifier . OP fparamlist CP
9 function: datatype identifier . OP fparamlist CP block
76 sdecl: identifier . arrsize
77 | identifier . arrsize EQ expression
OSB shift, and go to state 18
OP shift, and go to state 19
$default reduce using rule 74 (arrsize)
arrsize go to state 20
State 14
78 sdecl: pointer_expression . arrsize
79 | pointer_expression . arrsize EQ expression
OSB shift, and go to state 18
$default reduce using rule 74 (arrsize)
arrsize go to state 21
State 15
71 vdeclaration: datatype list .
72 list: list . COMMA sdecl
COMMA shift, and go to state 22
$default reduce using rule 71 (vdeclaration)
State 16
73 list: sdecl .
$default reduce using rule 73 (list)
State 17
70 pointer_expression: MUL identifier .
$default reduce using rule 70 (pointer_expression)
State 18
75 arrsize: OSB . constant CSB
NUMBER shift, and go to state 23
S_LIT shift, and go to state 24
aconst go to state 25
constant go to state 26
State 19
8 fdeclaration: datatype identifier OP . fparamlist CP
9 function: datatype identifier OP . fparamlist CP block
INT shift, and go to state 4
CHAR shift, and go to state 5
$default reduce using rule 30 (fparamlist)
fsdecl go to state 27
fparamlist go to state 28
datatype go to state 29
State 20
76 sdecl: identifier arrsize .
77 | identifier arrsize . EQ expression
EQ shift, and go to state 30
$default reduce using rule 76 (sdecl)
State 21
78 sdecl: pointer_expression arrsize .
79 | pointer_expression arrsize . EQ expression
EQ shift, and go to state 31
$default reduce using rule 78 (sdecl)
State 22
72 list: list COMMA . sdecl
IDENTIFIER shift, and go to state 11
MUL shift, and go to state 12
identifier go to state 32
pointer_expression go to state 14
sdecl go to state 33
State 23
42 aconst: NUMBER .
$default reduce using rule 42 (aconst)
State 24
45 constant: S_LIT .
$default reduce using rule 45 (constant)
State 25
46 constant: aconst .
$default reduce using rule 46 (constant)
State 26
75 arrsize: OSB constant . CSB
CSB shift, and go to state 34
State 27
31 fparamlist: fsdecl .
32 | fsdecl . COMMA fparamlist
COMMA shift, and go to state 35
$default reduce using rule 31 (fparamlist)
State 28
8 fdeclaration: datatype identifier OP fparamlist . CP
9 function: datatype identifier OP fparamlist . CP block
CP shift, and go to state 36
State 29
29 fsdecl: datatype . identifier
IDENTIFIER shift, and go to state 11
identifier go to state 37
State 30
77 sdecl: identifier arrsize EQ . expression
IDENTIFIER shift, and go to state 11
NUMBER shift, and go to state 23
AMP shift, and go to state 38
NOT shift, and go to state 39
OP shift, and go to state 40
S_LIT shift, and go to state 24
$default reduce using rule 47 (expression)
identifier go to state 41
funcall go to state 42
aconst go to state 25
constant go to state 43
expression go to state 44
State 31
79 sdecl: pointer_expression arrsize EQ . expression
IDENTIFIER shift, and go to state 11
NUMBER shift, and go to state 23
AMP shift, and go to state 38
NOT shift, and go to state 39
OP shift, and go to state 40
S_LIT shift, and go to state 24
$default reduce using rule 47 (expression)
identifier go to state 41
funcall go to state 42
aconst go to state 25
constant go to state 43
expression go to state 45
State 32
76 sdecl: identifier . arrsize
77 | identifier . arrsize EQ expression
OSB shift, and go to state 18
$default reduce using rule 74 (arrsize)
arrsize go to state 20
State 33
72 list: list COMMA sdecl .
$default reduce using rule 72 (list)
State 34
75 arrsize: OSB constant CSB .
$default reduce using rule 75 (arrsize)
State 35
32 fparamlist: fsdecl COMMA . fparamlist
INT shift, and go to state 4
CHAR shift, and go to state 5
$default reduce using rule 30 (fparamlist)
fsdecl go to state 27
fparamlist go to state 46
datatype go to state 29
State 36
8 fdeclaration: datatype identifier OP fparamlist CP .
9 function: datatype identifier OP fparamlist CP . block
OB shift, and go to state 47
$default reduce using rule 8 (fdeclaration)
block go to state 48
State 37
29 fsdecl: datatype identifier .
$default reduce using rule 29 (fsdecl)
State 38
63 expression: AMP . identifier
IDENTIFIER shift, and go to state 11
identifier go to state 49
State 39
62 expression: NOT . expression
IDENTIFIER shift, and go to state 11
NUMBER shift, and go to state 23
AMP shift, and go to state 38
NOT shift, and go to state 39
OP shift, and go to state 40
S_LIT shift, and go to state 24
$default reduce using rule 47 (expression)
identifier go to state 41
funcall go to state 42
aconst go to state 25
constant go to state 43
expression go to state 50
State 40
67 expression: OP . expression CP
IDENTIFIER shift, and go to state 11
NUMBER shift, and go to state 23
AMP shift, and go to state 38
NOT shift, and go to state 39
OP shift, and go to state 40
S_LIT shift, and go to state 24
$default reduce using rule 47 (expression)
identifier go to state 41
funcall go to state 42
aconst go to state 25
constant go to state 43
expression go to state 51
State 41
26 funcall: identifier . OP actarguments CP
60 expression: identifier . INCOP
61 | identifier . DECOP
65 | identifier . arrsize
OSB shift, and go to state 18
OP shift, and go to state 52
INCOP shift, and go to state 53
DECOP shift, and go to state 54
$default reduce using rule 74 (arrsize)
arrsize go to state 55
State 42
64 expression: funcall .
$default reduce using rule 64 (expression)
State 43
66 expression: constant .
$default reduce using rule 66 (expression)
State 44
48 expression: expression . PLUS expression
49 | expression . MINUS expression
50 | expression . MUL expression
51 | expression . DIV expression
52 | expression . GT expression
53 | expression . LT expression
54 | expression . LE expression
55 | expression . GE expression
56 | expression . EE expression
57 | expression . NE expression
58 | expression . AND expression
59 | expression . OR expression
77 sdecl: identifier arrsize EQ expression .
PLUS shift, and go to state 56
MINUS shift, and go to state 57
MUL shift, and go to state 58
DIV shift, and go to state 59
LE shift, and go to state 60
GE shift, and go to state 61
LT shift, and go to state 62
GT shift, and go to state 63
EE shift, and go to state 64
NE shift, and go to state 65
AND shift, and go to state 66
OR shift, and go to state 67
$default reduce using rule 77 (sdecl)
State 45
48 expression: expression . PLUS expression
49 | expression . MINUS expression
50 | expression . MUL expression
51 | expression . DIV expression
52 | expression . GT expression
53 | expression . LT expression
54 | expression . LE expression
55 | expression . GE expression
56 | expression . EE expression
57 | expression . NE expression
58 | expression . AND expression
59 | expression . OR expression
79 sdecl: pointer_expression arrsize EQ expression .
PLUS shift, and go to state 56
MINUS shift, and go to state 57
MUL shift, and go to state 58
DIV shift, and go to state 59
LE shift, and go to state 60
GE shift, and go to state 61
LT shift, and go to state 62
GT shift, and go to state 63
EE shift, and go to state 64
NE shift, and go to state 65
AND shift, and go to state 66
OR shift, and go to state 67
$default reduce using rule 79 (sdecl)
State 46
32 fparamlist: fsdecl COMMA fparamlist .
$default reduce using rule 32 (fparamlist)
State 47
22 block: OB . statement_list CB
$default reduce using rule 10 (statement_list)
statement_list go to state 68
State 48
9 function: datatype identifier OP fparamlist CP block .
$default reduce using rule 9 (function)
State 49
63 expression: AMP identifier .
$default reduce using rule 63 (expression)
State 50
48 expression: expression . PLUS expression
49 | expression . MINUS expression
50 | expression . MUL expression
51 | expression . DIV expression
52 | expression . GT expression
53 | expression . LT expression
54 | expression . LE expression
55 | expression . GE expression
56 | expression . EE expression
57 | expression . NE expression
58 | expression . AND expression
59 | expression . OR expression
62 | NOT expression .
$default reduce using rule 62 (expression)
State 51
48 expression: expression . PLUS expression
49 | expression . MINUS expression
50 | expression . MUL expression
51 | expression . DIV expression
52 | expression . GT expression
53 | expression . LT expression
54 | expression . LE expression
55 | expression . GE expression
56 | expression . EE expression
57 | expression . NE expression
58 | expression . AND expression
59 | expression . OR expression
67 | OP expression . CP
PLUS shift, and go to state 56
MINUS shift, and go to state 57
MUL shift, and go to state 58
DIV shift, and go to state 59
LE shift, and go to state 60
GE shift, and go to state 61
LT shift, and go to state 62
GT shift, and go to state 63
EE shift, and go to state 64
NE shift, and go to state 65
AND shift, and go to state 66
OR shift, and go to state 67
CP shift, and go to state 69
State 52
26 funcall: identifier OP . actarguments CP
IDENTIFIER shift, and go to state 11
NUMBER shift, and go to state 23
AMP shift, and go to state 38
NOT shift, and go to state 39
OP shift, and go to state 40
S_LIT shift, and go to state 24
$default reduce using rule 47 (expression)
identifier go to state 41
funcall go to state 42
actarguments go to state 70
aconst go to state 25
constant go to state 43
expression go to state 71
State 53
60 expression: identifier INCOP .
$default reduce using rule 60 (expression)
State 54
61 expression: identifier DECOP .
$default reduce using rule 61 (expression)
State 55
65 expression: identifier arrsize .
$default reduce using rule 65 (expression)
State 56
48 expression: expression PLUS . expression
IDENTIFIER shift, and go to state 11
NUMBER shift, and go to state 23
AMP shift, and go to state 38
NOT shift, and go to state 39
OP shift, and go to state 40
S_LIT shift, and go to state 24
$default reduce using rule 47 (expression)
identifier go to state 41
funcall go to state 42
aconst go to state 25
constant go to state 43
expression go to state 72
State 57
49 expression: expression MINUS . expression
IDENTIFIER shift, and go to state 11
NUMBER shift, and go to state 23
AMP shift, and go to state 38
NOT shift, and go to state 39
OP shift, and go to state 40
S_LIT shift, and go to state 24
$default reduce using rule 47 (expression)
identifier go to state 41
funcall go to state 42
aconst go to state 25
constant go to state 43
expression go to state 73
State 58
50 expression: expression MUL . expression
IDENTIFIER shift, and go to state 11
NUMBER shift, and go to state 23
AMP shift, and go to state 38
NOT shift, and go to state 39
OP shift, and go to state 40
S_LIT shift, and go to state 24
$default reduce using rule 47 (expression)
identifier go to state 41
funcall go to state 42
aconst go to state 25
constant go to state 43
expression go to state 74
State 59
51 expression: expression DIV . expression
IDENTIFIER shift, and go to state 11
NUMBER shift, and go to state 23
AMP shift, and go to state 38
NOT shift, and go to state 39
OP shift, and go to state 40
S_LIT shift, and go to state 24
$default reduce using rule 47 (expression)
identifier go to state 41
funcall go to state 42
aconst go to state 25
constant go to state 43
expression go to state 75
State 60
54 expression: expression LE . expression
IDENTIFIER shift, and go to state 11
NUMBER shift, and go to state 23
AMP shift, and go to state 38
NOT shift, and go to state 39
OP shift, and go to state 40
S_LIT shift, and go to state 24
$default reduce using rule 47 (expression)
identifier go to state 41
funcall go to state 42
aconst go to state 25
constant go to state 43
expression go to state 76