-
Notifications
You must be signed in to change notification settings - Fork 0
/
parser.out
663 lines (510 loc) · 20.9 KB
/
parser.out
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
Created by PLY version 3.11 (http://www.dabeaz.com/ply)
Unused terminals:
AND
AND_LOGICAL
COLON
EQUAL
GREATER
GREATEREQUAL
LESS
LESSEQUAL
NOT
NOTEQUAL
NUMBER
OR
OR_LOGICAL
PERCENT
SQUARE
Grammar
Rule 0 S' -> statements
Rule 1 statements -> statements statement
Rule 2 statements -> statement
Rule 3 statement -> INT ID EQUALS expr
Rule 4 statement -> STRING ID EQUALS expr
Rule 5 statement -> ID EQUALS expr
Rule 6 statement -> PRINT LPAREN print_expr RPAREN
Rule 7 print_expr -> expr
Rule 8 print_expr -> expr COMMA print_expr
Rule 9 expr -> expr PLUS expr
Rule 10 expr -> expr MINUS expr
Rule 11 expr -> expr MULT expr
Rule 12 expr -> expr DIV expr
Rule 13 expr -> INT
Rule 14 expr -> DOUBLE
Rule 15 expr -> ID
Rule 16 expr -> STRING
Rule 17 expr -> BOOL
Terminals, with rules where they appear
AND :
AND_LOGICAL :
BOOL : 17
COLON :
COMMA : 8
DIV : 12
DOUBLE : 14
EQUAL :
EQUALS : 3 4 5
GREATER :
GREATEREQUAL :
ID : 3 4 5 15
INT : 3 13
LESS :
LESSEQUAL :
LPAREN : 6
MINUS : 10
MULT : 11
NOT :
NOTEQUAL :
NUMBER :
OR :
OR_LOGICAL :
PERCENT :
PLUS : 9
PRINT : 6
RPAREN : 6
SQUARE :
STRING : 4 16
error :
Nonterminals, with rules where they appear
expr : 3 4 5 7 8 9 9 10 10 11 11 12 12
print_expr : 6 8
statement : 1 2
statements : 1 0
Parsing method: LALR
state 0
(0) S' -> . statements
(1) statements -> . statements statement
(2) statements -> . statement
(3) statement -> . INT ID EQUALS expr
(4) statement -> . STRING ID EQUALS expr
(5) statement -> . ID EQUALS expr
(6) statement -> . PRINT LPAREN print_expr RPAREN
INT shift and go to state 3
STRING shift and go to state 5
ID shift and go to state 4
PRINT shift and go to state 6
statements shift and go to state 1
statement shift and go to state 2
state 1
(0) S' -> statements .
(1) statements -> statements . statement
(3) statement -> . INT ID EQUALS expr
(4) statement -> . STRING ID EQUALS expr
(5) statement -> . ID EQUALS expr
(6) statement -> . PRINT LPAREN print_expr RPAREN
INT shift and go to state 3
STRING shift and go to state 5
ID shift and go to state 4
PRINT shift and go to state 6
statement shift and go to state 7
state 2
(2) statements -> statement .
INT reduce using rule 2 (statements -> statement .)
STRING reduce using rule 2 (statements -> statement .)
ID reduce using rule 2 (statements -> statement .)
PRINT reduce using rule 2 (statements -> statement .)
$end reduce using rule 2 (statements -> statement .)
state 3
(3) statement -> INT . ID EQUALS expr
ID shift and go to state 8
state 4
(5) statement -> ID . EQUALS expr
EQUALS shift and go to state 9
state 5
(4) statement -> STRING . ID EQUALS expr
ID shift and go to state 10
state 6
(6) statement -> PRINT . LPAREN print_expr RPAREN
LPAREN shift and go to state 11
state 7
(1) statements -> statements statement .
INT reduce using rule 1 (statements -> statements statement .)
STRING reduce using rule 1 (statements -> statements statement .)
ID reduce using rule 1 (statements -> statements statement .)
PRINT reduce using rule 1 (statements -> statements statement .)
$end reduce using rule 1 (statements -> statements statement .)
state 8
(3) statement -> INT ID . EQUALS expr
EQUALS shift and go to state 12
state 9
(5) statement -> ID EQUALS . expr
(9) expr -> . expr PLUS expr
(10) expr -> . expr MINUS expr
(11) expr -> . expr MULT expr
(12) expr -> . expr DIV expr
(13) expr -> . INT
(14) expr -> . DOUBLE
(15) expr -> . ID
(16) expr -> . STRING
(17) expr -> . BOOL
INT shift and go to state 15
DOUBLE shift and go to state 16
ID shift and go to state 13
STRING shift and go to state 17
BOOL shift and go to state 18
expr shift and go to state 14
state 10
(4) statement -> STRING ID . EQUALS expr
EQUALS shift and go to state 19
state 11
(6) statement -> PRINT LPAREN . print_expr RPAREN
(7) print_expr -> . expr
(8) print_expr -> . expr COMMA print_expr
(9) expr -> . expr PLUS expr
(10) expr -> . expr MINUS expr
(11) expr -> . expr MULT expr
(12) expr -> . expr DIV expr
(13) expr -> . INT
(14) expr -> . DOUBLE
(15) expr -> . ID
(16) expr -> . STRING
(17) expr -> . BOOL
INT shift and go to state 15
DOUBLE shift and go to state 16
ID shift and go to state 13
STRING shift and go to state 17
BOOL shift and go to state 18
print_expr shift and go to state 20
expr shift and go to state 21
state 12
(3) statement -> INT ID EQUALS . expr
(9) expr -> . expr PLUS expr
(10) expr -> . expr MINUS expr
(11) expr -> . expr MULT expr
(12) expr -> . expr DIV expr
(13) expr -> . INT
(14) expr -> . DOUBLE
(15) expr -> . ID
(16) expr -> . STRING
(17) expr -> . BOOL
INT shift and go to state 15
DOUBLE shift and go to state 16
ID shift and go to state 13
STRING shift and go to state 17
BOOL shift and go to state 18
expr shift and go to state 22
state 13
(15) expr -> ID .
PLUS reduce using rule 15 (expr -> ID .)
MINUS reduce using rule 15 (expr -> ID .)
MULT reduce using rule 15 (expr -> ID .)
DIV reduce using rule 15 (expr -> ID .)
INT reduce using rule 15 (expr -> ID .)
STRING reduce using rule 15 (expr -> ID .)
ID reduce using rule 15 (expr -> ID .)
PRINT reduce using rule 15 (expr -> ID .)
$end reduce using rule 15 (expr -> ID .)
COMMA reduce using rule 15 (expr -> ID .)
RPAREN reduce using rule 15 (expr -> ID .)
state 14
(5) statement -> ID EQUALS expr .
(9) expr -> expr . PLUS expr
(10) expr -> expr . MINUS expr
(11) expr -> expr . MULT expr
(12) expr -> expr . DIV expr
INT reduce using rule 5 (statement -> ID EQUALS expr .)
STRING reduce using rule 5 (statement -> ID EQUALS expr .)
ID reduce using rule 5 (statement -> ID EQUALS expr .)
PRINT reduce using rule 5 (statement -> ID EQUALS expr .)
$end reduce using rule 5 (statement -> ID EQUALS expr .)
PLUS shift and go to state 23
MINUS shift and go to state 24
MULT shift and go to state 25
DIV shift and go to state 26
state 15
(13) expr -> INT .
PLUS reduce using rule 13 (expr -> INT .)
MINUS reduce using rule 13 (expr -> INT .)
MULT reduce using rule 13 (expr -> INT .)
DIV reduce using rule 13 (expr -> INT .)
INT reduce using rule 13 (expr -> INT .)
STRING reduce using rule 13 (expr -> INT .)
ID reduce using rule 13 (expr -> INT .)
PRINT reduce using rule 13 (expr -> INT .)
$end reduce using rule 13 (expr -> INT .)
COMMA reduce using rule 13 (expr -> INT .)
RPAREN reduce using rule 13 (expr -> INT .)
state 16
(14) expr -> DOUBLE .
PLUS reduce using rule 14 (expr -> DOUBLE .)
MINUS reduce using rule 14 (expr -> DOUBLE .)
MULT reduce using rule 14 (expr -> DOUBLE .)
DIV reduce using rule 14 (expr -> DOUBLE .)
INT reduce using rule 14 (expr -> DOUBLE .)
STRING reduce using rule 14 (expr -> DOUBLE .)
ID reduce using rule 14 (expr -> DOUBLE .)
PRINT reduce using rule 14 (expr -> DOUBLE .)
$end reduce using rule 14 (expr -> DOUBLE .)
COMMA reduce using rule 14 (expr -> DOUBLE .)
RPAREN reduce using rule 14 (expr -> DOUBLE .)
state 17
(16) expr -> STRING .
PLUS reduce using rule 16 (expr -> STRING .)
MINUS reduce using rule 16 (expr -> STRING .)
MULT reduce using rule 16 (expr -> STRING .)
DIV reduce using rule 16 (expr -> STRING .)
INT reduce using rule 16 (expr -> STRING .)
STRING reduce using rule 16 (expr -> STRING .)
ID reduce using rule 16 (expr -> STRING .)
PRINT reduce using rule 16 (expr -> STRING .)
$end reduce using rule 16 (expr -> STRING .)
COMMA reduce using rule 16 (expr -> STRING .)
RPAREN reduce using rule 16 (expr -> STRING .)
state 18
(17) expr -> BOOL .
PLUS reduce using rule 17 (expr -> BOOL .)
MINUS reduce using rule 17 (expr -> BOOL .)
MULT reduce using rule 17 (expr -> BOOL .)
DIV reduce using rule 17 (expr -> BOOL .)
INT reduce using rule 17 (expr -> BOOL .)
STRING reduce using rule 17 (expr -> BOOL .)
ID reduce using rule 17 (expr -> BOOL .)
PRINT reduce using rule 17 (expr -> BOOL .)
$end reduce using rule 17 (expr -> BOOL .)
COMMA reduce using rule 17 (expr -> BOOL .)
RPAREN reduce using rule 17 (expr -> BOOL .)
state 19
(4) statement -> STRING ID EQUALS . expr
(9) expr -> . expr PLUS expr
(10) expr -> . expr MINUS expr
(11) expr -> . expr MULT expr
(12) expr -> . expr DIV expr
(13) expr -> . INT
(14) expr -> . DOUBLE
(15) expr -> . ID
(16) expr -> . STRING
(17) expr -> . BOOL
INT shift and go to state 15
DOUBLE shift and go to state 16
ID shift and go to state 13
STRING shift and go to state 17
BOOL shift and go to state 18
expr shift and go to state 27
state 20
(6) statement -> PRINT LPAREN print_expr . RPAREN
RPAREN shift and go to state 28
state 21
(7) print_expr -> expr .
(8) print_expr -> expr . COMMA print_expr
(9) expr -> expr . PLUS expr
(10) expr -> expr . MINUS expr
(11) expr -> expr . MULT expr
(12) expr -> expr . DIV expr
RPAREN reduce using rule 7 (print_expr -> expr .)
COMMA shift and go to state 29
PLUS shift and go to state 23
MINUS shift and go to state 24
MULT shift and go to state 25
DIV shift and go to state 26
state 22
(3) statement -> INT ID EQUALS expr .
(9) expr -> expr . PLUS expr
(10) expr -> expr . MINUS expr
(11) expr -> expr . MULT expr
(12) expr -> expr . DIV expr
INT reduce using rule 3 (statement -> INT ID EQUALS expr .)
STRING reduce using rule 3 (statement -> INT ID EQUALS expr .)
ID reduce using rule 3 (statement -> INT ID EQUALS expr .)
PRINT reduce using rule 3 (statement -> INT ID EQUALS expr .)
$end reduce using rule 3 (statement -> INT ID EQUALS expr .)
PLUS shift and go to state 23
MINUS shift and go to state 24
MULT shift and go to state 25
DIV shift and go to state 26
state 23
(9) expr -> expr PLUS . expr
(9) expr -> . expr PLUS expr
(10) expr -> . expr MINUS expr
(11) expr -> . expr MULT expr
(12) expr -> . expr DIV expr
(13) expr -> . INT
(14) expr -> . DOUBLE
(15) expr -> . ID
(16) expr -> . STRING
(17) expr -> . BOOL
INT shift and go to state 15
DOUBLE shift and go to state 16
ID shift and go to state 13
STRING shift and go to state 17
BOOL shift and go to state 18
expr shift and go to state 30
state 24
(10) expr -> expr MINUS . expr
(9) expr -> . expr PLUS expr
(10) expr -> . expr MINUS expr
(11) expr -> . expr MULT expr
(12) expr -> . expr DIV expr
(13) expr -> . INT
(14) expr -> . DOUBLE
(15) expr -> . ID
(16) expr -> . STRING
(17) expr -> . BOOL
INT shift and go to state 15
DOUBLE shift and go to state 16
ID shift and go to state 13
STRING shift and go to state 17
BOOL shift and go to state 18
expr shift and go to state 31
state 25
(11) expr -> expr MULT . expr
(9) expr -> . expr PLUS expr
(10) expr -> . expr MINUS expr
(11) expr -> . expr MULT expr
(12) expr -> . expr DIV expr
(13) expr -> . INT
(14) expr -> . DOUBLE
(15) expr -> . ID
(16) expr -> . STRING
(17) expr -> . BOOL
INT shift and go to state 15
DOUBLE shift and go to state 16
ID shift and go to state 13
STRING shift and go to state 17
BOOL shift and go to state 18
expr shift and go to state 32
state 26
(12) expr -> expr DIV . expr
(9) expr -> . expr PLUS expr
(10) expr -> . expr MINUS expr
(11) expr -> . expr MULT expr
(12) expr -> . expr DIV expr
(13) expr -> . INT
(14) expr -> . DOUBLE
(15) expr -> . ID
(16) expr -> . STRING
(17) expr -> . BOOL
INT shift and go to state 15
DOUBLE shift and go to state 16
ID shift and go to state 13
STRING shift and go to state 17
BOOL shift and go to state 18
expr shift and go to state 33
state 27
(4) statement -> STRING ID EQUALS expr .
(9) expr -> expr . PLUS expr
(10) expr -> expr . MINUS expr
(11) expr -> expr . MULT expr
(12) expr -> expr . DIV expr
INT reduce using rule 4 (statement -> STRING ID EQUALS expr .)
STRING reduce using rule 4 (statement -> STRING ID EQUALS expr .)
ID reduce using rule 4 (statement -> STRING ID EQUALS expr .)
PRINT reduce using rule 4 (statement -> STRING ID EQUALS expr .)
$end reduce using rule 4 (statement -> STRING ID EQUALS expr .)
PLUS shift and go to state 23
MINUS shift and go to state 24
MULT shift and go to state 25
DIV shift and go to state 26
state 28
(6) statement -> PRINT LPAREN print_expr RPAREN .
INT reduce using rule 6 (statement -> PRINT LPAREN print_expr RPAREN .)
STRING reduce using rule 6 (statement -> PRINT LPAREN print_expr RPAREN .)
ID reduce using rule 6 (statement -> PRINT LPAREN print_expr RPAREN .)
PRINT reduce using rule 6 (statement -> PRINT LPAREN print_expr RPAREN .)
$end reduce using rule 6 (statement -> PRINT LPAREN print_expr RPAREN .)
state 29
(8) print_expr -> expr COMMA . print_expr
(7) print_expr -> . expr
(8) print_expr -> . expr COMMA print_expr
(9) expr -> . expr PLUS expr
(10) expr -> . expr MINUS expr
(11) expr -> . expr MULT expr
(12) expr -> . expr DIV expr
(13) expr -> . INT
(14) expr -> . DOUBLE
(15) expr -> . ID
(16) expr -> . STRING
(17) expr -> . BOOL
INT shift and go to state 15
DOUBLE shift and go to state 16
ID shift and go to state 13
STRING shift and go to state 17
BOOL shift and go to state 18
expr shift and go to state 21
print_expr shift and go to state 34
state 30
(9) expr -> expr PLUS expr .
(9) expr -> expr . PLUS expr
(10) expr -> expr . MINUS expr
(11) expr -> expr . MULT expr
(12) expr -> expr . DIV expr
PLUS reduce using rule 9 (expr -> expr PLUS expr .)
MINUS reduce using rule 9 (expr -> expr PLUS expr .)
INT reduce using rule 9 (expr -> expr PLUS expr .)
STRING reduce using rule 9 (expr -> expr PLUS expr .)
ID reduce using rule 9 (expr -> expr PLUS expr .)
PRINT reduce using rule 9 (expr -> expr PLUS expr .)
$end reduce using rule 9 (expr -> expr PLUS expr .)
COMMA reduce using rule 9 (expr -> expr PLUS expr .)
RPAREN reduce using rule 9 (expr -> expr PLUS expr .)
MULT shift and go to state 25
DIV shift and go to state 26
! MULT [ reduce using rule 9 (expr -> expr PLUS expr .) ]
! DIV [ reduce using rule 9 (expr -> expr PLUS expr .) ]
! PLUS [ shift and go to state 23 ]
! MINUS [ shift and go to state 24 ]
state 31
(10) expr -> expr MINUS expr .
(9) expr -> expr . PLUS expr
(10) expr -> expr . MINUS expr
(11) expr -> expr . MULT expr
(12) expr -> expr . DIV expr
PLUS reduce using rule 10 (expr -> expr MINUS expr .)
MINUS reduce using rule 10 (expr -> expr MINUS expr .)
INT reduce using rule 10 (expr -> expr MINUS expr .)
STRING reduce using rule 10 (expr -> expr MINUS expr .)
ID reduce using rule 10 (expr -> expr MINUS expr .)
PRINT reduce using rule 10 (expr -> expr MINUS expr .)
$end reduce using rule 10 (expr -> expr MINUS expr .)
COMMA reduce using rule 10 (expr -> expr MINUS expr .)
RPAREN reduce using rule 10 (expr -> expr MINUS expr .)
MULT shift and go to state 25
DIV shift and go to state 26
! MULT [ reduce using rule 10 (expr -> expr MINUS expr .) ]
! DIV [ reduce using rule 10 (expr -> expr MINUS expr .) ]
! PLUS [ shift and go to state 23 ]
! MINUS [ shift and go to state 24 ]
state 32
(11) expr -> expr MULT expr .
(9) expr -> expr . PLUS expr
(10) expr -> expr . MINUS expr
(11) expr -> expr . MULT expr
(12) expr -> expr . DIV expr
PLUS reduce using rule 11 (expr -> expr MULT expr .)
MINUS reduce using rule 11 (expr -> expr MULT expr .)
MULT reduce using rule 11 (expr -> expr MULT expr .)
DIV reduce using rule 11 (expr -> expr MULT expr .)
INT reduce using rule 11 (expr -> expr MULT expr .)
STRING reduce using rule 11 (expr -> expr MULT expr .)
ID reduce using rule 11 (expr -> expr MULT expr .)
PRINT reduce using rule 11 (expr -> expr MULT expr .)
$end reduce using rule 11 (expr -> expr MULT expr .)
COMMA reduce using rule 11 (expr -> expr MULT expr .)
RPAREN reduce using rule 11 (expr -> expr MULT expr .)
! PLUS [ shift and go to state 23 ]
! MINUS [ shift and go to state 24 ]
! MULT [ shift and go to state 25 ]
! DIV [ shift and go to state 26 ]
state 33
(12) expr -> expr DIV expr .
(9) expr -> expr . PLUS expr
(10) expr -> expr . MINUS expr
(11) expr -> expr . MULT expr
(12) expr -> expr . DIV expr
PLUS reduce using rule 12 (expr -> expr DIV expr .)
MINUS reduce using rule 12 (expr -> expr DIV expr .)
MULT reduce using rule 12 (expr -> expr DIV expr .)
DIV reduce using rule 12 (expr -> expr DIV expr .)
INT reduce using rule 12 (expr -> expr DIV expr .)
STRING reduce using rule 12 (expr -> expr DIV expr .)
ID reduce using rule 12 (expr -> expr DIV expr .)
PRINT reduce using rule 12 (expr -> expr DIV expr .)
$end reduce using rule 12 (expr -> expr DIV expr .)
COMMA reduce using rule 12 (expr -> expr DIV expr .)
RPAREN reduce using rule 12 (expr -> expr DIV expr .)
! PLUS [ shift and go to state 23 ]
! MINUS [ shift and go to state 24 ]
! MULT [ shift and go to state 25 ]
! DIV [ shift and go to state 26 ]
state 34
(8) print_expr -> expr COMMA print_expr .
RPAREN reduce using rule 8 (print_expr -> expr COMMA print_expr .)