1;---------------------
2; LALR(1) parse tables
3;---------------------
4;
5; Suitable for input to the Common Lisp program
6;
7; LR(1)AndLALR(1)Parser.lsp
8;
9
10; TERMINALS
11;
12
13(COMMA + INTEGER ^ X $)
14
15; PRODUCTIONS
16;
17; Productions are numbered starting with 1.
18; All alternates were expanded into separate productions.
19
20(
21 ( (1) (S -> POLY MOD) )
22 ( (2) (MOD -> COMMA INTEGER) )
23 ( (3) (MOD -> EPSILON) )
24 ( (4) (POLY -> POLY + TERM) )
25 ( (5) (POLY -> TERM) )
26 ( (6) (TERM -> MULTIPLIER POWER) )
27 ( (7) (MULTIPLIER -> INTEGER) )
28 ( (8) (MULTIPLIER -> EPSILON) )
29 ( (9) (POWER -> X) )
30 ( (10) (POWER -> X ^ INTEGER) )
31 ( (11) (POWER -> EPSILON) )
32)
33
34; GOTO GRAPH
35;
36; Not needed for the parser, but here for reference and debugging.
37; **********
38; Goto graph of the LR(1) or LALR(1) grammar of the form
39;
40; (
41; ( <-- List of links.
42; (6 |a| 4) <-- Transition in Goto graph from state 6 to
43; state 4 on symbol a.
44; (1 |a| 2) <-- Transition from state 1 to state 2 on a.
45; )
46;
47; ( <-- List of sets of items.
48; ( 0 <-- State number 0.
49; 3668 <-- Hash value of core.
50; (
51; (SP -> DOT S |,| $) ----+
52; ( S -> DOT S |a| S |b| |,| $) |
53; ( S -> DOT EPSILON |,| $) +---- Set of items for state 0
54; ( S -> DOT S |a| S |b| |,| |a|) |
55; ( S -> DOT EPSILON |,| |a|) |
56; ) ----+
57; )
58
59(
60 (
61 (-1 NIL 0)
62 (0 S 1)
63 (0 POLY 2)
64 (0 INTEGER 3)
65 (0 TERM 4)
66 (0 MULTIPLIER 5)
67 (2 MOD 6)
68 (2 COMMA 7)
69 (2 + 8)
70 (5 POWER 9)
71 (5 X 10)
72 (7 INTEGER 11)
73 (8 INTEGER 3)
74 (8 TERM 12)
75 (8 MULTIPLIER 5)
76 (10 ^ 13)
77 (13 INTEGER 14)
78 )
79 (
80 (1
81 1752
82 (SP -> S DOT |,| $)
83 )
84 (4
85 2922
86 (POLY -> TERM DOT |,| COMMA)
87 (POLY -> TERM DOT |,| $)
88 (POLY -> TERM DOT |,| +)
89 )
90 (7
91 3307
92 (MOD -> COMMA DOT INTEGER |,| $)
93 )
94 (6
95 3876
96 (S -> POLY MOD DOT |,| $)
97 )
98 (13
99 4194
100 (POWER -> X ^ DOT INTEGER |,| COMMA)
101 (POWER -> X ^ DOT INTEGER |,| $)
102 (POWER -> X ^ DOT INTEGER |,| +)
103 )
104 (3
105 4917
106 (MULTIPLIER -> INTEGER DOT |,| X)
107 (MULTIPLIER -> INTEGER DOT |,| COMMA)
108 (MULTIPLIER -> INTEGER DOT |,| $)
109 (MULTIPLIER -> INTEGER DOT |,| +)
110 )
111 (10
112 5558
113 (POWER -> X DOT |,| COMMA)
114 (POWER -> X DOT ^ INTEGER |,| COMMA)
115 (POWER -> X DOT |,| $)
116 (POWER -> X DOT ^ INTEGER |,| $)
117 (POWER -> X DOT |,| +)
118 (POWER -> X DOT ^ INTEGER |,| +)
119 )
120 (11
121 5812
122 (MOD -> COMMA INTEGER DOT |,| $)
123 )
124 (12
125 6705
126 (POLY -> POLY + TERM DOT |,| COMMA)
127 (POLY -> POLY + TERM DOT |,| $)
128 (POLY -> POLY + TERM DOT |,| +)
129 )
130 (14
131 7215
132 (POWER -> X ^ INTEGER DOT |,| COMMA)
133 (POWER -> X ^ INTEGER DOT |,| $)
134 (POWER -> X ^ INTEGER DOT |,| +)
135 )
136 (9
137 7288
138 (TERM -> MULTIPLIER POWER DOT |,| COMMA)
139 (TERM -> MULTIPLIER POWER DOT |,| $)
140 (TERM -> MULTIPLIER POWER DOT |,| +)
141 )
142 (2
143 9449
144 (S -> POLY DOT MOD |,| $)
145 (POLY -> POLY DOT + TERM |,| COMMA)
146 (POLY -> POLY DOT + TERM |,| $)
147 (POLY -> POLY DOT + TERM |,| +)
148 (MOD -> DOT COMMA INTEGER |,| $)
149 (MOD -> DOT EPSILON |,| $)
150 )
151 (5
152 10416
153 (TERM -> MULTIPLIER DOT POWER |,| COMMA)
154 (TERM -> MULTIPLIER DOT POWER |,| $)
155 (TERM -> MULTIPLIER DOT POWER |,| +)
156 (POWER -> DOT X |,| COMMA)
157 (POWER -> DOT X ^ INTEGER |,| COMMA)
158 (POWER -> DOT EPSILON |,| COMMA)
159 (POWER -> DOT X |,| $)
160 (POWER -> DOT X ^ INTEGER |,| $)
161 (POWER -> DOT EPSILON |,| $)
162 (POWER -> DOT X |,| +)
163 (POWER -> DOT X ^ INTEGER |,| +)
164 (POWER -> DOT EPSILON |,| +)
165 )
166 (8
167 12416
168 (POLY -> POLY + DOT TERM |,| COMMA)
169 (POLY -> POLY + DOT TERM |,| $)
170 (POLY -> POLY + DOT TERM |,| +)
171 (TERM -> DOT MULTIPLIER POWER |,| COMMA)
172 (TERM -> DOT MULTIPLIER POWER |,| $)
173 (TERM -> DOT MULTIPLIER POWER |,| +)
174 (MULTIPLIER -> DOT INTEGER |,| X)
175 (MULTIPLIER -> DOT INTEGER |,| COMMA)
176 (MULTIPLIER -> DOT EPSILON |,| X)
177 (MULTIPLIER -> DOT EPSILON |,| COMMA)
178 (MULTIPLIER -> DOT INTEGER |,| $)
179 (MULTIPLIER -> DOT EPSILON |,| $)
180 (MULTIPLIER -> DOT INTEGER |,| +)
181 (MULTIPLIER -> DOT EPSILON |,| +)
182 )
183 (0
184 14102
185 (SP -> DOT S |,| $)
186 (S -> DOT POLY MOD |,| $)
187 (POLY -> DOT POLY + TERM |,| COMMA)
188 (POLY -> DOT POLY + TERM |,| $)
189 (POLY -> DOT TERM |,| COMMA)
190 (POLY -> DOT TERM |,| $)
191 (POLY -> DOT POLY + TERM |,| +)
192 (POLY -> DOT TERM |,| +)
193 (TERM -> DOT MULTIPLIER POWER |,| COMMA)
194 (TERM -> DOT MULTIPLIER POWER |,| $)
195 (TERM -> DOT MULTIPLIER POWER |,| +)
196 (MULTIPLIER -> DOT INTEGER |,| X)
197 (MULTIPLIER -> DOT INTEGER |,| COMMA)
198 (MULTIPLIER -> DOT EPSILON |,| X)
199 (MULTIPLIER -> DOT EPSILON |,| COMMA)
200 (MULTIPLIER -> DOT INTEGER |,| $)
201 (MULTIPLIER -> DOT EPSILON |,| $)
202 (MULTIPLIER -> DOT INTEGER |,| +)
203 (MULTIPLIER -> DOT EPSILON |,| +)
204 )
205 )
206)
207
208; ACTION TABLE
209;
210; (state
211; (item)
212; ...
213
214(
215 ( (0)
216 (
217 (INTEGER (S 3))
218 (X (R 8))
219 (COMMA (R 8))
220 ($ (R 8))
221 (+ (R 8))
222 (DEFAULT (ERROR))
223 )
224 )
225 ( (1)
226 (
227 ($ (ACC NIL))
228 (DEFAULT (ERROR))
229 )
230 )
231 ( (2)
232 (
233 (COMMA (S 7))
234 (+ (S 8))
235 ($ (R 3))
236 (DEFAULT (ERROR))
237 )
238 )
239 ( (3)
240 (
241 (X (R 7))
242 (COMMA (R 7))
243 ($ (R 7))
244 (+ (R 7))
245 (DEFAULT (ERROR))
246 )
247 )
248 ( (4)
249 (
250 (COMMA (R 5))
251 ($ (R 5))
252 (+ (R 5))
253 (DEFAULT (ERROR))
254 )
255 )
256 ( (5)
257 (
258 (X (S 10))
259 (COMMA (R 11))
260 ($ (R 11))
261 (+ (R 11))
262 (DEFAULT (ERROR))
263 )
264 )
265 ( (6)
266 (
267 ($ (R 1))
268 (DEFAULT (ERROR))
269 )
270 )
271 ( (7)
272 (
273 (INTEGER (S 11))
274 (DEFAULT (ERROR))
275 )
276 )
277 ( (8)
278 (
279 (INTEGER (S 3))
280 (X (R 8))
281 (COMMA (R 8))
282 ($ (R 8))
283 (+ (R 8))
284 (DEFAULT (ERROR))
285 )
286 )
287 ( (9)
288 (
289 (COMMA (R 6))
290 ($ (R 6))
291 (+ (R 6))
292 (DEFAULT (ERROR))
293 )
294 )
295 ( (10)
296 (
297 (COMMA (R 9))
298 (^ (S 13))
299 ($ (R 9))
300 (+ (R 9))
301 (DEFAULT (ERROR))
302 )
303 )
304 ( (11)
305 (
306 ($ (R 2))
307 (DEFAULT (ERROR))
308 )
309 )
310 ( (12)
311 (
312 (COMMA (R 4))
313 ($ (R 4))
314 (+ (R 4))
315 (DEFAULT (ERROR))
316 )
317 )
318 ( (13)
319 (
320 (INTEGER (S 14))
321 (DEFAULT (ERROR))
322 )
323 )
324 ( (14)
325 (
326 (COMMA (R 10))
327 ($ (R 10))
328 (+ (R 10))
329 (DEFAULT (ERROR))
330 )
331 )
332)
333
334; GOTO TABLE
335;
336; (state
337; (item)
338; ...
339
340(
341 ( (0)
342 (
343 (S 1)
344 (POLY 2)
345 (TERM 4)
346 (MULTIPLIER 5)
347 (DEFAULT (ERROR))
348 )
349 )
350 ( (2)
351 (
352 (MOD 6)
353 (DEFAULT (ERROR))
354 )
355 )
356 ( (5)
357 (
358 (POWER 9)
359 (DEFAULT (ERROR))
360 )
361 )
362 ( (8)
363 (
364 (TERM 12)
365 (MULTIPLIER 5)
366 (DEFAULT (ERROR))
367 )
368 )
369)
370
371
372; ERROR MESSAGE TABLE
373;
374; If the action table has an error state, the other non-error
375; actions show which symbol was failed to appear next on the input.
376;
377; The user can modify these minimal error messages.
378
379
380
381(
382
383 ((0) ("error - expecting one of the symbols + $ COMMA X INTEGER"))
384 ((1) ("error - expecting one of the symbols $"))
385 ((2) ("error - expecting one of the symbols $ + COMMA"))
386 ((3) ("error - expecting one of the symbols + $ COMMA X"))
387 ((4) ("error - expecting one of the symbols + $ COMMA"))
388 ((5) ("error - expecting one of the symbols + $ COMMA X"))
389 ((6) ("error - expecting one of the symbols $"))
390 ((7) ("error - expecting one of the symbols INTEGER"))
391 ((8) ("error - expecting one of the symbols + $ COMMA X INTEGER"))
392 ((9) ("error - expecting one of the symbols + $ COMMA"))
393 ((10) ("error - expecting one of the symbols + $ ^ COMMA"))
394 ((11) ("error - expecting one of the symbols $"))
395 ((12) ("error - expecting one of the symbols + $ COMMA"))
396 ((13) ("error - expecting one of the symbols INTEGER"))
397 ((14) ("error - expecting one of the symbols + $ COMMA"))
398)