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 DM |
21 | * |
22 | * Note that this file is also #included in madly.c, to allow compilation | |
23 | * of a second parser, Perl_madparse, that is identical to Perl_yyparse, | |
f05e27e5 DM |
24 | * but which includes extra code for dumping the parse tree. |
25 | * This is controlled by the PERL_IN_MADLY_C define. | |
0de566d7 DM |
26 | */ |
27 | ||
79072805 | 28 | #include "EXTERN.h" |
864dbfa3 | 29 | #define PERL_IN_PERLY_C |
79072805 | 30 | #include "perl.h" |
09bef843 | 31 | |
3797f23d DM |
32 | typedef unsigned char yytype_uint8; |
33 | typedef signed char yytype_int8; | |
34 | typedef unsigned short int yytype_uint16; | |
35 | typedef short int yytype_int16; | |
0de566d7 DM |
36 | typedef signed char yysigned_char; |
37 | ||
28ac2b49 Z |
38 | /* YYINITDEPTH -- initial size of the parser's stacks. */ |
39 | #define YYINITDEPTH 200 | |
40 | ||
0de566d7 DM |
41 | #ifdef DEBUGGING |
42 | # define YYDEBUG 1 | |
93a17b20 | 43 | #else |
0de566d7 | 44 | # define YYDEBUG 0 |
93a17b20 | 45 | #endif |
09bef843 | 46 | |
f05e27e5 DM |
47 | /* contains all the parser state tables; auto-generated from perly.y */ |
48 | #include "perly.tab" | |
0de566d7 DM |
49 | |
50 | # define YYSIZE_T size_t | |
51 | ||
0de566d7 | 52 | #define YYEOF 0 |
07a06489 | 53 | #define YYTERROR 1 |
0de566d7 DM |
54 | |
55 | #define YYACCEPT goto yyacceptlab | |
56 | #define YYABORT goto yyabortlab | |
57 | #define YYERROR goto yyerrlab1 | |
58 | ||
0de566d7 | 59 | /* Enable debugging if requested. */ |
9388183f | 60 | #ifdef DEBUGGING |
0de566d7 DM |
61 | |
62 | # define yydebug (DEBUG_p_TEST) | |
63 | ||
64 | # define YYFPRINTF PerlIO_printf | |
65 | ||
66 | # define YYDPRINTF(Args) \ | |
67 | do { \ | |
68 | if (yydebug) \ | |
69 | YYFPRINTF Args; \ | |
70 | } while (0) | |
71 | ||
9388183f | 72 | # define YYDSYMPRINTF(Title, Token, Value) \ |
0de566d7 DM |
73 | do { \ |
74 | if (yydebug) { \ | |
75 | YYFPRINTF (Perl_debug_log, "%s ", Title); \ | |
356f4fed | 76 | yysymprint (aTHX_ Perl_debug_log, Token, Value); \ |
0de566d7 DM |
77 | YYFPRINTF (Perl_debug_log, "\n"); \ |
78 | } \ | |
79 | } while (0) | |
80 | ||
81 | /*--------------------------------. | |
82 | | Print this symbol on YYOUTPUT. | | |
83 | `--------------------------------*/ | |
84 | ||
85 | static void | |
356f4fed | 86 | yysymprint(pTHX_ PerlIO * const yyoutput, int yytype, const YYSTYPE * const yyvaluep) |
0de566d7 | 87 | { |
0de566d7 DM |
88 | if (yytype < YYNTOKENS) { |
89 | YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); | |
90 | # ifdef YYPRINT | |
91 | YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); | |
9388183f | 92 | # else |
e4584336 | 93 | YYFPRINTF (yyoutput, "0x%"UVxf, (UV)yyvaluep->ival); |
0de566d7 DM |
94 | # endif |
95 | } | |
96 | else | |
97 | YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); | |
98 | ||
0de566d7 DM |
99 | YYFPRINTF (yyoutput, ")"); |
100 | } | |
101 | ||
102 | ||
9388183f | 103 | /* yy_stack_print() |
1654d593 DM |
104 | * print the top 8 items on the parse stack. |
105 | */ | |
0de566d7 DM |
106 | |
107 | static void | |
1654d593 | 108 | yy_stack_print (pTHX_ const yy_parser *parser) |
0de566d7 | 109 | { |
1654d593 | 110 | const yy_stack_frame *ps, *min; |
9388183f | 111 | |
2d29f438 | 112 | min = parser->ps - 8 + 1; |
22735491 DM |
113 | if (min <= parser->stack) |
114 | min = parser->stack + 1; | |
9388183f CB |
115 | |
116 | PerlIO_printf(Perl_debug_log, "\nindex:"); | |
1654d593 | 117 | for (ps = min; ps <= parser->ps; ps++) |
00c0e1ee | 118 | PerlIO_printf(Perl_debug_log, " %8d", (int)(ps - parser->stack)); |
1654d593 | 119 | |
9388183f | 120 | PerlIO_printf(Perl_debug_log, "\nstate:"); |
1654d593 DM |
121 | for (ps = min; ps <= parser->ps; ps++) |
122 | PerlIO_printf(Perl_debug_log, " %8d", ps->state); | |
123 | ||
9388183f | 124 | PerlIO_printf(Perl_debug_log, "\ntoken:"); |
1654d593 DM |
125 | for (ps = min; ps <= parser->ps; ps++) |
126 | PerlIO_printf(Perl_debug_log, " %8.8s", ps->name); | |
127 | ||
9388183f | 128 | PerlIO_printf(Perl_debug_log, "\nvalue:"); |
1654d593 DM |
129 | for (ps = min; ps <= parser->ps; ps++) { |
130 | switch (yy_type_tab[yystos[ps->state]]) { | |
d5c6462e | 131 | case toketype_opval: |
21612876 | 132 | PerlIO_printf(Perl_debug_log, " %8.8s", |
1654d593 DM |
133 | ps->val.opval |
134 | ? PL_op_name[ps->val.opval->op_type] | |
670f3923 | 135 | : "(Nullop)" |
21612876 | 136 | ); |
d5c6462e DM |
137 | break; |
138 | #ifndef PERL_IN_MADLY_C | |
d5c6462e DM |
139 | case toketype_i_tkval: |
140 | #endif | |
141 | case toketype_ival: | |
1654d593 | 142 | PerlIO_printf(Perl_debug_log, " %8"IVdf, (IV)ps->val.ival); |
d5c6462e DM |
143 | break; |
144 | default: | |
1654d593 | 145 | PerlIO_printf(Perl_debug_log, " %8"UVxf, (UV)ps->val.ival); |
d5c6462e | 146 | } |
21612876 | 147 | } |
9388183f | 148 | PerlIO_printf(Perl_debug_log, "\n\n"); |
0de566d7 DM |
149 | } |
150 | ||
1654d593 DM |
151 | # define YY_STACK_PRINT(parser) \ |
152 | do { \ | |
153 | if (yydebug && DEBUG_v_TEST) \ | |
154 | yy_stack_print (aTHX_ parser); \ | |
0de566d7 DM |
155 | } while (0) |
156 | ||
09bef843 | 157 | |
0de566d7 DM |
158 | /*------------------------------------------------. |
159 | | Report that the YYRULE is going to be reduced. | | |
160 | `------------------------------------------------*/ | |
161 | ||
162 | static void | |
163 | yy_reduce_print (pTHX_ int yyrule) | |
164 | { | |
165 | int yyi; | |
df35152e | 166 | const unsigned int yylineno = yyrline[yyrule]; |
0de566d7 DM |
167 | YYFPRINTF (Perl_debug_log, "Reducing stack by rule %d (line %u), ", |
168 | yyrule - 1, yylineno); | |
169 | /* Print the symbols being reduced, and their result. */ | |
170 | for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++) | |
171 | YYFPRINTF (Perl_debug_log, "%s ", yytname [yyrhs[yyi]]); | |
172 | YYFPRINTF (Perl_debug_log, "-> %s\n", yytname [yyr1[yyrule]]); | |
173 | } | |
174 | ||
175 | # define YY_REDUCE_PRINT(Rule) \ | |
176 | do { \ | |
177 | if (yydebug) \ | |
178 | yy_reduce_print (aTHX_ Rule); \ | |
179 | } while (0) | |
180 | ||
181 | #else /* !DEBUGGING */ | |
182 | # define YYDPRINTF(Args) | |
9388183f | 183 | # define YYDSYMPRINTF(Title, Token, Value) |
1654d593 | 184 | # define YY_STACK_PRINT(parser) |
0de566d7 DM |
185 | # define YY_REDUCE_PRINT(Rule) |
186 | #endif /* !DEBUGGING */ | |
187 | ||
718a7425 DM |
188 | /* called during cleanup (via SAVEDESTRUCTOR_X) to free any items on the |
189 | * parse stack, thus avoiding leaks if we die */ | |
190 | ||
191 | static void | |
22735491 | 192 | S_clear_yystack(pTHX_ const yy_parser *parser) |
718a7425 | 193 | { |
1654d593 | 194 | yy_stack_frame *ps = parser->ps; |
0934c9d9 | 195 | int i = 0; |
718a7425 | 196 | |
28ac2b49 | 197 | if (!parser->stack) |
718a7425 | 198 | return; |
1654d593 | 199 | |
718a7425 | 200 | YYDPRINTF ((Perl_debug_log, "clearing the parse stack\n")); |
670f3923 | 201 | |
8c63ea58 GG |
202 | for (i=0; i< parser->yylen; i++) { |
203 | SvREFCNT_dec(ps[-i].compcv); | |
204 | } | |
0aded6e1 | 205 | ps -= parser->yylen; |
670f3923 DM |
206 | |
207 | /* now free whole the stack, including the just-reduced ops */ | |
208 | ||
22735491 | 209 | while (ps > parser->stack) { |
503de470 | 210 | LEAVE_SCOPE(ps->savestack_ix); |
1654d593 DM |
211 | if (yy_type_tab[yystos[ps->state]] == toketype_opval |
212 | && ps->val.opval) | |
670f3923 | 213 | { |
8c63ea58 GG |
214 | if (ps->compcv != PL_compcv) { |
215 | PL_compcv = ps->compcv; | |
216 | PAD_SET_CUR_NOSAVE(CvPADLIST(PL_compcv), 1); | |
718a7425 DM |
217 | } |
218 | YYDPRINTF ((Perl_debug_log, "(freeing op)\n")); | |
571a568a | 219 | op_free(ps->val.opval); |
718a7425 | 220 | } |
8c63ea58 | 221 | SvREFCNT_dec(ps->compcv); |
1654d593 | 222 | ps--; |
718a7425 | 223 | } |
28ac2b49 Z |
224 | |
225 | Safefree(parser->stack); | |
718a7425 DM |
226 | } |
227 | ||
718a7425 | 228 | |
0de566d7 DM |
229 | /*----------. |
230 | | yyparse. | | |
231 | `----------*/ | |
232 | ||
79072805 | 233 | int |
bc463c31 | 234 | #ifdef PERL_IN_MADLY_C |
28ac2b49 | 235 | Perl_madparse (pTHX_ int gramtype) |
bc463c31 | 236 | #else |
28ac2b49 | 237 | Perl_yyparse (pTHX_ int gramtype) |
bc463c31 | 238 | #endif |
79072805 | 239 | { |
97aff369 | 240 | dVAR; |
eb578fdb KW |
241 | int yystate; |
242 | int yyn; | |
0de566d7 DM |
243 | int yyresult; |
244 | ||
0de566d7 | 245 | /* Lookahead token as an internal (translated) token number. */ |
714c8e96 | 246 | int yytoken = 0; |
0de566d7 | 247 | |
eb578fdb KW |
248 | yy_parser *parser; /* the parser object */ |
249 | yy_stack_frame *ps; /* current parser stack frame */ | |
a0d0e21e | 250 | |
1654d593 DM |
251 | #define YYPOPSTACK parser->ps = --ps |
252 | #define YYPUSHSTACK parser->ps = ++ps | |
0de566d7 | 253 | |
acdf0a21 | 254 | /* The variable used to return semantic value and location from the |
5912531f | 255 | action routines: ie $$. */ |
0de566d7 DM |
256 | YYSTYPE yyval; |
257 | ||
bc463c31 DM |
258 | #ifndef PERL_IN_MADLY_C |
259 | # ifdef PERL_MAD | |
00e74f14 | 260 | if (PL_madskills) |
28ac2b49 | 261 | return madparse(gramtype); |
bc463c31 | 262 | # endif |
81d86705 NC |
263 | #endif |
264 | ||
0de566d7 DM |
265 | YYDPRINTF ((Perl_debug_log, "Starting parse\n")); |
266 | ||
acdf0a21 | 267 | parser = PL_parser; |
1654d593 | 268 | |
28ac2b49 Z |
269 | ENTER; /* force parser state cleanup/restoration before we return */ |
270 | SAVEPPTR(parser->yylval.pval); | |
271 | SAVEINT(parser->yychar); | |
272 | SAVEINT(parser->yyerrstatus); | |
273 | SAVEINT(parser->stack_size); | |
274 | SAVEINT(parser->yylen); | |
275 | SAVEVPTR(parser->stack); | |
276 | SAVEVPTR(parser->ps); | |
277 | ||
278 | /* initialise state for this parse */ | |
279 | parser->yychar = gramtype; | |
280 | parser->yyerrstatus = 0; | |
281 | parser->stack_size = YYINITDEPTH; | |
282 | parser->yylen = 0; | |
283 | Newx(parser->stack, YYINITDEPTH, yy_stack_frame); | |
284 | ps = parser->ps = parser->stack; | |
285 | ps->state = 0; | |
e3abe207 | 286 | SAVEDESTRUCTOR_X(S_clear_yystack, parser); |
0de566d7 | 287 | |
0de566d7 DM |
288 | /*------------------------------------------------------------. |
289 | | yynewstate -- Push a new state, which is found in yystate. | | |
290 | `------------------------------------------------------------*/ | |
291 | yynewstate: | |
0de566d7 | 292 | |
1654d593 | 293 | yystate = ps->state; |
05a03161 | 294 | |
670f3923 | 295 | YYDPRINTF ((Perl_debug_log, "Entering state %d\n", yystate)); |
0de566d7 | 296 | |
5912531f | 297 | parser->yylen = 0; |
0de566d7 | 298 | |
1654d593 | 299 | { |
22735491 | 300 | size_t size = ps - parser->stack + 1; |
0de566d7 | 301 | |
1654d593 DM |
302 | /* grow the stack? We always leave 1 spare slot, |
303 | * in case of a '' -> 'foo' reduction */ | |
0de566d7 | 304 | |
85c508c3 | 305 | if (size >= (size_t)parser->stack_size - 1) { |
1654d593 DM |
306 | /* this will croak on insufficient memory */ |
307 | parser->stack_size *= 2; | |
22735491 DM |
308 | Renew(parser->stack, parser->stack_size, yy_stack_frame); |
309 | ps = parser->ps = parser->stack + size -1; | |
670f3923 | 310 | |
1654d593 DM |
311 | YYDPRINTF((Perl_debug_log, |
312 | "parser stack size increased to %lu frames\n", | |
313 | (unsigned long int)parser->stack_size)); | |
314 | } | |
93a17b20 | 315 | } |
0de566d7 | 316 | |
0de566d7 DM |
317 | /* Do appropriate processing given the current state. */ |
318 | /* Read a lookahead token if we need one and don't already have one. */ | |
0de566d7 DM |
319 | |
320 | /* First try to decide what to do without reference to lookahead token. */ | |
321 | ||
322 | yyn = yypact[yystate]; | |
323 | if (yyn == YYPACT_NINF) | |
324 | goto yydefault; | |
325 | ||
326 | /* Not known => get a lookahead token if don't already have one. */ | |
327 | ||
328 | /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ | |
5912531f | 329 | if (parser->yychar == YYEMPTY) { |
0de566d7 | 330 | YYDPRINTF ((Perl_debug_log, "Reading a token: ")); |
f05e27e5 | 331 | #ifdef PERL_IN_MADLY_C |
5912531f | 332 | parser->yychar = PL_madskills ? madlex() : yylex(); |
f05e27e5 | 333 | #else |
5912531f | 334 | parser->yychar = yylex(); |
81d86705 | 335 | #endif |
bc463c31 | 336 | |
12fbd33b | 337 | # ifdef EBCDIC |
5912531f DM |
338 | if (parser->yychar >= 0 && parser->yychar < 255) { |
339 | parser->yychar = NATIVE_TO_ASCII(parser->yychar); | |
12fbd33b DM |
340 | } |
341 | # endif | |
0de566d7 DM |
342 | } |
343 | ||
5912531f DM |
344 | if (parser->yychar <= YYEOF) { |
345 | parser->yychar = yytoken = YYEOF; | |
0de566d7 | 346 | YYDPRINTF ((Perl_debug_log, "Now at end of input.\n")); |
93a17b20 | 347 | } |
0de566d7 | 348 | else { |
5912531f DM |
349 | yytoken = YYTRANSLATE (parser->yychar); |
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 | ||
0de566d7 DM |
425 | |
426 | #define dep() deprecate("\"do\" to call subroutines") | |
f05e27e5 | 427 | |
bc463c31 | 428 | #ifdef PERL_IN_MADLY_C |
f05e27e5 DM |
429 | # define IVAL(i) (i)->tk_lval.ival |
430 | # define PVAL(p) (p)->tk_lval.pval | |
431 | # define TOKEN_GETMAD(a,b,c) token_getmad((a),(b),(c)) | |
432 | # define TOKEN_FREE(a) token_free(a) | |
433 | # define OP_GETMAD(a,b,c) op_getmad((a),(b),(c)) | |
434 | # define IF_MAD(a,b) (a) | |
435 | # define DO_MAD(a) a | |
436 | # define MAD | |
bc463c31 | 437 | #else |
f05e27e5 DM |
438 | # define IVAL(i) (i) |
439 | # define PVAL(p) (p) | |
440 | # define TOKEN_GETMAD(a,b,c) | |
441 | # define TOKEN_FREE(a) | |
442 | # define OP_GETMAD(a,b,c) | |
443 | # define IF_MAD(a,b) (b) | |
444 | # define DO_MAD(a) | |
445 | # undef MAD | |
bc463c31 | 446 | #endif |
7b57b0ea | 447 | |
f05e27e5 DM |
448 | /* contains all the rule actions; auto-generated from perly.y */ |
449 | #include "perly.act" | |
450 | ||
93a17b20 | 451 | } |
0de566d7 | 452 | |
670f3923 DM |
453 | { |
454 | int i; | |
5912531f | 455 | for (i=0; i< parser->yylen; i++) { |
8c63ea58 | 456 | SvREFCNT_dec(ps[-i].compcv); |
670f3923 DM |
457 | } |
458 | } | |
459 | ||
5912531f | 460 | parser->ps = ps -= (parser->yylen-1); |
0de566d7 | 461 | |
05a03161 DM |
462 | /* Now shift the result of the reduction. Determine what state |
463 | that goes to, based on the state we popped back to and the rule | |
464 | number reduced by. */ | |
465 | ||
1654d593 | 466 | ps->val = yyval; |
ec8ec19f | 467 | ps->compcv = (CV*)SvREFCNT_inc(PL_compcv); |
503de470 | 468 | ps->savestack_ix = PL_savestack_ix; |
9388183f | 469 | #ifdef DEBUGGING |
1654d593 | 470 | ps->name = (const char *)(yytname [yyr1[yyn]]); |
9388183f | 471 | #endif |
0de566d7 DM |
472 | |
473 | yyn = yyr1[yyn]; | |
474 | ||
1654d593 DM |
475 | yystate = yypgoto[yyn - YYNTOKENS] + ps[-1].state; |
476 | if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == ps[-1].state) | |
0de566d7 | 477 | yystate = yytable[yystate]; |
93a17b20 | 478 | else |
0de566d7 | 479 | yystate = yydefgoto[yyn - YYNTOKENS]; |
1654d593 | 480 | ps->state = yystate; |
05a03161 | 481 | |
0de566d7 DM |
482 | goto yynewstate; |
483 | ||
484 | ||
485 | /*------------------------------------. | |
486 | | yyerrlab -- here on detecting error | | |
487 | `------------------------------------*/ | |
488 | yyerrlab: | |
489 | /* If not already recovering from an error, report this error. */ | |
5912531f | 490 | if (!parser->yyerrstatus) { |
07a06489 | 491 | yyerror ("syntax error"); |
93a17b20 | 492 | } |
0de566d7 DM |
493 | |
494 | ||
5912531f | 495 | if (parser->yyerrstatus == 3) { |
0de566d7 DM |
496 | /* If just tried and failed to reuse lookahead token after an |
497 | error, discard it. */ | |
498 | ||
499 | /* Return failure if at end of input. */ | |
5912531f | 500 | if (parser->yychar == YYEOF) { |
0de566d7 | 501 | /* Pop the error token. */ |
8c63ea58 | 502 | SvREFCNT_dec(ps->compcv); |
0de566d7 DM |
503 | YYPOPSTACK; |
504 | /* Pop the rest of the stack. */ | |
22735491 | 505 | while (ps > parser->stack) { |
1654d593 | 506 | YYDSYMPRINTF ("Error: popping", yystos[ps->state], &ps->val); |
503de470 | 507 | LEAVE_SCOPE(ps->savestack_ix); |
1654d593 DM |
508 | if (yy_type_tab[yystos[ps->state]] == toketype_opval |
509 | && ps->val.opval) | |
670f3923 | 510 | { |
0539ab63 | 511 | YYDPRINTF ((Perl_debug_log, "(freeing op)\n")); |
8c63ea58 GG |
512 | if (ps->compcv != PL_compcv) { |
513 | PL_compcv = ps->compcv; | |
514 | PAD_SET_CUR_NOSAVE(CvPADLIST(PL_compcv), 1); | |
718a7425 | 515 | } |
1654d593 | 516 | op_free(ps->val.opval); |
0539ab63 | 517 | } |
8c63ea58 | 518 | SvREFCNT_dec(ps->compcv); |
0de566d7 DM |
519 | YYPOPSTACK; |
520 | } | |
521 | YYABORT; | |
522 | } | |
523 | ||
5912531f | 524 | YYDSYMPRINTF ("Error: discarding", yytoken, &parser->yylval); |
0e38ac78 GG |
525 | if (yy_type_tab[yytoken] == toketype_opval) |
526 | op_free(parser->yylval.opval); | |
5912531f | 527 | parser->yychar = YYEMPTY; |
0de566d7 | 528 | |
93a17b20 | 529 | } |
0de566d7 DM |
530 | |
531 | /* Else will try to reuse lookahead token after shifting the error | |
532 | token. */ | |
533 | goto yyerrlab1; | |
534 | ||
535 | ||
536 | /*----------------------------------------------------. | |
537 | | yyerrlab1 -- error raised explicitly by an action. | | |
538 | `----------------------------------------------------*/ | |
539 | yyerrlab1: | |
5912531f | 540 | parser->yyerrstatus = 3; /* Each real token shifted decrements this. */ |
0de566d7 DM |
541 | |
542 | for (;;) { | |
543 | yyn = yypact[yystate]; | |
544 | if (yyn != YYPACT_NINF) { | |
545 | yyn += YYTERROR; | |
546 | if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) { | |
547 | yyn = yytable[yyn]; | |
548 | if (0 < yyn) | |
549 | break; | |
550 | } | |
551 | } | |
552 | ||
553 | /* Pop the current state because it cannot handle the error token. */ | |
22735491 | 554 | if (ps == parser->stack) |
0de566d7 DM |
555 | YYABORT; |
556 | ||
1654d593 | 557 | YYDSYMPRINTF ("Error: popping", yystos[ps->state], &ps->val); |
503de470 | 558 | LEAVE_SCOPE(ps->savestack_ix); |
1654d593 | 559 | if (yy_type_tab[yystos[ps->state]] == toketype_opval && ps->val.opval) { |
0539ab63 | 560 | YYDPRINTF ((Perl_debug_log, "(freeing op)\n")); |
8c63ea58 GG |
561 | if (ps->compcv != PL_compcv) { |
562 | PL_compcv = ps->compcv; | |
563 | PAD_SET_CUR_NOSAVE(CvPADLIST(PL_compcv), 1); | |
718a7425 | 564 | } |
1654d593 | 565 | op_free(ps->val.opval); |
0539ab63 | 566 | } |
8c63ea58 | 567 | SvREFCNT_dec(ps->compcv); |
1654d593 DM |
568 | YYPOPSTACK; |
569 | yystate = ps->state; | |
0de566d7 | 570 | |
1654d593 | 571 | YY_STACK_PRINT(parser); |
93a17b20 | 572 | } |
0de566d7 DM |
573 | |
574 | if (yyn == YYFINAL) | |
575 | YYACCEPT; | |
576 | ||
577 | YYDPRINTF ((Perl_debug_log, "Shifting error token, ")); | |
578 | ||
1654d593 DM |
579 | YYPUSHSTACK; |
580 | ps->state = yyn; | |
5912531f | 581 | ps->val = parser->yylval; |
ec8ec19f | 582 | ps->compcv = (CV*)SvREFCNT_inc(PL_compcv); |
503de470 | 583 | ps->savestack_ix = PL_savestack_ix; |
9388183f | 584 | #ifdef DEBUGGING |
1654d593 | 585 | ps->name ="<err>"; |
9388183f | 586 | #endif |
0de566d7 | 587 | |
0de566d7 DM |
588 | goto yynewstate; |
589 | ||
590 | ||
591 | /*-------------------------------------. | |
592 | | yyacceptlab -- YYACCEPT comes here. | | |
593 | `-------------------------------------*/ | |
594 | yyacceptlab: | |
595 | yyresult = 0; | |
8c63ea58 GG |
596 | for (ps=parser->ps; ps > parser->stack; ps--) { |
597 | SvREFCNT_dec(ps->compcv); | |
598 | } | |
22735491 | 599 | parser->ps = parser->stack; /* disable cleanup */ |
0de566d7 DM |
600 | goto yyreturn; |
601 | ||
602 | /*-----------------------------------. | |
603 | | yyabortlab -- YYABORT comes here. | | |
604 | `-----------------------------------*/ | |
605 | yyabortlab: | |
606 | yyresult = 1; | |
607 | goto yyreturn; | |
608 | ||
0de566d7 | 609 | yyreturn: |
e3abe207 | 610 | LEAVE; /* force parser stack cleanup before we return */ |
0de566d7 | 611 | return yyresult; |
e1f15930 | 612 | } |
66610fdd RGS |
613 | |
614 | /* | |
615 | * Local variables: | |
616 | * c-indentation-style: bsd | |
617 | * c-basic-offset: 4 | |
14d04a33 | 618 | * indent-tabs-mode: nil |
66610fdd RGS |
619 | * End: |
620 | * | |
14d04a33 | 621 | * ex: set ts=8 sts=4 sw=4 et: |
37442d52 | 622 | */ |