This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Integrate mainline
[perl5.git] / perly_c.diff
... / ...
CommitLineData
1--- perly.c.orig Tue Jun 19 08:39:52 2001
2+++ perly.c Tue Jun 19 08:39:24 2001
3@@ -1,5 +1,5 @@
4 #ifndef lint
5-static char yysccsid[] = "@(#)yaccpar 1.8 (Berkeley) 01/20/91";
6+/* static char yysccsid[] = "@(#)yaccpar 1.8 (Berkeley) 01/20/91"; */
7 #endif
8 #define YYBYACC 1
9 #line 16 "perly.y"
10@@ -50,70 +50,9 @@
11 #define yylex yylex_r
12 #endif
13
14-#line 54 "y.tab.c"
15-#define WORD 257
16-#define METHOD 258
17-#define FUNCMETH 259
18-#define THING 260
19-#define PMFUNC 261
20-#define PRIVATEREF 262
21-#define FUNC0SUB 263
22-#define UNIOPSUB 264
23-#define LSTOPSUB 265
24-#define LABEL 266
25-#define FORMAT 267
26-#define SUB 268
27-#define ANONSUB 269
28-#define PACKAGE 270
29-#define USE 271
30-#define WHILE 272
31-#define UNTIL 273
32-#define IF 274
33-#define UNLESS 275
34-#define ELSE 276
35-#define ELSIF 277
36-#define CONTINUE 278
37-#define FOR 279
38-#define LOOPEX 280
39-#define DOTDOT 281
40-#define FUNC0 282
41-#define FUNC1 283
42-#define FUNC 284
43-#define UNIOP 285
44-#define LSTOP 286
45-#define RELOP 287
46-#define EQOP 288
47-#define MULOP 289
48-#define ADDOP 290
49-#define DOLSHARP 291
50-#define DO 292
51-#define HASHBRACK 293
52-#define NOAMP 294
53-#define LOCAL 295
54-#define MY 296
55-#define MYSUB 297
56-#define COLONATTR 298
57-#define PREC_LOW 299
58-#define OROP 300
59-#define ANDOP 301
60-#define NOTOP 302
61-#define ASSIGNOP 303
62-#define OROR 304
63-#define ANDAND 305
64-#define BITOROP 306
65-#define BITANDOP 307
66-#define SHIFTOP 308
67-#define MATCHOP 309
68-#define UMINUS 310
69-#define REFGEN 311
70-#define POWOP 312
71-#define PREINC 313
72-#define PREDEC 314
73-#define POSTINC 315
74-#define POSTDEC 316
75-#define ARROW 317
76+#line 54 "perly.c"
77 #define YYERRCODE 256
78-short yylhs[] = { -1,
79+static short yylhs[] = { -1,
80 0, 9, 7, 6, 10, 8, 11, 11, 11, 12,
81 12, 12, 12, 25, 25, 25, 25, 25, 25, 25,
82 15, 15, 15, 14, 14, 43, 43, 13, 13, 13,
83@@ -135,7 +74,7 @@
84 49, 34, 34, 35, 35, 35, 44, 24, 19, 20,
85 21, 22, 23, 36, 36, 36, 36,
86 };
87-short yylen[] = { 2,
88+static short yylen[] = { 2,
89 2, 4, 0, 0, 4, 0, 0, 2, 2, 2,
90 1, 2, 3, 1, 1, 3, 3, 3, 3, 3,
91 0, 2, 6, 7, 7, 0, 2, 8, 8, 10,
92@@ -157,7 +96,7 @@
93 1, 0, 1, 0, 1, 2, 1, 2, 2, 2,
94 2, 2, 2, 1, 1, 1, 1,
95 };
96-short yydefred[] = { 4,
97+static short yydefred[] = { 4,
98 0, 7, 0, 45, 58, 56, 0, 56, 56, 8,
99 46, 9, 11, 48, 0, 47, 49, 50, 0, 0,
100 0, 70, 71, 0, 14, 3, 173, 0, 0, 154,
101@@ -199,7 +138,7 @@
102 0, 22, 0, 0, 0, 31, 5, 0, 30, 0,
103 0, 33, 0, 23,
104 };
105-short yydgoto[] = { 1,
106+static short yydgoto[] = { 1,
107 10, 11, 20, 104, 19, 2, 95, 370, 98, 359,
108 3, 12, 13, 70, 375, 285, 72, 73, 74, 75,
109 76, 77, 78, 79, 291, 81, 292, 281, 283, 286,
110@@ -207,7 +146,7 @@
111 194, 327, 156, 289, 271, 225, 14, 83, 137, 84,
112 85, 86, 87, 15, 16, 17, 18, 93, 278,
113 };
114-short yysindex[] = { 0,
115+static short yysindex[] = { 0,
116 0, 0, -132, 0, 0, 0, -51, 0, 0, 0,
117 0, 0, 0, 0, 650, 0, 0, 0, -239, -215,
118 5, 0, 0, -215, 0, 0, 0, -31, -31, 0,
119@@ -249,7 +188,7 @@
120 449, 0, 2181, -150, 340, 0, 0, 355, 0, 216,
121 216, 0, -123, 0,
122 };
123-short yyrindex[] = { 0,
124+static short yyrindex[] = { 0,
125 0, 0, 247, 0, 0, 0, 0, 0, 0, 0,
126 0, 0, 0, 0, 0, 0, 0, 0, 274, 0,
127 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
128@@ -291,7 +230,7 @@
129 917, 0, 0, 119, 0, 0, 0, 0, 0, 0,
130 0, 0, 179, 0,
131 };
132-short yygindex[] = { 0,
133+static short yygindex[] = { 0,
134 0, 0, 196, 425, 0, 0, -2, 0, 37, 634,
135 -94, 0, 0, 0, -323, -15, 2445, 0, 999, 414,
136 417, 0, 0, 0, 463, -43, 0, 0, 321, -198,
137@@ -300,7 +239,7 @@
138 0, 0, 0, 0, 0, 0, 0, 0, 0,
139 };
140 #define YYTABLESIZE 4568
141-short yytable[] = { 71,
142+static short yytable[] = { 71,
143 197, 65, 121, 227, 65, 111, 220, 22, 198, 293,
144 139, 296, 315, 275, 305, 102, 273, 88, 113, 228,
145 60, 113, 279, 65, 317, 60, 182, 254, 325, 101,
146@@ -759,7 +698,7 @@
147 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
148 0, 0, 0, 0, 0, 0, 77, 77,
149 };
150-short yycheck[] = { 15,
151+static short yycheck[] = { 15,
152 95, 36, 46, 41, 36, 40, 59, 59, 100, 208,
153 54, 41, 59, 199, 41, 40, 196, 257, 41, 93,
154 123, 44, 202, 36, 93, 59, 40, 40, 59, 29,
155@@ -1224,7 +1163,7 @@
156 #endif
157 #define YYMAXTOKEN 317
158 #if YYDEBUG
159-char *yyname[] = {
160+static char *yyname[] = {
161 "end-of-file",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
162 "'!'",0,0,"'$'","'%'","'&'",0,"'('","')'","'*'","'+'","','","'-'",0,0,0,0,0,0,0,
163 0,0,0,0,0,"':'","';'",0,0,0,"'?'","'@'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
164@@ -1241,7 +1180,7 @@
165 "ANDAND","BITOROP","BITANDOP","SHIFTOP","MATCHOP","UMINUS","REFGEN","POWOP",
166 "PREINC","PREDEC","POSTINC","POSTDEC","ARROW",
167 };
168-char *yyrule[] = {
169+static char *yyrule[] = {
170 "$accept : prog",
171 "prog : progstart lineseq",
172 "block : '{' remember lineseq '}'",
173@@ -1456,17 +1395,6 @@
174 #define YYMAXDEPTH 500
175 #endif
176 #endif
177-int yydebug;
178-int yynerrs;
179-int yyerrflag;
180-int yychar;
181-short *yyssp;
182-YYSTYPE *yyvsp;
183-YYSTYPE yyval;
184-YYSTYPE yylval;
185-short yyss[YYSTACKSIZE];
186-YYSTYPE yyvs[YYSTACKSIZE];
187-#define yystacksize YYSTACKSIZE
188 #line 793 "perly.y"
189 /* PROGRAM */
190
191@@ -1477,7 +1405,7 @@
192 #endif
193 #define yyparse() Perl_yyparse(pTHX)
194
195-#line 1481 "y.tab.c"
196+#line 1409 "perly.c"
197 #define YYABORT goto yyabort
198 #define YYACCEPT goto yyaccept
199 #define YYERROR goto yyerrlab
200@@ -1485,11 +1413,31 @@
201 yyparse()
202 {
203 register int yym, yyn, yystate;
204+ register short *yyssp;
205+ register YYSTYPE *yyvsp;
206+ short* yyss;
207+ YYSTYPE* yyvs;
208+ unsigned yystacksize = YYSTACKSIZE;
209+ int retval = 0;
210 #if YYDEBUG
211 register char *yys;
212- extern char *getenv();
213+#endif
214+
215+ struct ysv *ysave;
216+#ifdef USE_ITHREADS
217+ ENTER; /* force yydestruct() before we return */
218+#endif
219+ New(73, ysave, 1, struct ysv);
220+ SAVEDESTRUCTOR_X(yydestruct, ysave);
221+ ysave->oldyydebug = yydebug;
222+ ysave->oldyynerrs = yynerrs;
223+ ysave->oldyyerrflag = yyerrflag;
224+ ysave->oldyychar = yychar;
225+ ysave->oldyyval = yyval;
226+ ysave->oldyylval = yylval;
227
228- if (yys = getenv("YYDEBUG"))
229+#if YYDEBUG
230+ if ((yys = getenv("YYDEBUG")))
231 {
232 yyn = *yys;
233 if (yyn >= '0' && yyn <= '9')
234@@ -1501,12 +1449,22 @@
235 yyerrflag = 0;
236 yychar = (-1);
237
238+ /*
239+ ** Initialize private stacks (yyparse may be called from an action)
240+ */
241+ New(73, yyss, yystacksize, short);
242+ New(73, yyvs, yystacksize, YYSTYPE);
243+ ysave->yyss = yyss;
244+ ysave->yyvs = yyvs;
245+ if (!yyvs || !yyss)
246+ goto yyoverflow;
247+
248 yyssp = yyss;
249 yyvsp = yyvs;
250 *yyssp = yystate = 0;
251
252 yyloop:
253- if (yyn = yydefred[yystate]) goto yyreduce;
254+ if ((yyn = yydefred[yystate])) goto yyreduce;
255 if (yychar < 0)
256 {
257 if ((yychar = yylex()) < 0) yychar = 0;
258@@ -1516,7 +1474,7 @@
259 yys = 0;
260 if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
261 if (!yys) yys = "illegal-symbol";
262- printf("yydebug: state %d, reading %d (%s)\n", yystate,
263+ PerlIO_printf(Perl_debug_log, "yydebug: state %d, reading %d (%s)\n", yystate,
264 yychar, yys);
265 }
266 #endif
267@@ -1526,12 +1484,24 @@
268 {
269 #if YYDEBUG
270 if (yydebug)
271- printf("yydebug: state %d, shifting to state %d\n",
272+ PerlIO_printf(Perl_debug_log, "yydebug: state %d, shifting to state %d\n",
273 yystate, yytable[yyn]);
274 #endif
275 if (yyssp >= yyss + yystacksize - 1)
276 {
277+ /*
278+ ** reallocate and recover. Note that pointers
279+ ** have to be reset, or bad things will happen
280+ */
281+ int yyps_index = (yyssp - yyss);
282+ int yypv_index = (yyvsp - yyvs);
283+ yystacksize += YYSTACKSIZE;
284+ ysave->yyvs = Renew(yyvs, yystacksize, YYSTYPE);
285+ ysave->yyss = Renew(yyss, yystacksize, short);
286+ if (!yyvs || !yyss)
287 goto yyoverflow;
288+ yyssp = yyss + yyps_index;
289+ yyvsp = yyvs + yypv_index;
290 }
291 *++yyssp = yystate = yytable[yyn];
292 *++yyvsp = yylval;
293@@ -1547,14 +1517,14 @@
294 }
295 if (yyerrflag) goto yyinrecovery;
296 #ifdef lint
297- goto yynewerror;
298+
299 #endif
300-yynewerror:
301+
302 yyerror("syntax error");
303 #ifdef lint
304- goto yyerrlab;
305+
306 #endif
307-yyerrlab:
308+
309 ++yynerrs;
310 yyinrecovery:
311 if (yyerrflag < 3)
312@@ -1567,12 +1537,24 @@
313 {
314 #if YYDEBUG
315 if (yydebug)
316- printf("yydebug: state %d, error recovery shifting\
317+ PerlIO_printf(Perl_debug_log, "yydebug: state %d, error recovery shifting\
318 to state %d\n", *yyssp, yytable[yyn]);
319 #endif
320 if (yyssp >= yyss + yystacksize - 1)
321 {
322+ /*
323+ ** reallocate and recover. Note that pointers
324+ ** have to be reset, or bad things will happen
325+ */
326+ int yyps_index = (yyssp - yyss);
327+ int yypv_index = (yyvsp - yyvs);
328+ yystacksize += YYSTACKSIZE;
329+ ysave->yyvs = Renew(yyvs, yystacksize, YYSTYPE);
330+ ysave->yyss = Renew(yyss, yystacksize, short);
331+ if (!yyvs || !yyss)
332 goto yyoverflow;
333+ yyssp = yyss + yyps_index;
334+ yyvsp = yyvs + yypv_index;
335 }
336 *++yyssp = yystate = yytable[yyn];
337 *++yyvsp = yylval;
338@@ -1582,7 +1564,7 @@
339 {
340 #if YYDEBUG
341 if (yydebug)
342- printf("yydebug: error recovery discarding state %d\n",
343+ PerlIO_printf(Perl_debug_log, "yydebug: error recovery discarding state %d\n",
344 *yyssp);
345 #endif
346 if (yyssp <= yyss) goto yyabort;
347@@ -1600,7 +1582,7 @@
348 yys = 0;
349 if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
350 if (!yys) yys = "illegal-symbol";
351- printf("yydebug: state %d, error recovery discards token %d (%s)\n",
352+ PerlIO_printf(Perl_debug_log, "yydebug: state %d, error recovery discards token %d (%s)\n",
353 yystate, yychar, yys);
354 }
355 #endif
356@@ -1610,7 +1592,7 @@
357 yyreduce:
358 #if YYDEBUG
359 if (yydebug)
360- printf("yydebug: state %d, reducing by rule %d (%s)\n",
361+ PerlIO_printf(Perl_debug_log, "yydebug: state %d, reducing by rule %d (%s)\n",
362 yystate, yyn, yyrule[yyn]);
363 #endif
364 yym = yylen[yyn];
365@@ -2473,7 +2455,7 @@
366 #line 790 "perly.y"
367 { yyval.opval = yyvsp[0].opval; }
368 break;
369-#line 2477 "y.tab.c"
370+#line 2459 "perly.c"
371 }
372 yyssp -= yym;
373 yystate = *yyssp;
374@@ -2483,7 +2465,7 @@
375 {
376 #if YYDEBUG
377 if (yydebug)
378- printf("yydebug: after reduction, shifting from state 0 to\
379+ PerlIO_printf(Perl_debug_log, "yydebug: after reduction, shifting from state 0 to\
380 state %d\n", YYFINAL);
381 #endif
382 yystate = YYFINAL;
383@@ -2498,7 +2480,7 @@
384 yys = 0;
385 if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
386 if (!yys) yys = "illegal-symbol";
387- printf("yydebug: state %d, reading %d (%s)\n",
388+ PerlIO_printf(Perl_debug_log, "yydebug: state %d, reading %d (%s)\n",
389 YYFINAL, yychar, yys);
390 }
391 #endif
392@@ -2513,20 +2495,50 @@
393 yystate = yydgoto[yym];
394 #if YYDEBUG
395 if (yydebug)
396- printf("yydebug: after reduction, shifting from state %d \
397+ PerlIO_printf(Perl_debug_log, "yydebug: after reduction, shifting from state %d \
398 to state %d\n", *yyssp, yystate);
399 #endif
400 if (yyssp >= yyss + yystacksize - 1)
401 {
402+ /*
403+ ** reallocate and recover. Note that pointers
404+ ** have to be reset, or bad things will happen
405+ */
406+ int yyps_index = (yyssp - yyss);
407+ int yypv_index = (yyvsp - yyvs);
408+ yystacksize += YYSTACKSIZE;
409+ ysave->yyvs = Renew(yyvs, yystacksize, YYSTYPE);
410+ ysave->yyss = Renew(yyss, yystacksize, short);
411+ if (!yyvs || !yyss)
412 goto yyoverflow;
413+ yyssp = yyss + yyps_index;
414+ yyvsp = yyvs + yypv_index;
415 }
416 *++yyssp = yystate;
417 *++yyvsp = yyval;
418 goto yyloop;
419 yyoverflow:
420- yyerror("yacc stack overflow");
421+ yyerror("Out of memory for yacc stack");
422 yyabort:
423- return (1);
424+ retval = 1;
425 yyaccept:
426- return (0);
427+#ifdef USE_ITHREADS
428+ LEAVE; /* force yydestruct() before we return */
429+#endif
430+ return retval;
431+}
432+
433+static void
434+yydestruct(pTHX_ void *ptr)
435+{
436+ struct ysv* ysave = (struct ysv*)ptr;
437+ if (ysave->yyss) Safefree(ysave->yyss);
438+ if (ysave->yyvs) Safefree(ysave->yyvs);
439+ yydebug = ysave->oldyydebug;
440+ yynerrs = ysave->oldyynerrs;
441+ yyerrflag = ysave->oldyyerrflag;
442+ yychar = ysave->oldyychar;
443+ yyval = ysave->oldyyval;
444+ yylval = ysave->oldyylval;
445+ Safefree(ysave);
446 }