3 * Copyright (c) 2004, 2005, 2006 Larry Wall and others
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/madly.y are now
11 * #included from the files perly.tab/madly.tab and perly.act/madly.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.
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.
29 /* allow stack size to grow effectively without limit */
30 #define YYMAXDEPTH 10000000
33 #define PERL_IN_PERLY_C
36 typedef unsigned char yytype_uint8;
37 typedef signed char yytype_int8;
38 typedef unsigned short int yytype_uint16;
39 typedef short int yytype_int16;
40 typedef signed char yysigned_char;
48 /* contains all the parser state tables; auto-generated from perly.y/madly.y */
49 #ifdef PERL_IN_MADLY_C
55 # define YYSIZE_T size_t
57 #define yyerrok (yyerrstatus = 0)
58 #define yyclearin (yychar = YYEMPTY)
62 #define YYACCEPT goto yyacceptlab
63 #define YYABORT goto yyabortlab
64 #define YYERROR goto yyerrlab1
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. */
71 #define YYFAIL goto yyerrlab
73 #define YYRECOVERING() (!!yyerrstatus)
75 #define YYBACKUP(Token, Value) \
77 if (yychar == YYEMPTY && yylen == 1) { \
80 yytoken = YYTRANSLATE (yychar); \
85 yyerror ("syntax error: cannot back up"); \
93 /* Enable debugging if requested. */
96 # define yydebug (DEBUG_p_TEST)
98 # define YYFPRINTF PerlIO_printf
100 # define YYDPRINTF(Args) \
106 # define YYDSYMPRINTF(Title, Token, Value) \
109 YYFPRINTF (Perl_debug_log, "%s ", Title); \
110 yysymprint (aTHX_ Perl_debug_log, Token, Value); \
111 YYFPRINTF (Perl_debug_log, "\n"); \
115 /*--------------------------------.
116 | Print this symbol on YYOUTPUT. |
117 `--------------------------------*/
120 yysymprint(pTHX_ PerlIO * const yyoutput, int yytype, const YYSTYPE * const yyvaluep)
122 if (yytype < YYNTOKENS) {
123 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
125 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
127 YYFPRINTF (yyoutput, "0x%"UVxf, (UV)yyvaluep->ival);
131 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
133 YYFPRINTF (yyoutput, ")");
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 */
142 yy_stack_print (pTHX_ const short *yyss, const short *yyssp, const YYSTYPE *yyvs, const char**yyns)
146 int count = (int)(yyssp - yyss);
149 start = count - 8 + 1;
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:");
157 for (i=0; i < count; i++)
158 PerlIO_printf(Perl_debug_log, " %8d", yyss[start+i]);
159 PerlIO_printf(Perl_debug_log, "\ntoken:");
160 for (i=0; i < count; i++)
161 PerlIO_printf(Perl_debug_log, " %8.8s", yyns[start+i]);
162 PerlIO_printf(Perl_debug_log, "\nvalue:");
163 for (i=0; i < count; i++) {
164 if (yy_is_opval[yystos[yyss[start+i]]]) {
165 PerlIO_printf(Perl_debug_log, " %8.8s",
167 ? PL_op_name[yyvs[start+i].opval->op_type]
172 PerlIO_printf(Perl_debug_log, " %8"UVxf, (UV)yyvs[start+i].ival);
174 PerlIO_printf(Perl_debug_log, "\n\n");
177 # define YY_STACK_PRINT(yyss, yyssp, yyvs, yyns) \
179 if (yydebug && DEBUG_v_TEST) \
180 yy_stack_print (aTHX_ (yyss), (yyssp), (yyvs), (yyns)); \
184 /*------------------------------------------------.
185 | Report that the YYRULE is going to be reduced. |
186 `------------------------------------------------*/
189 yy_reduce_print (pTHX_ int yyrule)
192 const unsigned int yylineno = yyrline[yyrule];
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]]);
201 # define YY_REDUCE_PRINT(Rule) \
204 yy_reduce_print (aTHX_ Rule); \
207 #else /* !DEBUGGING */
208 # define YYDPRINTF(Args)
209 # define YYDSYMPRINTF(Title, Token, Value)
210 # define YY_STACK_PRINT(yyss, yyssp, yyvs, yyns)
211 # define YY_REDUCE_PRINT(Rule)
212 #endif /* !DEBUGGING */
215 /* YYINITDEPTH -- initial size of the parser's stacks. */
217 # define YYINITDEPTH 200
223 # if defined (__GLIBC__) && defined (_STRING_H)
224 # define yystrlen strlen
226 /* Return the length of YYSTR. */
228 yystrlen (const char *yystr)
230 register const char *yys = yystr;
232 while (*yys++ != '\0')
235 return yys - yystr - 1;
241 # if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
242 # define yystpcpy stpcpy
244 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
247 yystpcpy (pTHX_ char *yydest, const char *yysrc)
249 register char *yyd = yydest;
250 register const char *yys = yysrc;
252 while ((*yyd++ = *yys++) != '\0')
260 #endif /* !YYERROR_VERBOSE */
267 #ifdef PERL_IN_MADLY_C
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;
281 /* Number of tokens to shift before error messages enabled. */
283 /* Lookahead token as an internal (translated) token number. */
286 /* two stacks and their tools:
287 yyss: related to states,
288 yyvs: related to semantic values,
290 Refer to the stacks thru separate pointers, to allow yyoverflow
291 to reallocate them elsewhere. */
293 /* The state stack. */
295 register short *yyssp;
297 /* The semantic value stack. */
299 register YYSTYPE *yyvsp;
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;
306 /* maintain also a stack of token/rule names for debugging with -Dpv */
307 const char **yyns, **yynsp;
309 # define YYPOPSTACK (yyvsp--, yyssp--, yynsp--)
311 # define YYPOPSTACK (yyvsp--, yyssp--)
315 YYSIZE_T yystacksize = YYINITDEPTH;
317 /* The variables used to return semantic value and location from the
322 /* When reducing, the number of symbols on the RHS of the reduced
326 #ifndef PERL_IN_MADLY_C
333 YYDPRINTF ((Perl_debug_log, "Starting parse\n"));
335 ENTER; /* force stack free before we return */
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 */
341 yyss_sv = newSV(YYINITDEPTH * sizeof(short));
342 yyvs_sv = newSV(YYINITDEPTH * sizeof(YYSTYPE));
345 yyss = (short *) SvPVX(yyss_sv);
346 yyvs = (YYSTYPE *) SvPVX(yyvs_sv);
347 /* note that elements zero of yyvs and yyns are not used */
351 yyns_sv = newSV(YYINITDEPTH * sizeof(char *));
353 /* XXX This seems strange to cast char * to char ** */
354 yyns = (const char **) SvPVX(yyns_sv);
361 yychar = YYEMPTY; /* Cause a token to be read. */
363 YYDPRINTF ((Perl_debug_log, "Entering state %d\n", yystate));
367 /*------------------------------------------------------------.
368 | yynewstate -- Push a new state, which is found in yystate. |
369 `------------------------------------------------------------*/
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.
379 if (yyss + yystacksize - 1 <= yyssp) {
380 /* Get the current used size of the three stacks, in elements. */
381 const YYSIZE_T yysize = yyssp - yyss + 1;
383 /* Extend the stack our own way. */
384 if (YYMAXDEPTH <= yystacksize)
387 if (YYMAXDEPTH < yystacksize)
388 yystacksize = YYMAXDEPTH;
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);
395 SvGROW(yyns_sv, yystacksize * sizeof(char *));
396 /* XXX This seems strange to cast char * to char ** */
397 yyns = (const char **) SvPVX(yyns_sv);
400 yynsp = yyns + yysize - 1;
405 yyssp = yyss + yysize - 1;
406 yyvsp = yyvs + yysize - 1;
409 YYDPRINTF ((Perl_debug_log, "Stack size increased to %lu\n",
410 (unsigned long int) yystacksize));
412 if (yyss + yystacksize - 1 <= yyssp)
423 /* Do appropriate processing given the current state. */
424 /* Read a lookahead token if we need one and don't already have one. */
427 /* First try to decide what to do without reference to lookahead token. */
429 yyn = yypact[yystate];
430 if (yyn == YYPACT_NINF)
433 /* Not known => get a lookahead token if don't already have one. */
435 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
436 if (yychar == YYEMPTY) {
437 YYDPRINTF ((Perl_debug_log, "Reading a token: "));
438 #ifndef PERL_IN_MADLY_C
440 yychar = PL_madskills ? madlex() : yylex();
447 if (yychar >= 0 && yychar < 255) {
448 yychar = NATIVE_TO_ASCII(yychar);
453 if (yychar <= YYEOF) {
454 yychar = yytoken = YYEOF;
455 YYDPRINTF ((Perl_debug_log, "Now at end of input.\n"));
458 yytoken = YYTRANSLATE (yychar);
459 YYDSYMPRINTF ("Next token is", yytoken, &yylval);
462 /* If the proper action on seeing token YYTOKEN is to reduce or to
463 detect an error, take that action. */
465 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
469 if (yyn == 0 || yyn == YYTABLE_NINF)
478 /* Shift the lookahead token. */
479 YYDPRINTF ((Perl_debug_log, "Shifting token %s, ", yytname[yytoken]));
481 /* Discard the token being shifted unless it is eof. */
487 *++yynsp = (const char *)(yytname[yytoken]);
491 /* Count tokens shifted since error; after three, turn off error
497 YYDPRINTF ((Perl_debug_log, "Entering state %d\n", yystate));
502 /*-----------------------------------------------------------.
503 | yydefault -- do the default action for the current state. |
504 `-----------------------------------------------------------*/
506 yyn = yydefact[yystate];
512 /*-----------------------------.
513 | yyreduce -- Do a reduction. |
514 `-----------------------------*/
516 /* yyn is the number of a rule to reduce with. */
519 /* If YYLEN is nonzero, implement the default value of the action:
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];
530 YY_REDUCE_PRINT (yyn);
533 /* contains all the rule actions; auto-generated from perly.y or madly.y */
535 #define dep() deprecate("\"do\" to call subroutines")
536 #ifdef PERL_IN_MADLY_C
537 # include "madly.act"
539 # include "perly.act"
553 *++yynsp = (const char *)(yytname [yyr1[yyn]]);
556 /* Now shift the result of the reduction. Determine what state
557 that goes to, based on the state we popped back to and the rule
558 number reduced by. */
562 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
563 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
564 yystate = yytable[yystate];
566 yystate = yydefgoto[yyn - YYNTOKENS];
568 YYDPRINTF ((Perl_debug_log, "Entering state %d\n", yystate));
571 /* tmp push yystate for stack print; this is normally pushed later in
575 YY_STACK_PRINT (yyss, yyssp, yyvs, yyns);
582 /*------------------------------------.
583 | yyerrlab -- here on detecting error |
584 `------------------------------------*/
586 /* If not already recovering from an error, report this error. */
590 yyn = yypact[yystate];
592 if (YYPACT_NINF < yyn && yyn < YYLAST) {
594 const int yytype = YYTRANSLATE (yychar);
599 /* Start YYX at -YYN if negative to avoid negative indexes in
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]);
607 Newx(yymsg, yysize, char *);
609 const char *yyp = yystpcpy (yymsg, "syntax error, unexpected ");
610 yyp = yystpcpy (yyp, yytname[yytype]);
614 for (yyx = yyn < 0 ? -yyn : 0;
615 yyx < (int) (sizeof (yytname) / sizeof (char *));
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]);
628 YYSTACK_FREE (yymsg);
631 yyerror ("syntax error; also virtual memory exhausted");
634 #endif /* YYERROR_VERBOSE */
635 yyerror ("syntax error");
639 if (yyerrstatus == 3) {
640 /* If just tried and failed to reuse lookahead token after an
641 error, discard it. */
643 /* Return failure if at end of input. */
644 if (yychar == YYEOF) {
645 /* Pop the error token. */
647 /* Pop the rest of the stack. */
648 while (yyss < yyssp) {
649 YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp);
650 if (yy_is_opval[yystos[*yyssp]]) {
651 YYDPRINTF ((Perl_debug_log, "(freeing op)\n"));
652 op_free(yyvsp->opval);
659 YYDSYMPRINTF ("Error: discarding", yytoken, &yylval);
664 /* Else will try to reuse lookahead token after shifting the error
669 /*----------------------------------------------------.
670 | yyerrlab1 -- error raised explicitly by an action. |
671 `----------------------------------------------------*/
673 yyerrstatus = 3; /* Each real token shifted decrements this. */
676 yyn = yypact[yystate];
677 if (yyn != YYPACT_NINF) {
679 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) {
686 /* Pop the current state because it cannot handle the error token. */
690 YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp);
691 if (yy_is_opval[yystos[*yyssp]]) {
692 YYDPRINTF ((Perl_debug_log, "(freeing op)\n"));
693 op_free(yyvsp->opval);
701 YY_STACK_PRINT (yyss, yyssp, yyvs, yyns);
707 YYDPRINTF ((Perl_debug_log, "Shifting error token, "));
715 YYDPRINTF ((Perl_debug_log, "Entering state %d\n", yystate));
720 /*-------------------------------------.
721 | yyacceptlab -- YYACCEPT comes here. |
722 `-------------------------------------*/
727 /*-----------------------------------.
728 | yyabortlab -- YYABORT comes here. |
729 `-----------------------------------*/
734 /*----------------------------------------------.
735 | yyoverflowlab -- parser overflow comes here. |
736 `----------------------------------------------*/
738 yyerror ("parser stack overflow");
744 LEAVE; /* force stack free before we return */
751 * c-indentation-style: bsd
753 * indent-tabs-mode: t
756 * ex: set ts=8 sts=4 sw=4 noet: