-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathproj1.output
1517 lines (889 loc) · 27.4 KB
/
proj1.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
DIGITS
SPECIAL
SPACE
KEYWORD
SQUAREBRACKET_START
SQUAREBRACKET_END
MOD
RANGE
SINGLEQUOTE
DOUBLEQUOTE
LIST
Grammar
0 $accept: P $end
1 P: S
2 S: Simple S
3 | Compound S
4 | /* empty */
5 IS: In Simple IS
6 | In Compound IS
7 | /* empty */
8 In: INDENT
9 | In INDENT
10 Simple: Assignment LB
11 | Print LB
12 Assignment: ID opassgn E1
13 opassgn: DIVIDEEQUAL
14 | MULEQUAL
15 | MINUSEQUAL
16 | EQUAL
17 | PLUSEQUAL
18 E1: E1 OP1 E2
19 | E2
20 E2: E2 OP2 E3
21 | E3
22 $@1: /* empty */
23 E3: E4 EXPONENTIAL $@1 E3
24 | E4
25 E4: INTEGER
26 | NUM
27 | ID
28 | SPECIAL_START E1 SPECIAL_END
29 OP1: PLUS
30 | MINUS
31 OP2: MUL
32 | DIVIDE
33 Compound: if_else LB
34 | only_if LB
35 | while_loop LB
36 only_if: IF condition COLON LB IND
37 $@2: /* empty */
38 if_else: IF condition COLON LB IND $@2 else_1
39 $@3: /* empty */
40 else_1: ELSE $@3 COLON LB IND
41 while_loop: WHILE condition COLON LB IND
42 condition: cond
43 cond: cond opor cond1
44 | cond1
45 cond1: cond1 opand cond2
46 | cond2
47 cond2: opnot cond2
48 | cond3
49 cond3: SPECIAL_START cond SPECIAL_END
50 | relexp
51 | bool
52 relexp: relexp relop E1
53 | ID
54 | NUM
55 | INTEGER
56 relop: comparison
57 | IN
58 | NOTIN
59 comparison: LESSTHAN
60 | LESSTHANEQUAL
61 | GREATERTHAN
62 | GREATERTHANEQUAL
63 | DOUBLEEQUAL
64 | NOTEQUAL
65 bool: T
66 | F
67 opor: OR
68 opand: AND
69 opnot: NOT
70 IND: IS
71 Print: PRINT SPECIAL_START toprint SPECIAL_END
72 | PRINT SPECIAL_START toprint SEP EQUAL STRING END EQUAL STRING SPECIAL_END
73 | PRINT SPECIAL_START toprint SEP EQUAL STRING SPECIAL_END
74 | PRINT SPECIAL_START toprint END EQUAL STRING SPECIAL_END
75 toprint: X
76 | X COMMA toprint
77 X: STRING
78 | ID
79 | NUM
80 | INTEGER
81 LB: NL
Terminals, with rules where they appear
$end (0) 0
error (256)
DIGITS (258)
ID (259) 12 27 53 78
PLUS (260) 29
MINUS (261) 30
MUL (262) 31
DIVIDE (263) 32
NUM (264) 26 54 79
STRING (265) 72 73 74 77
INTEGER (266) 25 55 80
SPECIAL (267)
NL (268) 81
SPACE (269)
KEYWORD (270)
SPECIAL_START (271) 28 49 71 72 73 74
SPECIAL_END (272) 28 49 71 72 73 74
IF (273) 36 38
ELSE (274) 40
WHILE (275) 41
SEP (276) 72 73
END (277) 72 74
OR (278) 67
AND (279) 68
NOT (280) 69
IN (281) 57
NOTIN (282) 58
T (283) 65
F (284) 66
COLON (285) 36 38 40 41
SQUAREBRACKET_START (286)
SQUAREBRACKET_END (287)
MOD (288)
EQUAL (289) 16 72 73 74
PLUSEQUAL (290) 17
PRINT (291) 71 72 73 74
RANGE (292)
SINGLEQUOTE (293)
DOUBLEQUOTE (294)
EXPONENTIAL (295) 23
COMMA (296) 76
INDENT (297) 8 9
LIST (298)
DIVIDEEQUAL (299) 13
MINUSEQUAL (300) 15
MULEQUAL (301) 14
LESSTHAN (302) 59
LESSTHANEQUAL (303) 60
GREATERTHAN (304) 61
GREATERTHANEQUAL (305) 62
DOUBLEEQUAL (306) 63
NOTEQUAL (307) 64
Nonterminals, with rules where they appear
$accept (53)
on left: 0
P (54)
on left: 1, on right: 0
S (55)
on left: 2 3 4, on right: 1 2 3
IS (56)
on left: 5 6 7, on right: 5 6 70
In (57)
on left: 8 9, on right: 5 6 9
Simple (58)
on left: 10 11, on right: 2 5
Assignment (59)
on left: 12, on right: 10
opassgn (60)
on left: 13 14 15 16 17, on right: 12
E1 (61)
on left: 18 19, on right: 12 18 28 52
E2 (62)
on left: 20 21, on right: 18 19 20
E3 (63)
on left: 23 24, on right: 20 21 23
$@1 (64)
on left: 22, on right: 23
E4 (65)
on left: 25 26 27 28, on right: 23 24
OP1 (66)
on left: 29 30, on right: 18
OP2 (67)
on left: 31 32, on right: 20
Compound (68)
on left: 33 34 35, on right: 3 6
only_if (69)
on left: 36, on right: 34
if_else (70)
on left: 38, on right: 33
$@2 (71)
on left: 37, on right: 38
else_1 (72)
on left: 40, on right: 38
$@3 (73)
on left: 39, on right: 40
while_loop (74)
on left: 41, on right: 35
condition (75)
on left: 42, on right: 36 38 41
cond (76)
on left: 43 44, on right: 42 43 49
cond1 (77)
on left: 45 46, on right: 43 44 45
cond2 (78)
on left: 47 48, on right: 45 46 47
cond3 (79)
on left: 49 50 51, on right: 48
relexp (80)
on left: 52 53 54 55, on right: 50 52
relop (81)
on left: 56 57 58, on right: 52
comparison (82)
on left: 59 60 61 62 63 64, on right: 56
bool (83)
on left: 65 66, on right: 51
opor (84)
on left: 67, on right: 43
opand (85)
on left: 68, on right: 45
opnot (86)
on left: 69, on right: 47
IND (87)
on left: 70, on right: 36 38 40 41
Print (88)
on left: 71 72 73 74, on right: 11
toprint (89)
on left: 75 76, on right: 71 72 73 74 76
X (90)
on left: 77 78 79 80, on right: 75 76
LB (91)
on left: 81, on right: 10 11 33 34 35 36 38 40 41
State 0
0 $accept: . P $end
ID shift, and go to state 1
IF shift, and go to state 2
WHILE shift, and go to state 3
PRINT shift, and go to state 4
$default reduce using rule 4 (S)
P go to state 5
S go to state 6
Simple go to state 7
Assignment go to state 8
Compound go to state 9
only_if go to state 10
if_else go to state 11
while_loop go to state 12
Print go to state 13
State 1
12 Assignment: ID . opassgn E1
EQUAL shift, and go to state 14
PLUSEQUAL shift, and go to state 15
DIVIDEEQUAL shift, and go to state 16
MINUSEQUAL shift, and go to state 17
MULEQUAL shift, and go to state 18
opassgn go to state 19
State 2
36 only_if: IF . condition COLON LB IND
38 if_else: IF . condition COLON LB IND $@2 else_1
ID shift, and go to state 20
NUM shift, and go to state 21
INTEGER shift, and go to state 22
SPECIAL_START shift, and go to state 23
NOT shift, and go to state 24
T shift, and go to state 25
F shift, and go to state 26
condition go to state 27
cond go to state 28
cond1 go to state 29
cond2 go to state 30
cond3 go to state 31
relexp go to state 32
bool go to state 33
opnot go to state 34
State 3
41 while_loop: WHILE . condition COLON LB IND
ID shift, and go to state 20
NUM shift, and go to state 21
INTEGER shift, and go to state 22
SPECIAL_START shift, and go to state 23
NOT shift, and go to state 24
T shift, and go to state 25
F shift, and go to state 26
condition go to state 35
cond go to state 28
cond1 go to state 29
cond2 go to state 30
cond3 go to state 31
relexp go to state 32
bool go to state 33
opnot go to state 34
State 4
71 Print: PRINT . SPECIAL_START toprint SPECIAL_END
72 | PRINT . SPECIAL_START toprint SEP EQUAL STRING END EQUAL STRING SPECIAL_END
73 | PRINT . SPECIAL_START toprint SEP EQUAL STRING SPECIAL_END
74 | PRINT . SPECIAL_START toprint END EQUAL STRING SPECIAL_END
SPECIAL_START shift, and go to state 36
State 5
0 $accept: P . $end
$end shift, and go to state 37
State 6
1 P: S .
$default reduce using rule 1 (P)
State 7
2 S: Simple . S
ID shift, and go to state 1
IF shift, and go to state 2
WHILE shift, and go to state 3
PRINT shift, and go to state 4
$default reduce using rule 4 (S)
S go to state 38
Simple go to state 7
Assignment go to state 8
Compound go to state 9
only_if go to state 10
if_else go to state 11
while_loop go to state 12
Print go to state 13
State 8
10 Simple: Assignment . LB
NL shift, and go to state 39
LB go to state 40
State 9
3 S: Compound . S
ID shift, and go to state 1
IF shift, and go to state 2
WHILE shift, and go to state 3
PRINT shift, and go to state 4
$default reduce using rule 4 (S)
S go to state 41
Simple go to state 7
Assignment go to state 8
Compound go to state 9
only_if go to state 10
if_else go to state 11
while_loop go to state 12
Print go to state 13
State 10
34 Compound: only_if . LB
NL shift, and go to state 39
LB go to state 42
State 11
33 Compound: if_else . LB
NL shift, and go to state 39
LB go to state 43
State 12
35 Compound: while_loop . LB
NL shift, and go to state 39
LB go to state 44
State 13
11 Simple: Print . LB
NL shift, and go to state 39
LB go to state 45
State 14
16 opassgn: EQUAL .
$default reduce using rule 16 (opassgn)
State 15
17 opassgn: PLUSEQUAL .
$default reduce using rule 17 (opassgn)
State 16
13 opassgn: DIVIDEEQUAL .
$default reduce using rule 13 (opassgn)
State 17
15 opassgn: MINUSEQUAL .
$default reduce using rule 15 (opassgn)
State 18
14 opassgn: MULEQUAL .
$default reduce using rule 14 (opassgn)
State 19
12 Assignment: ID opassgn . E1
ID shift, and go to state 46
NUM shift, and go to state 47
INTEGER shift, and go to state 48
SPECIAL_START shift, and go to state 49
E1 go to state 50
E2 go to state 51
E3 go to state 52
E4 go to state 53
State 20
53 relexp: ID .
$default reduce using rule 53 (relexp)
State 21
54 relexp: NUM .
$default reduce using rule 54 (relexp)
State 22
55 relexp: INTEGER .
$default reduce using rule 55 (relexp)
State 23
49 cond3: SPECIAL_START . cond SPECIAL_END
ID shift, and go to state 20
NUM shift, and go to state 21
INTEGER shift, and go to state 22
SPECIAL_START shift, and go to state 23
NOT shift, and go to state 24
T shift, and go to state 25
F shift, and go to state 26
cond go to state 54
cond1 go to state 29
cond2 go to state 30
cond3 go to state 31
relexp go to state 32
bool go to state 33
opnot go to state 34
State 24
69 opnot: NOT .
$default reduce using rule 69 (opnot)
State 25
65 bool: T .
$default reduce using rule 65 (bool)
State 26
66 bool: F .
$default reduce using rule 66 (bool)
State 27
36 only_if: IF condition . COLON LB IND
38 if_else: IF condition . COLON LB IND $@2 else_1
COLON shift, and go to state 55
State 28
42 condition: cond .
43 cond: cond . opor cond1
OR shift, and go to state 56
$default reduce using rule 42 (condition)
opor go to state 57
State 29
44 cond: cond1 .
45 cond1: cond1 . opand cond2
AND shift, and go to state 58
$default reduce using rule 44 (cond)
opand go to state 59
State 30
46 cond1: cond2 .
$default reduce using rule 46 (cond1)
State 31
48 cond2: cond3 .
$default reduce using rule 48 (cond2)
State 32
50 cond3: relexp .
52 relexp: relexp . relop E1
IN shift, and go to state 60
NOTIN shift, and go to state 61
LESSTHAN shift, and go to state 62
LESSTHANEQUAL shift, and go to state 63
GREATERTHAN shift, and go to state 64
GREATERTHANEQUAL shift, and go to state 65
DOUBLEEQUAL shift, and go to state 66
NOTEQUAL shift, and go to state 67
$default reduce using rule 50 (cond3)
relop go to state 68
comparison go to state 69
State 33
51 cond3: bool .
$default reduce using rule 51 (cond3)
State 34
47 cond2: opnot . cond2
ID shift, and go to state 20
NUM shift, and go to state 21
INTEGER shift, and go to state 22
SPECIAL_START shift, and go to state 23
NOT shift, and go to state 24
T shift, and go to state 25
F shift, and go to state 26
cond2 go to state 70
cond3 go to state 31
relexp go to state 32
bool go to state 33
opnot go to state 34
State 35
41 while_loop: WHILE condition . COLON LB IND
COLON shift, and go to state 71
State 36
71 Print: PRINT SPECIAL_START . toprint SPECIAL_END
72 | PRINT SPECIAL_START . toprint SEP EQUAL STRING END EQUAL STRING SPECIAL_END
73 | PRINT SPECIAL_START . toprint SEP EQUAL STRING SPECIAL_END
74 | PRINT SPECIAL_START . toprint END EQUAL STRING SPECIAL_END
ID shift, and go to state 72
NUM shift, and go to state 73
STRING shift, and go to state 74
INTEGER shift, and go to state 75
toprint go to state 76
X go to state 77
State 37
0 $accept: P $end .
$default accept
State 38
2 S: Simple S .
$default reduce using rule 2 (S)
State 39
81 LB: NL .
$default reduce using rule 81 (LB)
State 40
10 Simple: Assignment LB .
$default reduce using rule 10 (Simple)
State 41
3 S: Compound S .
$default reduce using rule 3 (S)
State 42
34 Compound: only_if LB .
$default reduce using rule 34 (Compound)
State 43
33 Compound: if_else LB .
$default reduce using rule 33 (Compound)
State 44
35 Compound: while_loop LB .
$default reduce using rule 35 (Compound)
State 45
11 Simple: Print LB .
$default reduce using rule 11 (Simple)
State 46
27 E4: ID .
$default reduce using rule 27 (E4)
State 47
26 E4: NUM .
$default reduce using rule 26 (E4)
State 48
25 E4: INTEGER .
$default reduce using rule 25 (E4)
State 49
28 E4: SPECIAL_START . E1 SPECIAL_END
ID shift, and go to state 46
NUM shift, and go to state 47
INTEGER shift, and go to state 48
SPECIAL_START shift, and go to state 49
E1 go to state 78
E2 go to state 51
E3 go to state 52
E4 go to state 53
State 50
12 Assignment: ID opassgn E1 .
18 E1: E1 . OP1 E2
PLUS shift, and go to state 79
MINUS shift, and go to state 80
$default reduce using rule 12 (Assignment)
OP1 go to state 81
State 51
19 E1: E2 .
20 E2: E2 . OP2 E3
MUL shift, and go to state 82
DIVIDE shift, and go to state 83
$default reduce using rule 19 (E1)
OP2 go to state 84
State 52
21 E2: E3 .
$default reduce using rule 21 (E2)
State 53
23 E3: E4 . EXPONENTIAL $@1 E3
24 | E4 .
EXPONENTIAL shift, and go to state 85
$default reduce using rule 24 (E3)
State 54
43 cond: cond . opor cond1
49 cond3: SPECIAL_START cond . SPECIAL_END
SPECIAL_END shift, and go to state 86
OR shift, and go to state 56
opor go to state 57
State 55
36 only_if: IF condition COLON . LB IND
38 if_else: IF condition COLON . LB IND $@2 else_1
NL shift, and go to state 39
LB go to state 87
State 56
67 opor: OR .
$default reduce using rule 67 (opor)
State 57
43 cond: cond opor . cond1
ID shift, and go to state 20
NUM shift, and go to state 21
INTEGER shift, and go to state 22
SPECIAL_START shift, and go to state 23
NOT shift, and go to state 24
T shift, and go to state 25
F shift, and go to state 26
cond1 go to state 88
cond2 go to state 30
cond3 go to state 31
relexp go to state 32
bool go to state 33
opnot go to state 34
State 58
68 opand: AND .
$default reduce using rule 68 (opand)
State 59
45 cond1: cond1 opand . cond2
ID shift, and go to state 20
NUM shift, and go to state 21
INTEGER shift, and go to state 22
SPECIAL_START shift, and go to state 23
NOT shift, and go to state 24
T shift, and go to state 25
F shift, and go to state 26
cond2 go to state 89
cond3 go to state 31
relexp go to state 32
bool go to state 33
opnot go to state 34
State 60
57 relop: IN .
$default reduce using rule 57 (relop)
State 61
58 relop: NOTIN .
$default reduce using rule 58 (relop)
State 62
59 comparison: LESSTHAN .
$default reduce using rule 59 (comparison)
State 63
60 comparison: LESSTHANEQUAL .
$default reduce using rule 60 (comparison)
State 64
61 comparison: GREATERTHAN .
$default reduce using rule 61 (comparison)
State 65
62 comparison: GREATERTHANEQUAL .
$default reduce using rule 62 (comparison)
State 66
63 comparison: DOUBLEEQUAL .
$default reduce using rule 63 (comparison)
State 67
64 comparison: NOTEQUAL .
$default reduce using rule 64 (comparison)
State 68
52 relexp: relexp relop . E1
ID shift, and go to state 46
NUM shift, and go to state 47
INTEGER shift, and go to state 48
SPECIAL_START shift, and go to state 49
E1 go to state 90
E2 go to state 51
E3 go to state 52
E4 go to state 53
State 69
56 relop: comparison .
$default reduce using rule 56 (relop)
State 70
47 cond2: opnot cond2 .
$default reduce using rule 47 (cond2)
State 71
41 while_loop: WHILE condition COLON . LB IND