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 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 /* Enable debugging if requested. */
82 # define yydebug (DEBUG_p_TEST)
84 # define YYFPRINTF PerlIO_printf
86 # define YYDPRINTF(Args) \
92 # define YYDSYMPRINTF(Title, Token, Value) \
95 YYFPRINTF (Perl_debug_log, "%s ", Title); \
96 yysymprint (Perl_debug_log, Token, Value); \
97 YYFPRINTF (Perl_debug_log, "\n"); \
101 /*--------------------------------.
102 | Print this symbol on YYOUTPUT. |
103 `--------------------------------*/
106 yysymprint(PerlIO * const yyoutput, int yytype, const YYSTYPE * const yyvaluep)
108 if (yytype < YYNTOKENS) {
109 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
111 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
113 YYFPRINTF (yyoutput, "0x%"UVxf, (UV)yyvaluep->ival);
117 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
119 YYFPRINTF (yyoutput, ")");
124 * print the top 8 items on the parse stack. The args have the same
125 * meanings as the local vars in yyparse() of the same name */
128 yy_stack_print (pTHX_ const short *yyss, const short *yyssp, const YYSTYPE *yyvs, const char**yyns)
132 int count = (int)(yyssp - yyss);
135 start = count - 8 + 1;
139 PerlIO_printf(Perl_debug_log, "\nindex:");
140 for (i=0; i < count; i++)
141 PerlIO_printf(Perl_debug_log, " %8d", start+i);
142 PerlIO_printf(Perl_debug_log, "\nstate:");
143 for (i=0; i < count; i++)
144 PerlIO_printf(Perl_debug_log, " %8d", yyss[start+i]);
145 PerlIO_printf(Perl_debug_log, "\ntoken:");
146 for (i=0; i < count; i++)
147 PerlIO_printf(Perl_debug_log, " %8.8s", yyns[start+i]);
148 PerlIO_printf(Perl_debug_log, "\nvalue:");
149 for (i=0; i < count; i++) {
150 if (yy_is_opval[yystos[yyss[start+i]]]) {
151 PerlIO_printf(Perl_debug_log, " %8.8s",
153 ? PL_op_name[yyvs[start+i].opval->op_type]
158 PerlIO_printf(Perl_debug_log, " %8"UVxf, (UV)yyvs[start+i].ival);
160 PerlIO_printf(Perl_debug_log, "\n\n");
163 # define YY_STACK_PRINT(yyss, yyssp, yyvs, yyns) \
165 if (yydebug && DEBUG_v_TEST) \
166 yy_stack_print (aTHX_ (yyss), (yyssp), (yyvs), (yyns)); \
170 /*------------------------------------------------.
171 | Report that the YYRULE is going to be reduced. |
172 `------------------------------------------------*/
175 yy_reduce_print (pTHX_ int yyrule)
178 const unsigned int yylineno = yyrline[yyrule];
179 YYFPRINTF (Perl_debug_log, "Reducing stack by rule %d (line %u), ",
180 yyrule - 1, yylineno);
181 /* Print the symbols being reduced, and their result. */
182 for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
183 YYFPRINTF (Perl_debug_log, "%s ", yytname [yyrhs[yyi]]);
184 YYFPRINTF (Perl_debug_log, "-> %s\n", yytname [yyr1[yyrule]]);
187 # define YY_REDUCE_PRINT(Rule) \
190 yy_reduce_print (aTHX_ Rule); \
193 #else /* !DEBUGGING */
194 # define YYDPRINTF(Args)
195 # define YYDSYMPRINTF(Title, Token, Value)
196 # define YY_STACK_PRINT(yyss, yyssp, yyvs, yyns)
197 # define YY_REDUCE_PRINT(Rule)
198 #endif /* !DEBUGGING */
201 /* YYINITDEPTH -- initial size of the parser's stacks. */
203 # define YYINITDEPTH 200
209 # if defined (__GLIBC__) && defined (_STRING_H)
210 # define yystrlen strlen
212 /* Return the length of YYSTR. */
214 yystrlen (const char *yystr)
216 register const char *yys = yystr;
218 while (*yys++ != '\0')
221 return yys - yystr - 1;
227 # if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
228 # define yystpcpy stpcpy
230 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
233 yystpcpy (pTHX_ char *yydest, const char *yysrc)
235 register char *yyd = yydest;
236 register const char *yys = yysrc;
238 while ((*yyd++ = *yys++) != '\0')
246 #endif /* !YYERROR_VERBOSE */
256 int yychar; /* The lookahead symbol. */
257 YYSTYPE yylval; /* The semantic value of the lookahead symbol. */
258 int yynerrs; /* Number of syntax errors so far. */
259 register int yystate;
263 /* Number of tokens to shift before error messages enabled. */
265 /* Lookahead token as an internal (translated) token number. */
268 /* two stacks and their tools:
269 yyss: related to states,
270 yyvs: related to semantic values,
272 Refer to the stacks thru separate pointers, to allow yyoverflow
273 to reallocate them elsewhere. */
275 /* The state stack. */
277 register short *yyssp;
279 /* The semantic value stack. */
281 register YYSTYPE *yyvsp;
283 /* for ease of re-allocation and automatic freeing, have two SVs whose
284 * SvPVX points to the stacks */
285 SV *yyss_sv, *yyvs_sv;
288 /* maintain also a stack of token/rule names for debugging with -Dpv */
289 const char **yyns, **yynsp;
291 # define YYPOPSTACK (yyvsp--, yyssp--, yynsp--)
293 # define YYPOPSTACK (yyvsp--, yyssp--)
297 YYSIZE_T yystacksize = YYINITDEPTH;
299 /* The variables used to return semantic value and location from the
304 /* When reducing, the number of symbols on the RHS of the reduced
313 YYDPRINTF ((Perl_debug_log, "Starting parse\n"));
315 ENTER; /* force stack free before we return */
316 SAVEVPTR(PL_yycharp);
317 SAVEVPTR(PL_yylvalp);
318 PL_yycharp = &yychar; /* so PL_yyerror() can access it */
319 PL_yylvalp = &yylval; /* so various functions in toke.c can access it */
321 yyss_sv = newSV(YYINITDEPTH * sizeof(short));
322 yyvs_sv = newSV(YYINITDEPTH * sizeof(YYSTYPE));
325 yyss = (short *) SvPVX(yyss_sv);
326 yyvs = (YYSTYPE *) SvPVX(yyvs_sv);
327 /* note that elements zero of yyvs and yyns are not used */
331 yyns_sv = newSV(YYINITDEPTH * sizeof(char *));
333 /* XXX This seems strange to cast char * to char ** */
334 yyns = (const char **) SvPVX(yyns_sv);
341 yychar = YYEMPTY; /* Cause a token to be read. */
345 YYDPRINTF ((Perl_debug_log, "Entering state %d\n", yystate));
349 /*------------------------------------------------------------.
350 | yynewstate -- Push a new state, which is found in yystate. |
351 `------------------------------------------------------------*/
353 /* In all cases, when you get here, the value and location stacks
354 have just been pushed. so pushing a state here evens the stacks.
361 if (yyss + yystacksize - 1 <= yyssp) {
362 /* Get the current used size of the three stacks, in elements. */
363 const YYSIZE_T yysize = yyssp - yyss + 1;
365 /* Extend the stack our own way. */
366 if (YYMAXDEPTH <= yystacksize)
369 if (YYMAXDEPTH < yystacksize)
370 yystacksize = YYMAXDEPTH;
372 SvGROW(yyss_sv, yystacksize * sizeof(short));
373 SvGROW(yyvs_sv, yystacksize * sizeof(YYSTYPE));
374 yyss = (short *) SvPVX(yyss_sv);
375 yyvs = (YYSTYPE *) SvPVX(yyvs_sv);
377 SvGROW(yyns_sv, yystacksize * sizeof(char *));
378 /* XXX This seems strange to cast char * to char ** */
379 yyns = (const char **) SvPVX(yyns_sv);
382 yynsp = yyns + yysize - 1;
387 yyssp = yyss + yysize - 1;
388 yyvsp = yyvs + yysize - 1;
391 YYDPRINTF ((Perl_debug_log, "Stack size increased to %lu\n",
392 (unsigned long int) yystacksize));
394 if (yyss + yystacksize - 1 <= yyssp)
405 /* Do appropriate processing given the current state. */
406 /* Read a lookahead token if we need one and don't already have one. */
409 /* First try to decide what to do without reference to lookahead token. */
411 yyn = yypact[yystate];
412 if (yyn == YYPACT_NINF)
415 /* Not known => get a lookahead token if don't already have one. */
417 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
418 if (yychar == YYEMPTY) {
419 YYDPRINTF ((Perl_debug_log, "Reading a token: "));
421 yychar = PL_madskills ? madlex() : yylex();
426 if (yychar >= 0 && yychar < 255) {
427 yychar = NATIVE_TO_ASCII(yychar);
432 if (yychar <= YYEOF) {
433 yychar = yytoken = YYEOF;
434 YYDPRINTF ((Perl_debug_log, "Now at end of input.\n"));
437 yytoken = YYTRANSLATE (yychar);
438 YYDSYMPRINTF ("Next token is", yytoken, &yylval);
441 /* If the proper action on seeing token YYTOKEN is to reduce or to
442 detect an error, take that action. */
444 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
448 if (yyn == 0 || yyn == YYTABLE_NINF)
457 /* Shift the lookahead token. */
458 YYDPRINTF ((Perl_debug_log, "Shifting token %s, ", yytname[yytoken]));
460 /* Discard the token being shifted unless it is eof. */
466 *++yynsp = (const char *)(yytname[yytoken]);
470 /* Count tokens shifted since error; after three, turn off error
476 YYDPRINTF ((Perl_debug_log, "Entering state %d\n", yystate));
481 /*-----------------------------------------------------------.
482 | yydefault -- do the default action for the current state. |
483 `-----------------------------------------------------------*/
485 yyn = yydefact[yystate];
491 /*-----------------------------.
492 | yyreduce -- Do a reduction. |
493 `-----------------------------*/
495 /* yyn is the number of a rule to reduce with. */
498 /* If YYLEN is nonzero, implement the default value of the action:
501 Otherwise, the following line sets YYVAL to garbage.
502 This behavior is undocumented and Bison
503 users should not rely upon it. Assigning to YYVAL
504 unconditionally makes the parser a bit smaller, and it avoids a
505 GCC warning that YYVAL may be used uninitialized. */
506 yyval = yyvsp[1-yylen];
509 YY_REDUCE_PRINT (yyn);
512 /* contains all the rule actions; auto-generated from perly.y */
514 #define dep() deprecate("\"do\" to call subroutines")
528 *++yynsp = (const char *)(yytname [yyr1[yyn]]);
531 /* Now shift the result of the reduction. Determine what state
532 that goes to, based on the state we popped back to and the rule
533 number reduced by. */
537 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
538 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
539 yystate = yytable[yystate];
541 yystate = yydefgoto[yyn - YYNTOKENS];
543 YYDPRINTF ((Perl_debug_log, "Entering state %d\n", yystate));
546 /* tmp push yystate for stack print; this is normally pushed later in
550 YY_STACK_PRINT (yyss, yyssp, yyvs, yyns);
557 /*------------------------------------.
558 | yyerrlab -- here on detecting error |
559 `------------------------------------*/
561 /* If not already recovering from an error, report this error. */
565 yyn = yypact[yystate];
567 if (YYPACT_NINF < yyn && yyn < YYLAST) {
569 const int yytype = YYTRANSLATE (yychar);
574 /* Start YYX at -YYN if negative to avoid negative indexes in
576 for (yyx = yyn < 0 ? -yyn : 0;
577 yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++)
578 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
579 yysize += yystrlen (yytname[yyx]) + 15, yycount++;
580 yysize += yystrlen ("syntax error, unexpected ") + 1;
581 yysize += yystrlen (yytname[yytype]);
582 Newx(yymsg, yysize, char *);
584 const char *yyp = yystpcpy (yymsg, "syntax error, unexpected ");
585 yyp = yystpcpy (yyp, yytname[yytype]);
589 for (yyx = yyn < 0 ? -yyn : 0;
590 yyx < (int) (sizeof (yytname) / sizeof (char *));
593 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) {
594 const char *yyq = ! yycount ?
595 ", expecting " : " or ";
596 yyp = yystpcpy (yyp, yyq);
597 yyp = yystpcpy (yyp, yytname[yyx]);
603 YYSTACK_FREE (yymsg);
606 yyerror ("syntax error; also virtual memory exhausted");
609 #endif /* YYERROR_VERBOSE */
610 yyerror ("syntax error");
614 if (yyerrstatus == 3) {
615 /* If just tried and failed to reuse lookahead token after an
616 error, discard it. */
618 /* Return failure if at end of input. */
619 if (yychar == YYEOF) {
620 /* Pop the error token. */
622 /* Pop the rest of the stack. */
623 while (yyss < yyssp) {
624 YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp);
625 if (yy_is_opval[yystos[*yyssp]]) {
626 YYDPRINTF ((Perl_debug_log, "(freeing op)\n"));
627 op_free(yyvsp->opval);
634 YYDSYMPRINTF ("Error: discarding", yytoken, &yylval);
639 /* Else will try to reuse lookahead token after shifting the error
644 /*----------------------------------------------------.
645 | yyerrlab1 -- error raised explicitly by an action. |
646 `----------------------------------------------------*/
648 yyerrstatus = 3; /* Each real token shifted decrements this. */
651 yyn = yypact[yystate];
652 if (yyn != YYPACT_NINF) {
654 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) {
661 /* Pop the current state because it cannot handle the error token. */
665 YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp);
666 if (yy_is_opval[yystos[*yyssp]]) {
667 YYDPRINTF ((Perl_debug_log, "(freeing op)\n"));
668 op_free(yyvsp->opval);
676 YY_STACK_PRINT (yyss, yyssp, yyvs, yyns);
682 YYDPRINTF ((Perl_debug_log, "Shifting error token, "));
690 YYDPRINTF ((Perl_debug_log, "Entering state %d\n", yystate));
695 /*-------------------------------------.
696 | yyacceptlab -- YYACCEPT comes here. |
697 `-------------------------------------*/
702 /*-----------------------------------.
703 | yyabortlab -- YYABORT comes here. |
704 `-----------------------------------*/
709 /*----------------------------------------------.
710 | yyoverflowlab -- parser overflow comes here. |
711 `----------------------------------------------*/
713 yyerror ("parser stack overflow");
719 LEAVE; /* force stack free before we return */
726 * c-indentation-style: bsd
728 * indent-tabs-mode: t
731 * ex: set ts=8 sts=4 sw=4 noet: