-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathparser.output
More file actions
621 lines (365 loc) · 13.1 KB
/
parser.output
File metadata and controls
621 lines (365 loc) · 13.1 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
State 38 conflicts: 1 shift/reduce
Grammar
0 $accept: statement_list $end
1 statement_list: top_statement
2 | statement_list top_statement
3 top_statement: statement
4 | function_declaration
5 | "\n" top_statement
6 statement: assignment
7 | function_call
8 | return
9 assignment: IDENTIFIER EQUAL expression
10 function_call: IDENTIFIER OPEN_PAREN args_list CLOSE_PAREN
11 args_list: expression
12 | args_list COMMA expression
13 return: RET expression
14 function_declaration: DEF IDENTIFIER OPEN_PAREN CLOSE_PAREN COLON body
15 | DEF IDENTIFIER OPEN_PAREN param_list CLOSE_PAREN COLON body
16 param_list: IDENTIFIER
17 | param_list COMMA IDENTIFIER
18 body: TAB statement
19 | body TAB statement
20 expression: OPEN_PAREN expression CLOSE_PAREN
21 | binary_expression
22 | variable
23 | function_call
24 | INT_TOKEN
25 | FLOAT_TOKEN
26 | STRING_TOKEN
27 | BOOL_TOKEN
28 binary_expression: expression OP expression
29 variable: IDENTIFIER
Terminals, with rules where they appear
$end (0) 0
error (256)
DEF (258) 14 15
RET (259) 13
EQUAL (260) 9
OPEN_PAREN (261) 10 14 15 20
CLOSE_PAREN (262) 10 14 15 20
COMMA (263) 12 17
COLON (264) 14 15
TAB (265) 18 19
IDENTIFIER (266) 9 10 14 15 16 17 29
INT_TOKEN (267) 24
FLOAT_TOKEN (268) 25
STRING_TOKEN (269) 26
BOOL_TOKEN (270) 27
OP (271) 28
"\n" (272) 5
Nonterminals, with rules where they appear
$accept (18)
on left: 0
statement_list (19)
on left: 1 2, on right: 0 2
top_statement (20)
on left: 3 4 5, on right: 1 2 5
statement (21)
on left: 6 7 8, on right: 3 18 19
assignment (22)
on left: 9, on right: 6
function_call (23)
on left: 10, on right: 7 23
args_list (24)
on left: 11 12, on right: 10 12
return (25)
on left: 13, on right: 8
function_declaration (26)
on left: 14 15, on right: 4
param_list (27)
on left: 16 17, on right: 15 17
body (28)
on left: 18 19, on right: 14 15 19
expression (29)
on left: 20 21 22 23 24 25 26 27, on right: 9 11 12 13 20 28
binary_expression (30)
on left: 28, on right: 21
variable (31)
on left: 29, on right: 22
State 0
0 $accept: . statement_list $end
DEF shift, and go to state 1
RET shift, and go to state 2
IDENTIFIER shift, and go to state 3
"\n" shift, and go to state 4
statement_list go to state 5
top_statement go to state 6
statement go to state 7
assignment go to state 8
function_call go to state 9
return go to state 10
function_declaration go to state 11
State 1
14 function_declaration: DEF . IDENTIFIER OPEN_PAREN CLOSE_PAREN COLON body
15 | DEF . IDENTIFIER OPEN_PAREN param_list CLOSE_PAREN COLON body
IDENTIFIER shift, and go to state 12
State 2
13 return: RET . expression
OPEN_PAREN shift, and go to state 13
IDENTIFIER shift, and go to state 14
INT_TOKEN shift, and go to state 15
FLOAT_TOKEN shift, and go to state 16
STRING_TOKEN shift, and go to state 17
BOOL_TOKEN shift, and go to state 18
function_call go to state 19
expression go to state 20
binary_expression go to state 21
variable go to state 22
State 3
9 assignment: IDENTIFIER . EQUAL expression
10 function_call: IDENTIFIER . OPEN_PAREN args_list CLOSE_PAREN
EQUAL shift, and go to state 23
OPEN_PAREN shift, and go to state 24
State 4
5 top_statement: "\n" . top_statement
DEF shift, and go to state 1
RET shift, and go to state 2
IDENTIFIER shift, and go to state 3
"\n" shift, and go to state 4
top_statement go to state 25
statement go to state 7
assignment go to state 8
function_call go to state 9
return go to state 10
function_declaration go to state 11
State 5
0 $accept: statement_list . $end
2 statement_list: statement_list . top_statement
$end shift, and go to state 26
DEF shift, and go to state 1
RET shift, and go to state 2
IDENTIFIER shift, and go to state 3
"\n" shift, and go to state 4
top_statement go to state 27
statement go to state 7
assignment go to state 8
function_call go to state 9
return go to state 10
function_declaration go to state 11
State 6
1 statement_list: top_statement .
$default reduce using rule 1 (statement_list)
State 7
3 top_statement: statement .
$default reduce using rule 3 (top_statement)
State 8
6 statement: assignment .
$default reduce using rule 6 (statement)
State 9
7 statement: function_call .
$default reduce using rule 7 (statement)
State 10
8 statement: return .
$default reduce using rule 8 (statement)
State 11
4 top_statement: function_declaration .
$default reduce using rule 4 (top_statement)
State 12
14 function_declaration: DEF IDENTIFIER . OPEN_PAREN CLOSE_PAREN COLON body
15 | DEF IDENTIFIER . OPEN_PAREN param_list CLOSE_PAREN COLON body
OPEN_PAREN shift, and go to state 28
State 13
20 expression: OPEN_PAREN . expression CLOSE_PAREN
OPEN_PAREN shift, and go to state 13
IDENTIFIER shift, and go to state 14
INT_TOKEN shift, and go to state 15
FLOAT_TOKEN shift, and go to state 16
STRING_TOKEN shift, and go to state 17
BOOL_TOKEN shift, and go to state 18
function_call go to state 19
expression go to state 29
binary_expression go to state 21
variable go to state 22
State 14
10 function_call: IDENTIFIER . OPEN_PAREN args_list CLOSE_PAREN
29 variable: IDENTIFIER .
OPEN_PAREN shift, and go to state 24
$default reduce using rule 29 (variable)
State 15
24 expression: INT_TOKEN .
$default reduce using rule 24 (expression)
State 16
25 expression: FLOAT_TOKEN .
$default reduce using rule 25 (expression)
State 17
26 expression: STRING_TOKEN .
$default reduce using rule 26 (expression)
State 18
27 expression: BOOL_TOKEN .
$default reduce using rule 27 (expression)
State 19
23 expression: function_call .
$default reduce using rule 23 (expression)
State 20
13 return: RET expression .
28 binary_expression: expression . OP expression
OP shift, and go to state 30
$default reduce using rule 13 (return)
State 21
21 expression: binary_expression .
$default reduce using rule 21 (expression)
State 22
22 expression: variable .
$default reduce using rule 22 (expression)
State 23
9 assignment: IDENTIFIER EQUAL . expression
OPEN_PAREN shift, and go to state 13
IDENTIFIER shift, and go to state 14
INT_TOKEN shift, and go to state 15
FLOAT_TOKEN shift, and go to state 16
STRING_TOKEN shift, and go to state 17
BOOL_TOKEN shift, and go to state 18
function_call go to state 19
expression go to state 31
binary_expression go to state 21
variable go to state 22
State 24
10 function_call: IDENTIFIER OPEN_PAREN . args_list CLOSE_PAREN
OPEN_PAREN shift, and go to state 13
IDENTIFIER shift, and go to state 14
INT_TOKEN shift, and go to state 15
FLOAT_TOKEN shift, and go to state 16
STRING_TOKEN shift, and go to state 17
BOOL_TOKEN shift, and go to state 18
function_call go to state 19
args_list go to state 32
expression go to state 33
binary_expression go to state 21
variable go to state 22
State 25
5 top_statement: "\n" top_statement .
$default reduce using rule 5 (top_statement)
State 26
0 $accept: statement_list $end .
$default accept
State 27
2 statement_list: statement_list top_statement .
$default reduce using rule 2 (statement_list)
State 28
14 function_declaration: DEF IDENTIFIER OPEN_PAREN . CLOSE_PAREN COLON body
15 | DEF IDENTIFIER OPEN_PAREN . param_list CLOSE_PAREN COLON body
CLOSE_PAREN shift, and go to state 34
IDENTIFIER shift, and go to state 35
param_list go to state 36
State 29
20 expression: OPEN_PAREN expression . CLOSE_PAREN
28 binary_expression: expression . OP expression
CLOSE_PAREN shift, and go to state 37
OP shift, and go to state 30
State 30
28 binary_expression: expression OP . expression
OPEN_PAREN shift, and go to state 13
IDENTIFIER shift, and go to state 14
INT_TOKEN shift, and go to state 15
FLOAT_TOKEN shift, and go to state 16
STRING_TOKEN shift, and go to state 17
BOOL_TOKEN shift, and go to state 18
function_call go to state 19
expression go to state 38
binary_expression go to state 21
variable go to state 22
State 31
9 assignment: IDENTIFIER EQUAL expression .
28 binary_expression: expression . OP expression
OP shift, and go to state 30
$default reduce using rule 9 (assignment)
State 32
10 function_call: IDENTIFIER OPEN_PAREN args_list . CLOSE_PAREN
12 args_list: args_list . COMMA expression
CLOSE_PAREN shift, and go to state 39
COMMA shift, and go to state 40
State 33
11 args_list: expression .
28 binary_expression: expression . OP expression
OP shift, and go to state 30
$default reduce using rule 11 (args_list)
State 34
14 function_declaration: DEF IDENTIFIER OPEN_PAREN CLOSE_PAREN . COLON body
COLON shift, and go to state 41
State 35
16 param_list: IDENTIFIER .
$default reduce using rule 16 (param_list)
State 36
15 function_declaration: DEF IDENTIFIER OPEN_PAREN param_list . CLOSE_PAREN COLON body
17 param_list: param_list . COMMA IDENTIFIER
CLOSE_PAREN shift, and go to state 42
COMMA shift, and go to state 43
State 37
20 expression: OPEN_PAREN expression CLOSE_PAREN .
$default reduce using rule 20 (expression)
State 38
28 binary_expression: expression . OP expression
28 | expression OP expression .
OP shift, and go to state 30
OP [reduce using rule 28 (binary_expression)]
$default reduce using rule 28 (binary_expression)
State 39
10 function_call: IDENTIFIER OPEN_PAREN args_list CLOSE_PAREN .
$default reduce using rule 10 (function_call)
State 40
12 args_list: args_list COMMA . expression
OPEN_PAREN shift, and go to state 13
IDENTIFIER shift, and go to state 14
INT_TOKEN shift, and go to state 15
FLOAT_TOKEN shift, and go to state 16
STRING_TOKEN shift, and go to state 17
BOOL_TOKEN shift, and go to state 18
function_call go to state 19
expression go to state 44
binary_expression go to state 21
variable go to state 22
State 41
14 function_declaration: DEF IDENTIFIER OPEN_PAREN CLOSE_PAREN COLON . body
TAB shift, and go to state 45
body go to state 46
State 42
15 function_declaration: DEF IDENTIFIER OPEN_PAREN param_list CLOSE_PAREN . COLON body
COLON shift, and go to state 47
State 43
17 param_list: param_list COMMA . IDENTIFIER
IDENTIFIER shift, and go to state 48
State 44
12 args_list: args_list COMMA expression .
28 binary_expression: expression . OP expression
OP shift, and go to state 30
$default reduce using rule 12 (args_list)
State 45
18 body: TAB . statement
RET shift, and go to state 2
IDENTIFIER shift, and go to state 3
statement go to state 49
assignment go to state 8
function_call go to state 9
return go to state 10
State 46
14 function_declaration: DEF IDENTIFIER OPEN_PAREN CLOSE_PAREN COLON body .
19 body: body . TAB statement
TAB shift, and go to state 50
$default reduce using rule 14 (function_declaration)
State 47
15 function_declaration: DEF IDENTIFIER OPEN_PAREN param_list CLOSE_PAREN COLON . body
TAB shift, and go to state 45
body go to state 51
State 48
17 param_list: param_list COMMA IDENTIFIER .
$default reduce using rule 17 (param_list)
State 49
18 body: TAB statement .
$default reduce using rule 18 (body)
State 50
19 body: body TAB . statement
RET shift, and go to state 2
IDENTIFIER shift, and go to state 3
statement go to state 52
assignment go to state 8
function_call go to state 9
return go to state 10
State 51
15 function_declaration: DEF IDENTIFIER OPEN_PAREN param_list CLOSE_PAREN COLON body .
19 body: body . TAB statement
TAB shift, and go to state 50
$default reduce using rule 15 (function_declaration)
State 52
19 body: body TAB statement .
$default reduce using rule 19 (body)