3 * Copyright (c) 2004 Larry Wall
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.
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
10 * and edited; the bits that are dependent on perly.y are now #included
11 * from the files perly.tab and perly.act.
13 * Here is an important copyright statement from the original, generated
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.
23 /* allow stack size to grow effectively without limit */
24 #define YYMAXDEPTH 10000000
27 #define PERL_IN_PERLY_C
30 typedef signed char yysigned_char;
38 /* contains all the parser state tables; auto-generated from perly.y */
41 # define YYSIZE_T size_t
43 #define yyerrok (yyerrstatus = 0)
44 #define yyclearin (yychar = YYEMPTY)
48 #define YYACCEPT goto yyacceptlab
49 #define YYABORT goto yyabortlab
50 #define YYERROR goto yyerrlab1
53 /* Like YYERROR except do call yyerror. This remains here temporarily
54 to ease the transition to the new meaning of YYERROR, for GCC.
55 Once GCC version 2 has supplanted version 1, this can go. */
57 #define YYFAIL goto yyerrlab
59 #define YYRECOVERING() (!!yyerrstatus)
61 #define YYBACKUP(Token, Value) \
63 if (yychar == YYEMPTY && yylen == 1) { \
66 yytoken = YYTRANSLATE (yychar); \
71 yyerror ("syntax error: cannot back up"); \
79 /* YYLEX -- calling `yylex' with the right arguments. */
81 # define YYLEX yylex_r (&yylval, &yychar)
83 /* Enable debugging if requested. */
86 # define yydebug (DEBUG_p_TEST)
88 # define YYFPRINTF PerlIO_printf
90 # define YYDPRINTF(Args) \
96 # define YYDSYMPRINT(Args) \
102 # define YYDSYMPRINTF(Title, Token, Value) \
105 YYFPRINTF (Perl_debug_log, "%s ", Title); \
106 yysymprint (aTHX_ Perl_debug_log, Token, Value); \
107 YYFPRINTF (Perl_debug_log, "\n"); \
111 /*--------------------------------.
112 | Print this symbol on YYOUTPUT. |
113 `--------------------------------*/
116 yysymprint (pTHX_ PerlIO *yyoutput, int yytype, YYSTYPE *yyvaluep)
118 /* Pacify ``unused variable'' warnings. */
121 if (yytype < YYNTOKENS) {
122 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
124 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
126 YYFPRINTF (yyoutput, "0x%x", yyvaluep->ival);
130 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
136 YYFPRINTF (yyoutput, ")");
141 * print the top 8 items on the parse stack. The args have the same
142 * meanings as the local vars in yyparse() of the same name */
145 yy_stack_print (pTHX_ short *yyss, short *yyssp, YYSTYPE *yyvs, char**yyns)
149 int count = (int)(yyssp - yyss);
152 start = count - 8 + 1;
156 PerlIO_printf(Perl_debug_log, "\nindex:");
157 for (i=0; i < count; i++)
158 PerlIO_printf(Perl_debug_log, " %8d", start+i);
159 PerlIO_printf(Perl_debug_log, "\nstate:");
160 for (i=0, yyss += start; i < count; i++, yyss++)
161 PerlIO_printf(Perl_debug_log, " %8d", *yyss);
162 PerlIO_printf(Perl_debug_log, "\ntoken:");
163 for (i=0, yyns += start; i < count; i++, yyns++)
164 PerlIO_printf(Perl_debug_log, " %8.8s", *yyns);
165 PerlIO_printf(Perl_debug_log, "\nvalue:");
166 for (i=0, yyvs += start; i < count; i++, yyvs++)
167 PerlIO_printf(Perl_debug_log, " %8x", yyvs->ival);
168 PerlIO_printf(Perl_debug_log, "\n\n");
171 # define YY_STACK_PRINT(yyss, yyssp, yyvs, yyns) \
173 if (yydebug && DEBUG_v_TEST) \
174 yy_stack_print (aTHX_ (yyss), (yyssp), (yyvs), (yyns)); \
178 /*------------------------------------------------.
179 | Report that the YYRULE is going to be reduced. |
180 `------------------------------------------------*/
183 yy_reduce_print (pTHX_ int yyrule)
186 unsigned int yylineno = yyrline[yyrule];
187 YYFPRINTF (Perl_debug_log, "Reducing stack by rule %d (line %u), ",
188 yyrule - 1, yylineno);
189 /* Print the symbols being reduced, and their result. */
190 for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
191 YYFPRINTF (Perl_debug_log, "%s ", yytname [yyrhs[yyi]]);
192 YYFPRINTF (Perl_debug_log, "-> %s\n", yytname [yyr1[yyrule]]);
195 # define YY_REDUCE_PRINT(Rule) \
198 yy_reduce_print (aTHX_ Rule); \
201 #else /* !DEBUGGING */
202 # define YYDPRINTF(Args)
203 # define YYDSYMPRINT(Args)
204 # define YYDSYMPRINTF(Title, Token, Value)
205 # define YY_STACK_PRINT(yyss, yyssp, yyvs, yyns)
206 # define YY_REDUCE_PRINT(Rule)
207 #endif /* !DEBUGGING */
210 /* YYINITDEPTH -- initial size of the parser's stacks. */
212 # define YYINITDEPTH 200
218 # if defined (__GLIBC__) && defined (_STRING_H)
219 # define yystrlen strlen
221 /* Return the length of YYSTR. */
223 yystrlen (const char *yystr)
225 register const char *yys = yystr;
227 while (*yys++ != '\0')
230 return yys - yystr - 1;
236 # if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
237 # define yystpcpy stpcpy
239 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
242 yystpcpy (pTHX_ char *yydest, const char *yysrc)
244 register char *yyd = yydest;
245 register const char *yys = yysrc;
247 while ((*yyd++ = *yys++) != '\0')
255 #endif /* !YYERROR_VERBOSE */
258 /*-----------------------------------------------.
259 | Release the memory associated to this symbol. |
260 `-----------------------------------------------*/
263 yydestruct (int yytype, YYSTYPE *yyvaluep)
265 /* Pacify ``unused variable'' warnings. */
284 int yychar; /* The lookahead symbol. */
285 YYSTYPE yylval; /* The semantic value of the lookahead symbol. */
286 int yynerrs; /* Number of syntax errors so far. */
287 register int yystate;
291 /* Number of tokens to shift before error messages enabled. */
293 /* Lookahead token as an internal (translated) token number. */
296 /* two stacks and their tools:
297 `yyss': related to states,
298 `yyvs': related to semantic values,
300 Refer to the stacks thru separate pointers, to allow yyoverflow
301 to reallocate them elsewhere. */
303 /* The state stack. */
305 register short *yyssp;
307 /* The semantic value stack. */
309 register YYSTYPE *yyvsp;
311 /* for ease of re-allocation and automatic freeing, have two SVs whose
312 * SvPVX points to the stacks */
313 SV *yyss_sv, *yyvs_sv;
316 /* maintain also a stack of token/rule names for debugging with -Dpv */
317 char **yyns, **yynsp;
319 # define YYPOPSTACK (yyvsp--, yyssp--, yynsp--)
321 # define YYPOPSTACK (yyvsp--, yyssp--)
325 YYSIZE_T yystacksize = YYINITDEPTH;
327 /* The variables used to return semantic value and location from the
332 /* When reducing, the number of symbols on the RHS of the reduced
336 YYDPRINTF ((Perl_debug_log, "Starting parse\n"));
339 /* XXX is this needed anymore? DAPM 13-Feb-04;
340 * if not, delete the correspinding LEAVE too */
341 ENTER; /* force stack free before we return */
343 yyss_sv = NEWSV(73, YYINITDEPTH * sizeof(short));
344 yyvs_sv = NEWSV(73, YYINITDEPTH * sizeof(YYSTYPE));
347 yyss = (short *) SvPVX(yyss_sv);
348 yyvs = (YYSTYPE *) SvPVX(yyvs_sv);
349 /* note that elements zero of yyvs and yyns are not used */
353 yyns_sv = NEWSV(73, YYINITDEPTH * sizeof(char *));
355 yyns = (char **) SvPVX(yyns_sv);
362 yychar = YYEMPTY; /* Cause a token to be read. */
366 YYDPRINTF ((Perl_debug_log, "Entering state %d\n", yystate));
370 /*------------------------------------------------------------.
371 | yynewstate -- Push a new state, which is found in yystate. |
372 `------------------------------------------------------------*/
374 /* In all cases, when you get here, the value and location stacks
375 have just been pushed. so pushing a state here evens the stacks.
382 if (yyss + yystacksize - 1 <= yyssp) {
383 /* Get the current used size of the three stacks, in elements. */
384 YYSIZE_T yysize = yyssp - yyss + 1;
386 /* Extend the stack our own way. */
387 if (YYMAXDEPTH <= yystacksize)
390 if (YYMAXDEPTH < yystacksize)
391 yystacksize = YYMAXDEPTH;
393 SvGROW(yyss_sv, yystacksize * sizeof(short));
394 SvGROW(yyvs_sv, yystacksize * sizeof(YYSTYPE));
395 yyss = (short *) SvPVX(yyss_sv);
396 yyvs = (YYSTYPE *) SvPVX(yyvs_sv);
398 SvGROW(yyns_sv, yystacksize * sizeof(char *));
399 yyns = (char **) SvPVX(yyns_sv);
402 yynsp = yyns + yysize - 1;
407 yyssp = yyss + yysize - 1;
408 yyvsp = yyvs + yysize - 1;
411 YYDPRINTF ((Perl_debug_log, "Stack size increased to %lu\n",
412 (unsigned long int) yystacksize));
414 if (yyss + yystacksize - 1 <= yyssp)
425 /* Do appropriate processing given the current state. */
426 /* Read a lookahead token if we need one and don't already have one. */
429 /* First try to decide what to do without reference to lookahead token. */
431 yyn = yypact[yystate];
432 if (yyn == YYPACT_NINF)
435 /* Not known => get a lookahead token if don't already have one. */
437 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
438 if (yychar == YYEMPTY) {
439 YYDPRINTF ((Perl_debug_log, "Reading a token: "));
443 if (yychar <= YYEOF) {
444 yychar = yytoken = YYEOF;
445 YYDPRINTF ((Perl_debug_log, "Now at end of input.\n"));
448 yytoken = YYTRANSLATE (yychar);
449 YYDSYMPRINTF ("Next token is", yytoken, &yylval);
452 /* If the proper action on seeing token YYTOKEN is to reduce or to
453 detect an error, take that action. */
455 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
459 if (yyn == 0 || yyn == YYTABLE_NINF)
468 /* Shift the lookahead token. */
469 YYDPRINTF ((Perl_debug_log, "Shifting token %s, ", yytname[yytoken]));
471 /* Discard the token being shifted unless it is eof. */
477 *++yynsp = (char *)(yytname[yytoken]);
481 /* Count tokens shifted since error; after three, turn off error
487 YYDPRINTF ((Perl_debug_log, "Entering state %d\n", yystate));
492 /*-----------------------------------------------------------.
493 | yydefault -- do the default action for the current state. |
494 `-----------------------------------------------------------*/
496 yyn = yydefact[yystate];
502 /*-----------------------------.
503 | yyreduce -- Do a reduction. |
504 `-----------------------------*/
506 /* yyn is the number of a rule to reduce with. */
509 /* If YYLEN is nonzero, implement the default value of the action:
512 Otherwise, the following line sets YYVAL to garbage.
513 This behavior is undocumented and Bison
514 users should not rely upon it. Assigning to YYVAL
515 unconditionally makes the parser a bit smaller, and it avoids a
516 GCC warning that YYVAL may be used uninitialized. */
517 yyval = yyvsp[1-yylen];
520 YY_REDUCE_PRINT (yyn);
523 /* contains all the rule actions; auto-generated from perly.y */
525 #define dep() deprecate("\"do\" to call subroutines")
539 *++yynsp = (char *)(yytname [yyr1[yyn]]);
542 /* Now `shift' the result of the reduction. Determine what state
543 that goes to, based on the state we popped back to and the rule
544 number reduced by. */
548 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
549 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
550 yystate = yytable[yystate];
552 yystate = yydefgoto[yyn - YYNTOKENS];
554 YYDPRINTF ((Perl_debug_log, "Entering state %d\n", yystate));
557 /* tmp push yystate for stack print; this is normally pushed later in
561 YY_STACK_PRINT (yyss, yyssp, yyvs, yyns);
568 /*------------------------------------.
569 | yyerrlab -- here on detecting error |
570 `------------------------------------*/
572 /* If not already recovering from an error, report this error. */
576 yyn = yypact[yystate];
578 if (YYPACT_NINF < yyn && yyn < YYLAST) {
580 int yytype = YYTRANSLATE (yychar);
585 /* Start YYX at -YYN if negative to avoid negative indexes in
587 for (yyx = yyn < 0 ? -yyn : 0;
588 yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++)
589 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
590 yysize += yystrlen (yytname[yyx]) + 15, yycount++;
591 yysize += yystrlen ("syntax error, unexpected ") + 1;
592 yysize += yystrlen (yytname[yytype]);
593 New(yymsg, yysize, char *);
595 char *yyp = yystpcpy (yymsg, "syntax error, unexpected ");
596 yyp = yystpcpy (yyp, yytname[yytype]);
600 for (yyx = yyn < 0 ? -yyn : 0;
601 yyx < (int) (sizeof (yytname) / sizeof (char *));
604 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) {
605 const char *yyq = ! yycount ?
606 ", expecting " : " or ";
607 yyp = yystpcpy (yyp, yyq);
608 yyp = yystpcpy (yyp, yytname[yyx]);
614 YYSTACK_FREE (yymsg);
617 yyerror ("syntax error; also virtual memory exhausted");
620 #endif /* YYERROR_VERBOSE */
621 yyerror ("syntax error");
625 if (yyerrstatus == 3) {
626 /* If just tried and failed to reuse lookahead token after an
627 error, discard it. */
629 /* Return failure if at end of input. */
630 if (yychar == YYEOF) {
631 /* Pop the error token. */
633 /* Pop the rest of the stack. */
634 while (yyss < yyssp) {
635 YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp);
636 yydestruct (yystos[*yyssp], yyvsp);
642 YYDSYMPRINTF ("Error: discarding", yytoken, &yylval);
643 yydestruct (yytoken, &yylval);
648 /* Else will try to reuse lookahead token after shifting the error
653 /*----------------------------------------------------.
654 | yyerrlab1 -- error raised explicitly by an action. |
655 `----------------------------------------------------*/
657 yyerrstatus = 3; /* Each real token shifted decrements this. */
660 yyn = yypact[yystate];
661 if (yyn != YYPACT_NINF) {
663 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) {
670 /* Pop the current state because it cannot handle the error token. */
674 YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp);
675 yydestruct (yystos[yystate], yyvsp);
682 YY_STACK_PRINT (yyss, yyssp, yyvs, yyns);
688 YYDPRINTF ((Perl_debug_log, "Shifting error token, "));
696 YYDPRINTF ((Perl_debug_log, "Entering state %d\n", yystate));
701 /*-------------------------------------.
702 | yyacceptlab -- YYACCEPT comes here. |
703 `-------------------------------------*/
708 /*-----------------------------------.
709 | yyabortlab -- YYABORT comes here. |
710 `-----------------------------------*/
715 /*----------------------------------------------.
716 | yyoverflowlab -- parser overflow comes here. |
717 `----------------------------------------------*/
719 yyerror ("parser stack overflow");
726 LEAVE; /* force stack free before we return */