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
304 YYDPRINTF ((Perl_debug_log, "Starting parse\n"));
306 ENTER; /* force stack free before we return */
307 SAVEVPTR(PL_yycharp);
308 SAVEVPTR(PL_yylvalp);
309 PL_yycharp = &yychar; /* so PL_yyerror() can access it */
310 PL_yylvalp = &yylval; /* so various functions in toke.c can access it */
312 yyss_sv = newSV(YYINITDEPTH * sizeof(short));
313 yyvs_sv = newSV(YYINITDEPTH * sizeof(YYSTYPE));
316 yyss = (short *) SvPVX(yyss_sv);
317 yyvs = (YYSTYPE *) SvPVX(yyvs_sv);
318 /* note that elements zero of yyvs and yyns are not used */
322 yyns_sv = newSV(YYINITDEPTH * sizeof(char *));
324 /* XXX This seems strange to cast char * to char ** */
325 yyns = (const char **) SvPVX(yyns_sv);
332 yychar = YYEMPTY; /* Cause a token to be read. */
336 YYDPRINTF ((Perl_debug_log, "Entering state %d\n", yystate));
340 /*------------------------------------------------------------.
341 | yynewstate -- Push a new state, which is found in yystate. |
342 `------------------------------------------------------------*/
344 /* In all cases, when you get here, the value and location stacks
345 have just been pushed. so pushing a state here evens the stacks.
352 if (yyss + yystacksize - 1 <= yyssp) {
353 /* Get the current used size of the three stacks, in elements. */
354 const YYSIZE_T yysize = yyssp - yyss + 1;
356 /* Extend the stack our own way. */
357 if (YYMAXDEPTH <= yystacksize)
360 if (YYMAXDEPTH < yystacksize)
361 yystacksize = YYMAXDEPTH;
363 SvGROW(yyss_sv, yystacksize * sizeof(short));
364 SvGROW(yyvs_sv, yystacksize * sizeof(YYSTYPE));
365 yyss = (short *) SvPVX(yyss_sv);
366 yyvs = (YYSTYPE *) SvPVX(yyvs_sv);
368 SvGROW(yyns_sv, yystacksize * sizeof(char *));
369 /* XXX This seems strange to cast char * to char ** */
370 yyns = (const char **) SvPVX(yyns_sv);
373 yynsp = yyns + yysize - 1;
378 yyssp = yyss + yysize - 1;
379 yyvsp = yyvs + yysize - 1;
382 YYDPRINTF ((Perl_debug_log, "Stack size increased to %lu\n",
383 (unsigned long int) yystacksize));
385 if (yyss + yystacksize - 1 <= yyssp)
396 /* Do appropriate processing given the current state. */
397 /* Read a lookahead token if we need one and don't already have one. */
400 /* First try to decide what to do without reference to lookahead token. */
402 yyn = yypact[yystate];
403 if (yyn == YYPACT_NINF)
406 /* Not known => get a lookahead token if don't already have one. */
408 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
409 if (yychar == YYEMPTY) {
410 YYDPRINTF ((Perl_debug_log, "Reading a token: "));
412 yychar = PL_madskills ? madlex() : yylex();
417 if (yychar >= 0 && yychar < 255) {
418 yychar = NATIVE_TO_ASCII(yychar);
423 if (yychar <= YYEOF) {
424 yychar = yytoken = YYEOF;
425 YYDPRINTF ((Perl_debug_log, "Now at end of input.\n"));
428 yytoken = YYTRANSLATE (yychar);
429 YYDSYMPRINTF ("Next token is", yytoken, &yylval);
432 /* If the proper action on seeing token YYTOKEN is to reduce or to
433 detect an error, take that action. */
435 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
439 if (yyn == 0 || yyn == YYTABLE_NINF)
448 /* Shift the lookahead token. */
449 YYDPRINTF ((Perl_debug_log, "Shifting token %s, ", yytname[yytoken]));
451 /* Discard the token being shifted unless it is eof. */
457 *++yynsp = (const char *)(yytname[yytoken]);
461 /* Count tokens shifted since error; after three, turn off error
467 YYDPRINTF ((Perl_debug_log, "Entering state %d\n", yystate));
472 /*-----------------------------------------------------------.
473 | yydefault -- do the default action for the current state. |
474 `-----------------------------------------------------------*/
476 yyn = yydefact[yystate];
482 /*-----------------------------.
483 | yyreduce -- Do a reduction. |
484 `-----------------------------*/
486 /* yyn is the number of a rule to reduce with. */
489 /* If YYLEN is nonzero, implement the default value of the action:
492 Otherwise, the following line sets YYVAL to garbage.
493 This behavior is undocumented and Bison
494 users should not rely upon it. Assigning to YYVAL
495 unconditionally makes the parser a bit smaller, and it avoids a
496 GCC warning that YYVAL may be used uninitialized. */
497 yyval = yyvsp[1-yylen];
500 YY_REDUCE_PRINT (yyn);
503 /* contains all the rule actions; auto-generated from perly.y */
505 #define dep() deprecate("\"do\" to call subroutines")
519 *++yynsp = (const char *)(yytname [yyr1[yyn]]);
522 /* Now shift the result of the reduction. Determine what state
523 that goes to, based on the state we popped back to and the rule
524 number reduced by. */
528 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
529 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
530 yystate = yytable[yystate];
532 yystate = yydefgoto[yyn - YYNTOKENS];
534 YYDPRINTF ((Perl_debug_log, "Entering state %d\n", yystate));
537 /* tmp push yystate for stack print; this is normally pushed later in
541 YY_STACK_PRINT (yyss, yyssp, yyvs, yyns);
548 /*------------------------------------.
549 | yyerrlab -- here on detecting error |
550 `------------------------------------*/
552 /* If not already recovering from an error, report this error. */
556 yyn = yypact[yystate];
558 if (YYPACT_NINF < yyn && yyn < YYLAST) {
560 const int yytype = YYTRANSLATE (yychar);
565 /* Start YYX at -YYN if negative to avoid negative indexes in
567 for (yyx = yyn < 0 ? -yyn : 0;
568 yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++)
569 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
570 yysize += yystrlen (yytname[yyx]) + 15, yycount++;
571 yysize += yystrlen ("syntax error, unexpected ") + 1;
572 yysize += yystrlen (yytname[yytype]);
573 Newx(yymsg, yysize, char *);
575 const char *yyp = yystpcpy (yymsg, "syntax error, unexpected ");
576 yyp = yystpcpy (yyp, yytname[yytype]);
580 for (yyx = yyn < 0 ? -yyn : 0;
581 yyx < (int) (sizeof (yytname) / sizeof (char *));
584 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) {
585 const char *yyq = ! yycount ?
586 ", expecting " : " or ";
587 yyp = yystpcpy (yyp, yyq);
588 yyp = yystpcpy (yyp, yytname[yyx]);
594 YYSTACK_FREE (yymsg);
597 yyerror ("syntax error; also virtual memory exhausted");
600 #endif /* YYERROR_VERBOSE */
601 yyerror ("syntax error");
605 if (yyerrstatus == 3) {
606 /* If just tried and failed to reuse lookahead token after an
607 error, discard it. */
609 /* Return failure if at end of input. */
610 if (yychar == YYEOF) {
611 /* Pop the error token. */
613 /* Pop the rest of the stack. */
614 while (yyss < yyssp) {
615 YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp);
621 YYDSYMPRINTF ("Error: discarding", yytoken, &yylval);
626 /* Else will try to reuse lookahead token after shifting the error
631 /*----------------------------------------------------.
632 | yyerrlab1 -- error raised explicitly by an action. |
633 `----------------------------------------------------*/
635 yyerrstatus = 3; /* Each real token shifted decrements this. */
638 yyn = yypact[yystate];
639 if (yyn != YYPACT_NINF) {
641 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) {
648 /* Pop the current state because it cannot handle the error token. */
652 YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp);
659 YY_STACK_PRINT (yyss, yyssp, yyvs, yyns);
665 YYDPRINTF ((Perl_debug_log, "Shifting error token, "));
673 YYDPRINTF ((Perl_debug_log, "Entering state %d\n", yystate));
678 /*-------------------------------------.
679 | yyacceptlab -- YYACCEPT comes here. |
680 `-------------------------------------*/
685 /*-----------------------------------.
686 | yyabortlab -- YYABORT comes here. |
687 `-----------------------------------*/
692 /*----------------------------------------------.
693 | yyoverflowlab -- parser overflow comes here. |
694 `----------------------------------------------*/
696 yyerror ("parser stack overflow");
702 LEAVE; /* force stack free before we return */
709 * c-indentation-style: bsd
711 * indent-tabs-mode: t
714 * ex: set ts=8 sts=4 sw=4 noet: