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. */
343 YYDPRINTF ((Perl_debug_log, "Entering state %d\n", yystate));
347 /*------------------------------------------------------------.
348 | yynewstate -- Push a new state, which is found in yystate. |
349 `------------------------------------------------------------*/
351 /* In all cases, when you get here, the value and location stacks
352 have just been pushed. so pushing a state here evens the stacks.
359 if (yyss + yystacksize - 1 <= yyssp) {
360 /* Get the current used size of the three stacks, in elements. */
361 const YYSIZE_T yysize = yyssp - yyss + 1;
363 /* Extend the stack our own way. */
364 if (YYMAXDEPTH <= yystacksize)
367 if (YYMAXDEPTH < yystacksize)
368 yystacksize = YYMAXDEPTH;
370 SvGROW(yyss_sv, yystacksize * sizeof(short));
371 SvGROW(yyvs_sv, yystacksize * sizeof(YYSTYPE));
372 yyss = (short *) SvPVX(yyss_sv);
373 yyvs = (YYSTYPE *) SvPVX(yyvs_sv);
375 SvGROW(yyns_sv, yystacksize * sizeof(char *));
376 /* XXX This seems strange to cast char * to char ** */
377 yyns = (const char **) SvPVX(yyns_sv);
380 yynsp = yyns + yysize - 1;
385 yyssp = yyss + yysize - 1;
386 yyvsp = yyvs + yysize - 1;
389 YYDPRINTF ((Perl_debug_log, "Stack size increased to %lu\n",
390 (unsigned long int) yystacksize));
392 if (yyss + yystacksize - 1 <= yyssp)
403 /* Do appropriate processing given the current state. */
404 /* Read a lookahead token if we need one and don't already have one. */
407 /* First try to decide what to do without reference to lookahead token. */
409 yyn = yypact[yystate];
410 if (yyn == YYPACT_NINF)
413 /* Not known => get a lookahead token if don't already have one. */
415 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
416 if (yychar == YYEMPTY) {
417 YYDPRINTF ((Perl_debug_log, "Reading a token: "));
419 yychar = PL_madskills ? madlex() : yylex();
424 if (yychar >= 0 && yychar < 255) {
425 yychar = NATIVE_TO_ASCII(yychar);
430 if (yychar <= YYEOF) {
431 yychar = yytoken = YYEOF;
432 YYDPRINTF ((Perl_debug_log, "Now at end of input.\n"));
435 yytoken = YYTRANSLATE (yychar);
436 YYDSYMPRINTF ("Next token is", yytoken, &yylval);
439 /* If the proper action on seeing token YYTOKEN is to reduce or to
440 detect an error, take that action. */
442 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
446 if (yyn == 0 || yyn == YYTABLE_NINF)
455 /* Shift the lookahead token. */
456 YYDPRINTF ((Perl_debug_log, "Shifting token %s, ", yytname[yytoken]));
458 /* Discard the token being shifted unless it is eof. */
464 *++yynsp = (const char *)(yytname[yytoken]);
468 /* Count tokens shifted since error; after three, turn off error
474 YYDPRINTF ((Perl_debug_log, "Entering state %d\n", yystate));
479 /*-----------------------------------------------------------.
480 | yydefault -- do the default action for the current state. |
481 `-----------------------------------------------------------*/
483 yyn = yydefact[yystate];
489 /*-----------------------------.
490 | yyreduce -- Do a reduction. |
491 `-----------------------------*/
493 /* yyn is the number of a rule to reduce with. */
496 /* If YYLEN is nonzero, implement the default value of the action:
499 Otherwise, the following line sets YYVAL to garbage.
500 This behavior is undocumented and Bison
501 users should not rely upon it. Assigning to YYVAL
502 unconditionally makes the parser a bit smaller, and it avoids a
503 GCC warning that YYVAL may be used uninitialized. */
504 yyval = yyvsp[1-yylen];
507 YY_REDUCE_PRINT (yyn);
510 /* contains all the rule actions; auto-generated from perly.y */
512 #define dep() deprecate("\"do\" to call subroutines")
526 *++yynsp = (const char *)(yytname [yyr1[yyn]]);
529 /* Now shift the result of the reduction. Determine what state
530 that goes to, based on the state we popped back to and the rule
531 number reduced by. */
535 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
536 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
537 yystate = yytable[yystate];
539 yystate = yydefgoto[yyn - YYNTOKENS];
541 YYDPRINTF ((Perl_debug_log, "Entering state %d\n", yystate));
544 /* tmp push yystate for stack print; this is normally pushed later in
548 YY_STACK_PRINT (yyss, yyssp, yyvs, yyns);
555 /*------------------------------------.
556 | yyerrlab -- here on detecting error |
557 `------------------------------------*/
559 /* If not already recovering from an error, report this error. */
563 yyn = yypact[yystate];
565 if (YYPACT_NINF < yyn && yyn < YYLAST) {
567 const int yytype = YYTRANSLATE (yychar);
572 /* Start YYX at -YYN if negative to avoid negative indexes in
574 for (yyx = yyn < 0 ? -yyn : 0;
575 yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++)
576 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
577 yysize += yystrlen (yytname[yyx]) + 15, yycount++;
578 yysize += yystrlen ("syntax error, unexpected ") + 1;
579 yysize += yystrlen (yytname[yytype]);
580 Newx(yymsg, yysize, char *);
582 const char *yyp = yystpcpy (yymsg, "syntax error, unexpected ");
583 yyp = yystpcpy (yyp, yytname[yytype]);
587 for (yyx = yyn < 0 ? -yyn : 0;
588 yyx < (int) (sizeof (yytname) / sizeof (char *));
591 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) {
592 const char *yyq = ! yycount ?
593 ", expecting " : " or ";
594 yyp = yystpcpy (yyp, yyq);
595 yyp = yystpcpy (yyp, yytname[yyx]);
601 YYSTACK_FREE (yymsg);
604 yyerror ("syntax error; also virtual memory exhausted");
607 #endif /* YYERROR_VERBOSE */
608 yyerror ("syntax error");
612 if (yyerrstatus == 3) {
613 /* If just tried and failed to reuse lookahead token after an
614 error, discard it. */
616 /* Return failure if at end of input. */
617 if (yychar == YYEOF) {
618 /* Pop the error token. */
620 /* Pop the rest of the stack. */
621 while (yyss < yyssp) {
622 YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp);
623 if (yy_is_opval[yystos[*yyssp]]) {
624 YYDPRINTF ((Perl_debug_log, "(freeing op)\n"));
625 op_free(yyvsp->opval);
632 YYDSYMPRINTF ("Error: discarding", yytoken, &yylval);
637 /* Else will try to reuse lookahead token after shifting the error
642 /*----------------------------------------------------.
643 | yyerrlab1 -- error raised explicitly by an action. |
644 `----------------------------------------------------*/
646 yyerrstatus = 3; /* Each real token shifted decrements this. */
649 yyn = yypact[yystate];
650 if (yyn != YYPACT_NINF) {
652 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) {
659 /* Pop the current state because it cannot handle the error token. */
663 YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp);
664 if (yy_is_opval[yystos[*yyssp]]) {
665 YYDPRINTF ((Perl_debug_log, "(freeing op)\n"));
666 op_free(yyvsp->opval);
674 YY_STACK_PRINT (yyss, yyssp, yyvs, yyns);
680 YYDPRINTF ((Perl_debug_log, "Shifting error token, "));
688 YYDPRINTF ((Perl_debug_log, "Entering state %d\n", yystate));
693 /*-------------------------------------.
694 | yyacceptlab -- YYACCEPT comes here. |
695 `-------------------------------------*/
700 /*-----------------------------------.
701 | yyabortlab -- YYABORT comes here. |
702 `-----------------------------------*/
707 /*----------------------------------------------.
708 | yyoverflowlab -- parser overflow comes here. |
709 `----------------------------------------------*/
711 yyerror ("parser stack overflow");
717 LEAVE; /* force stack free before we return */
724 * c-indentation-style: bsd
726 * indent-tabs-mode: t
729 * ex: set ts=8 sts=4 sw=4 noet: