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