Summary Files Commits Branches @commit @diff @stats
path: root / Year 3 / Compilers, Introduction / coolc-spim / my-code / coursework / pa2 / cool.output
blob: 254c7e5c3a350f2285fe6ad3b3c1f914fdf19b19 (plain) (blame)
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
Terminals unused in grammar

    ELSE
    FI
    IF
    IN
    LET
    LOOP
    POOL
    THEN
    WHILE
    CASE
    ESAC
    OF
    DARROW
    NEW
    ISVOID
    STR_CONST
    INT_CONST
    BOOL_CONST
    OBJECTID
    ASSIGN
    NOT
    LE
    ERROR


Grammar

    0 $accept: program $end

    1 program: class_list

    2 class_list: class
    3           | class_list class

    4 class: CLASS TYPEID '{' dummy_feature_list '}' ';'
    5      | CLASS TYPEID INHERITS TYPEID '{' dummy_feature_list '}' ';'

    6 dummy_feature_list: %empty


Terminals, with rules where they appear

    $end (0) 0
    ';' (59) 4 5
    '{' (123) 4 5
    '}' (125) 4 5
    error (256)
    CLASS (258) 4 5
    ELSE (259)
    FI (260)
    IF (261)
    IN (262)
    INHERITS (263) 5
    LET (264)
    LOOP (265)
    POOL (266)
    THEN (267)
    WHILE (268)
    CASE (269)
    ESAC (270)
    OF (271)
    DARROW (272)
    NEW (273)
    ISVOID (274)
    STR_CONST <symbol> (275)
    INT_CONST <symbol> (276)
    BOOL_CONST <boolean> (277)
    TYPEID <symbol> (278) 4 5
    OBJECTID <symbol> (279)
    ASSIGN (280)
    NOT (281)
    LE (282)
    ERROR (283)


Nonterminals, with rules where they appear

    $accept (32)
        on left: 0
    program <program> (33)
        on left: 1
        on right: 0
    class_list <classes> (34)
        on left: 2 3
        on right: 1 3
    class <class_> (35)
        on left: 4 5
        on right: 2 3
    dummy_feature_list <features> (36)
        on left: 6
        on right: 4 5


State 0

    0 $accept: . program $end

    CLASS  shift, and go to state 1

    program     go to state 2
    class_list  go to state 3
    class       go to state 4


State 1

    4 class: CLASS . TYPEID '{' dummy_feature_list '}' ';'
    5      | CLASS . TYPEID INHERITS TYPEID '{' dummy_feature_list '}' ';'

    TYPEID  shift, and go to state 5


State 2

    0 $accept: program . $end

    $end  shift, and go to state 6


State 3

    1 program: class_list .
    3 class_list: class_list . class

    CLASS  shift, and go to state 1

    $default  reduce using rule 1 (program)

    class  go to state 7


State 4

    2 class_list: class .

    $default  reduce using rule 2 (class_list)


State 5

    4 class: CLASS TYPEID . '{' dummy_feature_list '}' ';'
    5      | CLASS TYPEID . INHERITS TYPEID '{' dummy_feature_list '}' ';'

    INHERITS  shift, and go to state 8
    '{'       shift, and go to state 9


State 6

    0 $accept: program $end .

    $default  accept


State 7

    3 class_list: class_list class .

    $default  reduce using rule 3 (class_list)


State 8

    5 class: CLASS TYPEID INHERITS . TYPEID '{' dummy_feature_list '}' ';'

    TYPEID  shift, and go to state 10


State 9

    4 class: CLASS TYPEID '{' . dummy_feature_list '}' ';'

    $default  reduce using rule 6 (dummy_feature_list)

    dummy_feature_list  go to state 11


State 10

    5 class: CLASS TYPEID INHERITS TYPEID . '{' dummy_feature_list '}' ';'

    '{'  shift, and go to state 12


State 11

    4 class: CLASS TYPEID '{' dummy_feature_list . '}' ';'

    '}'  shift, and go to state 13


State 12

    5 class: CLASS TYPEID INHERITS TYPEID '{' . dummy_feature_list '}' ';'

    $default  reduce using rule 6 (dummy_feature_list)

    dummy_feature_list  go to state 14


State 13

    4 class: CLASS TYPEID '{' dummy_feature_list '}' . ';'

    ';'  shift, and go to state 15


State 14

    5 class: CLASS TYPEID INHERITS TYPEID '{' dummy_feature_list . '}' ';'

    '}'  shift, and go to state 16


State 15

    4 class: CLASS TYPEID '{' dummy_feature_list '}' ';' .

    $default  reduce using rule 4 (class)


State 16

    5 class: CLASS TYPEID INHERITS TYPEID '{' dummy_feature_list '}' . ';'

    ';'  shift, and go to state 17


State 17

    5 class: CLASS TYPEID INHERITS TYPEID '{' dummy_feature_list '}' ';' .

    $default  reduce using rule 5 (class)