Commit | Line | Data |
a5f75d66 |
1 | *** perly.c.orig Wed Feb 14 15:29:04 1996 |
2 | --- perly.c Wed Feb 14 15:29:05 1996 |
93a17b20 |
3 | *************** |
4633a7c4 |
4 | *** 12,82 **** |
a0d0e21e |
5 | deprecate("\"do\" to call subroutines"); |
6 | } |
7 | |
748a9306 |
8 | - #line 29 "perly.y" |
a0d0e21e |
9 | - typedef union { |
10 | - I32 ival; |
11 | - char *pval; |
12 | - OP *opval; |
13 | - GV *gvval; |
14 | - } YYSTYPE; |
15 | - #line 23 "y.tab.c" |
16 | - #define WORD 257 |
17 | - #define METHOD 258 |
18 | - #define FUNCMETH 259 |
19 | - #define THING 260 |
20 | - #define PMFUNC 261 |
21 | - #define PRIVATEREF 262 |
4633a7c4 |
22 | - #define FUNC0SUB 263 |
23 | - #define UNIOPSUB 264 |
24 | - #define LSTOPSUB 265 |
25 | - #define LABEL 266 |
26 | - #define FORMAT 267 |
27 | - #define SUB 268 |
28 | - #define ANONSUB 269 |
29 | - #define PACKAGE 270 |
30 | - #define USE 271 |
31 | - #define WHILE 272 |
32 | - #define UNTIL 273 |
33 | - #define IF 274 |
34 | - #define UNLESS 275 |
35 | - #define ELSE 276 |
36 | - #define ELSIF 277 |
37 | - #define CONTINUE 278 |
38 | - #define FOR 279 |
39 | - #define LOOPEX 280 |
40 | - #define DOTDOT 281 |
41 | - #define FUNC0 282 |
42 | - #define FUNC1 283 |
43 | - #define FUNC 284 |
44 | - #define RELOP 285 |
45 | - #define EQOP 286 |
46 | - #define MULOP 287 |
47 | - #define ADDOP 288 |
48 | - #define DOLSHARP 289 |
49 | - #define DO 290 |
50 | - #define LOCAL 291 |
51 | - #define HASHBRACK 292 |
52 | - #define NOAMP 293 |
53 | - #define OROP 294 |
54 | - #define ANDOP 295 |
55 | - #define NOTOP 296 |
56 | - #define LSTOP 297 |
57 | - #define ASSIGNOP 298 |
58 | - #define OROR 299 |
59 | - #define ANDAND 300 |
60 | - #define BITOROP 301 |
61 | - #define BITANDOP 302 |
62 | - #define UNIOP 303 |
63 | - #define SHIFTOP 304 |
64 | - #define MATCHOP 305 |
65 | - #define UMINUS 306 |
66 | - #define REFGEN 307 |
67 | - #define POWOP 308 |
68 | - #define PREINC 309 |
69 | - #define PREDEC 310 |
70 | - #define POSTINC 311 |
71 | - #define POSTDEC 312 |
72 | - #define ARROW 313 |
a0d0e21e |
73 | #define YYERRCODE 256 |
74 | short yylhs[] = { -1, |
4633a7c4 |
75 | 31, 0, 5, 3, 6, 6, 6, 7, 7, 7, |
a0d0e21e |
76 | --- 12,17 ---- |
77 | *************** |
c07a80fd |
78 | *** 1381,1393 **** |
93a17b20 |
79 | int yynerrs; |
80 | int yyerrflag; |
81 | int yychar; |
82 | - short *yyssp; |
83 | - YYSTYPE *yyvsp; |
84 | YYSTYPE yyval; |
85 | YYSTYPE yylval; |
86 | - short yyss[YYSTACKSIZE]; |
87 | - YYSTYPE yyvs[YYSTACKSIZE]; |
88 | - #define yystacksize YYSTACKSIZE |
a5f75d66 |
89 | #line 571 "perly.y" |
93a17b20 |
90 | /* PROGRAM */ |
c07a80fd |
91 | #line 1394 "y.tab.c" |
92 | --- 1316,1323 ---- |
93a17b20 |
93 | *************** |
c07a80fd |
94 | *** 1394,1407 **** |
95 | --- 1324,1382 ---- |
a0d0e21e |
96 | #define YYABORT goto yyabort |
97 | #define YYACCEPT goto yyaccept |
98 | #define YYERROR goto yyerrlab |
99 | + |
100 | + struct ysv { |
101 | + short* yyss; |
102 | + YYSTYPE* yyvs; |
103 | + int oldyydebug; |
104 | + int oldyynerrs; |
105 | + int oldyyerrflag; |
106 | + int oldyychar; |
107 | + YYSTYPE oldyyval; |
108 | + YYSTYPE oldyylval; |
109 | + }; |
110 | + |
111 | + void |
112 | + yydestruct(ptr) |
113 | + void* ptr; |
114 | + { |
115 | + struct ysv* ysave = (struct ysv*)ptr; |
116 | + if (ysave->yyss) Safefree(ysave->yyss); |
117 | + if (ysave->yyvs) Safefree(ysave->yyvs); |
118 | + yydebug = ysave->oldyydebug; |
119 | + yynerrs = ysave->oldyynerrs; |
120 | + yyerrflag = ysave->oldyyerrflag; |
121 | + yychar = ysave->oldyychar; |
122 | + yyval = ysave->oldyyval; |
123 | + yylval = ysave->oldyylval; |
124 | + Safefree(ysave); |
125 | + } |
126 | + |
127 | int |
93a17b20 |
128 | yyparse() |
129 | { |
130 | register int yym, yyn, yystate; |
131 | + register short *yyssp; |
132 | + register YYSTYPE *yyvsp; |
133 | + short* yyss; |
134 | + YYSTYPE* yyvs; |
135 | + unsigned yystacksize = YYSTACKSIZE; |
93a17b20 |
136 | + int retval = 0; |
93a17b20 |
137 | #if YYDEBUG |
138 | register char *yys; |
139 | extern char *getenv(); |
a0d0e21e |
140 | + #endif |
141 | |
142 | + struct ysv *ysave = (struct ysv*)safemalloc(sizeof(struct ysv)); |
143 | + SAVEDESTRUCTOR(yydestruct, ysave); |
144 | + ysave->oldyydebug = yydebug; |
145 | + ysave->oldyynerrs = yynerrs; |
146 | + ysave->oldyyerrflag = yyerrflag; |
147 | + ysave->oldyychar = yychar; |
148 | + ysave->oldyyval = yyval; |
149 | + ysave->oldyylval = yylval; |
150 | + |
151 | + #if YYDEBUG |
152 | if (yys = getenv("YYDEBUG")) |
153 | { |
154 | yyn = *yys; |
93a17b20 |
155 | *************** |
c07a80fd |
156 | *** 1414,1419 **** |
157 | --- 1389,1402 ---- |
93a17b20 |
158 | yyerrflag = 0; |
159 | yychar = (-1); |
160 | |
161 | + /* |
162 | + ** Initialize private stacks (yyparse may be called from an action) |
163 | + */ |
a0d0e21e |
164 | + ysave->yyss = yyss = (short*)safemalloc(yystacksize*sizeof(short)); |
165 | + ysave->yyvs = yyvs = (YYSTYPE*)safemalloc(yystacksize*sizeof(YYSTYPE)); |
93a17b20 |
166 | + if (!yyvs || !yyss) |
167 | + goto yyoverflow; |
168 | + |
169 | yyssp = yyss; |
170 | yyvsp = yyvs; |
171 | *yyssp = yystate = 0; |
172 | *************** |
c07a80fd |
173 | *** 1429,1435 **** |
ed6116ce |
174 | yys = 0; |
175 | if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; |
176 | if (!yys) yys = "illegal-symbol"; |
177 | ! printf("yydebug: state %d, reading %d (%s)\n", yystate, |
178 | yychar, yys); |
179 | } |
180 | #endif |
c07a80fd |
181 | --- 1412,1418 ---- |
ed6116ce |
182 | yys = 0; |
183 | if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; |
184 | if (!yys) yys = "illegal-symbol"; |
185 | ! fprintf(stderr, "yydebug: state %d, reading %d (%s)\n", yystate, |
186 | yychar, yys); |
187 | } |
188 | #endif |
189 | *************** |
c07a80fd |
190 | *** 1439,1450 **** |
ed6116ce |
191 | { |
192 | #if YYDEBUG |
193 | if (yydebug) |
194 | ! printf("yydebug: state %d, shifting to state %d\n", |
195 | yystate, yytable[yyn]); |
93a17b20 |
196 | #endif |
197 | if (yyssp >= yyss + yystacksize - 1) |
198 | { |
199 | ! goto yyoverflow; |
200 | } |
201 | *++yyssp = yystate = yytable[yyn]; |
202 | *++yyvsp = yylval; |
c07a80fd |
203 | --- 1422,1447 ---- |
ed6116ce |
204 | { |
205 | #if YYDEBUG |
206 | if (yydebug) |
207 | ! fprintf(stderr, "yydebug: state %d, shifting to state %d\n", |
208 | yystate, yytable[yyn]); |
93a17b20 |
209 | #endif |
210 | if (yyssp >= yyss + yystacksize - 1) |
211 | { |
212 | ! /* |
213 | ! ** reallocate and recover. Note that pointers |
214 | ! ** have to be reset, or bad things will happen |
215 | ! */ |
216 | ! int yyps_index = (yyssp - yyss); |
217 | ! int yypv_index = (yyvsp - yyvs); |
218 | ! yystacksize += YYSTACKSIZE; |
a0d0e21e |
219 | ! ysave->yyvs = yyvs = |
220 | ! (YYSTYPE*)realloc((char*)yyvs,yystacksize * sizeof(YYSTYPE)); |
221 | ! ysave->yyss = yyss = |
222 | ! (short*)realloc((char*)yyss,yystacksize * sizeof(short)); |
93a17b20 |
223 | ! if (!yyvs || !yyss) |
224 | ! goto yyoverflow; |
225 | ! yyssp = yyss + yyps_index; |
226 | ! yyvsp = yyvs + yypv_index; |
227 | } |
228 | *++yyssp = yystate = yytable[yyn]; |
229 | *++yyvsp = yylval; |
230 | *************** |
c07a80fd |
231 | *** 1480,1491 **** |
ed6116ce |
232 | { |
233 | #if YYDEBUG |
234 | if (yydebug) |
235 | ! printf("yydebug: state %d, error recovery shifting\ |
236 | ! to state %d\n", *yyssp, yytable[yyn]); |
93a17b20 |
237 | #endif |
238 | if (yyssp >= yyss + yystacksize - 1) |
239 | { |
240 | ! goto yyoverflow; |
241 | } |
242 | *++yyssp = yystate = yytable[yyn]; |
243 | *++yyvsp = yylval; |
c07a80fd |
244 | --- 1477,1503 ---- |
ed6116ce |
245 | { |
246 | #if YYDEBUG |
247 | if (yydebug) |
248 | ! fprintf(stderr, |
249 | ! "yydebug: state %d, error recovery shifting to state %d\n", |
250 | ! *yyssp, yytable[yyn]); |
93a17b20 |
251 | #endif |
252 | if (yyssp >= yyss + yystacksize - 1) |
253 | { |
254 | ! /* |
255 | ! ** reallocate and recover. Note that pointers |
256 | ! ** have to be reset, or bad things will happen |
257 | ! */ |
258 | ! int yyps_index = (yyssp - yyss); |
259 | ! int yypv_index = (yyvsp - yyvs); |
260 | ! yystacksize += YYSTACKSIZE; |
a0d0e21e |
261 | ! ysave->yyvs = yyvs = (YYSTYPE*)realloc((char*)yyvs, |
93a17b20 |
262 | ! yystacksize * sizeof(YYSTYPE)); |
a0d0e21e |
263 | ! ysave->yyss = yyss = (short*)realloc((char*)yyss, |
93a17b20 |
264 | ! yystacksize * sizeof(short)); |
265 | ! if (!yyvs || !yyss) |
266 | ! goto yyoverflow; |
267 | ! yyssp = yyss + yyps_index; |
268 | ! yyvsp = yyvs + yypv_index; |
269 | } |
270 | *++yyssp = yystate = yytable[yyn]; |
271 | *++yyvsp = yylval; |
272 | *************** |
c07a80fd |
273 | *** 1495,1502 **** |
ed6116ce |
274 | { |
275 | #if YYDEBUG |
276 | if (yydebug) |
277 | ! printf("yydebug: error recovery discarding state %d\n", |
278 | ! *yyssp); |
279 | #endif |
280 | if (yyssp <= yyss) goto yyabort; |
281 | --yyssp; |
c07a80fd |
282 | --- 1507,1515 ---- |
ed6116ce |
283 | { |
284 | #if YYDEBUG |
285 | if (yydebug) |
286 | ! fprintf(stderr, |
287 | ! "yydebug: error recovery discarding state %d\n", |
288 | ! *yyssp); |
289 | #endif |
290 | if (yyssp <= yyss) goto yyabort; |
291 | --yyssp; |
292 | *************** |
c07a80fd |
293 | *** 1513,1520 **** |
ed6116ce |
294 | yys = 0; |
295 | if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; |
296 | if (!yys) yys = "illegal-symbol"; |
297 | ! printf("yydebug: state %d, error recovery discards token %d (%s)\n", |
298 | ! yystate, yychar, yys); |
299 | } |
300 | #endif |
301 | yychar = (-1); |
c07a80fd |
302 | --- 1526,1534 ---- |
ed6116ce |
303 | yys = 0; |
304 | if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; |
305 | if (!yys) yys = "illegal-symbol"; |
306 | ! fprintf(stderr, |
307 | ! "yydebug: state %d, error recovery discards token %d (%s)\n", |
308 | ! yystate, yychar, yys); |
309 | } |
310 | #endif |
311 | yychar = (-1); |
312 | *************** |
c07a80fd |
313 | *** 1523,1529 **** |
ed6116ce |
314 | yyreduce: |
315 | #if YYDEBUG |
316 | if (yydebug) |
317 | ! printf("yydebug: state %d, reducing by rule %d (%s)\n", |
318 | yystate, yyn, yyrule[yyn]); |
319 | #endif |
320 | yym = yylen[yyn]; |
c07a80fd |
321 | --- 1537,1543 ---- |
ed6116ce |
322 | yyreduce: |
323 | #if YYDEBUG |
324 | if (yydebug) |
325 | ! fprintf(stderr, "yydebug: state %d, reducing by rule %d (%s)\n", |
326 | yystate, yyn, yyrule[yyn]); |
327 | #endif |
328 | yym = yylen[yyn]; |
329 | *************** |
a5f75d66 |
330 | *** 2242,2249 **** |
ed6116ce |
331 | { |
332 | #if YYDEBUG |
333 | if (yydebug) |
334 | ! printf("yydebug: after reduction, shifting from state 0 to\ |
335 | ! state %d\n", YYFINAL); |
336 | #endif |
337 | yystate = YYFINAL; |
338 | *++yyssp = YYFINAL; |
a5f75d66 |
339 | --- 2256,2264 ---- |
ed6116ce |
340 | { |
341 | #if YYDEBUG |
342 | if (yydebug) |
343 | ! fprintf(stderr, |
344 | ! "yydebug: after reduction, shifting from state 0 to state %d\n", |
345 | ! YYFINAL); |
346 | #endif |
347 | yystate = YYFINAL; |
348 | *++yyssp = YYFINAL; |
349 | *************** |
a5f75d66 |
350 | *** 2257,2263 **** |
ed6116ce |
351 | yys = 0; |
352 | if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; |
353 | if (!yys) yys = "illegal-symbol"; |
354 | ! printf("yydebug: state %d, reading %d (%s)\n", |
355 | YYFINAL, yychar, yys); |
356 | } |
357 | #endif |
a5f75d66 |
358 | --- 2272,2278 ---- |
ed6116ce |
359 | yys = 0; |
360 | if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; |
361 | if (!yys) yys = "illegal-symbol"; |
362 | ! fprintf(stderr, "yydebug: state %d, reading %d (%s)\n", |
363 | YYFINAL, yychar, yys); |
364 | } |
365 | #endif |
366 | *************** |
a5f75d66 |
367 | *** 2272,2291 **** |
ed6116ce |
368 | yystate = yydgoto[yym]; |
369 | #if YYDEBUG |
370 | if (yydebug) |
371 | ! printf("yydebug: after reduction, shifting from state %d \ |
372 | ! to state %d\n", *yyssp, yystate); |
93a17b20 |
373 | #endif |
374 | if (yyssp >= yyss + yystacksize - 1) |
375 | { |
376 | ! goto yyoverflow; |
377 | } |
378 | *++yyssp = yystate; |
379 | *++yyvsp = yyval; |
380 | goto yyloop; |
381 | yyoverflow: |
382 | ! yyerror("yacc stack overflow"); |
383 | yyabort: |
384 | ! return (1); |
385 | yyaccept: |
386 | ! return (0); |
387 | } |
a5f75d66 |
388 | --- 2287,2321 ---- |
ed6116ce |
389 | yystate = yydgoto[yym]; |
390 | #if YYDEBUG |
391 | if (yydebug) |
392 | ! fprintf(stderr, |
393 | ! "yydebug: after reduction, shifting from state %d to state %d\n", |
394 | ! *yyssp, yystate); |
93a17b20 |
395 | #endif |
396 | if (yyssp >= yyss + yystacksize - 1) |
397 | { |
398 | ! /* |
399 | ! ** reallocate and recover. Note that pointers |
400 | ! ** have to be reset, or bad things will happen |
401 | ! */ |
402 | ! int yyps_index = (yyssp - yyss); |
403 | ! int yypv_index = (yyvsp - yyvs); |
404 | ! yystacksize += YYSTACKSIZE; |
a0d0e21e |
405 | ! ysave->yyvs = yyvs = |
406 | ! (YYSTYPE*)realloc((char*)yyvs,yystacksize * sizeof(YYSTYPE)); |
407 | ! ysave->yyss = yyss = |
408 | ! (short*)realloc((char*)yyss,yystacksize * sizeof(short)); |
93a17b20 |
409 | ! if (!yyvs || !yyss) |
410 | ! goto yyoverflow; |
411 | ! yyssp = yyss + yyps_index; |
412 | ! yyvsp = yyvs + yypv_index; |
413 | } |
414 | *++yyssp = yystate; |
415 | *++yyvsp = yyval; |
416 | goto yyloop; |
417 | yyoverflow: |
418 | ! yyerror("Out of memory for yacc stack"); |
419 | yyabort: |
420 | ! retval = 1; |
421 | yyaccept: |
93a17b20 |
422 | ! return retval; |
423 | } |