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, YYSTYPE *yyvaluep)
114 /* Pacify ``unused variable'' warnings. */
117 if (yytype < YYNTOKENS) {
118 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
120 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
122 YYFPRINTF (yyoutput, "0x%x", yyvaluep->ival);
126 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
132 YYFPRINTF (yyoutput, ")");
137 * print the top 8 items on the parse stack. The args have the same
138 * meanings as the local vars in yyparse() of the same name */
141 yy_stack_print (pTHX_ short *yyss, short *yyssp, YYSTYPE *yyvs, char**yyns)
145 int count = (int)(yyssp - yyss);
148 start = count - 8 + 1;
152 PerlIO_printf(Perl_debug_log, "\nindex:");
153 for (i=0; i < count; i++)
154 PerlIO_printf(Perl_debug_log, " %8d", start+i);
155 PerlIO_printf(Perl_debug_log, "\nstate:");
156 for (i=0, yyss += start; i < count; i++, yyss++)
157 PerlIO_printf(Perl_debug_log, " %8d", *yyss);
158 PerlIO_printf(Perl_debug_log, "\ntoken:");
159 for (i=0, yyns += start; i < count; i++, yyns++)
160 PerlIO_printf(Perl_debug_log, " %8.8s", *yyns);
161 PerlIO_printf(Perl_debug_log, "\nvalue:");
162 for (i=0, yyvs += start; i < count; i++, yyvs++)
163 PerlIO_printf(Perl_debug_log, " %8x", yyvs->ival);
164 PerlIO_printf(Perl_debug_log, "\n\n");
167 # define YY_STACK_PRINT(yyss, yyssp, yyvs, yyns) \
169 if (yydebug && DEBUG_v_TEST) \
170 yy_stack_print (aTHX_ (yyss), (yyssp), (yyvs), (yyns)); \
174 /*------------------------------------------------.
175 | Report that the YYRULE is going to be reduced. |
176 `------------------------------------------------*/
179 yy_reduce_print (pTHX_ int yyrule)
182 unsigned int yylineno = yyrline[yyrule];
183 YYFPRINTF (Perl_debug_log, "Reducing stack by rule %d (line %u), ",
184 yyrule - 1, yylineno);
185 /* Print the symbols being reduced, and their result. */
186 for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
187 YYFPRINTF (Perl_debug_log, "%s ", yytname [yyrhs[yyi]]);
188 YYFPRINTF (Perl_debug_log, "-> %s\n", yytname [yyr1[yyrule]]);
191 # define YY_REDUCE_PRINT(Rule) \
194 yy_reduce_print (aTHX_ Rule); \
197 #else /* !DEBUGGING */
198 # define YYDPRINTF(Args)
199 # define YYDSYMPRINT(Args)
200 # define YYDSYMPRINTF(Title, Token, Value)
201 # define YY_STACK_PRINT(yyss, yyssp, yyvs, yyns)
202 # define YY_REDUCE_PRINT(Rule)
203 #endif /* !DEBUGGING */
206 /* YYINITDEPTH -- initial size of the parser's stacks. */
208 # define YYINITDEPTH 200
214 # if defined (__GLIBC__) && defined (_STRING_H)
215 # define yystrlen strlen
217 /* Return the length of YYSTR. */
219 yystrlen (const char *yystr)
221 register const char *yys = yystr;
223 while (*yys++ != '\0')
226 return yys - yystr - 1;
232 # if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
233 # define yystpcpy stpcpy
235 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
238 yystpcpy (pTHX_ char *yydest, const char *yysrc)
240 register char *yyd = yydest;
241 register const char *yys = yysrc;
243 while ((*yyd++ = *yys++) != '\0')
251 #endif /* !YYERROR_VERBOSE */
254 /*-----------------------------------------------.
255 | Release the memory associated to this symbol. |
256 `-----------------------------------------------*/
259 yydestruct (int yytype, YYSTYPE *yyvaluep)
261 /* Pacify ``unused variable'' warnings. */
280 int yychar; /* The lookahead symbol. */
281 YYSTYPE yylval; /* The semantic value of the lookahead symbol. */
282 int yynerrs; /* Number of syntax errors so far. */
283 register int yystate;
287 /* Number of tokens to shift before error messages enabled. */
289 /* Lookahead token as an internal (translated) token number. */
292 /* two stacks and their tools:
293 `yyss': related to states,
294 `yyvs': related to semantic values,
296 Refer to the stacks thru separate pointers, to allow yyoverflow
297 to reallocate them elsewhere. */
299 /* The state stack. */
301 register short *yyssp;
303 /* The semantic value stack. */
305 register YYSTYPE *yyvsp;
307 /* for ease of re-allocation and automatic freeing, have two SVs whose
308 * SvPVX points to the stacks */
309 SV *yyss_sv, *yyvs_sv;
312 /* maintain also a stack of token/rule names for debugging with -Dpv */
313 char **yyns, **yynsp;
315 # define YYPOPSTACK (yyvsp--, yyssp--, yynsp--)
317 # define YYPOPSTACK (yyvsp--, yyssp--)
321 YYSIZE_T yystacksize = YYINITDEPTH;
323 /* The variables used to return semantic value and location from the
328 /* When reducing, the number of symbols on the RHS of the reduced
332 YYDPRINTF ((Perl_debug_log, "Starting parse\n"));
334 ENTER; /* force stack free before we return */
335 SAVEVPTR(PL_yycharp);
336 SAVEVPTR(PL_yylvalp);
337 PL_yycharp = &yychar; /* so PL_yyerror() can access it */
338 PL_yylvalp = &yylval; /* so various functions in toke.c can access it */
340 yyss_sv = NEWSV(73, YYINITDEPTH * sizeof(short));
341 yyvs_sv = NEWSV(73, YYINITDEPTH * sizeof(YYSTYPE));
344 yyss = (short *) SvPVX(yyss_sv);
345 yyvs = (YYSTYPE *) SvPVX(yyvs_sv);
346 /* note that elements zero of yyvs and yyns are not used */
350 yyns_sv = NEWSV(73, YYINITDEPTH * sizeof(char *));
352 yyns = (char **) SvPVX(yyns_sv);
359 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 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 yyns = (char **) SvPVX(yyns_sv);
399 yynsp = yyns + yysize - 1;
404 yyssp = yyss + yysize - 1;
405 yyvsp = yyvs + yysize - 1;
408 YYDPRINTF ((Perl_debug_log, "Stack size increased to %lu\n",
409 (unsigned long int) yystacksize));
411 if (yyss + yystacksize - 1 <= yyssp)
422 /* Do appropriate processing given the current state. */
423 /* Read a lookahead token if we need one and don't already have one. */
426 /* First try to decide what to do without reference to lookahead token. */
428 yyn = yypact[yystate];
429 if (yyn == YYPACT_NINF)
432 /* Not known => get a lookahead token if don't already have one. */
434 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
435 if (yychar == YYEMPTY) {
436 YYDPRINTF ((Perl_debug_log, "Reading a token: "));
439 if (yychar >= 0 && yychar < 255) {
440 yychar = NATIVE_TO_ASCII(yychar);
445 if (yychar <= YYEOF) {
446 yychar = yytoken = YYEOF;
447 YYDPRINTF ((Perl_debug_log, "Now at end of input.\n"));
450 yytoken = YYTRANSLATE (yychar);
451 YYDSYMPRINTF ("Next token is", yytoken, &yylval);
454 /* If the proper action on seeing token YYTOKEN is to reduce or to
455 detect an error, take that action. */
457 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
461 if (yyn == 0 || yyn == YYTABLE_NINF)
470 /* Shift the lookahead token. */
471 YYDPRINTF ((Perl_debug_log, "Shifting token %s, ", yytname[yytoken]));
473 /* Discard the token being shifted unless it is eof. */
479 *++yynsp = (char *)(yytname[yytoken]);
483 /* Count tokens shifted since error; after three, turn off error
489 YYDPRINTF ((Perl_debug_log, "Entering state %d\n", yystate));
494 /*-----------------------------------------------------------.
495 | yydefault -- do the default action for the current state. |
496 `-----------------------------------------------------------*/
498 yyn = yydefact[yystate];
504 /*-----------------------------.
505 | yyreduce -- Do a reduction. |
506 `-----------------------------*/
508 /* yyn is the number of a rule to reduce with. */
511 /* If YYLEN is nonzero, implement the default value of the action:
514 Otherwise, the following line sets YYVAL to garbage.
515 This behavior is undocumented and Bison
516 users should not rely upon it. Assigning to YYVAL
517 unconditionally makes the parser a bit smaller, and it avoids a
518 GCC warning that YYVAL may be used uninitialized. */
519 yyval = yyvsp[1-yylen];
522 YY_REDUCE_PRINT (yyn);
525 /* contains all the rule actions; auto-generated from perly.y */
527 #define dep() deprecate("\"do\" to call subroutines")
541 *++yynsp = (char *)(yytname [yyr1[yyn]]);
544 /* Now `shift' the result of the reduction. Determine what state
545 that goes to, based on the state we popped back to and the rule
546 number reduced by. */
550 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
551 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
552 yystate = yytable[yystate];
554 yystate = yydefgoto[yyn - YYNTOKENS];
556 YYDPRINTF ((Perl_debug_log, "Entering state %d\n", yystate));
559 /* tmp push yystate for stack print; this is normally pushed later in
563 YY_STACK_PRINT (yyss, yyssp, yyvs, yyns);
570 /*------------------------------------.
571 | yyerrlab -- here on detecting error |
572 `------------------------------------*/
574 /* If not already recovering from an error, report this error. */
578 yyn = yypact[yystate];
580 if (YYPACT_NINF < yyn && yyn < YYLAST) {
582 int yytype = YYTRANSLATE (yychar);
587 /* Start YYX at -YYN if negative to avoid negative indexes in
589 for (yyx = yyn < 0 ? -yyn : 0;
590 yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++)
591 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
592 yysize += yystrlen (yytname[yyx]) + 15, yycount++;
593 yysize += yystrlen ("syntax error, unexpected ") + 1;
594 yysize += yystrlen (yytname[yytype]);
595 New(yymsg, yysize, char *);
597 char *yyp = yystpcpy (yymsg, "syntax error, unexpected ");
598 yyp = yystpcpy (yyp, yytname[yytype]);
602 for (yyx = yyn < 0 ? -yyn : 0;
603 yyx < (int) (sizeof (yytname) / sizeof (char *));
606 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) {
607 const char *yyq = ! yycount ?
608 ", expecting " : " or ";
609 yyp = yystpcpy (yyp, yyq);
610 yyp = yystpcpy (yyp, yytname[yyx]);
616 YYSTACK_FREE (yymsg);
619 yyerror ("syntax error; also virtual memory exhausted");
622 #endif /* YYERROR_VERBOSE */
623 yyerror ("syntax error");
627 if (yyerrstatus == 3) {
628 /* If just tried and failed to reuse lookahead token after an
629 error, discard it. */
631 /* Return failure if at end of input. */
632 if (yychar == YYEOF) {
633 /* Pop the error token. */
635 /* Pop the rest of the stack. */
636 while (yyss < yyssp) {
637 YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp);
638 yydestruct (yystos[*yyssp], yyvsp);
644 YYDSYMPRINTF ("Error: discarding", yytoken, &yylval);
645 yydestruct (yytoken, &yylval);
650 /* Else will try to reuse lookahead token after shifting the error
655 /*----------------------------------------------------.
656 | yyerrlab1 -- error raised explicitly by an action. |
657 `----------------------------------------------------*/
659 yyerrstatus = 3; /* Each real token shifted decrements this. */
662 yyn = yypact[yystate];
663 if (yyn != YYPACT_NINF) {
665 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) {
672 /* Pop the current state because it cannot handle the error token. */
676 YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp);
677 yydestruct (yystos[yystate], yyvsp);
684 YY_STACK_PRINT (yyss, yyssp, yyvs, yyns);
690 YYDPRINTF ((Perl_debug_log, "Shifting error token, "));
698 YYDPRINTF ((Perl_debug_log, "Entering state %d\n", yystate));
703 /*-------------------------------------.
704 | yyacceptlab -- YYACCEPT comes here. |
705 `-------------------------------------*/
710 /*-----------------------------------.
711 | yyabortlab -- YYABORT comes here. |
712 `-----------------------------------*/
717 /*----------------------------------------------.
718 | yyoverflowlab -- parser overflow comes here. |
719 `----------------------------------------------*/
721 yyerror ("parser stack overflow");
727 LEAVE; /* force stack free before we return */