Commit | Line | Data |
---|---|---|
0de566d7 DM |
1 | /* perly.c |
2 | * | |
2eee27d7 SS |
3 | * Copyright (c) 2004, 2005, 2006, 2007, 2008, |
4 | * 2009, 2010, 2011 by Larry Wall and others | |
0de566d7 DM |
5 | * |
6 | * You may distribute under the terms of either the GNU General Public | |
7 | * License or the Artistic License, as specified in the README file. | |
8 | * | |
9 | * Note that this file was originally generated as an output from | |
10 | * GNU bison version 1.875, but now the code is statically maintained | |
f05e27e5 DM |
11 | * and edited; the bits that are dependent on perly.y are now |
12 | * #included from the files perly.tab and perly.act. | |
0de566d7 DM |
13 | * |
14 | * Here is an important copyright statement from the original, generated | |
15 | * file: | |
16 | * | |
17 | * As a special exception, when this file is copied by Bison into a | |
18 | * Bison output file, you may use that output file without | |
19 | * restriction. This special exception was added by the Free | |
20 | * Software Foundation in version 1.24 of Bison. | |
bc463c31 | 21 | * |
0de566d7 DM |
22 | */ |
23 | ||
79072805 | 24 | #include "EXTERN.h" |
864dbfa3 | 25 | #define PERL_IN_PERLY_C |
79072805 | 26 | #include "perl.h" |
30d9c59b | 27 | #include "feature.h" |
09bef843 | 28 | |
3797f23d DM |
29 | typedef unsigned char yytype_uint8; |
30 | typedef signed char yytype_int8; | |
31 | typedef unsigned short int yytype_uint16; | |
32 | typedef short int yytype_int16; | |
0de566d7 DM |
33 | typedef signed char yysigned_char; |
34 | ||
28ac2b49 Z |
35 | /* YYINITDEPTH -- initial size of the parser's stacks. */ |
36 | #define YYINITDEPTH 200 | |
37 | ||
599f1ac6 FC |
38 | #ifdef YYDEBUG |
39 | # undef YYDEBUG | |
40 | #endif | |
41 | #ifdef DEBUGGING | |
42 | # define YYDEBUG 1 | |
43 | #else | |
44 | # define YYDEBUG 0 | |
45 | #endif | |
46 | ||
b3045d9c FC |
47 | #ifndef YY_NULL |
48 | # define YY_NULL 0 | |
93a17b20 | 49 | #endif |
09bef843 | 50 | |
f39ff1f3 DM |
51 | #ifndef YY_NULLPTR |
52 | # define YY_NULLPTR NULL | |
53 | #endif | |
54 | ||
f05e27e5 DM |
55 | /* contains all the parser state tables; auto-generated from perly.y */ |
56 | #include "perly.tab" | |
0de566d7 DM |
57 | |
58 | # define YYSIZE_T size_t | |
59 | ||
0de566d7 | 60 | #define YYEOF 0 |
07a06489 | 61 | #define YYTERROR 1 |
0de566d7 DM |
62 | |
63 | #define YYACCEPT goto yyacceptlab | |
64 | #define YYABORT goto yyabortlab | |
65 | #define YYERROR goto yyerrlab1 | |
66 | ||
0de566d7 | 67 | /* Enable debugging if requested. */ |
9388183f | 68 | #ifdef DEBUGGING |
0de566d7 DM |
69 | |
70 | # define yydebug (DEBUG_p_TEST) | |
71 | ||
72 | # define YYFPRINTF PerlIO_printf | |
73 | ||
74 | # define YYDPRINTF(Args) \ | |
75 | do { \ | |
76 | if (yydebug) \ | |
77 | YYFPRINTF Args; \ | |
78 | } while (0) | |
79 | ||
9388183f | 80 | # define YYDSYMPRINTF(Title, Token, Value) \ |
0de566d7 DM |
81 | do { \ |
82 | if (yydebug) { \ | |
83 | YYFPRINTF (Perl_debug_log, "%s ", Title); \ | |
356f4fed | 84 | yysymprint (aTHX_ Perl_debug_log, Token, Value); \ |
0de566d7 DM |
85 | YYFPRINTF (Perl_debug_log, "\n"); \ |
86 | } \ | |
87 | } while (0) | |
88 | ||
89 | /*--------------------------------. | |
90 | | Print this symbol on YYOUTPUT. | | |
91 | `--------------------------------*/ | |
92 | ||
93 | static void | |
356f4fed | 94 | yysymprint(pTHX_ PerlIO * const yyoutput, int yytype, const YYSTYPE * const yyvaluep) |
0de566d7 | 95 | { |
dc3bf405 | 96 | PERL_UNUSED_CONTEXT; |
0de566d7 DM |
97 | if (yytype < YYNTOKENS) { |
98 | YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); | |
99 | # ifdef YYPRINT | |
100 | YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); | |
9388183f | 101 | # else |
e4584336 | 102 | YYFPRINTF (yyoutput, "0x%"UVxf, (UV)yyvaluep->ival); |
0de566d7 DM |
103 | # endif |
104 | } | |
105 | else | |
106 | YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); | |
107 | ||
0de566d7 DM |
108 | YYFPRINTF (yyoutput, ")"); |
109 | } | |
110 | ||
111 | ||
9388183f | 112 | /* yy_stack_print() |
1654d593 DM |
113 | * print the top 8 items on the parse stack. |
114 | */ | |
0de566d7 DM |
115 | |
116 | static void | |
1654d593 | 117 | yy_stack_print (pTHX_ const yy_parser *parser) |
0de566d7 | 118 | { |
1654d593 | 119 | const yy_stack_frame *ps, *min; |
9388183f | 120 | |
2d29f438 | 121 | min = parser->ps - 8 + 1; |
22735491 DM |
122 | if (min <= parser->stack) |
123 | min = parser->stack + 1; | |
9388183f CB |
124 | |
125 | PerlIO_printf(Perl_debug_log, "\nindex:"); | |
1654d593 | 126 | for (ps = min; ps <= parser->ps; ps++) |
00c0e1ee | 127 | PerlIO_printf(Perl_debug_log, " %8d", (int)(ps - parser->stack)); |
1654d593 | 128 | |
9388183f | 129 | PerlIO_printf(Perl_debug_log, "\nstate:"); |
1654d593 DM |
130 | for (ps = min; ps <= parser->ps; ps++) |
131 | PerlIO_printf(Perl_debug_log, " %8d", ps->state); | |
132 | ||
9388183f | 133 | PerlIO_printf(Perl_debug_log, "\ntoken:"); |
1654d593 DM |
134 | for (ps = min; ps <= parser->ps; ps++) |
135 | PerlIO_printf(Perl_debug_log, " %8.8s", ps->name); | |
136 | ||
9388183f | 137 | PerlIO_printf(Perl_debug_log, "\nvalue:"); |
1654d593 DM |
138 | for (ps = min; ps <= parser->ps; ps++) { |
139 | switch (yy_type_tab[yystos[ps->state]]) { | |
d5c6462e | 140 | case toketype_opval: |
21612876 | 141 | PerlIO_printf(Perl_debug_log, " %8.8s", |
1654d593 DM |
142 | ps->val.opval |
143 | ? PL_op_name[ps->val.opval->op_type] | |
670f3923 | 144 | : "(Nullop)" |
21612876 | 145 | ); |
d5c6462e | 146 | break; |
d5c6462e | 147 | case toketype_ival: |
1654d593 | 148 | PerlIO_printf(Perl_debug_log, " %8"IVdf, (IV)ps->val.ival); |
d5c6462e DM |
149 | break; |
150 | default: | |
1654d593 | 151 | PerlIO_printf(Perl_debug_log, " %8"UVxf, (UV)ps->val.ival); |
d5c6462e | 152 | } |
21612876 | 153 | } |
9388183f | 154 | PerlIO_printf(Perl_debug_log, "\n\n"); |
0de566d7 DM |
155 | } |
156 | ||
1654d593 DM |
157 | # define YY_STACK_PRINT(parser) \ |
158 | do { \ | |
159 | if (yydebug && DEBUG_v_TEST) \ | |
160 | yy_stack_print (aTHX_ parser); \ | |
0de566d7 DM |
161 | } while (0) |
162 | ||
09bef843 | 163 | |
0de566d7 DM |
164 | /*------------------------------------------------. |
165 | | Report that the YYRULE is going to be reduced. | | |
166 | `------------------------------------------------*/ | |
167 | ||
168 | static void | |
169 | yy_reduce_print (pTHX_ int yyrule) | |
170 | { | |
171 | int yyi; | |
df35152e | 172 | const unsigned int yylineno = yyrline[yyrule]; |
0de566d7 DM |
173 | YYFPRINTF (Perl_debug_log, "Reducing stack by rule %d (line %u), ", |
174 | yyrule - 1, yylineno); | |
175 | /* Print the symbols being reduced, and their result. */ | |
f39ff1f3 DM |
176 | #if PERL_BISON_VERSION >= 30000 /* 3.0+ */ |
177 | for (yyi = 0; yyi < yyr2[yyrule]; yyi++) | |
178 | YYFPRINTF (Perl_debug_log, "%s ", | |
179 | yytname [yystos[(PL_parser->ps)[yyi + 1 - yyr2[yyrule]].state]]); | |
180 | #else | |
0de566d7 DM |
181 | for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++) |
182 | YYFPRINTF (Perl_debug_log, "%s ", yytname [yyrhs[yyi]]); | |
f39ff1f3 | 183 | #endif |
0de566d7 DM |
184 | YYFPRINTF (Perl_debug_log, "-> %s\n", yytname [yyr1[yyrule]]); |
185 | } | |
186 | ||
187 | # define YY_REDUCE_PRINT(Rule) \ | |
188 | do { \ | |
189 | if (yydebug) \ | |
190 | yy_reduce_print (aTHX_ Rule); \ | |
191 | } while (0) | |
192 | ||
193 | #else /* !DEBUGGING */ | |
194 | # define YYDPRINTF(Args) | |
9388183f | 195 | # define YYDSYMPRINTF(Title, Token, Value) |
1654d593 | 196 | # define YY_STACK_PRINT(parser) |
0de566d7 DM |
197 | # define YY_REDUCE_PRINT(Rule) |
198 | #endif /* !DEBUGGING */ | |
199 | ||
718a7425 DM |
200 | /* called during cleanup (via SAVEDESTRUCTOR_X) to free any items on the |
201 | * parse stack, thus avoiding leaks if we die */ | |
202 | ||
203 | static void | |
22735491 | 204 | S_clear_yystack(pTHX_ const yy_parser *parser) |
718a7425 | 205 | { |
1654d593 | 206 | yy_stack_frame *ps = parser->ps; |
0934c9d9 | 207 | int i = 0; |
718a7425 | 208 | |
28ac2b49 | 209 | if (!parser->stack) |
718a7425 | 210 | return; |
1654d593 | 211 | |
718a7425 | 212 | YYDPRINTF ((Perl_debug_log, "clearing the parse stack\n")); |
670f3923 | 213 | |
8c63ea58 GG |
214 | for (i=0; i< parser->yylen; i++) { |
215 | SvREFCNT_dec(ps[-i].compcv); | |
216 | } | |
0aded6e1 | 217 | ps -= parser->yylen; |
670f3923 DM |
218 | |
219 | /* now free whole the stack, including the just-reduced ops */ | |
220 | ||
22735491 | 221 | while (ps > parser->stack) { |
503de470 | 222 | LEAVE_SCOPE(ps->savestack_ix); |
1654d593 DM |
223 | if (yy_type_tab[yystos[ps->state]] == toketype_opval |
224 | && ps->val.opval) | |
670f3923 | 225 | { |
a293d0fd | 226 | if (ps->compcv && (ps->compcv != PL_compcv)) { |
8c63ea58 GG |
227 | PL_compcv = ps->compcv; |
228 | PAD_SET_CUR_NOSAVE(CvPADLIST(PL_compcv), 1); | |
325e1816 | 229 | PL_comppad_name = PadlistNAMES(CvPADLIST(PL_compcv)); |
718a7425 DM |
230 | } |
231 | YYDPRINTF ((Perl_debug_log, "(freeing op)\n")); | |
571a568a | 232 | op_free(ps->val.opval); |
718a7425 | 233 | } |
8c63ea58 | 234 | SvREFCNT_dec(ps->compcv); |
1654d593 | 235 | ps--; |
718a7425 | 236 | } |
28ac2b49 Z |
237 | |
238 | Safefree(parser->stack); | |
718a7425 DM |
239 | } |
240 | ||
718a7425 | 241 | |
0de566d7 DM |
242 | /*----------. |
243 | | yyparse. | | |
244 | `----------*/ | |
245 | ||
79072805 | 246 | int |
28ac2b49 | 247 | Perl_yyparse (pTHX_ int gramtype) |
79072805 | 248 | { |
eb578fdb KW |
249 | int yystate; |
250 | int yyn; | |
0de566d7 DM |
251 | int yyresult; |
252 | ||
0de566d7 | 253 | /* Lookahead token as an internal (translated) token number. */ |
714c8e96 | 254 | int yytoken = 0; |
0de566d7 | 255 | |
eb578fdb KW |
256 | yy_parser *parser; /* the parser object */ |
257 | yy_stack_frame *ps; /* current parser stack frame */ | |
a0d0e21e | 258 | |
1654d593 DM |
259 | #define YYPOPSTACK parser->ps = --ps |
260 | #define YYPUSHSTACK parser->ps = ++ps | |
0de566d7 | 261 | |
acdf0a21 | 262 | /* The variable used to return semantic value and location from the |
5912531f | 263 | action routines: ie $$. */ |
0de566d7 DM |
264 | YYSTYPE yyval; |
265 | ||
0de566d7 DM |
266 | YYDPRINTF ((Perl_debug_log, "Starting parse\n")); |
267 | ||
acdf0a21 | 268 | parser = PL_parser; |
1654d593 | 269 | |
28ac2b49 Z |
270 | ENTER; /* force parser state cleanup/restoration before we return */ |
271 | SAVEPPTR(parser->yylval.pval); | |
272 | SAVEINT(parser->yychar); | |
273 | SAVEINT(parser->yyerrstatus); | |
274 | SAVEINT(parser->stack_size); | |
275 | SAVEINT(parser->yylen); | |
276 | SAVEVPTR(parser->stack); | |
277 | SAVEVPTR(parser->ps); | |
278 | ||
279 | /* initialise state for this parse */ | |
280 | parser->yychar = gramtype; | |
281 | parser->yyerrstatus = 0; | |
282 | parser->stack_size = YYINITDEPTH; | |
283 | parser->yylen = 0; | |
284 | Newx(parser->stack, YYINITDEPTH, yy_stack_frame); | |
285 | ps = parser->ps = parser->stack; | |
286 | ps->state = 0; | |
e3abe207 | 287 | SAVEDESTRUCTOR_X(S_clear_yystack, parser); |
0de566d7 | 288 | |
0de566d7 DM |
289 | /*------------------------------------------------------------. |
290 | | yynewstate -- Push a new state, which is found in yystate. | | |
291 | `------------------------------------------------------------*/ | |
292 | yynewstate: | |
0de566d7 | 293 | |
1654d593 | 294 | yystate = ps->state; |
05a03161 | 295 | |
670f3923 | 296 | YYDPRINTF ((Perl_debug_log, "Entering state %d\n", yystate)); |
0de566d7 | 297 | |
5912531f | 298 | parser->yylen = 0; |
0de566d7 | 299 | |
1654d593 | 300 | { |
22735491 | 301 | size_t size = ps - parser->stack + 1; |
0de566d7 | 302 | |
1654d593 DM |
303 | /* grow the stack? We always leave 1 spare slot, |
304 | * in case of a '' -> 'foo' reduction */ | |
0de566d7 | 305 | |
85c508c3 | 306 | if (size >= (size_t)parser->stack_size - 1) { |
1654d593 DM |
307 | /* this will croak on insufficient memory */ |
308 | parser->stack_size *= 2; | |
22735491 DM |
309 | Renew(parser->stack, parser->stack_size, yy_stack_frame); |
310 | ps = parser->ps = parser->stack + size -1; | |
670f3923 | 311 | |
1654d593 DM |
312 | YYDPRINTF((Perl_debug_log, |
313 | "parser stack size increased to %lu frames\n", | |
314 | (unsigned long int)parser->stack_size)); | |
315 | } | |
93a17b20 | 316 | } |
0de566d7 | 317 | |
0de566d7 DM |
318 | /* Do appropriate processing given the current state. */ |
319 | /* Read a lookahead token if we need one and don't already have one. */ | |
0de566d7 DM |
320 | |
321 | /* First try to decide what to do without reference to lookahead token. */ | |
322 | ||
323 | yyn = yypact[yystate]; | |
324 | if (yyn == YYPACT_NINF) | |
325 | goto yydefault; | |
326 | ||
327 | /* Not known => get a lookahead token if don't already have one. */ | |
328 | ||
329 | /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ | |
5912531f | 330 | if (parser->yychar == YYEMPTY) { |
37b6dcb8 | 331 | YYDPRINTF ((Perl_debug_log, "Reading a token:\n")); |
5912531f | 332 | parser->yychar = yylex(); |
0de566d7 DM |
333 | } |
334 | ||
5912531f DM |
335 | if (parser->yychar <= YYEOF) { |
336 | parser->yychar = yytoken = YYEOF; | |
0de566d7 | 337 | YYDPRINTF ((Perl_debug_log, "Now at end of input.\n")); |
93a17b20 | 338 | } |
0de566d7 | 339 | else { |
100b2bb8 KW |
340 | /* perly.tab is shipped based on an ASCII system, so need to index it |
341 | * with characters translated to ASCII. Although it's not designed for | |
342 | * this purpose, we can use NATIVE_TO_UNI here. It returns its | |
343 | * argument on ASCII platforms, and on EBCDIC translates native to | |
344 | * ascii in the 0-255 range, leaving everything else unchanged. This | |
345 | * jibes with yylex() returning some bare characters in that range, but | |
346 | * all tokens it returns are either 0, or above 255. There could be a | |
347 | * problem if NULs weren't 0, or were ever returned as raw chars by | |
348 | * yylex() */ | |
349 | yytoken = YYTRANSLATE (NATIVE_TO_UNI(parser->yychar)); | |
5912531f | 350 | YYDSYMPRINTF ("Next token is", yytoken, &parser->yylval); |
93a17b20 | 351 | } |
771df094 | 352 | |
0de566d7 DM |
353 | /* If the proper action on seeing token YYTOKEN is to reduce or to |
354 | detect an error, take that action. */ | |
355 | yyn += yytoken; | |
356 | if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) | |
357 | goto yydefault; | |
358 | yyn = yytable[yyn]; | |
359 | if (yyn <= 0) { | |
360 | if (yyn == 0 || yyn == YYTABLE_NINF) | |
361 | goto yyerrlab; | |
362 | yyn = -yyn; | |
363 | goto yyreduce; | |
364 | } | |
7b57b0ea | 365 | |
0de566d7 DM |
366 | if (yyn == YYFINAL) |
367 | YYACCEPT; | |
771df094 | 368 | |
0de566d7 DM |
369 | /* Shift the lookahead token. */ |
370 | YYDPRINTF ((Perl_debug_log, "Shifting token %s, ", yytname[yytoken])); | |
371 | ||
372 | /* Discard the token being shifted unless it is eof. */ | |
5912531f DM |
373 | if (parser->yychar != YYEOF) |
374 | parser->yychar = YYEMPTY; | |
0de566d7 | 375 | |
1654d593 DM |
376 | YYPUSHSTACK; |
377 | ps->state = yyn; | |
5912531f | 378 | ps->val = parser->yylval; |
ec8ec19f | 379 | ps->compcv = (CV*)SvREFCNT_inc(PL_compcv); |
503de470 | 380 | ps->savestack_ix = PL_savestack_ix; |
9388183f | 381 | #ifdef DEBUGGING |
1654d593 | 382 | ps->name = (const char *)(yytname[yytoken]); |
9388183f | 383 | #endif |
0de566d7 | 384 | |
0de566d7 DM |
385 | /* Count tokens shifted since error; after three, turn off error |
386 | status. */ | |
5912531f DM |
387 | if (parser->yyerrstatus) |
388 | parser->yyerrstatus--; | |
0de566d7 | 389 | |
0de566d7 DM |
390 | goto yynewstate; |
391 | ||
392 | ||
393 | /*-----------------------------------------------------------. | |
394 | | yydefault -- do the default action for the current state. | | |
395 | `-----------------------------------------------------------*/ | |
396 | yydefault: | |
397 | yyn = yydefact[yystate]; | |
398 | if (yyn == 0) | |
399 | goto yyerrlab; | |
400 | goto yyreduce; | |
401 | ||
402 | ||
403 | /*-----------------------------. | |
404 | | yyreduce -- Do a reduction. | | |
405 | `-----------------------------*/ | |
406 | yyreduce: | |
407 | /* yyn is the number of a rule to reduce with. */ | |
5912531f | 408 | parser->yylen = yyr2[yyn]; |
0de566d7 DM |
409 | |
410 | /* If YYLEN is nonzero, implement the default value of the action: | |
a0288114 | 411 | "$$ = $1". |
0de566d7 DM |
412 | |
413 | Otherwise, the following line sets YYVAL to garbage. | |
414 | This behavior is undocumented and Bison | |
415 | users should not rely upon it. Assigning to YYVAL | |
416 | unconditionally makes the parser a bit smaller, and it avoids a | |
417 | GCC warning that YYVAL may be used uninitialized. */ | |
5912531f | 418 | yyval = ps[1-parser->yylen].val; |
0de566d7 | 419 | |
1654d593 | 420 | YY_STACK_PRINT(parser); |
0de566d7 | 421 | YY_REDUCE_PRINT (yyn); |
718a7425 | 422 | |
0de566d7 DM |
423 | switch (yyn) { |
424 | ||
f05e27e5 DM |
425 | /* contains all the rule actions; auto-generated from perly.y */ |
426 | #include "perly.act" | |
427 | ||
93a17b20 | 428 | } |
0de566d7 | 429 | |
670f3923 DM |
430 | { |
431 | int i; | |
5912531f | 432 | for (i=0; i< parser->yylen; i++) { |
8c63ea58 | 433 | SvREFCNT_dec(ps[-i].compcv); |
670f3923 DM |
434 | } |
435 | } | |
436 | ||
5912531f | 437 | parser->ps = ps -= (parser->yylen-1); |
0de566d7 | 438 | |
05a03161 DM |
439 | /* Now shift the result of the reduction. Determine what state |
440 | that goes to, based on the state we popped back to and the rule | |
441 | number reduced by. */ | |
442 | ||
1654d593 | 443 | ps->val = yyval; |
ec8ec19f | 444 | ps->compcv = (CV*)SvREFCNT_inc(PL_compcv); |
503de470 | 445 | ps->savestack_ix = PL_savestack_ix; |
9388183f | 446 | #ifdef DEBUGGING |
1654d593 | 447 | ps->name = (const char *)(yytname [yyr1[yyn]]); |
9388183f | 448 | #endif |
0de566d7 DM |
449 | |
450 | yyn = yyr1[yyn]; | |
451 | ||
1654d593 DM |
452 | yystate = yypgoto[yyn - YYNTOKENS] + ps[-1].state; |
453 | if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == ps[-1].state) | |
0de566d7 | 454 | yystate = yytable[yystate]; |
93a17b20 | 455 | else |
0de566d7 | 456 | yystate = yydefgoto[yyn - YYNTOKENS]; |
1654d593 | 457 | ps->state = yystate; |
05a03161 | 458 | |
0de566d7 DM |
459 | goto yynewstate; |
460 | ||
461 | ||
462 | /*------------------------------------. | |
463 | | yyerrlab -- here on detecting error | | |
464 | `------------------------------------*/ | |
465 | yyerrlab: | |
466 | /* If not already recovering from an error, report this error. */ | |
5912531f | 467 | if (!parser->yyerrstatus) { |
07a06489 | 468 | yyerror ("syntax error"); |
93a17b20 | 469 | } |
0de566d7 DM |
470 | |
471 | ||
5912531f | 472 | if (parser->yyerrstatus == 3) { |
0de566d7 DM |
473 | /* If just tried and failed to reuse lookahead token after an |
474 | error, discard it. */ | |
475 | ||
476 | /* Return failure if at end of input. */ | |
5912531f | 477 | if (parser->yychar == YYEOF) { |
0de566d7 | 478 | /* Pop the error token. */ |
8c63ea58 | 479 | SvREFCNT_dec(ps->compcv); |
0de566d7 DM |
480 | YYPOPSTACK; |
481 | /* Pop the rest of the stack. */ | |
22735491 | 482 | while (ps > parser->stack) { |
1654d593 | 483 | YYDSYMPRINTF ("Error: popping", yystos[ps->state], &ps->val); |
503de470 | 484 | LEAVE_SCOPE(ps->savestack_ix); |
1654d593 DM |
485 | if (yy_type_tab[yystos[ps->state]] == toketype_opval |
486 | && ps->val.opval) | |
670f3923 | 487 | { |
0539ab63 | 488 | YYDPRINTF ((Perl_debug_log, "(freeing op)\n")); |
8c63ea58 GG |
489 | if (ps->compcv != PL_compcv) { |
490 | PL_compcv = ps->compcv; | |
491 | PAD_SET_CUR_NOSAVE(CvPADLIST(PL_compcv), 1); | |
718a7425 | 492 | } |
1654d593 | 493 | op_free(ps->val.opval); |
0539ab63 | 494 | } |
8c63ea58 | 495 | SvREFCNT_dec(ps->compcv); |
0de566d7 DM |
496 | YYPOPSTACK; |
497 | } | |
498 | YYABORT; | |
499 | } | |
500 | ||
5912531f DM |
501 | YYDSYMPRINTF ("Error: discarding", yytoken, &parser->yylval); |
502 | parser->yychar = YYEMPTY; | |
0de566d7 | 503 | |
93a17b20 | 504 | } |
0de566d7 DM |
505 | |
506 | /* Else will try to reuse lookahead token after shifting the error | |
507 | token. */ | |
508 | goto yyerrlab1; | |
509 | ||
510 | ||
511 | /*----------------------------------------------------. | |
512 | | yyerrlab1 -- error raised explicitly by an action. | | |
513 | `----------------------------------------------------*/ | |
514 | yyerrlab1: | |
5912531f | 515 | parser->yyerrstatus = 3; /* Each real token shifted decrements this. */ |
0de566d7 DM |
516 | |
517 | for (;;) { | |
518 | yyn = yypact[yystate]; | |
519 | if (yyn != YYPACT_NINF) { | |
520 | yyn += YYTERROR; | |
521 | if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) { | |
522 | yyn = yytable[yyn]; | |
523 | if (0 < yyn) | |
524 | break; | |
525 | } | |
526 | } | |
527 | ||
528 | /* Pop the current state because it cannot handle the error token. */ | |
22735491 | 529 | if (ps == parser->stack) |
0de566d7 DM |
530 | YYABORT; |
531 | ||
1654d593 | 532 | YYDSYMPRINTF ("Error: popping", yystos[ps->state], &ps->val); |
503de470 | 533 | LEAVE_SCOPE(ps->savestack_ix); |
1654d593 | 534 | if (yy_type_tab[yystos[ps->state]] == toketype_opval && ps->val.opval) { |
0539ab63 | 535 | YYDPRINTF ((Perl_debug_log, "(freeing op)\n")); |
8c63ea58 GG |
536 | if (ps->compcv != PL_compcv) { |
537 | PL_compcv = ps->compcv; | |
538 | PAD_SET_CUR_NOSAVE(CvPADLIST(PL_compcv), 1); | |
718a7425 | 539 | } |
1654d593 | 540 | op_free(ps->val.opval); |
0539ab63 | 541 | } |
8c63ea58 | 542 | SvREFCNT_dec(ps->compcv); |
1654d593 DM |
543 | YYPOPSTACK; |
544 | yystate = ps->state; | |
0de566d7 | 545 | |
1654d593 | 546 | YY_STACK_PRINT(parser); |
93a17b20 | 547 | } |
0de566d7 DM |
548 | |
549 | if (yyn == YYFINAL) | |
550 | YYACCEPT; | |
551 | ||
552 | YYDPRINTF ((Perl_debug_log, "Shifting error token, ")); | |
553 | ||
1654d593 DM |
554 | YYPUSHSTACK; |
555 | ps->state = yyn; | |
5912531f | 556 | ps->val = parser->yylval; |
ec8ec19f | 557 | ps->compcv = (CV*)SvREFCNT_inc(PL_compcv); |
503de470 | 558 | ps->savestack_ix = PL_savestack_ix; |
9388183f | 559 | #ifdef DEBUGGING |
1654d593 | 560 | ps->name ="<err>"; |
9388183f | 561 | #endif |
0de566d7 | 562 | |
0de566d7 DM |
563 | goto yynewstate; |
564 | ||
565 | ||
566 | /*-------------------------------------. | |
567 | | yyacceptlab -- YYACCEPT comes here. | | |
568 | `-------------------------------------*/ | |
569 | yyacceptlab: | |
570 | yyresult = 0; | |
8c63ea58 GG |
571 | for (ps=parser->ps; ps > parser->stack; ps--) { |
572 | SvREFCNT_dec(ps->compcv); | |
573 | } | |
22735491 | 574 | parser->ps = parser->stack; /* disable cleanup */ |
0de566d7 DM |
575 | goto yyreturn; |
576 | ||
577 | /*-----------------------------------. | |
578 | | yyabortlab -- YYABORT comes here. | | |
579 | `-----------------------------------*/ | |
580 | yyabortlab: | |
581 | yyresult = 1; | |
582 | goto yyreturn; | |
583 | ||
0de566d7 | 584 | yyreturn: |
e3abe207 | 585 | LEAVE; /* force parser stack cleanup before we return */ |
0de566d7 | 586 | return yyresult; |
e1f15930 | 587 | } |
66610fdd RGS |
588 | |
589 | /* | |
14d04a33 | 590 | * ex: set ts=8 sts=4 sw=4 et: |
37442d52 | 591 | */ |