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 /* Enable debugging if requested. */
82 # define yydebug (DEBUG_p_TEST)
84 # define YYFPRINTF PerlIO_printf
86 # define YYDPRINTF(Args) \
92 # define YYDSYMPRINT(Args) \
98 # define YYDSYMPRINTF(Title, Token, Value) \
101 YYFPRINTF (Perl_debug_log, "%s ", Title); \
102 yysymprint (aTHX_ Perl_debug_log, Token, Value); \
103 YYFPRINTF (Perl_debug_log, "\n"); \
107 /*--------------------------------.
108 | Print this symbol on YYOUTPUT. |
109 `--------------------------------*/
112 yysymprint (pTHX_ PerlIO *yyoutput, int yytype, const YYSTYPE *yyvaluep)
114 if (yytype < YYNTOKENS) {
115 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
117 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
119 YYFPRINTF (yyoutput, "0x%"UVxf, (UV)yyvaluep->ival);
123 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
125 YYFPRINTF (yyoutput, ")");
130 * print the top 8 items on the parse stack. The args have the same
131 * meanings as the local vars in yyparse() of the same name */
134 yy_stack_print (pTHX_ const short *yyss, const short *yyssp, const YYSTYPE *yyvs, const char**yyns)
138 int count = (int)(yyssp - yyss);
141 start = count - 8 + 1;
145 PerlIO_printf(Perl_debug_log, "\nindex:");
146 for (i=0; i < count; i++)
147 PerlIO_printf(Perl_debug_log, " %8d", start+i);
148 PerlIO_printf(Perl_debug_log, "\nstate:");
149 for (i=0, yyss += start; i < count; i++, yyss++)
150 PerlIO_printf(Perl_debug_log, " %8d", *yyss);
151 PerlIO_printf(Perl_debug_log, "\ntoken:");
152 for (i=0, yyns += start; i < count; i++, yyns++)
153 PerlIO_printf(Perl_debug_log, " %8.8s", *yyns);
154 PerlIO_printf(Perl_debug_log, "\nvalue:");
155 for (i=0, yyvs += start; i < count; i++, yyvs++)
156 PerlIO_printf(Perl_debug_log, " %8"UVxf, (UV)yyvs->ival);
157 PerlIO_printf(Perl_debug_log, "\n\n");
160 # define YY_STACK_PRINT(yyss, yyssp, yyvs, yyns) \
162 if (yydebug && DEBUG_v_TEST) \
163 yy_stack_print (aTHX_ (yyss), (yyssp), (yyvs), (yyns)); \
167 /*------------------------------------------------.
168 | Report that the YYRULE is going to be reduced. |
169 `------------------------------------------------*/
172 yy_reduce_print (pTHX_ int yyrule)
175 const unsigned int yylineno = yyrline[yyrule];
176 YYFPRINTF (Perl_debug_log, "Reducing stack by rule %d (line %u), ",
177 yyrule - 1, yylineno);
178 /* Print the symbols being reduced, and their result. */
179 for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
180 YYFPRINTF (Perl_debug_log, "%s ", yytname [yyrhs[yyi]]);
181 YYFPRINTF (Perl_debug_log, "-> %s\n", yytname [yyr1[yyrule]]);
184 # define YY_REDUCE_PRINT(Rule) \
187 yy_reduce_print (aTHX_ Rule); \
190 #else /* !DEBUGGING */
191 # define YYDPRINTF(Args)
192 # define YYDSYMPRINT(Args)
193 # define YYDSYMPRINTF(Title, Token, Value)
194 # define YY_STACK_PRINT(yyss, yyssp, yyvs, yyns)
195 # define YY_REDUCE_PRINT(Rule)
196 #endif /* !DEBUGGING */
199 /* YYINITDEPTH -- initial size of the parser's stacks. */
201 # define YYINITDEPTH 200
207 # if defined (__GLIBC__) && defined (_STRING_H)
208 # define yystrlen strlen
210 /* Return the length of YYSTR. */
212 yystrlen (const char *yystr)
214 register const char *yys = yystr;
216 while (*yys++ != '\0')
219 return yys - yystr - 1;
225 # if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
226 # define yystpcpy stpcpy
228 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
231 yystpcpy (pTHX_ char *yydest, const char *yysrc)
233 register char *yyd = yydest;
234 register const char *yys = yysrc;
236 while ((*yyd++ = *yys++) != '\0')
244 #endif /* !YYERROR_VERBOSE */
254 int yychar; /* The lookahead symbol. */
255 YYSTYPE yylval; /* The semantic value of the lookahead symbol. */
256 int yynerrs; /* Number of syntax errors so far. */
257 register int yystate;
261 /* Number of tokens to shift before error messages enabled. */
263 /* Lookahead token as an internal (translated) token number. */
266 /* two stacks and their tools:
267 yyss: related to states,
268 yyvs: related to semantic values,
270 Refer to the stacks thru separate pointers, to allow yyoverflow
271 to reallocate them elsewhere. */
273 /* The state stack. */
275 register short *yyssp;
277 /* The semantic value stack. */
279 register YYSTYPE *yyvsp;
281 /* for ease of re-allocation and automatic freeing, have two SVs whose
282 * SvPVX points to the stacks */
283 SV *yyss_sv, *yyvs_sv;
286 /* maintain also a stack of token/rule names for debugging with -Dpv */
287 const char **yyns, **yynsp;
289 # define YYPOPSTACK (yyvsp--, yyssp--, yynsp--)
291 # define YYPOPSTACK (yyvsp--, yyssp--)
295 YYSIZE_T yystacksize = YYINITDEPTH;
297 /* The variables used to return semantic value and location from the
302 /* When reducing, the number of symbols on the RHS of the reduced
306 YYDPRINTF ((Perl_debug_log, "Starting parse\n"));
308 ENTER; /* force stack free before we return */
309 SAVEVPTR(PL_yycharp);
310 SAVEVPTR(PL_yylvalp);
311 PL_yycharp = &yychar; /* so PL_yyerror() can access it */
312 PL_yylvalp = &yylval; /* so various functions in toke.c can access it */
314 yyss_sv = NEWSV(73, YYINITDEPTH * sizeof(short));
315 yyvs_sv = NEWSV(73, YYINITDEPTH * sizeof(YYSTYPE));
318 yyss = (short *) SvPVX(yyss_sv);
319 yyvs = (YYSTYPE *) SvPVX(yyvs_sv);
320 /* note that elements zero of yyvs and yyns are not used */
324 yyns_sv = NEWSV(73, YYINITDEPTH * sizeof(char *));
326 /* XXX This seems strange to cast char * to char ** */
327 yyns = (const char **) SvPVX(yyns_sv);
334 yychar = YYEMPTY; /* Cause a token to be read. */
338 YYDPRINTF ((Perl_debug_log, "Entering state %d\n", yystate));
342 /*------------------------------------------------------------.
343 | yynewstate -- Push a new state, which is found in yystate. |
344 `------------------------------------------------------------*/
346 /* In all cases, when you get here, the value and location stacks
347 have just been pushed. so pushing a state here evens the stacks.
354 if (yyss + yystacksize - 1 <= yyssp) {
355 /* Get the current used size of the three stacks, in elements. */
356 const YYSIZE_T yysize = yyssp - yyss + 1;
358 /* Extend the stack our own way. */
359 if (YYMAXDEPTH <= yystacksize)
362 if (YYMAXDEPTH < yystacksize)
363 yystacksize = YYMAXDEPTH;
365 SvGROW(yyss_sv, yystacksize * sizeof(short));
366 SvGROW(yyvs_sv, yystacksize * sizeof(YYSTYPE));
367 yyss = (short *) SvPVX(yyss_sv);
368 yyvs = (YYSTYPE *) SvPVX(yyvs_sv);
370 SvGROW(yyns_sv, yystacksize * sizeof(char *));
371 /* XXX This seems strange to cast char * to char ** */
372 yyns = (const char **) SvPVX(yyns_sv);
375 yynsp = yyns + yysize - 1;
380 yyssp = yyss + yysize - 1;
381 yyvsp = yyvs + yysize - 1;
384 YYDPRINTF ((Perl_debug_log, "Stack size increased to %lu\n",
385 (unsigned long int) yystacksize));
387 if (yyss + yystacksize - 1 <= yyssp)
398 /* Do appropriate processing given the current state. */
399 /* Read a lookahead token if we need one and don't already have one. */
402 /* First try to decide what to do without reference to lookahead token. */
404 yyn = yypact[yystate];
405 if (yyn == YYPACT_NINF)
408 /* Not known => get a lookahead token if don't already have one. */
410 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
411 if (yychar == YYEMPTY) {
412 YYDPRINTF ((Perl_debug_log, "Reading a token: "));
415 if (yychar >= 0 && yychar < 255) {
416 yychar = NATIVE_TO_ASCII(yychar);
421 if (yychar <= YYEOF) {
422 yychar = yytoken = YYEOF;
423 YYDPRINTF ((Perl_debug_log, "Now at end of input.\n"));
426 yytoken = YYTRANSLATE (yychar);
427 YYDSYMPRINTF ("Next token is", yytoken, &yylval);
430 /* If the proper action on seeing token YYTOKEN is to reduce or to
431 detect an error, take that action. */
433 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
437 if (yyn == 0 || yyn == YYTABLE_NINF)
446 /* Shift the lookahead token. */
447 YYDPRINTF ((Perl_debug_log, "Shifting token %s, ", yytname[yytoken]));
449 /* Discard the token being shifted unless it is eof. */
455 *++yynsp = (const char *)(yytname[yytoken]);
459 /* Count tokens shifted since error; after three, turn off error
465 YYDPRINTF ((Perl_debug_log, "Entering state %d\n", yystate));
470 /*-----------------------------------------------------------.
471 | yydefault -- do the default action for the current state. |
472 `-----------------------------------------------------------*/
474 yyn = yydefact[yystate];
480 /*-----------------------------.
481 | yyreduce -- Do a reduction. |
482 `-----------------------------*/
484 /* yyn is the number of a rule to reduce with. */
487 /* If YYLEN is nonzero, implement the default value of the action:
490 Otherwise, the following line sets YYVAL to garbage.
491 This behavior is undocumented and Bison
492 users should not rely upon it. Assigning to YYVAL
493 unconditionally makes the parser a bit smaller, and it avoids a
494 GCC warning that YYVAL may be used uninitialized. */
495 yyval = yyvsp[1-yylen];
498 YY_REDUCE_PRINT (yyn);
501 /* contains all the rule actions; auto-generated from perly.y */
503 #define dep() deprecate("\"do\" to call subroutines")
517 *++yynsp = (const char *)(yytname [yyr1[yyn]]);
520 /* Now shift the result of the reduction. Determine what state
521 that goes to, based on the state we popped back to and the rule
522 number reduced by. */
526 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
527 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
528 yystate = yytable[yystate];
530 yystate = yydefgoto[yyn - YYNTOKENS];
532 YYDPRINTF ((Perl_debug_log, "Entering state %d\n", yystate));
535 /* tmp push yystate for stack print; this is normally pushed later in
539 YY_STACK_PRINT (yyss, yyssp, yyvs, yyns);
546 /*------------------------------------.
547 | yyerrlab -- here on detecting error |
548 `------------------------------------*/
550 /* If not already recovering from an error, report this error. */
554 yyn = yypact[yystate];
556 if (YYPACT_NINF < yyn && yyn < YYLAST) {
558 const int yytype = YYTRANSLATE (yychar);
563 /* Start YYX at -YYN if negative to avoid negative indexes in
565 for (yyx = yyn < 0 ? -yyn : 0;
566 yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++)
567 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
568 yysize += yystrlen (yytname[yyx]) + 15, yycount++;
569 yysize += yystrlen ("syntax error, unexpected ") + 1;
570 yysize += yystrlen (yytname[yytype]);
571 Newx(yymsg, yysize, char *);
573 const char *yyp = yystpcpy (yymsg, "syntax error, unexpected ");
574 yyp = yystpcpy (yyp, yytname[yytype]);
578 for (yyx = yyn < 0 ? -yyn : 0;
579 yyx < (int) (sizeof (yytname) / sizeof (char *));
582 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) {
583 const char *yyq = ! yycount ?
584 ", expecting " : " or ";
585 yyp = yystpcpy (yyp, yyq);
586 yyp = yystpcpy (yyp, yytname[yyx]);
592 YYSTACK_FREE (yymsg);
595 yyerror ("syntax error; also virtual memory exhausted");
598 #endif /* YYERROR_VERBOSE */
599 yyerror ("syntax error");
603 if (yyerrstatus == 3) {
604 /* If just tried and failed to reuse lookahead token after an
605 error, discard it. */
607 /* Return failure if at end of input. */
608 if (yychar == YYEOF) {
609 /* Pop the error token. */
611 /* Pop the rest of the stack. */
612 while (yyss < yyssp) {
613 YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp);
619 YYDSYMPRINTF ("Error: discarding", yytoken, &yylval);
624 /* Else will try to reuse lookahead token after shifting the error
629 /*----------------------------------------------------.
630 | yyerrlab1 -- error raised explicitly by an action. |
631 `----------------------------------------------------*/
633 yyerrstatus = 3; /* Each real token shifted decrements this. */
636 yyn = yypact[yystate];
637 if (yyn != YYPACT_NINF) {
639 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) {
646 /* Pop the current state because it cannot handle the error token. */
650 YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp);
657 YY_STACK_PRINT (yyss, yyssp, yyvs, yyns);
663 YYDPRINTF ((Perl_debug_log, "Shifting error token, "));
671 YYDPRINTF ((Perl_debug_log, "Entering state %d\n", yystate));
676 /*-------------------------------------.
677 | yyacceptlab -- YYACCEPT comes here. |
678 `-------------------------------------*/
683 /*-----------------------------------.
684 | yyabortlab -- YYABORT comes here. |
685 `-----------------------------------*/
690 /*----------------------------------------------.
691 | yyoverflowlab -- parser overflow comes here. |
692 `----------------------------------------------*/
694 yyerror ("parser stack overflow");
700 LEAVE; /* force stack free before we return */
707 * c-indentation-style: bsd
709 * indent-tabs-mode: t
712 * ex: set ts=8 sts=4 sw=4 noet: