Commit | Line | Data |
---|---|---|
55497cff | 1 | Index: perly.c |
93a17b20 | 2 | *************** |
bbce6d69 | 3 | *** 13,82 **** |
a0d0e21e LW |
4 | } |
5 | ||
748a9306 | 6 | - #line 29 "perly.y" |
a0d0e21e LW |
7 | - typedef union { |
8 | - I32 ival; | |
9 | - char *pval; | |
10 | - OP *opval; | |
11 | - GV *gvval; | |
12 | - } YYSTYPE; | |
13 | - #line 23 "y.tab.c" | |
14 | - #define WORD 257 | |
15 | - #define METHOD 258 | |
16 | - #define FUNCMETH 259 | |
17 | - #define THING 260 | |
18 | - #define PMFUNC 261 | |
19 | - #define PRIVATEREF 262 | |
4633a7c4 LW |
20 | - #define FUNC0SUB 263 |
21 | - #define UNIOPSUB 264 | |
22 | - #define LSTOPSUB 265 | |
23 | - #define LABEL 266 | |
24 | - #define FORMAT 267 | |
25 | - #define SUB 268 | |
26 | - #define ANONSUB 269 | |
27 | - #define PACKAGE 270 | |
28 | - #define USE 271 | |
29 | - #define WHILE 272 | |
30 | - #define UNTIL 273 | |
31 | - #define IF 274 | |
32 | - #define UNLESS 275 | |
33 | - #define ELSE 276 | |
34 | - #define ELSIF 277 | |
35 | - #define CONTINUE 278 | |
36 | - #define FOR 279 | |
37 | - #define LOOPEX 280 | |
38 | - #define DOTDOT 281 | |
39 | - #define FUNC0 282 | |
40 | - #define FUNC1 283 | |
41 | - #define FUNC 284 | |
42 | - #define RELOP 285 | |
43 | - #define EQOP 286 | |
44 | - #define MULOP 287 | |
45 | - #define ADDOP 288 | |
46 | - #define DOLSHARP 289 | |
47 | - #define DO 290 | |
55497cff | 48 | - #define HASHBRACK 291 |
49 | - #define NOAMP 292 | |
50 | - #define LOCAL 293 | |
51 | - #define MY 294 | |
52 | - #define OROP 295 | |
53 | - #define ANDOP 296 | |
54 | - #define NOTOP 297 | |
55 | - #define LSTOP 298 | |
56 | - #define ASSIGNOP 299 | |
57 | - #define OROR 300 | |
58 | - #define ANDAND 301 | |
59 | - #define BITOROP 302 | |
60 | - #define BITANDOP 303 | |
61 | - #define UNIOP 304 | |
62 | - #define SHIFTOP 305 | |
63 | - #define MATCHOP 306 | |
64 | - #define UMINUS 307 | |
65 | - #define REFGEN 308 | |
66 | - #define POWOP 309 | |
67 | - #define PREINC 310 | |
68 | - #define PREDEC 311 | |
69 | - #define POSTINC 312 | |
70 | - #define POSTDEC 313 | |
71 | - #define ARROW 314 | |
a0d0e21e LW |
72 | #define YYERRCODE 256 |
73 | short yylhs[] = { -1, | |
bbce6d69 | 74 | --- 13,16 ---- |
a0d0e21e | 75 | *************** |
bbce6d69 | 76 | *** 1357,1367 **** |
93a17b20 LW |
77 | int yyerrflag; |
78 | int yychar; | |
79 | - short *yyssp; | |
80 | - YYSTYPE *yyvsp; | |
81 | YYSTYPE yyval; | |
82 | YYSTYPE yylval; | |
83 | - short yyss[YYSTACKSIZE]; | |
84 | - YYSTYPE yyvs[YYSTACKSIZE]; | |
85 | - #define yystacksize YYSTACKSIZE | |
bbce6d69 | 86 | #line 616 "perly.y" |
93a17b20 | 87 | /* PROGRAM */ |
bbce6d69 | 88 | --- 1291,1296 ---- |
89 | *************** | |
90 | *** 1370,1381 **** | |
91 | --- 1299,1355 ---- | |
a0d0e21e LW |
92 | #define YYACCEPT goto yyaccept |
93 | #define YYERROR goto yyerrlab | |
94 | + | |
95 | + struct ysv { | |
96 | + short* yyss; | |
97 | + YYSTYPE* yyvs; | |
98 | + int oldyydebug; | |
99 | + int oldyynerrs; | |
100 | + int oldyyerrflag; | |
101 | + int oldyychar; | |
102 | + YYSTYPE oldyyval; | |
103 | + YYSTYPE oldyylval; | |
104 | + }; | |
105 | + | |
106 | + void | |
107 | + yydestruct(ptr) | |
108 | + void* ptr; | |
109 | + { | |
110 | + struct ysv* ysave = (struct ysv*)ptr; | |
489bbe73 | 111 | + if (ysave->yyss) Safefree(ysave->yyss); |
112 | + if (ysave->yyvs) Safefree(ysave->yyvs); | |
a0d0e21e LW |
113 | + yydebug = ysave->oldyydebug; |
114 | + yynerrs = ysave->oldyynerrs; | |
115 | + yyerrflag = ysave->oldyyerrflag; | |
116 | + yychar = ysave->oldyychar; | |
117 | + yyval = ysave->oldyyval; | |
118 | + yylval = ysave->oldyylval; | |
489bbe73 | 119 | + Safefree(ysave); |
a0d0e21e LW |
120 | + } |
121 | + | |
122 | int | |
93a17b20 LW |
123 | yyparse() |
124 | { | |
125 | register int yym, yyn, yystate; | |
126 | + register short *yyssp; | |
127 | + register YYSTYPE *yyvsp; | |
128 | + short* yyss; | |
129 | + YYSTYPE* yyvs; | |
130 | + unsigned yystacksize = YYSTACKSIZE; | |
93a17b20 | 131 | + int retval = 0; |
93a17b20 LW |
132 | #if YYDEBUG |
133 | register char *yys; | |
134 | extern char *getenv(); | |
a0d0e21e | 135 | + #endif |
55497cff | 136 | + |
a0d0e21e LW |
137 | + struct ysv *ysave = (struct ysv*)safemalloc(sizeof(struct ysv)); |
138 | + SAVEDESTRUCTOR(yydestruct, ysave); | |
139 | + ysave->oldyydebug = yydebug; | |
140 | + ysave->oldyynerrs = yynerrs; | |
141 | + ysave->oldyyerrflag = yyerrflag; | |
142 | + ysave->oldyychar = yychar; | |
143 | + ysave->oldyyval = yyval; | |
144 | + ysave->oldyylval = yylval; | |
55497cff | 145 | |
a0d0e21e LW |
146 | + #if YYDEBUG |
147 | if (yys = getenv("YYDEBUG")) | |
148 | { | |
93a17b20 | 149 | *************** |
bbce6d69 | 150 | *** 1390,1393 **** |
151 | --- 1364,1375 ---- | |
93a17b20 LW |
152 | yychar = (-1); |
153 | ||
154 | + /* | |
155 | + ** Initialize private stacks (yyparse may be called from an action) | |
156 | + */ | |
a0d0e21e LW |
157 | + ysave->yyss = yyss = (short*)safemalloc(yystacksize*sizeof(short)); |
158 | + ysave->yyvs = yyvs = (YYSTYPE*)safemalloc(yystacksize*sizeof(YYSTYPE)); | |
93a17b20 LW |
159 | + if (!yyvs || !yyss) |
160 | + goto yyoverflow; | |
161 | + | |
162 | yyssp = yyss; | |
163 | yyvsp = yyvs; | |
93a17b20 | 164 | *************** |
bbce6d69 | 165 | *** 1405,1409 **** |
ed6116ce LW |
166 | if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; |
167 | if (!yys) yys = "illegal-symbol"; | |
168 | ! printf("yydebug: state %d, reading %d (%s)\n", yystate, | |
169 | yychar, yys); | |
170 | } | |
bbce6d69 | 171 | --- 1387,1391 ---- |
ed6116ce LW |
172 | if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; |
173 | if (!yys) yys = "illegal-symbol"; | |
174 | ! fprintf(stderr, "yydebug: state %d, reading %d (%s)\n", yystate, | |
175 | yychar, yys); | |
176 | } | |
ed6116ce | 177 | *************** |
bbce6d69 | 178 | *** 1415,1424 **** |
ed6116ce LW |
179 | #if YYDEBUG |
180 | if (yydebug) | |
181 | ! printf("yydebug: state %d, shifting to state %d\n", | |
182 | yystate, yytable[yyn]); | |
93a17b20 LW |
183 | #endif |
184 | if (yyssp >= yyss + yystacksize - 1) | |
185 | { | |
186 | ! goto yyoverflow; | |
187 | } | |
188 | *++yyssp = yystate = yytable[yyn]; | |
bbce6d69 | 189 | --- 1397,1420 ---- |
ed6116ce LW |
190 | #if YYDEBUG |
191 | if (yydebug) | |
192 | ! fprintf(stderr, "yydebug: state %d, shifting to state %d\n", | |
193 | yystate, yytable[yyn]); | |
93a17b20 LW |
194 | #endif |
195 | if (yyssp >= yyss + yystacksize - 1) | |
196 | { | |
197 | ! /* | |
198 | ! ** reallocate and recover. Note that pointers | |
199 | ! ** have to be reset, or bad things will happen | |
200 | ! */ | |
201 | ! int yyps_index = (yyssp - yyss); | |
202 | ! int yypv_index = (yyvsp - yyvs); | |
203 | ! yystacksize += YYSTACKSIZE; | |
a0d0e21e LW |
204 | ! ysave->yyvs = yyvs = |
205 | ! (YYSTYPE*)realloc((char*)yyvs,yystacksize * sizeof(YYSTYPE)); | |
206 | ! ysave->yyss = yyss = | |
207 | ! (short*)realloc((char*)yyss,yystacksize * sizeof(short)); | |
93a17b20 LW |
208 | ! if (!yyvs || !yyss) |
209 | ! goto yyoverflow; | |
210 | ! yyssp = yyss + yyps_index; | |
211 | ! yyvsp = yyvs + yypv_index; | |
212 | } | |
213 | *++yyssp = yystate = yytable[yyn]; | |
93a17b20 | 214 | *************** |
bbce6d69 | 215 | *** 1456,1465 **** |
ed6116ce LW |
216 | #if YYDEBUG |
217 | if (yydebug) | |
218 | ! printf("yydebug: state %d, error recovery shifting\ | |
219 | ! to state %d\n", *yyssp, yytable[yyn]); | |
93a17b20 LW |
220 | #endif |
221 | if (yyssp >= yyss + yystacksize - 1) | |
222 | { | |
223 | ! goto yyoverflow; | |
224 | } | |
225 | *++yyssp = yystate = yytable[yyn]; | |
bbce6d69 | 226 | --- 1452,1476 ---- |
ed6116ce LW |
227 | #if YYDEBUG |
228 | if (yydebug) | |
229 | ! fprintf(stderr, | |
230 | ! "yydebug: state %d, error recovery shifting to state %d\n", | |
231 | ! *yyssp, yytable[yyn]); | |
93a17b20 LW |
232 | #endif |
233 | if (yyssp >= yyss + yystacksize - 1) | |
234 | { | |
235 | ! /* | |
236 | ! ** reallocate and recover. Note that pointers | |
237 | ! ** have to be reset, or bad things will happen | |
238 | ! */ | |
239 | ! int yyps_index = (yyssp - yyss); | |
240 | ! int yypv_index = (yyvsp - yyvs); | |
241 | ! yystacksize += YYSTACKSIZE; | |
a0d0e21e | 242 | ! ysave->yyvs = yyvs = (YYSTYPE*)realloc((char*)yyvs, |
93a17b20 | 243 | ! yystacksize * sizeof(YYSTYPE)); |
a0d0e21e | 244 | ! ysave->yyss = yyss = (short*)realloc((char*)yyss, |
93a17b20 LW |
245 | ! yystacksize * sizeof(short)); |
246 | ! if (!yyvs || !yyss) | |
247 | ! goto yyoverflow; | |
248 | ! yyssp = yyss + yyps_index; | |
249 | ! yyvsp = yyvs + yypv_index; | |
250 | } | |
251 | *++yyssp = yystate = yytable[yyn]; | |
93a17b20 | 252 | *************** |
bbce6d69 | 253 | *** 1471,1476 **** |
ed6116ce LW |
254 | #if YYDEBUG |
255 | if (yydebug) | |
256 | ! printf("yydebug: error recovery discarding state %d\n", | |
257 | ! *yyssp); | |
258 | #endif | |
259 | if (yyssp <= yyss) goto yyabort; | |
bbce6d69 | 260 | --- 1482,1488 ---- |
ed6116ce LW |
261 | #if YYDEBUG |
262 | if (yydebug) | |
263 | ! fprintf(stderr, | |
264 | ! "yydebug: error recovery discarding state %d\n", | |
265 | ! *yyssp); | |
266 | #endif | |
267 | if (yyssp <= yyss) goto yyabort; | |
ed6116ce | 268 | *************** |
bbce6d69 | 269 | *** 1489,1494 **** |
ed6116ce LW |
270 | if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; |
271 | if (!yys) yys = "illegal-symbol"; | |
272 | ! printf("yydebug: state %d, error recovery discards token %d (%s)\n", | |
273 | ! yystate, yychar, yys); | |
274 | } | |
275 | #endif | |
bbce6d69 | 276 | --- 1501,1507 ---- |
ed6116ce LW |
277 | if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; |
278 | if (!yys) yys = "illegal-symbol"; | |
279 | ! fprintf(stderr, | |
280 | ! "yydebug: state %d, error recovery discards token %d (%s)\n", | |
281 | ! yystate, yychar, yys); | |
282 | } | |
283 | #endif | |
ed6116ce | 284 | *************** |
bbce6d69 | 285 | *** 1499,1503 **** |
ed6116ce LW |
286 | #if YYDEBUG |
287 | if (yydebug) | |
288 | ! printf("yydebug: state %d, reducing by rule %d (%s)\n", | |
289 | yystate, yyn, yyrule[yyn]); | |
290 | #endif | |
bbce6d69 | 291 | --- 1512,1516 ---- |
ed6116ce LW |
292 | #if YYDEBUG |
293 | if (yydebug) | |
294 | ! fprintf(stderr, "yydebug: state %d, reducing by rule %d (%s)\n", | |
295 | yystate, yyn, yyrule[yyn]); | |
296 | #endif | |
ed6116ce | 297 | *************** |
bbce6d69 | 298 | *** 2268,2273 **** |
ed6116ce LW |
299 | #if YYDEBUG |
300 | if (yydebug) | |
301 | ! printf("yydebug: after reduction, shifting from state 0 to\ | |
302 | ! state %d\n", YYFINAL); | |
303 | #endif | |
304 | yystate = YYFINAL; | |
bbce6d69 | 305 | --- 2281,2287 ---- |
ed6116ce LW |
306 | #if YYDEBUG |
307 | if (yydebug) | |
308 | ! fprintf(stderr, | |
309 | ! "yydebug: after reduction, shifting from state 0 to state %d\n", | |
310 | ! YYFINAL); | |
311 | #endif | |
312 | yystate = YYFINAL; | |
ed6116ce | 313 | *************** |
bbce6d69 | 314 | *** 2283,2287 **** |
ed6116ce LW |
315 | if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; |
316 | if (!yys) yys = "illegal-symbol"; | |
317 | ! printf("yydebug: state %d, reading %d (%s)\n", | |
318 | YYFINAL, yychar, yys); | |
319 | } | |
bbce6d69 | 320 | --- 2297,2301 ---- |
ed6116ce LW |
321 | if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; |
322 | if (!yys) yys = "illegal-symbol"; | |
323 | ! fprintf(stderr, "yydebug: state %d, reading %d (%s)\n", | |
324 | YYFINAL, yychar, yys); | |
325 | } | |
ed6116ce | 326 | *************** |
bbce6d69 | 327 | *** 2298,2307 **** |
ed6116ce LW |
328 | #if YYDEBUG |
329 | if (yydebug) | |
330 | ! printf("yydebug: after reduction, shifting from state %d \ | |
331 | ! to state %d\n", *yyssp, yystate); | |
93a17b20 LW |
332 | #endif |
333 | if (yyssp >= yyss + yystacksize - 1) | |
334 | { | |
335 | ! goto yyoverflow; | |
336 | } | |
337 | *++yyssp = yystate; | |
bbce6d69 | 338 | --- 2312,2336 ---- |
ed6116ce LW |
339 | #if YYDEBUG |
340 | if (yydebug) | |
341 | ! fprintf(stderr, | |
342 | ! "yydebug: after reduction, shifting from state %d to state %d\n", | |
343 | ! *yyssp, yystate); | |
93a17b20 LW |
344 | #endif |
345 | if (yyssp >= yyss + yystacksize - 1) | |
346 | { | |
347 | ! /* | |
348 | ! ** reallocate and recover. Note that pointers | |
349 | ! ** have to be reset, or bad things will happen | |
350 | ! */ | |
351 | ! int yyps_index = (yyssp - yyss); | |
352 | ! int yypv_index = (yyvsp - yyvs); | |
353 | ! yystacksize += YYSTACKSIZE; | |
a0d0e21e LW |
354 | ! ysave->yyvs = yyvs = |
355 | ! (YYSTYPE*)realloc((char*)yyvs,yystacksize * sizeof(YYSTYPE)); | |
356 | ! ysave->yyss = yyss = | |
357 | ! (short*)realloc((char*)yyss,yystacksize * sizeof(short)); | |
93a17b20 LW |
358 | ! if (!yyvs || !yyss) |
359 | ! goto yyoverflow; | |
360 | ! yyssp = yyss + yyps_index; | |
361 | ! yyvsp = yyvs + yypv_index; | |
362 | } | |
363 | *++yyssp = yystate; | |
bbce6d69 | 364 | *************** |
365 | *** 2309,2316 **** | |
366 | goto yyloop; | |
367 | yyoverflow: | |
368 | ! yyerror("yacc stack overflow"); | |
369 | yyabort: | |
370 | ! return (1); | |
371 | yyaccept: | |
372 | ! return (0); | |
373 | } | |
374 | --- 2338,2345 ---- | |
93a17b20 LW |
375 | goto yyloop; |
376 | yyoverflow: | |
377 | ! yyerror("Out of memory for yacc stack"); | |
378 | yyabort: | |
379 | ! retval = 1; | |
380 | yyaccept: | |
93a17b20 LW |
381 | ! return retval; |
382 | } |