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, Location) \
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);
128 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
134 YYFPRINTF (yyoutput, ")");
138 /*------------------------------------------------------------------.
139 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
141 `------------------------------------------------------------------*/
144 yy_stack_print (pTHX_ short *bottom, short *top)
146 YYFPRINTF (Perl_debug_log, "Stack now");
147 for (/* Nothing. */; bottom <= top; ++bottom)
148 YYFPRINTF (Perl_debug_log, " %d", *bottom);
149 YYFPRINTF (Perl_debug_log, "\n");
152 # define YY_STACK_PRINT(Bottom, Top) \
155 yy_stack_print (aTHX_ (Bottom), (Top)); \
159 /*------------------------------------------------.
160 | Report that the YYRULE is going to be reduced. |
161 `------------------------------------------------*/
164 yy_reduce_print (pTHX_ int yyrule)
167 unsigned int yylineno = yyrline[yyrule];
168 YYFPRINTF (Perl_debug_log, "Reducing stack by rule %d (line %u), ",
169 yyrule - 1, yylineno);
170 /* Print the symbols being reduced, and their result. */
171 for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
172 YYFPRINTF (Perl_debug_log, "%s ", yytname [yyrhs[yyi]]);
173 YYFPRINTF (Perl_debug_log, "-> %s\n", yytname [yyr1[yyrule]]);
176 # define YY_REDUCE_PRINT(Rule) \
179 yy_reduce_print (aTHX_ Rule); \
182 #else /* !DEBUGGING */
183 # define YYDPRINTF(Args)
184 # define YYDSYMPRINT(Args)
185 # define YYDSYMPRINTF(Title, Token, Value, Location)
186 # define YY_STACK_PRINT(Bottom, Top)
187 # define YY_REDUCE_PRINT(Rule)
188 #endif /* !DEBUGGING */
191 /* YYINITDEPTH -- initial size of the parser's stacks. */
193 # define YYINITDEPTH 200
199 # if defined (__GLIBC__) && defined (_STRING_H)
200 # define yystrlen strlen
202 /* Return the length of YYSTR. */
204 yystrlen (const char *yystr)
206 register const char *yys = yystr;
208 while (*yys++ != '\0')
211 return yys - yystr - 1;
217 # if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
218 # define yystpcpy stpcpy
220 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
223 yystpcpy (pTHX_ char *yydest, const char *yysrc)
225 register char *yyd = yydest;
226 register const char *yys = yysrc;
228 while ((*yyd++ = *yys++) != '\0')
236 #endif /* !YYERROR_VERBOSE */
239 /*-----------------------------------------------.
240 | Release the memory associated to this symbol. |
241 `-----------------------------------------------*/
244 yydestruct (int yytype, YYSTYPE *yyvaluep)
246 /* Pacify ``unused variable'' warnings. */
265 int yychar; /* The lookahead symbol. */
266 YYSTYPE yylval; /* The semantic value of the lookahead symbol. */
267 int yynerrs; /* Number of syntax errors so far. */
268 register int yystate;
272 /* Number of tokens to shift before error messages enabled. */
274 /* Lookahead token as an internal (translated) token number. */
277 /* two stacks and their tools:
278 `yyss': related to states,
279 `yyvs': related to semantic values,
281 Refer to the stacks thru separate pointers, to allow yyoverflow
282 to reallocate them elsewhere. */
284 /* The state stack. */
286 register short *yyssp;
288 /* The semantic value stack. */
290 register YYSTYPE *yyvsp;
292 /* for ease of re-allocation and automatic freeing, have two SVs whose
293 * SvPVX points to the stacks */
294 SV *yyss_sv, *yyvs_sv;
296 #define YYPOPSTACK (yyvsp--, yyssp--)
298 YYSIZE_T yystacksize = YYINITDEPTH;
300 /* The variables used to return semantic value and location from the
305 /* When reducing, the number of symbols on the RHS of the reduced
309 YYDPRINTF ((Perl_debug_log, "Starting parse\n"));
311 yyss_sv = NEWSV(73, YYINITDEPTH * sizeof(short));
312 yyvs_sv = NEWSV(73, YYINITDEPTH * sizeof(YYSTYPE));
314 /* XXX is this needed anymore? DAPM 13-Feb-04;
315 * if not, delete the correspinding LEAVE too */
316 ENTER; /* force stack free before we return */
320 yyss = (short *) SvPVX(yyss_sv);
321 yyvs = (YYSTYPE *) SvPVX(yyvs_sv);
326 yychar = YYEMPTY; /* Cause a token to be read. */
328 /* Initialize stack pointers.
329 Waste one element of value and location stack
330 so that they stay on the same level as the state stack.
331 The wasted elements are never initialized. */
338 /*------------------------------------------------------------.
339 | yynewstate -- Push a new state, which is found in yystate. |
340 `------------------------------------------------------------*/
342 /* In all cases, when you get here, the value and location stacks
343 have just been pushed. so pushing a state here evens the stacks.
350 if (yyss + yystacksize - 1 <= yyssp) {
351 /* Get the current used size of the three stacks, in elements. */
352 YYSIZE_T yysize = yyssp - yyss + 1;
354 /* Extend the stack our own way. */
355 if (YYMAXDEPTH <= yystacksize)
358 if (YYMAXDEPTH < yystacksize)
359 yystacksize = YYMAXDEPTH;
361 SvGROW(yyss_sv, yystacksize * sizeof(short));
362 SvGROW(yyvs_sv, yystacksize * sizeof(YYSTYPE));
363 yyss = (short *) SvPVX(yyss_sv);
364 yyvs = (YYSTYPE *) SvPVX(yyvs_sv);
368 yyssp = yyss + yysize - 1;
369 yyvsp = yyvs + yysize - 1;
372 YYDPRINTF ((Perl_debug_log, "Stack size increased to %lu\n",
373 (unsigned long int) yystacksize));
375 if (yyss + yystacksize - 1 <= yyssp)
379 YYDPRINTF ((Perl_debug_log, "Entering state %d\n", yystate));
388 /* Do appropriate processing given the current state. */
389 /* Read a lookahead token if we need one and don't already have one. */
392 /* First try to decide what to do without reference to lookahead token. */
394 yyn = yypact[yystate];
395 if (yyn == YYPACT_NINF)
398 /* Not known => get a lookahead token if don't already have one. */
400 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
401 if (yychar == YYEMPTY) {
402 YYDPRINTF ((Perl_debug_log, "Reading a token: "));
406 if (yychar <= YYEOF) {
407 yychar = yytoken = YYEOF;
408 YYDPRINTF ((Perl_debug_log, "Now at end of input.\n"));
411 yytoken = YYTRANSLATE (yychar);
412 YYDSYMPRINTF ("Next token is", yytoken, &yylval, &yylloc);
415 /* If the proper action on seeing token YYTOKEN is to reduce or to
416 detect an error, take that action. */
418 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
422 if (yyn == 0 || yyn == YYTABLE_NINF)
431 /* Shift the lookahead token. */
432 YYDPRINTF ((Perl_debug_log, "Shifting token %s, ", yytname[yytoken]));
434 /* Discard the token being shifted unless it is eof. */
441 /* Count tokens shifted since error; after three, turn off error
450 /*-----------------------------------------------------------.
451 | yydefault -- do the default action for the current state. |
452 `-----------------------------------------------------------*/
454 yyn = yydefact[yystate];
460 /*-----------------------------.
461 | yyreduce -- Do a reduction. |
462 `-----------------------------*/
464 /* yyn is the number of a rule to reduce with. */
467 /* If YYLEN is nonzero, implement the default value of the action:
470 Otherwise, the following line sets YYVAL to garbage.
471 This behavior is undocumented and Bison
472 users should not rely upon it. Assigning to YYVAL
473 unconditionally makes the parser a bit smaller, and it avoids a
474 GCC warning that YYVAL may be used uninitialized. */
475 yyval = yyvsp[1-yylen];
478 YY_REDUCE_PRINT (yyn);
481 /* contains all the rule actions; auto-generated from perly.y */
483 #define dep() deprecate("\"do\" to call subroutines")
491 YY_STACK_PRINT (yyss, yyssp);
496 /* Now `shift' the result of the reduction. Determine what state
497 that goes to, based on the state we popped back to and the rule
498 number reduced by. */
502 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
503 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
504 yystate = yytable[yystate];
506 yystate = yydefgoto[yyn - YYNTOKENS];
511 /*------------------------------------.
512 | yyerrlab -- here on detecting error |
513 `------------------------------------*/
515 /* If not already recovering from an error, report this error. */
519 yyn = yypact[yystate];
521 if (YYPACT_NINF < yyn && yyn < YYLAST) {
523 int yytype = YYTRANSLATE (yychar);
528 /* Start YYX at -YYN if negative to avoid negative indexes in
530 for (yyx = yyn < 0 ? -yyn : 0;
531 yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++)
532 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
533 yysize += yystrlen (yytname[yyx]) + 15, yycount++;
534 yysize += yystrlen ("syntax error, unexpected ") + 1;
535 yysize += yystrlen (yytname[yytype]);
536 New(yymsg, yysize, char *);
538 char *yyp = yystpcpy (yymsg, "syntax error, unexpected ");
539 yyp = yystpcpy (yyp, yytname[yytype]);
543 for (yyx = yyn < 0 ? -yyn : 0;
544 yyx < (int) (sizeof (yytname) / sizeof (char *));
547 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) {
548 const char *yyq = ! yycount ?
549 ", expecting " : " or ";
550 yyp = yystpcpy (yyp, yyq);
551 yyp = yystpcpy (yyp, yytname[yyx]);
557 YYSTACK_FREE (yymsg);
560 yyerror ("syntax error; also virtual memory exhausted");
563 #endif /* YYERROR_VERBOSE */
564 yyerror ("syntax error");
568 if (yyerrstatus == 3) {
569 /* If just tried and failed to reuse lookahead token after an
570 error, discard it. */
572 /* Return failure if at end of input. */
573 if (yychar == YYEOF) {
574 /* Pop the error token. */
576 /* Pop the rest of the stack. */
577 while (yyss < yyssp) {
578 YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
579 yydestruct (yystos[*yyssp], yyvsp);
585 YYDSYMPRINTF ("Error: discarding", yytoken, &yylval, &yylloc);
586 yydestruct (yytoken, &yylval);
591 /* Else will try to reuse lookahead token after shifting the error
596 /*----------------------------------------------------.
597 | yyerrlab1 -- error raised explicitly by an action. |
598 `----------------------------------------------------*/
600 yyerrstatus = 3; /* Each real token shifted decrements this. */
603 yyn = yypact[yystate];
604 if (yyn != YYPACT_NINF) {
606 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) {
613 /* Pop the current state because it cannot handle the error token. */
617 YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
618 yydestruct (yystos[yystate], yyvsp);
622 YY_STACK_PRINT (yyss, yyssp);
628 YYDPRINTF ((Perl_debug_log, "Shifting error token, "));
636 /*-------------------------------------.
637 | yyacceptlab -- YYACCEPT comes here. |
638 `-------------------------------------*/
643 /*-----------------------------------.
644 | yyabortlab -- YYABORT comes here. |
645 `-----------------------------------*/
650 /*----------------------------------------------.
651 | yyoverflowlab -- parser overflow comes here. |
652 `----------------------------------------------*/
654 yyerror ("parser stack overflow");
661 LEAVE; /* force stack free before we return */