forked from JessicaDouthit00/C-Compiler
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparser.out
More file actions
133 lines (90 loc) · 3.61 KB
/
parser.out
File metadata and controls
133 lines (90 loc) · 3.61 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
Created by PLY version 3.11 (http://www.dabeaz.com/ply)
Grammar
Rule 0 S' -> program
Rule 1 program -> opt_stmts
Rule 2 opt_stmts -> statement_list
Rule 3 opt_stmts -> null
Rule 4 null -> <empty>
Rule 5 statement_list -> statement_list statement
Rule 6 statement_list -> statement
Rule 7 statement -> while_statement
Rule 7 statement -> assignment
Rule 8 statement -> expression
Rule 9 statement -> compound_statement
Rule 10 statement -> conditional_statement
rule 11 statement -> PRINT '(' expression ')' ';'
Rule 12 assignment -> NAME '=' expression;
Rule 13 expression -> expression '+' expression
Rule 14 expression -> expression '-' expression
Rule 15 expression -> expression '*' expression
Rule 16 expression -> expression '/' expression
Rule 17 expression -> expression '**' expression
Rule 18 expression -> '(' expression ')'
Rule 19 expression -> NUMBER
Rule 20 expression -> NAME
Rule 22 compound_statement -> '{' statement_list '}'
Rule 22 conditional_statement -> IF '(' expression ')' statement
Rule 23 conditional_statement -> IF '(' expression ')' statement ELSE statement
rule 24 statement -> PRINT '(' expression ')' ';'
Terminals, with rules where they appear
NUMBER : 8
error :
Nonterminals, with rules where they appear
null : 3
number : 7
opt_stmts : 1
program : 0
statement : 5 6
statement_list : 2 5
Parsing method: LALR
state 0
(0) S' -> . program
(1) program -> . opt_stmts
(2) opt_stmts -> . statement_list
(3) opt_stmts -> . null
(5) statement_list -> . statement_list statement
(6) statement_list -> . statement
(4) null -> .
(7) statement -> . number
(8) number -> . NUMBER
$end reduce using rule 4 (null -> .)
NUMBER shift and go to state 7
program shift and go to state 1
opt_stmts shift and go to state 2
statement_list shift and go to state 3
null shift and go to state 4
statement shift and go to state 5
number shift and go to state 6
state 1
(0) S' -> program .
state 2
(1) program -> opt_stmts .
$end reduce using rule 1 (program -> opt_stmts .)
state 3
(2) opt_stmts -> statement_list .
(5) statement_list -> statement_list . statement
(7) statement -> . number
(8) number -> . NUMBER
$end reduce using rule 2 (opt_stmts -> statement_list .)
NUMBER shift and go to state 7
statement shift and go to state 8
number shift and go to state 6
state 4
(3) opt_stmts -> null .
$end reduce using rule 3 (opt_stmts -> null .)
state 5
(6) statement_list -> statement .
NUMBER reduce using rule 6 (statement_list -> statement .)
$end reduce using rule 6 (statement_list -> statement .)
state 6
(7) statement -> number .
NUMBER reduce using rule 7 (statement -> number .)
$end reduce using rule 7 (statement -> number .)
state 7
(8) number -> NUMBER .
NUMBER reduce using rule 8 (number -> NUMBER .)
$end reduce using rule 8 (number -> NUMBER .)
state 8
(5) statement_list -> statement_list statement .
NUMBER reduce using rule 5 (statement_list -> statement_list statement .)
$end reduce using rule 5 (statement_list -> statement_list statement .)