perl 5.003_01: pod/perlref.pod
[p5sagit/p5-mst-13.2.git] / perly.c.diff
CommitLineData
ae70e55a 1*** perly.c.orig Sun Jul 7 23:27:45 1996
2--- perly.c Sun Jul 7 23:27:46 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***************
ae70e55a 78*** 1375,1387 ****
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 */
ae70e55a 91 #line 1388 "y.tab.c"
92--- 1310,1317 ----
93a17b20 93***************
ae70e55a 94*** 1388,1401 ****
95--- 1318,1376 ----
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;
ae70e55a 116+ if (ysave->yyss) safefree((char *)ysave->yyss);
117+ if (ysave->yyvs) safefree((char *)ysave->yyvs);
a0d0e21e 118+ yydebug = ysave->oldyydebug;
119+ yynerrs = ysave->oldyynerrs;
120+ yyerrflag = ysave->oldyyerrflag;
121+ yychar = ysave->oldyychar;
122+ yyval = ysave->oldyyval;
123+ yylval = ysave->oldyylval;
ae70e55a 124+ safefree((char *)ysave);
a0d0e21e 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***************
ae70e55a 156*** 1408,1413 ****
157--- 1383,1396 ----
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***************
ae70e55a 173*** 1423,1429 ****
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
ae70e55a 181--- 1406,1412 ----
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***************
ae70e55a 190*** 1433,1444 ****
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;
ae70e55a 203--- 1416,1441 ----
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***************
ae70e55a 231*** 1474,1485 ****
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;
ae70e55a 244--- 1471,1497 ----
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***************
ae70e55a 273*** 1489,1496 ****
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;
ae70e55a 282--- 1501,1509 ----
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***************
ae70e55a 293*** 1507,1514 ****
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);
ae70e55a 302--- 1520,1528 ----
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***************
ae70e55a 313*** 1517,1523 ****
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];
ae70e55a 321--- 1531,1537 ----
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***************
ae70e55a 330*** 2236,2243 ****
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;
ae70e55a 339--- 2250,2258 ----
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***************
ae70e55a 350*** 2251,2257 ****
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
ae70e55a 358--- 2266,2272 ----
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***************
ae70e55a 367*** 2266,2285 ****
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 }
ae70e55a 388--- 2281,2315 ----
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 }