This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
add support for bison 2.3
[perl5.git] / perly.c
CommitLineData
0de566d7
DM
1/* perly.c
2 *
54ca4ee7 3 * Copyright (c) 2004, 2005, 2006 Larry Wall and others
0de566d7
DM
4 *
5 * You may distribute under the terms of either the GNU General Public
6 * License or the Artistic License, as specified in the README file.
7 *
8 * Note that this file was originally generated as an output from
9 * GNU bison version 1.875, but now the code is statically maintained
356f4fed
DM
10 * and edited; the bits that are dependent on perly.y/madly.y are now
11 * #included from the files perly.tab/madly.tab and perly.act/madly.act.
0de566d7
DM
12 *
13 * Here is an important copyright statement from the original, generated
14 * file:
15 *
16 * As a special exception, when this file is copied by Bison into a
17 * Bison output file, you may use that output file without
18 * restriction. This special exception was added by the Free
19 * Software Foundation in version 1.24 of Bison.
bc463c31
DM
20 *
21 * Note that this file is also #included in madly.c, to allow compilation
22 * of a second parser, Perl_madparse, that is identical to Perl_yyparse,
23 * but which includes the parser tables from madly.{tab,act} rather than
24 * perly.{tab,act}. This is controlled by the PERL_IN_MADLY_C define.
0de566d7
DM
25 */
26
27
3797f23d 28
0de566d7
DM
29/* allow stack size to grow effectively without limit */
30#define YYMAXDEPTH 10000000
31
79072805 32#include "EXTERN.h"
864dbfa3 33#define PERL_IN_PERLY_C
79072805 34#include "perl.h"
09bef843 35
3797f23d
DM
36typedef unsigned char yytype_uint8;
37typedef signed char yytype_int8;
38typedef unsigned short int yytype_uint16;
39typedef short int yytype_int16;
0de566d7
DM
40typedef signed char yysigned_char;
41
42#ifdef DEBUGGING
43# define YYDEBUG 1
93a17b20 44#else
0de566d7 45# define YYDEBUG 0
93a17b20 46#endif
09bef843 47
356f4fed 48/* contains all the parser state tables; auto-generated from perly.y/madly.y */
bc463c31
DM
49#ifdef PERL_IN_MADLY_C
50# include "madly.tab"
51#else
52# include "perly.tab"
53#endif
0de566d7
DM
54
55# define YYSIZE_T size_t
56
57#define yyerrok (yyerrstatus = 0)
58#define yyclearin (yychar = YYEMPTY)
59#define YYEMPTY (-2)
60#define YYEOF 0
61
62#define YYACCEPT goto yyacceptlab
63#define YYABORT goto yyabortlab
64#define YYERROR goto yyerrlab1
65
66
67/* Like YYERROR except do call yyerror. This remains here temporarily
68 to ease the transition to the new meaning of YYERROR, for GCC.
69 Once GCC version 2 has supplanted version 1, this can go. */
70
71#define YYFAIL goto yyerrlab
72
73#define YYRECOVERING() (!!yyerrstatus)
74
75#define YYBACKUP(Token, Value) \
76do \
77 if (yychar == YYEMPTY && yylen == 1) { \
78 yychar = (Token); \
79 yylval = (Value); \
80 yytoken = YYTRANSLATE (yychar); \
81 YYPOPSTACK; \
82 goto yybackup; \
83 } \
84 else { \
85 yyerror ("syntax error: cannot back up"); \
86 YYERROR; \
87 } \
88while (0)
89
90#define YYTERROR 1
91#define YYERRCODE 256
92
0de566d7 93/* Enable debugging if requested. */
9388183f 94#ifdef DEBUGGING
0de566d7
DM
95
96# define yydebug (DEBUG_p_TEST)
97
98# define YYFPRINTF PerlIO_printf
99
100# define YYDPRINTF(Args) \
101do { \
102 if (yydebug) \
103 YYFPRINTF Args; \
104} while (0)
105
9388183f 106# define YYDSYMPRINTF(Title, Token, Value) \
0de566d7
DM
107do { \
108 if (yydebug) { \
109 YYFPRINTF (Perl_debug_log, "%s ", Title); \
356f4fed 110 yysymprint (aTHX_ Perl_debug_log, Token, Value); \
0de566d7
DM
111 YYFPRINTF (Perl_debug_log, "\n"); \
112 } \
113} while (0)
114
115/*--------------------------------.
116| Print this symbol on YYOUTPUT. |
117`--------------------------------*/
118
119static void
356f4fed 120yysymprint(pTHX_ PerlIO * const yyoutput, int yytype, const YYSTYPE * const yyvaluep)
0de566d7 121{
0de566d7
DM
122 if (yytype < YYNTOKENS) {
123 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
124# ifdef YYPRINT
125 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
9388183f 126# else
e4584336 127 YYFPRINTF (yyoutput, "0x%"UVxf, (UV)yyvaluep->ival);
0de566d7
DM
128# endif
129 }
130 else
131 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
132
0de566d7
DM
133 YYFPRINTF (yyoutput, ")");
134}
135
136
9388183f
CB
137/* yy_stack_print()
138 * print the top 8 items on the parse stack. The args have the same
139 * meanings as the local vars in yyparse() of the same name */
0de566d7
DM
140
141static void
df35152e 142yy_stack_print (pTHX_ const short *yyss, const short *yyssp, const YYSTYPE *yyvs, const char**yyns)
0de566d7 143{
9388183f
CB
144 int i;
145 int start = 1;
146 int count = (int)(yyssp - yyss);
147
148 if (count > 8) {
149 start = count - 8 + 1;
150 count = 8;
151 }
152
153 PerlIO_printf(Perl_debug_log, "\nindex:");
154 for (i=0; i < count; i++)
155 PerlIO_printf(Perl_debug_log, " %8d", start+i);
156 PerlIO_printf(Perl_debug_log, "\nstate:");
21612876
DM
157 for (i=0; i < count; i++)
158 PerlIO_printf(Perl_debug_log, " %8d", yyss[start+i]);
9388183f 159 PerlIO_printf(Perl_debug_log, "\ntoken:");
21612876
DM
160 for (i=0; i < count; i++)
161 PerlIO_printf(Perl_debug_log, " %8.8s", yyns[start+i]);
9388183f 162 PerlIO_printf(Perl_debug_log, "\nvalue:");
21612876
DM
163 for (i=0; i < count; i++) {
164 if (yy_is_opval[yystos[yyss[start+i]]]) {
165 PerlIO_printf(Perl_debug_log, " %8.8s",
166 yyvs[start+i].opval
167 ? PL_op_name[yyvs[start+i].opval->op_type]
168 : "NULL"
169 );
170 }
171 else
172 PerlIO_printf(Perl_debug_log, " %8"UVxf, (UV)yyvs[start+i].ival);
173 }
9388183f 174 PerlIO_printf(Perl_debug_log, "\n\n");
0de566d7
DM
175}
176
9388183f 177# define YY_STACK_PRINT(yyss, yyssp, yyvs, yyns) \
0de566d7 178do { \
9388183f
CB
179 if (yydebug && DEBUG_v_TEST) \
180 yy_stack_print (aTHX_ (yyss), (yyssp), (yyvs), (yyns)); \
0de566d7
DM
181} while (0)
182
09bef843 183
0de566d7
DM
184/*------------------------------------------------.
185| Report that the YYRULE is going to be reduced. |
186`------------------------------------------------*/
187
188static void
189yy_reduce_print (pTHX_ int yyrule)
190{
191 int yyi;
df35152e 192 const unsigned int yylineno = yyrline[yyrule];
0de566d7
DM
193 YYFPRINTF (Perl_debug_log, "Reducing stack by rule %d (line %u), ",
194 yyrule - 1, yylineno);
195 /* Print the symbols being reduced, and their result. */
196 for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
197 YYFPRINTF (Perl_debug_log, "%s ", yytname [yyrhs[yyi]]);
198 YYFPRINTF (Perl_debug_log, "-> %s\n", yytname [yyr1[yyrule]]);
199}
200
201# define YY_REDUCE_PRINT(Rule) \
202do { \
203 if (yydebug) \
204 yy_reduce_print (aTHX_ Rule); \
205} while (0)
206
207#else /* !DEBUGGING */
208# define YYDPRINTF(Args)
9388183f
CB
209# define YYDSYMPRINTF(Title, Token, Value)
210# define YY_STACK_PRINT(yyss, yyssp, yyvs, yyns)
0de566d7
DM
211# define YY_REDUCE_PRINT(Rule)
212#endif /* !DEBUGGING */
213
214
215/* YYINITDEPTH -- initial size of the parser's stacks. */
216#ifndef YYINITDEPTH
217# define YYINITDEPTH 200
09bef843 218#endif
09bef843 219
0de566d7
DM
220
221#if YYERROR_VERBOSE
222# ifndef yystrlen
223# if defined (__GLIBC__) && defined (_STRING_H)
224# define yystrlen strlen
225# else
226/* Return the length of YYSTR. */
227static YYSIZE_T
228yystrlen (const char *yystr)
229{
230 register const char *yys = yystr;
231
232 while (*yys++ != '\0')
233 continue;
234
235 return yys - yystr - 1;
236}
237# endif
238# endif
239
240# ifndef yystpcpy
241# if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
242# define yystpcpy stpcpy
243# else
244/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
245 YYDEST. */
246static char *
247yystpcpy (pTHX_ char *yydest, const char *yysrc)
248{
249 register char *yyd = yydest;
250 register const char *yys = yysrc;
251
252 while ((*yyd++ = *yys++) != '\0')
253 continue;
254
255 return yyd - 1;
256}
257# endif
258# endif
259
260#endif /* !YYERROR_VERBOSE */
261
0de566d7
DM
262/*----------.
263| yyparse. |
264`----------*/
265
79072805 266int
bc463c31
DM
267#ifdef PERL_IN_MADLY_C
268Perl_madparse (pTHX)
269#else
0de566d7 270Perl_yyparse (pTHX)
bc463c31 271#endif
79072805 272{
97aff369 273 dVAR;
0de566d7
DM
274 int yychar; /* The lookahead symbol. */
275 YYSTYPE yylval; /* The semantic value of the lookahead symbol. */
276 int yynerrs; /* Number of syntax errors so far. */
277 register int yystate;
278 register int yyn;
279 int yyresult;
280
281 /* Number of tokens to shift before error messages enabled. */
282 int yyerrstatus;
283 /* Lookahead token as an internal (translated) token number. */
284 int yytoken = 0;
285
286 /* two stacks and their tools:
a0288114
AL
287 yyss: related to states,
288 yyvs: related to semantic values,
0de566d7
DM
289
290 Refer to the stacks thru separate pointers, to allow yyoverflow
291 to reallocate them elsewhere. */
292
293 /* The state stack. */
294 short *yyss;
93a17b20 295 register short *yyssp;
0de566d7
DM
296
297 /* The semantic value stack. */
298 YYSTYPE *yyvs;
93a17b20 299 register YYSTYPE *yyvsp;
a0d0e21e 300
0de566d7
DM
301 /* for ease of re-allocation and automatic freeing, have two SVs whose
302 * SvPVX points to the stacks */
303 SV *yyss_sv, *yyvs_sv;
304
9388183f
CB
305#ifdef DEBUGGING
306 /* maintain also a stack of token/rule names for debugging with -Dpv */
e1ec3a88 307 const char **yyns, **yynsp;
9388183f
CB
308 SV *yyns_sv;
309# define YYPOPSTACK (yyvsp--, yyssp--, yynsp--)
310#else
311# define YYPOPSTACK (yyvsp--, yyssp--)
312#endif
313
0de566d7
DM
314
315 YYSIZE_T yystacksize = YYINITDEPTH;
316
317 /* The variables used to return semantic value and location from the
318 action routines. */
319 YYSTYPE yyval;
320
321
322 /* When reducing, the number of symbols on the RHS of the reduced
323 rule. */
324 int yylen;
325
bc463c31
DM
326#ifndef PERL_IN_MADLY_C
327# ifdef PERL_MAD
00e74f14
NC
328 if (PL_madskills)
329 return madparse();
bc463c31 330# endif
81d86705
NC
331#endif
332
0de566d7
DM
333 YYDPRINTF ((Perl_debug_log, "Starting parse\n"));
334
0de566d7 335 ENTER; /* force stack free before we return */
12fbd33b
DM
336 SAVEVPTR(PL_yycharp);
337 SAVEVPTR(PL_yylvalp);
338 PL_yycharp = &yychar; /* so PL_yyerror() can access it */
339 PL_yylvalp = &yylval; /* so various functions in toke.c can access it */
340
561b68a9
SH
341 yyss_sv = newSV(YYINITDEPTH * sizeof(short));
342 yyvs_sv = newSV(YYINITDEPTH * sizeof(YYSTYPE));
0de566d7
DM
343 SAVEFREESV(yyss_sv);
344 SAVEFREESV(yyvs_sv);
345 yyss = (short *) SvPVX(yyss_sv);
346 yyvs = (YYSTYPE *) SvPVX(yyvs_sv);
9388183f
CB
347 /* note that elements zero of yyvs and yyns are not used */
348 yyssp = yyss;
349 yyvsp = yyvs;
350#ifdef DEBUGGING
561b68a9 351 yyns_sv = newSV(YYINITDEPTH * sizeof(char *));
9388183f 352 SAVEFREESV(yyns_sv);
a28509cc 353 /* XXX This seems strange to cast char * to char ** */
94a11853 354 yyns = (const char **) SvPVX(yyns_sv);
9388183f
CB
355 yynsp = yyns;
356#endif
79072805 357
0de566d7
DM
358 yystate = 0;
359 yyerrstatus = 0;
93a17b20 360 yynerrs = 0;
0de566d7
DM
361 yychar = YYEMPTY; /* Cause a token to be read. */
362
9388183f 363 YYDPRINTF ((Perl_debug_log, "Entering state %d\n", yystate));
0de566d7
DM
364
365 goto yysetstate;
366
367/*------------------------------------------------------------.
368| yynewstate -- Push a new state, which is found in yystate. |
369`------------------------------------------------------------*/
370 yynewstate:
371 /* In all cases, when you get here, the value and location stacks
372 have just been pushed. so pushing a state here evens the stacks.
373 */
374 yyssp++;
375
376 yysetstate:
377 *yyssp = yystate;
378
379 if (yyss + yystacksize - 1 <= yyssp) {
380 /* Get the current used size of the three stacks, in elements. */
df35152e 381 const YYSIZE_T yysize = yyssp - yyss + 1;
0de566d7
DM
382
383 /* Extend the stack our own way. */
384 if (YYMAXDEPTH <= yystacksize)
385 goto yyoverflowlab;
386 yystacksize *= 2;
387 if (YYMAXDEPTH < yystacksize)
388 yystacksize = YYMAXDEPTH;
389
390 SvGROW(yyss_sv, yystacksize * sizeof(short));
391 SvGROW(yyvs_sv, yystacksize * sizeof(YYSTYPE));
392 yyss = (short *) SvPVX(yyss_sv);
393 yyvs = (YYSTYPE *) SvPVX(yyvs_sv);
9388183f
CB
394#ifdef DEBUGGING
395 SvGROW(yyns_sv, yystacksize * sizeof(char *));
a28509cc 396 /* XXX This seems strange to cast char * to char ** */
94a11853 397 yyns = (const char **) SvPVX(yyns_sv);
9388183f
CB
398 if (! yyns)
399 goto yyoverflowlab;
400 yynsp = yyns + yysize - 1;
401#endif
0de566d7
DM
402 if (!yyss || ! yyvs)
403 goto yyoverflowlab;
404
405 yyssp = yyss + yysize - 1;
406 yyvsp = yyvs + yysize - 1;
407
408
409 YYDPRINTF ((Perl_debug_log, "Stack size increased to %lu\n",
410 (unsigned long int) yystacksize));
411
412 if (yyss + yystacksize - 1 <= yyssp)
413 YYABORT;
93a17b20 414 }
0de566d7 415
0de566d7
DM
416 goto yybackup;
417
418 /*-----------.
419 | yybackup. |
420 `-----------*/
421 yybackup:
422
423/* Do appropriate processing given the current state. */
424/* Read a lookahead token if we need one and don't already have one. */
425/* yyresume: */
426
427 /* First try to decide what to do without reference to lookahead token. */
428
429 yyn = yypact[yystate];
430 if (yyn == YYPACT_NINF)
431 goto yydefault;
432
433 /* Not known => get a lookahead token if don't already have one. */
434
435 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
436 if (yychar == YYEMPTY) {
437 YYDPRINTF ((Perl_debug_log, "Reading a token: "));
bc463c31
DM
438#ifndef PERL_IN_MADLY_C
439# ifdef PERL_MAD
00e74f14 440 yychar = PL_madskills ? madlex() : yylex();
bc463c31 441# else
12fbd33b 442 yychar = yylex();
bc463c31 443# endif
81d86705 444#endif
bc463c31 445
12fbd33b
DM
446# ifdef EBCDIC
447 if (yychar >= 0 && yychar < 255) {
448 yychar = NATIVE_TO_ASCII(yychar);
449 }
450# endif
0de566d7
DM
451 }
452
453 if (yychar <= YYEOF) {
454 yychar = yytoken = YYEOF;
455 YYDPRINTF ((Perl_debug_log, "Now at end of input.\n"));
93a17b20 456 }
0de566d7
DM
457 else {
458 yytoken = YYTRANSLATE (yychar);
9388183f 459 YYDSYMPRINTF ("Next token is", yytoken, &yylval);
93a17b20 460 }
771df094 461
0de566d7
DM
462 /* If the proper action on seeing token YYTOKEN is to reduce or to
463 detect an error, take that action. */
464 yyn += yytoken;
465 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
466 goto yydefault;
467 yyn = yytable[yyn];
468 if (yyn <= 0) {
469 if (yyn == 0 || yyn == YYTABLE_NINF)
470 goto yyerrlab;
471 yyn = -yyn;
472 goto yyreduce;
473 }
7b57b0ea 474
0de566d7
DM
475 if (yyn == YYFINAL)
476 YYACCEPT;
771df094 477
0de566d7
DM
478 /* Shift the lookahead token. */
479 YYDPRINTF ((Perl_debug_log, "Shifting token %s, ", yytname[yytoken]));
480
481 /* Discard the token being shifted unless it is eof. */
482 if (yychar != YYEOF)
483 yychar = YYEMPTY;
484
485 *++yyvsp = yylval;
9388183f 486#ifdef DEBUGGING
e1ec3a88 487 *++yynsp = (const char *)(yytname[yytoken]);
9388183f 488#endif
0de566d7
DM
489
490
491 /* Count tokens shifted since error; after three, turn off error
492 status. */
493 if (yyerrstatus)
494 yyerrstatus--;
495
496 yystate = yyn;
9388183f
CB
497 YYDPRINTF ((Perl_debug_log, "Entering state %d\n", yystate));
498
0de566d7
DM
499 goto yynewstate;
500
501
502 /*-----------------------------------------------------------.
503 | yydefault -- do the default action for the current state. |
504 `-----------------------------------------------------------*/
505 yydefault:
506 yyn = yydefact[yystate];
507 if (yyn == 0)
508 goto yyerrlab;
509 goto yyreduce;
510
511
512 /*-----------------------------.
513 | yyreduce -- Do a reduction. |
514 `-----------------------------*/
515 yyreduce:
516 /* yyn is the number of a rule to reduce with. */
517 yylen = yyr2[yyn];
518
519 /* If YYLEN is nonzero, implement the default value of the action:
a0288114 520 "$$ = $1".
0de566d7
DM
521
522 Otherwise, the following line sets YYVAL to garbage.
523 This behavior is undocumented and Bison
524 users should not rely upon it. Assigning to YYVAL
525 unconditionally makes the parser a bit smaller, and it avoids a
526 GCC warning that YYVAL may be used uninitialized. */
527 yyval = yyvsp[1-yylen];
528
529
530 YY_REDUCE_PRINT (yyn);
531 switch (yyn) {
532
356f4fed 533/* contains all the rule actions; auto-generated from perly.y or madly.y */
0de566d7
DM
534
535#define dep() deprecate("\"do\" to call subroutines")
bc463c31
DM
536#ifdef PERL_IN_MADLY_C
537# include "madly.act"
538#else
539# include "perly.act"
540#endif
7b57b0ea 541
93a17b20 542 }
0de566d7
DM
543
544 yyvsp -= yylen;
545 yyssp -= yylen;
9388183f
CB
546#ifdef DEBUGGING
547 yynsp -= yylen;
548#endif
0de566d7 549
0de566d7
DM
550
551 *++yyvsp = yyval;
9388183f 552#ifdef DEBUGGING
e1ec3a88 553 *++yynsp = (const char *)(yytname [yyr1[yyn]]);
9388183f 554#endif
0de566d7 555
a0288114 556 /* Now shift the result of the reduction. Determine what state
0de566d7
DM
557 that goes to, based on the state we popped back to and the rule
558 number reduced by. */
559
560 yyn = yyr1[yyn];
561
562 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
563 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
564 yystate = yytable[yystate];
93a17b20 565 else
0de566d7
DM
566 yystate = yydefgoto[yyn - YYNTOKENS];
567
9388183f
CB
568 YYDPRINTF ((Perl_debug_log, "Entering state %d\n", yystate));
569
570#ifdef DEBUGGING
571 /* tmp push yystate for stack print; this is normally pushed later in
572 * yynewstate */
573 yyssp++;
574 *yyssp = yystate;
575 YY_STACK_PRINT (yyss, yyssp, yyvs, yyns);
576 yyssp--;
577#endif
578
0de566d7
DM
579 goto yynewstate;
580
581
582 /*------------------------------------.
583 | yyerrlab -- here on detecting error |
584 `------------------------------------*/
585 yyerrlab:
586 /* If not already recovering from an error, report this error. */
587 if (!yyerrstatus) {
588 ++yynerrs;
589#if YYERROR_VERBOSE
590 yyn = yypact[yystate];
591
592 if (YYPACT_NINF < yyn && yyn < YYLAST) {
593 YYSIZE_T yysize = 0;
df35152e 594 const int yytype = YYTRANSLATE (yychar);
0de566d7
DM
595 char *yymsg;
596 int yyx, yycount;
597
598 yycount = 0;
599 /* Start YYX at -YYN if negative to avoid negative indexes in
600 YYCHECK. */
601 for (yyx = yyn < 0 ? -yyn : 0;
602 yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++)
603 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
604 yysize += yystrlen (yytname[yyx]) + 15, yycount++;
605 yysize += yystrlen ("syntax error, unexpected ") + 1;
606 yysize += yystrlen (yytname[yytype]);
4b711db3 607 Newx(yymsg, yysize, char *);
0de566d7 608 if (yymsg != 0) {
df35152e 609 const char *yyp = yystpcpy (yymsg, "syntax error, unexpected ");
0de566d7
DM
610 yyp = yystpcpy (yyp, yytname[yytype]);
611
612 if (yycount < 5) {
613 yycount = 0;
614 for (yyx = yyn < 0 ? -yyn : 0;
615 yyx < (int) (sizeof (yytname) / sizeof (char *));
616 yyx++)
617 {
618 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) {
619 const char *yyq = ! yycount ?
620 ", expecting " : " or ";
621 yyp = yystpcpy (yyp, yyq);
622 yyp = yystpcpy (yyp, yytname[yyx]);
623 yycount++;
624 }
625 }
ecb2f335 626 }
0de566d7
DM
627 yyerror (yymsg);
628 YYSTACK_FREE (yymsg);
629 }
630 else
631 yyerror ("syntax error; also virtual memory exhausted");
632 }
633 else
634#endif /* YYERROR_VERBOSE */
635 yyerror ("syntax error");
93a17b20 636 }
0de566d7
DM
637
638
639 if (yyerrstatus == 3) {
640 /* If just tried and failed to reuse lookahead token after an
641 error, discard it. */
642
643 /* Return failure if at end of input. */
644 if (yychar == YYEOF) {
645 /* Pop the error token. */
646 YYPOPSTACK;
647 /* Pop the rest of the stack. */
648 while (yyss < yyssp) {
9388183f 649 YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp);
0539ab63
DM
650 if (yy_is_opval[yystos[*yyssp]]) {
651 YYDPRINTF ((Perl_debug_log, "(freeing op)\n"));
652 op_free(yyvsp->opval);
653 }
0de566d7
DM
654 YYPOPSTACK;
655 }
656 YYABORT;
657 }
658
9388183f 659 YYDSYMPRINTF ("Error: discarding", yytoken, &yylval);
0de566d7
DM
660 yychar = YYEMPTY;
661
93a17b20 662 }
0de566d7
DM
663
664 /* Else will try to reuse lookahead token after shifting the error
665 token. */
666 goto yyerrlab1;
667
668
669 /*----------------------------------------------------.
670 | yyerrlab1 -- error raised explicitly by an action. |
671 `----------------------------------------------------*/
672 yyerrlab1:
673 yyerrstatus = 3; /* Each real token shifted decrements this. */
674
675 for (;;) {
676 yyn = yypact[yystate];
677 if (yyn != YYPACT_NINF) {
678 yyn += YYTERROR;
679 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) {
680 yyn = yytable[yyn];
681 if (0 < yyn)
682 break;
683 }
684 }
685
686 /* Pop the current state because it cannot handle the error token. */
687 if (yyssp == yyss)
688 YYABORT;
689
9388183f 690 YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp);
0539ab63
DM
691 if (yy_is_opval[yystos[*yyssp]]) {
692 YYDPRINTF ((Perl_debug_log, "(freeing op)\n"));
693 op_free(yyvsp->opval);
694 }
0de566d7 695 yyvsp--;
9388183f
CB
696#ifdef DEBUGGING
697 yynsp--;
698#endif
0de566d7
DM
699 yystate = *--yyssp;
700
9388183f 701 YY_STACK_PRINT (yyss, yyssp, yyvs, yyns);
93a17b20 702 }
0de566d7
DM
703
704 if (yyn == YYFINAL)
705 YYACCEPT;
706
707 YYDPRINTF ((Perl_debug_log, "Shifting error token, "));
708
709 *++yyvsp = yylval;
9388183f
CB
710#ifdef DEBUGGING
711 *++yynsp ="<err>";
712#endif
0de566d7
DM
713
714 yystate = yyn;
9388183f
CB
715 YYDPRINTF ((Perl_debug_log, "Entering state %d\n", yystate));
716
0de566d7
DM
717 goto yynewstate;
718
719
720 /*-------------------------------------.
721 | yyacceptlab -- YYACCEPT comes here. |
722 `-------------------------------------*/
723 yyacceptlab:
724 yyresult = 0;
725 goto yyreturn;
726
727 /*-----------------------------------.
728 | yyabortlab -- YYABORT comes here. |
729 `-----------------------------------*/
730 yyabortlab:
731 yyresult = 1;
732 goto yyreturn;
733
734 /*----------------------------------------------.
735 | yyoverflowlab -- parser overflow comes here. |
736 `----------------------------------------------*/
737 yyoverflowlab:
738 yyerror ("parser stack overflow");
739 yyresult = 2;
740 /* Fall through. */
741
742 yyreturn:
743
c86b7e91 744 LEAVE; /* force stack free before we return */
e1f15930 745
0de566d7 746 return yyresult;
e1f15930 747}
66610fdd
RGS
748
749/*
750 * Local variables:
751 * c-indentation-style: bsd
752 * c-basic-offset: 4
753 * indent-tabs-mode: t
754 * End:
755 *
37442d52
RGS
756 * ex: set ts=8 sts=4 sw=4 noet:
757 */