Commit | Line | Data |
---|---|---|
0de566d7 DM |
1 | /* perly.c |
2 | * | |
54ca4ee7 | 3 | * Copyright (c) 2004, 2005, 2006 Larry Wall and others |
0de566d7 DM |
4 | * |
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. | |
7 | * | |
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. | |
12 | * | |
13 | * Here is an important copyright statement from the original, generated | |
14 | * file: | |
15 | * | |
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. | |
20 | */ | |
21 | ||
22 | ||
23 | /* allow stack size to grow effectively without limit */ | |
24 | #define YYMAXDEPTH 10000000 | |
25 | ||
79072805 | 26 | #include "EXTERN.h" |
864dbfa3 | 27 | #define PERL_IN_PERLY_C |
79072805 | 28 | #include "perl.h" |
09bef843 | 29 | |
0de566d7 DM |
30 | typedef signed char yysigned_char; |
31 | ||
32 | #ifdef DEBUGGING | |
33 | # define YYDEBUG 1 | |
93a17b20 | 34 | #else |
0de566d7 | 35 | # define YYDEBUG 0 |
93a17b20 | 36 | #endif |
09bef843 | 37 | |
0de566d7 DM |
38 | /* contains all the parser state tables; auto-generated from perly.y */ |
39 | #include "perly.tab" | |
40 | ||
41 | # define YYSIZE_T size_t | |
42 | ||
43 | #define yyerrok (yyerrstatus = 0) | |
44 | #define yyclearin (yychar = YYEMPTY) | |
45 | #define YYEMPTY (-2) | |
46 | #define YYEOF 0 | |
47 | ||
48 | #define YYACCEPT goto yyacceptlab | |
49 | #define YYABORT goto yyabortlab | |
50 | #define YYERROR goto yyerrlab1 | |
51 | ||
52 | ||
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. */ | |
56 | ||
57 | #define YYFAIL goto yyerrlab | |
58 | ||
59 | #define YYRECOVERING() (!!yyerrstatus) | |
60 | ||
61 | #define YYBACKUP(Token, Value) \ | |
62 | do \ | |
63 | if (yychar == YYEMPTY && yylen == 1) { \ | |
64 | yychar = (Token); \ | |
65 | yylval = (Value); \ | |
66 | yytoken = YYTRANSLATE (yychar); \ | |
67 | YYPOPSTACK; \ | |
68 | goto yybackup; \ | |
69 | } \ | |
70 | else { \ | |
71 | yyerror ("syntax error: cannot back up"); \ | |
72 | YYERROR; \ | |
73 | } \ | |
74 | while (0) | |
75 | ||
76 | #define YYTERROR 1 | |
77 | #define YYERRCODE 256 | |
78 | ||
0de566d7 | 79 | /* Enable debugging if requested. */ |
9388183f | 80 | #ifdef DEBUGGING |
0de566d7 DM |
81 | |
82 | # define yydebug (DEBUG_p_TEST) | |
83 | ||
84 | # define YYFPRINTF PerlIO_printf | |
85 | ||
86 | # define YYDPRINTF(Args) \ | |
87 | do { \ | |
88 | if (yydebug) \ | |
89 | YYFPRINTF Args; \ | |
90 | } while (0) | |
91 | ||
9388183f | 92 | # define YYDSYMPRINTF(Title, Token, Value) \ |
0de566d7 DM |
93 | do { \ |
94 | if (yydebug) { \ | |
95 | YYFPRINTF (Perl_debug_log, "%s ", Title); \ | |
ac9a0352 | 96 | yysymprint (Perl_debug_log, Token, Value); \ |
0de566d7 DM |
97 | YYFPRINTF (Perl_debug_log, "\n"); \ |
98 | } \ | |
99 | } while (0) | |
100 | ||
101 | /*--------------------------------. | |
102 | | Print this symbol on YYOUTPUT. | | |
103 | `--------------------------------*/ | |
104 | ||
105 | static void | |
ac9a0352 | 106 | yysymprint(PerlIO * const yyoutput, int yytype, const YYSTYPE * const yyvaluep) |
0de566d7 | 107 | { |
0de566d7 DM |
108 | if (yytype < YYNTOKENS) { |
109 | YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); | |
110 | # ifdef YYPRINT | |
111 | YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); | |
9388183f | 112 | # else |
e4584336 | 113 | YYFPRINTF (yyoutput, "0x%"UVxf, (UV)yyvaluep->ival); |
0de566d7 DM |
114 | # endif |
115 | } | |
116 | else | |
117 | YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); | |
118 | ||
0de566d7 DM |
119 | YYFPRINTF (yyoutput, ")"); |
120 | } | |
121 | ||
122 | ||
9388183f CB |
123 | /* yy_stack_print() |
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 */ | |
0de566d7 DM |
126 | |
127 | static void | |
df35152e | 128 | yy_stack_print (pTHX_ const short *yyss, const short *yyssp, const YYSTYPE *yyvs, const char**yyns) |
0de566d7 | 129 | { |
9388183f CB |
130 | int i; |
131 | int start = 1; | |
132 | int count = (int)(yyssp - yyss); | |
133 | ||
134 | if (count > 8) { | |
135 | start = count - 8 + 1; | |
136 | count = 8; | |
137 | } | |
138 | ||
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++) | |
e4584336 | 150 | PerlIO_printf(Perl_debug_log, " %8"UVxf, (UV)yyvs->ival); |
9388183f | 151 | PerlIO_printf(Perl_debug_log, "\n\n"); |
0de566d7 DM |
152 | } |
153 | ||
9388183f | 154 | # define YY_STACK_PRINT(yyss, yyssp, yyvs, yyns) \ |
0de566d7 | 155 | do { \ |
9388183f CB |
156 | if (yydebug && DEBUG_v_TEST) \ |
157 | yy_stack_print (aTHX_ (yyss), (yyssp), (yyvs), (yyns)); \ | |
0de566d7 DM |
158 | } while (0) |
159 | ||
09bef843 | 160 | |
0de566d7 DM |
161 | /*------------------------------------------------. |
162 | | Report that the YYRULE is going to be reduced. | | |
163 | `------------------------------------------------*/ | |
164 | ||
165 | static void | |
166 | yy_reduce_print (pTHX_ int yyrule) | |
167 | { | |
168 | int yyi; | |
df35152e | 169 | const unsigned int yylineno = yyrline[yyrule]; |
0de566d7 DM |
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]]); | |
176 | } | |
177 | ||
178 | # define YY_REDUCE_PRINT(Rule) \ | |
179 | do { \ | |
180 | if (yydebug) \ | |
181 | yy_reduce_print (aTHX_ Rule); \ | |
182 | } while (0) | |
183 | ||
184 | #else /* !DEBUGGING */ | |
185 | # define YYDPRINTF(Args) | |
9388183f CB |
186 | # define YYDSYMPRINTF(Title, Token, Value) |
187 | # define YY_STACK_PRINT(yyss, yyssp, yyvs, yyns) | |
0de566d7 DM |
188 | # define YY_REDUCE_PRINT(Rule) |
189 | #endif /* !DEBUGGING */ | |
190 | ||
191 | ||
192 | /* YYINITDEPTH -- initial size of the parser's stacks. */ | |
193 | #ifndef YYINITDEPTH | |
194 | # define YYINITDEPTH 200 | |
09bef843 | 195 | #endif |
09bef843 | 196 | |
0de566d7 DM |
197 | |
198 | #if YYERROR_VERBOSE | |
199 | # ifndef yystrlen | |
200 | # if defined (__GLIBC__) && defined (_STRING_H) | |
201 | # define yystrlen strlen | |
202 | # else | |
203 | /* Return the length of YYSTR. */ | |
204 | static YYSIZE_T | |
205 | yystrlen (const char *yystr) | |
206 | { | |
207 | register const char *yys = yystr; | |
208 | ||
209 | while (*yys++ != '\0') | |
210 | continue; | |
211 | ||
212 | return yys - yystr - 1; | |
213 | } | |
214 | # endif | |
215 | # endif | |
216 | ||
217 | # ifndef yystpcpy | |
218 | # if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE) | |
219 | # define yystpcpy stpcpy | |
220 | # else | |
221 | /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in | |
222 | YYDEST. */ | |
223 | static char * | |
224 | yystpcpy (pTHX_ char *yydest, const char *yysrc) | |
225 | { | |
226 | register char *yyd = yydest; | |
227 | register const char *yys = yysrc; | |
228 | ||
229 | while ((*yyd++ = *yys++) != '\0') | |
230 | continue; | |
231 | ||
232 | return yyd - 1; | |
233 | } | |
234 | # endif | |
235 | # endif | |
236 | ||
237 | #endif /* !YYERROR_VERBOSE */ | |
238 | ||
0de566d7 DM |
239 | /*----------. |
240 | | yyparse. | | |
241 | `----------*/ | |
242 | ||
79072805 | 243 | int |
0de566d7 | 244 | Perl_yyparse (pTHX) |
79072805 | 245 | { |
97aff369 | 246 | dVAR; |
0de566d7 DM |
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; | |
251 | register int yyn; | |
252 | int yyresult; | |
253 | ||
254 | /* Number of tokens to shift before error messages enabled. */ | |
255 | int yyerrstatus; | |
256 | /* Lookahead token as an internal (translated) token number. */ | |
257 | int yytoken = 0; | |
258 | ||
259 | /* two stacks and their tools: | |
a0288114 AL |
260 | yyss: related to states, |
261 | yyvs: related to semantic values, | |
0de566d7 DM |
262 | |
263 | Refer to the stacks thru separate pointers, to allow yyoverflow | |
264 | to reallocate them elsewhere. */ | |
265 | ||
266 | /* The state stack. */ | |
267 | short *yyss; | |
93a17b20 | 268 | register short *yyssp; |
0de566d7 DM |
269 | |
270 | /* The semantic value stack. */ | |
271 | YYSTYPE *yyvs; | |
93a17b20 | 272 | register YYSTYPE *yyvsp; |
a0d0e21e | 273 | |
0de566d7 DM |
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; | |
277 | ||
9388183f CB |
278 | #ifdef DEBUGGING |
279 | /* maintain also a stack of token/rule names for debugging with -Dpv */ | |
e1ec3a88 | 280 | const char **yyns, **yynsp; |
9388183f CB |
281 | SV *yyns_sv; |
282 | # define YYPOPSTACK (yyvsp--, yyssp--, yynsp--) | |
283 | #else | |
284 | # define YYPOPSTACK (yyvsp--, yyssp--) | |
285 | #endif | |
286 | ||
0de566d7 DM |
287 | |
288 | YYSIZE_T yystacksize = YYINITDEPTH; | |
289 | ||
290 | /* The variables used to return semantic value and location from the | |
291 | action routines. */ | |
292 | YYSTYPE yyval; | |
293 | ||
294 | ||
295 | /* When reducing, the number of symbols on the RHS of the reduced | |
296 | rule. */ | |
297 | int yylen; | |
298 | ||
299 | YYDPRINTF ((Perl_debug_log, "Starting parse\n")); | |
300 | ||
0de566d7 | 301 | ENTER; /* force stack free before we return */ |
12fbd33b DM |
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 */ | |
306 | ||
561b68a9 SH |
307 | yyss_sv = newSV(YYINITDEPTH * sizeof(short)); |
308 | yyvs_sv = newSV(YYINITDEPTH * sizeof(YYSTYPE)); | |
0de566d7 DM |
309 | SAVEFREESV(yyss_sv); |
310 | SAVEFREESV(yyvs_sv); | |
311 | yyss = (short *) SvPVX(yyss_sv); | |
312 | yyvs = (YYSTYPE *) SvPVX(yyvs_sv); | |
9388183f CB |
313 | /* note that elements zero of yyvs and yyns are not used */ |
314 | yyssp = yyss; | |
315 | yyvsp = yyvs; | |
316 | #ifdef DEBUGGING | |
561b68a9 | 317 | yyns_sv = newSV(YYINITDEPTH * sizeof(char *)); |
9388183f | 318 | SAVEFREESV(yyns_sv); |
a28509cc | 319 | /* XXX This seems strange to cast char * to char ** */ |
94a11853 | 320 | yyns = (const char **) SvPVX(yyns_sv); |
9388183f CB |
321 | yynsp = yyns; |
322 | #endif | |
79072805 | 323 | |
0de566d7 DM |
324 | yystate = 0; |
325 | yyerrstatus = 0; | |
93a17b20 | 326 | yynerrs = 0; |
0de566d7 DM |
327 | yychar = YYEMPTY; /* Cause a token to be read. */ |
328 | ||
79072805 | 329 | |
9388183f CB |
330 | |
331 | YYDPRINTF ((Perl_debug_log, "Entering state %d\n", yystate)); | |
0de566d7 DM |
332 | |
333 | goto yysetstate; | |
334 | ||
335 | /*------------------------------------------------------------. | |
336 | | yynewstate -- Push a new state, which is found in yystate. | | |
337 | `------------------------------------------------------------*/ | |
338 | yynewstate: | |
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. | |
341 | */ | |
342 | yyssp++; | |
343 | ||
344 | yysetstate: | |
345 | *yyssp = yystate; | |
346 | ||
347 | if (yyss + yystacksize - 1 <= yyssp) { | |
348 | /* Get the current used size of the three stacks, in elements. */ | |
df35152e | 349 | const YYSIZE_T yysize = yyssp - yyss + 1; |
0de566d7 DM |
350 | |
351 | /* Extend the stack our own way. */ | |
352 | if (YYMAXDEPTH <= yystacksize) | |
353 | goto yyoverflowlab; | |
354 | yystacksize *= 2; | |
355 | if (YYMAXDEPTH < yystacksize) | |
356 | yystacksize = YYMAXDEPTH; | |
357 | ||
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); | |
9388183f CB |
362 | #ifdef DEBUGGING |
363 | SvGROW(yyns_sv, yystacksize * sizeof(char *)); | |
a28509cc | 364 | /* XXX This seems strange to cast char * to char ** */ |
94a11853 | 365 | yyns = (const char **) SvPVX(yyns_sv); |
9388183f CB |
366 | if (! yyns) |
367 | goto yyoverflowlab; | |
368 | yynsp = yyns + yysize - 1; | |
369 | #endif | |
0de566d7 DM |
370 | if (!yyss || ! yyvs) |
371 | goto yyoverflowlab; | |
372 | ||
373 | yyssp = yyss + yysize - 1; | |
374 | yyvsp = yyvs + yysize - 1; | |
375 | ||
376 | ||
377 | YYDPRINTF ((Perl_debug_log, "Stack size increased to %lu\n", | |
378 | (unsigned long int) yystacksize)); | |
379 | ||
380 | if (yyss + yystacksize - 1 <= yyssp) | |
381 | YYABORT; | |
93a17b20 | 382 | } |
0de566d7 | 383 | |
0de566d7 DM |
384 | goto yybackup; |
385 | ||
386 | /*-----------. | |
387 | | yybackup. | | |
388 | `-----------*/ | |
389 | yybackup: | |
390 | ||
391 | /* Do appropriate processing given the current state. */ | |
392 | /* Read a lookahead token if we need one and don't already have one. */ | |
393 | /* yyresume: */ | |
394 | ||
395 | /* First try to decide what to do without reference to lookahead token. */ | |
396 | ||
397 | yyn = yypact[yystate]; | |
398 | if (yyn == YYPACT_NINF) | |
399 | goto yydefault; | |
400 | ||
401 | /* Not known => get a lookahead token if don't already have one. */ | |
402 | ||
403 | /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ | |
404 | if (yychar == YYEMPTY) { | |
405 | YYDPRINTF ((Perl_debug_log, "Reading a token: ")); | |
12fbd33b DM |
406 | yychar = yylex(); |
407 | # ifdef EBCDIC | |
408 | if (yychar >= 0 && yychar < 255) { | |
409 | yychar = NATIVE_TO_ASCII(yychar); | |
410 | } | |
411 | # endif | |
0de566d7 DM |
412 | } |
413 | ||
414 | if (yychar <= YYEOF) { | |
415 | yychar = yytoken = YYEOF; | |
416 | YYDPRINTF ((Perl_debug_log, "Now at end of input.\n")); | |
93a17b20 | 417 | } |
0de566d7 DM |
418 | else { |
419 | yytoken = YYTRANSLATE (yychar); | |
9388183f | 420 | YYDSYMPRINTF ("Next token is", yytoken, &yylval); |
93a17b20 | 421 | } |
771df094 | 422 | |
0de566d7 DM |
423 | /* If the proper action on seeing token YYTOKEN is to reduce or to |
424 | detect an error, take that action. */ | |
425 | yyn += yytoken; | |
426 | if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) | |
427 | goto yydefault; | |
428 | yyn = yytable[yyn]; | |
429 | if (yyn <= 0) { | |
430 | if (yyn == 0 || yyn == YYTABLE_NINF) | |
431 | goto yyerrlab; | |
432 | yyn = -yyn; | |
433 | goto yyreduce; | |
434 | } | |
7b57b0ea | 435 | |
0de566d7 DM |
436 | if (yyn == YYFINAL) |
437 | YYACCEPT; | |
771df094 | 438 | |
0de566d7 DM |
439 | /* Shift the lookahead token. */ |
440 | YYDPRINTF ((Perl_debug_log, "Shifting token %s, ", yytname[yytoken])); | |
441 | ||
442 | /* Discard the token being shifted unless it is eof. */ | |
443 | if (yychar != YYEOF) | |
444 | yychar = YYEMPTY; | |
445 | ||
446 | *++yyvsp = yylval; | |
9388183f | 447 | #ifdef DEBUGGING |
e1ec3a88 | 448 | *++yynsp = (const char *)(yytname[yytoken]); |
9388183f | 449 | #endif |
0de566d7 DM |
450 | |
451 | ||
452 | /* Count tokens shifted since error; after three, turn off error | |
453 | status. */ | |
454 | if (yyerrstatus) | |
455 | yyerrstatus--; | |
456 | ||
457 | yystate = yyn; | |
9388183f CB |
458 | YYDPRINTF ((Perl_debug_log, "Entering state %d\n", yystate)); |
459 | ||
0de566d7 DM |
460 | goto yynewstate; |
461 | ||
462 | ||
463 | /*-----------------------------------------------------------. | |
464 | | yydefault -- do the default action for the current state. | | |
465 | `-----------------------------------------------------------*/ | |
466 | yydefault: | |
467 | yyn = yydefact[yystate]; | |
468 | if (yyn == 0) | |
469 | goto yyerrlab; | |
470 | goto yyreduce; | |
471 | ||
472 | ||
473 | /*-----------------------------. | |
474 | | yyreduce -- Do a reduction. | | |
475 | `-----------------------------*/ | |
476 | yyreduce: | |
477 | /* yyn is the number of a rule to reduce with. */ | |
478 | yylen = yyr2[yyn]; | |
479 | ||
480 | /* If YYLEN is nonzero, implement the default value of the action: | |
a0288114 | 481 | "$$ = $1". |
0de566d7 DM |
482 | |
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]; | |
489 | ||
490 | ||
491 | YY_REDUCE_PRINT (yyn); | |
492 | switch (yyn) { | |
493 | ||
494 | /* contains all the rule actions; auto-generated from perly.y */ | |
495 | ||
496 | #define dep() deprecate("\"do\" to call subroutines") | |
497 | #include "perly.act" | |
7b57b0ea | 498 | |
93a17b20 | 499 | } |
0de566d7 DM |
500 | |
501 | yyvsp -= yylen; | |
502 | yyssp -= yylen; | |
9388183f CB |
503 | #ifdef DEBUGGING |
504 | yynsp -= yylen; | |
505 | #endif | |
0de566d7 | 506 | |
0de566d7 DM |
507 | |
508 | *++yyvsp = yyval; | |
9388183f | 509 | #ifdef DEBUGGING |
e1ec3a88 | 510 | *++yynsp = (const char *)(yytname [yyr1[yyn]]); |
9388183f | 511 | #endif |
0de566d7 | 512 | |
a0288114 | 513 | /* Now shift the result of the reduction. Determine what state |
0de566d7 DM |
514 | that goes to, based on the state we popped back to and the rule |
515 | number reduced by. */ | |
516 | ||
517 | yyn = yyr1[yyn]; | |
518 | ||
519 | yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; | |
520 | if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) | |
521 | yystate = yytable[yystate]; | |
93a17b20 | 522 | else |
0de566d7 DM |
523 | yystate = yydefgoto[yyn - YYNTOKENS]; |
524 | ||
9388183f CB |
525 | YYDPRINTF ((Perl_debug_log, "Entering state %d\n", yystate)); |
526 | ||
527 | #ifdef DEBUGGING | |
528 | /* tmp push yystate for stack print; this is normally pushed later in | |
529 | * yynewstate */ | |
530 | yyssp++; | |
531 | *yyssp = yystate; | |
532 | YY_STACK_PRINT (yyss, yyssp, yyvs, yyns); | |
533 | yyssp--; | |
534 | #endif | |
535 | ||
0de566d7 DM |
536 | goto yynewstate; |
537 | ||
538 | ||
539 | /*------------------------------------. | |
540 | | yyerrlab -- here on detecting error | | |
541 | `------------------------------------*/ | |
542 | yyerrlab: | |
543 | /* If not already recovering from an error, report this error. */ | |
544 | if (!yyerrstatus) { | |
545 | ++yynerrs; | |
546 | #if YYERROR_VERBOSE | |
547 | yyn = yypact[yystate]; | |
548 | ||
549 | if (YYPACT_NINF < yyn && yyn < YYLAST) { | |
550 | YYSIZE_T yysize = 0; | |
df35152e | 551 | const int yytype = YYTRANSLATE (yychar); |
0de566d7 DM |
552 | char *yymsg; |
553 | int yyx, yycount; | |
554 | ||
555 | yycount = 0; | |
556 | /* Start YYX at -YYN if negative to avoid negative indexes in | |
557 | YYCHECK. */ | |
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]); | |
4b711db3 | 564 | Newx(yymsg, yysize, char *); |
0de566d7 | 565 | if (yymsg != 0) { |
df35152e | 566 | const char *yyp = yystpcpy (yymsg, "syntax error, unexpected "); |
0de566d7 DM |
567 | yyp = yystpcpy (yyp, yytname[yytype]); |
568 | ||
569 | if (yycount < 5) { | |
570 | yycount = 0; | |
571 | for (yyx = yyn < 0 ? -yyn : 0; | |
572 | yyx < (int) (sizeof (yytname) / sizeof (char *)); | |
573 | yyx++) | |
574 | { | |
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]); | |
580 | yycount++; | |
581 | } | |
582 | } | |
ecb2f335 | 583 | } |
0de566d7 DM |
584 | yyerror (yymsg); |
585 | YYSTACK_FREE (yymsg); | |
586 | } | |
587 | else | |
588 | yyerror ("syntax error; also virtual memory exhausted"); | |
589 | } | |
590 | else | |
591 | #endif /* YYERROR_VERBOSE */ | |
592 | yyerror ("syntax error"); | |
93a17b20 | 593 | } |
0de566d7 DM |
594 | |
595 | ||
596 | if (yyerrstatus == 3) { | |
597 | /* If just tried and failed to reuse lookahead token after an | |
598 | error, discard it. */ | |
599 | ||
600 | /* Return failure if at end of input. */ | |
601 | if (yychar == YYEOF) { | |
602 | /* Pop the error token. */ | |
603 | YYPOPSTACK; | |
604 | /* Pop the rest of the stack. */ | |
605 | while (yyss < yyssp) { | |
9388183f | 606 | YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp); |
0de566d7 DM |
607 | YYPOPSTACK; |
608 | } | |
609 | YYABORT; | |
610 | } | |
611 | ||
9388183f | 612 | YYDSYMPRINTF ("Error: discarding", yytoken, &yylval); |
0de566d7 DM |
613 | yychar = YYEMPTY; |
614 | ||
93a17b20 | 615 | } |
0de566d7 DM |
616 | |
617 | /* Else will try to reuse lookahead token after shifting the error | |
618 | token. */ | |
619 | goto yyerrlab1; | |
620 | ||
621 | ||
622 | /*----------------------------------------------------. | |
623 | | yyerrlab1 -- error raised explicitly by an action. | | |
624 | `----------------------------------------------------*/ | |
625 | yyerrlab1: | |
626 | yyerrstatus = 3; /* Each real token shifted decrements this. */ | |
627 | ||
628 | for (;;) { | |
629 | yyn = yypact[yystate]; | |
630 | if (yyn != YYPACT_NINF) { | |
631 | yyn += YYTERROR; | |
632 | if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) { | |
633 | yyn = yytable[yyn]; | |
634 | if (0 < yyn) | |
635 | break; | |
636 | } | |
637 | } | |
638 | ||
639 | /* Pop the current state because it cannot handle the error token. */ | |
640 | if (yyssp == yyss) | |
641 | YYABORT; | |
642 | ||
9388183f | 643 | YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp); |
0de566d7 | 644 | yyvsp--; |
9388183f CB |
645 | #ifdef DEBUGGING |
646 | yynsp--; | |
647 | #endif | |
0de566d7 DM |
648 | yystate = *--yyssp; |
649 | ||
9388183f | 650 | YY_STACK_PRINT (yyss, yyssp, yyvs, yyns); |
93a17b20 | 651 | } |
0de566d7 DM |
652 | |
653 | if (yyn == YYFINAL) | |
654 | YYACCEPT; | |
655 | ||
656 | YYDPRINTF ((Perl_debug_log, "Shifting error token, ")); | |
657 | ||
658 | *++yyvsp = yylval; | |
9388183f CB |
659 | #ifdef DEBUGGING |
660 | *++yynsp ="<err>"; | |
661 | #endif | |
0de566d7 DM |
662 | |
663 | yystate = yyn; | |
9388183f CB |
664 | YYDPRINTF ((Perl_debug_log, "Entering state %d\n", yystate)); |
665 | ||
0de566d7 DM |
666 | goto yynewstate; |
667 | ||
668 | ||
669 | /*-------------------------------------. | |
670 | | yyacceptlab -- YYACCEPT comes here. | | |
671 | `-------------------------------------*/ | |
672 | yyacceptlab: | |
673 | yyresult = 0; | |
674 | goto yyreturn; | |
675 | ||
676 | /*-----------------------------------. | |
677 | | yyabortlab -- YYABORT comes here. | | |
678 | `-----------------------------------*/ | |
679 | yyabortlab: | |
680 | yyresult = 1; | |
681 | goto yyreturn; | |
682 | ||
683 | /*----------------------------------------------. | |
684 | | yyoverflowlab -- parser overflow comes here. | | |
685 | `----------------------------------------------*/ | |
686 | yyoverflowlab: | |
687 | yyerror ("parser stack overflow"); | |
688 | yyresult = 2; | |
689 | /* Fall through. */ | |
690 | ||
691 | yyreturn: | |
692 | ||
12fbd33b | 693 | LEAVE; /* force stack free before we return */ |
e1f15930 | 694 | |
0de566d7 | 695 | return yyresult; |
e1f15930 | 696 | } |
66610fdd RGS |
697 | |
698 | /* | |
699 | * Local variables: | |
700 | * c-indentation-style: bsd | |
701 | * c-basic-offset: 4 | |
702 | * indent-tabs-mode: t | |
703 | * End: | |
704 | * | |
37442d52 RGS |
705 | * ex: set ts=8 sts=4 sw=4 noet: |
706 | */ |