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, yyss += start; i < count; i++, yyss++)
144 PerlIO_printf(Perl_debug_log, " %8d", *yyss);
145 PerlIO_printf(Perl_debug_log, "\ntoken:");
146 for (i=0, yyns += start; i < count; i++, yyns++)
147 PerlIO_printf(Perl_debug_log, " %8.8s", *yyns);
148 PerlIO_printf(Perl_debug_log, "\nvalue:");
149 for (i=0, yyvs += start; i < count; i++, yyvs++)
150 PerlIO_printf(Perl_debug_log, " %8"UVxf, (UV)yyvs->ival);
151 PerlIO_printf(Perl_debug_log, "\n\n");
154 # define YY_STACK_PRINT(yyss, yyssp, yyvs, yyns) \
156 if (yydebug && DEBUG_v_TEST) \
157 yy_stack_print (aTHX_ (yyss), (yyssp), (yyvs), (yyns)); \
161 /*------------------------------------------------.
162 | Report that the YYRULE is going to be reduced. |
163 `------------------------------------------------*/
166 yy_reduce_print (pTHX_ int yyrule)
169 const unsigned int yylineno = yyrline[yyrule];
170 YYFPRINTF (Perl_debug_log, "Reducing stack by rule %d (line %u), ",
171 yyrule - 1, yylineno);
172 /* Print the symbols being reduced, and their result. */
173 for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
174 YYFPRINTF (Perl_debug_log, "%s ", yytname [yyrhs[yyi]]);
175 YYFPRINTF (Perl_debug_log, "-> %s\n", yytname [yyr1[yyrule]]);
178 # define YY_REDUCE_PRINT(Rule) \
181 yy_reduce_print (aTHX_ Rule); \
184 #else /* !DEBUGGING */
185 # define YYDPRINTF(Args)
186 # define YYDSYMPRINTF(Title, Token, Value)
187 # define YY_STACK_PRINT(yyss, yyssp, yyvs, yyns)
188 # define YY_REDUCE_PRINT(Rule)
189 #endif /* !DEBUGGING */
192 /* YYINITDEPTH -- initial size of the parser's stacks. */
194 # define YYINITDEPTH 200
200 # if defined (__GLIBC__) && defined (_STRING_H)
201 # define yystrlen strlen
203 /* Return the length of YYSTR. */
205 yystrlen (const char *yystr)
207 register const char *yys = yystr;
209 while (*yys++ != '\0')
212 return yys - yystr - 1;
218 # if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
219 # define yystpcpy stpcpy
221 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
224 yystpcpy (pTHX_ char *yydest, const char *yysrc)
226 register char *yyd = yydest;
227 register const char *yys = yysrc;
229 while ((*yyd++ = *yys++) != '\0')
237 #endif /* !YYERROR_VERBOSE */
247 int yychar; /* The lookahead symbol. */
248 YYSTYPE yylval; /* The semantic value of the lookahead symbol. */
249 int yynerrs; /* Number of syntax errors so far. */
250 register int yystate;
254 /* Number of tokens to shift before error messages enabled. */
256 /* Lookahead token as an internal (translated) token number. */
259 /* two stacks and their tools:
260 yyss: related to states,
261 yyvs: related to semantic values,
263 Refer to the stacks thru separate pointers, to allow yyoverflow
264 to reallocate them elsewhere. */
266 /* The state stack. */
268 register short *yyssp;
270 /* The semantic value stack. */
272 register YYSTYPE *yyvsp;
274 /* for ease of re-allocation and automatic freeing, have two SVs whose
275 * SvPVX points to the stacks */
276 SV *yyss_sv, *yyvs_sv;
279 /* maintain also a stack of token/rule names for debugging with -Dpv */
280 const char **yyns, **yynsp;
282 # define YYPOPSTACK (yyvsp--, yyssp--, yynsp--)
284 # define YYPOPSTACK (yyvsp--, yyssp--)
288 YYSIZE_T yystacksize = YYINITDEPTH;
290 /* The variables used to return semantic value and location from the
295 /* When reducing, the number of symbols on the RHS of the reduced
299 YYDPRINTF ((Perl_debug_log, "Starting parse\n"));
301 ENTER; /* force stack free before we return */
302 SAVEVPTR(PL_yycharp);
303 SAVEVPTR(PL_yylvalp);
304 PL_yycharp = &yychar; /* so PL_yyerror() can access it */
305 PL_yylvalp = &yylval; /* so various functions in toke.c can access it */
307 yyss_sv = newSV(YYINITDEPTH * sizeof(short));
308 yyvs_sv = newSV(YYINITDEPTH * sizeof(YYSTYPE));
311 yyss = (short *) SvPVX(yyss_sv);
312 yyvs = (YYSTYPE *) SvPVX(yyvs_sv);
313 /* note that elements zero of yyvs and yyns are not used */
317 yyns_sv = newSV(YYINITDEPTH * sizeof(char *));
319 /* XXX This seems strange to cast char * to char ** */
320 yyns = (const char **) SvPVX(yyns_sv);
327 yychar = YYEMPTY; /* Cause a token to be read. */
331 YYDPRINTF ((Perl_debug_log, "Entering state %d\n", yystate));
335 /*------------------------------------------------------------.
336 | yynewstate -- Push a new state, which is found in yystate. |
337 `------------------------------------------------------------*/
339 /* In all cases, when you get here, the value and location stacks
340 have just been pushed. so pushing a state here evens the stacks.
347 if (yyss + yystacksize - 1 <= yyssp) {
348 /* Get the current used size of the three stacks, in elements. */
349 const YYSIZE_T yysize = yyssp - yyss + 1;
351 /* Extend the stack our own way. */
352 if (YYMAXDEPTH <= yystacksize)
355 if (YYMAXDEPTH < yystacksize)
356 yystacksize = YYMAXDEPTH;
358 SvGROW(yyss_sv, yystacksize * sizeof(short));
359 SvGROW(yyvs_sv, yystacksize * sizeof(YYSTYPE));
360 yyss = (short *) SvPVX(yyss_sv);
361 yyvs = (YYSTYPE *) SvPVX(yyvs_sv);
363 SvGROW(yyns_sv, yystacksize * sizeof(char *));
364 /* XXX This seems strange to cast char * to char ** */
365 yyns = (const char **) SvPVX(yyns_sv);
368 yynsp = yyns + yysize - 1;
373 yyssp = yyss + yysize - 1;
374 yyvsp = yyvs + yysize - 1;
377 YYDPRINTF ((Perl_debug_log, "Stack size increased to %lu\n",
378 (unsigned long int) yystacksize));
380 if (yyss + yystacksize - 1 <= yyssp)
391 /* Do appropriate processing given the current state. */
392 /* Read a lookahead token if we need one and don't already have one. */
395 /* First try to decide what to do without reference to lookahead token. */
397 yyn = yypact[yystate];
398 if (yyn == YYPACT_NINF)
401 /* Not known => get a lookahead token if don't already have one. */
403 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
404 if (yychar == YYEMPTY) {
405 YYDPRINTF ((Perl_debug_log, "Reading a token: "));
408 if (yychar >= 0 && yychar < 255) {
409 yychar = NATIVE_TO_ASCII(yychar);
414 if (yychar <= YYEOF) {
415 yychar = yytoken = YYEOF;
416 YYDPRINTF ((Perl_debug_log, "Now at end of input.\n"));
419 yytoken = YYTRANSLATE (yychar);
420 YYDSYMPRINTF ("Next token is", yytoken, &yylval);
423 /* If the proper action on seeing token YYTOKEN is to reduce or to
424 detect an error, take that action. */
426 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
430 if (yyn == 0 || yyn == YYTABLE_NINF)
439 /* Shift the lookahead token. */
440 YYDPRINTF ((Perl_debug_log, "Shifting token %s, ", yytname[yytoken]));
442 /* Discard the token being shifted unless it is eof. */
448 *++yynsp = (const char *)(yytname[yytoken]);
452 /* Count tokens shifted since error; after three, turn off error
458 YYDPRINTF ((Perl_debug_log, "Entering state %d\n", yystate));
463 /*-----------------------------------------------------------.
464 | yydefault -- do the default action for the current state. |
465 `-----------------------------------------------------------*/
467 yyn = yydefact[yystate];
473 /*-----------------------------.
474 | yyreduce -- Do a reduction. |
475 `-----------------------------*/
477 /* yyn is the number of a rule to reduce with. */
480 /* If YYLEN is nonzero, implement the default value of the action:
483 Otherwise, the following line sets YYVAL to garbage.
484 This behavior is undocumented and Bison
485 users should not rely upon it. Assigning to YYVAL
486 unconditionally makes the parser a bit smaller, and it avoids a
487 GCC warning that YYVAL may be used uninitialized. */
488 yyval = yyvsp[1-yylen];
491 YY_REDUCE_PRINT (yyn);
494 /* contains all the rule actions; auto-generated from perly.y */
496 #define dep() deprecate("\"do\" to call subroutines")
510 *++yynsp = (const char *)(yytname [yyr1[yyn]]);
513 /* Now shift the result of the reduction. Determine what state
514 that goes to, based on the state we popped back to and the rule
515 number reduced by. */
519 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
520 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
521 yystate = yytable[yystate];
523 yystate = yydefgoto[yyn - YYNTOKENS];
525 YYDPRINTF ((Perl_debug_log, "Entering state %d\n", yystate));
528 /* tmp push yystate for stack print; this is normally pushed later in
532 YY_STACK_PRINT (yyss, yyssp, yyvs, yyns);
539 /*------------------------------------.
540 | yyerrlab -- here on detecting error |
541 `------------------------------------*/
543 /* If not already recovering from an error, report this error. */
547 yyn = yypact[yystate];
549 if (YYPACT_NINF < yyn && yyn < YYLAST) {
551 const int yytype = YYTRANSLATE (yychar);
556 /* Start YYX at -YYN if negative to avoid negative indexes in
558 for (yyx = yyn < 0 ? -yyn : 0;
559 yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++)
560 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
561 yysize += yystrlen (yytname[yyx]) + 15, yycount++;
562 yysize += yystrlen ("syntax error, unexpected ") + 1;
563 yysize += yystrlen (yytname[yytype]);
564 Newx(yymsg, yysize, char *);
566 const char *yyp = yystpcpy (yymsg, "syntax error, unexpected ");
567 yyp = yystpcpy (yyp, yytname[yytype]);
571 for (yyx = yyn < 0 ? -yyn : 0;
572 yyx < (int) (sizeof (yytname) / sizeof (char *));
575 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) {
576 const char *yyq = ! yycount ?
577 ", expecting " : " or ";
578 yyp = yystpcpy (yyp, yyq);
579 yyp = yystpcpy (yyp, yytname[yyx]);
585 YYSTACK_FREE (yymsg);
588 yyerror ("syntax error; also virtual memory exhausted");
591 #endif /* YYERROR_VERBOSE */
592 yyerror ("syntax error");
596 if (yyerrstatus == 3) {
597 /* If just tried and failed to reuse lookahead token after an
598 error, discard it. */
600 /* Return failure if at end of input. */
601 if (yychar == YYEOF) {
602 /* Pop the error token. */
604 /* Pop the rest of the stack. */
605 while (yyss < yyssp) {
606 YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp);
612 YYDSYMPRINTF ("Error: discarding", yytoken, &yylval);
617 /* Else will try to reuse lookahead token after shifting the error
622 /*----------------------------------------------------.
623 | yyerrlab1 -- error raised explicitly by an action. |
624 `----------------------------------------------------*/
626 yyerrstatus = 3; /* Each real token shifted decrements this. */
629 yyn = yypact[yystate];
630 if (yyn != YYPACT_NINF) {
632 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) {
639 /* Pop the current state because it cannot handle the error token. */
643 YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp);
650 YY_STACK_PRINT (yyss, yyssp, yyvs, yyns);
656 YYDPRINTF ((Perl_debug_log, "Shifting error token, "));
664 YYDPRINTF ((Perl_debug_log, "Entering state %d\n", yystate));
669 /*-------------------------------------.
670 | yyacceptlab -- YYACCEPT comes here. |
671 `-------------------------------------*/
676 /*-----------------------------------.
677 | yyabortlab -- YYABORT comes here. |
678 `-----------------------------------*/
683 /*----------------------------------------------.
684 | yyoverflowlab -- parser overflow comes here. |
685 `----------------------------------------------*/
687 yyerror ("parser stack overflow");
693 LEAVE; /* force stack free before we return */
700 * c-indentation-style: bsd
702 * indent-tabs-mode: t
705 * ex: set ts=8 sts=4 sw=4 noet: