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 | ||
599f1ac6 FC |
41 | #ifdef YYDEBUG |
42 | # undef YYDEBUG | |
43 | #endif | |
44 | #ifdef DEBUGGING | |
45 | # define YYDEBUG 1 | |
46 | #else | |
47 | # define YYDEBUG 0 | |
48 | #endif | |
49 | ||
b3045d9c FC |
50 | #ifndef YY_NULL |
51 | # define YY_NULL 0 | |
93a17b20 | 52 | #endif |
09bef843 | 53 | |
f05e27e5 DM |
54 | /* contains all the parser state tables; auto-generated from perly.y */ |
55 | #include "perly.tab" | |
0de566d7 DM |
56 | |
57 | # define YYSIZE_T size_t | |
58 | ||
0de566d7 | 59 | #define YYEOF 0 |
07a06489 | 60 | #define YYTERROR 1 |
0de566d7 DM |
61 | |
62 | #define YYACCEPT goto yyacceptlab | |
63 | #define YYABORT goto yyabortlab | |
64 | #define YYERROR goto yyerrlab1 | |
65 | ||
0de566d7 | 66 | /* Enable debugging if requested. */ |
9388183f | 67 | #ifdef DEBUGGING |
0de566d7 DM |
68 | |
69 | # define yydebug (DEBUG_p_TEST) | |
70 | ||
71 | # define YYFPRINTF PerlIO_printf | |
72 | ||
73 | # define YYDPRINTF(Args) \ | |
74 | do { \ | |
75 | if (yydebug) \ | |
76 | YYFPRINTF Args; \ | |
77 | } while (0) | |
78 | ||
9388183f | 79 | # define YYDSYMPRINTF(Title, Token, Value) \ |
0de566d7 DM |
80 | do { \ |
81 | if (yydebug) { \ | |
82 | YYFPRINTF (Perl_debug_log, "%s ", Title); \ | |
356f4fed | 83 | yysymprint (aTHX_ Perl_debug_log, Token, Value); \ |
0de566d7 DM |
84 | YYFPRINTF (Perl_debug_log, "\n"); \ |
85 | } \ | |
86 | } while (0) | |
87 | ||
88 | /*--------------------------------. | |
89 | | Print this symbol on YYOUTPUT. | | |
90 | `--------------------------------*/ | |
91 | ||
92 | static void | |
356f4fed | 93 | yysymprint(pTHX_ PerlIO * const yyoutput, int yytype, const YYSTYPE * const yyvaluep) |
0de566d7 | 94 | { |
0de566d7 DM |
95 | if (yytype < YYNTOKENS) { |
96 | YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); | |
97 | # ifdef YYPRINT | |
98 | YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); | |
9388183f | 99 | # else |
e4584336 | 100 | YYFPRINTF (yyoutput, "0x%"UVxf, (UV)yyvaluep->ival); |
0de566d7 DM |
101 | # endif |
102 | } | |
103 | else | |
104 | YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); | |
105 | ||
0de566d7 DM |
106 | YYFPRINTF (yyoutput, ")"); |
107 | } | |
108 | ||
109 | ||
9388183f | 110 | /* yy_stack_print() |
1654d593 DM |
111 | * print the top 8 items on the parse stack. |
112 | */ | |
0de566d7 DM |
113 | |
114 | static void | |
1654d593 | 115 | yy_stack_print (pTHX_ const yy_parser *parser) |
0de566d7 | 116 | { |
1654d593 | 117 | const yy_stack_frame *ps, *min; |
9388183f | 118 | |
2d29f438 | 119 | min = parser->ps - 8 + 1; |
22735491 DM |
120 | if (min <= parser->stack) |
121 | min = parser->stack + 1; | |
9388183f CB |
122 | |
123 | PerlIO_printf(Perl_debug_log, "\nindex:"); | |
1654d593 | 124 | for (ps = min; ps <= parser->ps; ps++) |
00c0e1ee | 125 | PerlIO_printf(Perl_debug_log, " %8d", (int)(ps - parser->stack)); |
1654d593 | 126 | |
9388183f | 127 | PerlIO_printf(Perl_debug_log, "\nstate:"); |
1654d593 DM |
128 | for (ps = min; ps <= parser->ps; ps++) |
129 | PerlIO_printf(Perl_debug_log, " %8d", ps->state); | |
130 | ||
9388183f | 131 | PerlIO_printf(Perl_debug_log, "\ntoken:"); |
1654d593 DM |
132 | for (ps = min; ps <= parser->ps; ps++) |
133 | PerlIO_printf(Perl_debug_log, " %8.8s", ps->name); | |
134 | ||
9388183f | 135 | PerlIO_printf(Perl_debug_log, "\nvalue:"); |
1654d593 DM |
136 | for (ps = min; ps <= parser->ps; ps++) { |
137 | switch (yy_type_tab[yystos[ps->state]]) { | |
d5c6462e | 138 | case toketype_opval: |
21612876 | 139 | PerlIO_printf(Perl_debug_log, " %8.8s", |
1654d593 DM |
140 | ps->val.opval |
141 | ? PL_op_name[ps->val.opval->op_type] | |
670f3923 | 142 | : "(Nullop)" |
21612876 | 143 | ); |
d5c6462e DM |
144 | break; |
145 | #ifndef PERL_IN_MADLY_C | |
d5c6462e DM |
146 | case toketype_i_tkval: |
147 | #endif | |
148 | case toketype_ival: | |
1654d593 | 149 | PerlIO_printf(Perl_debug_log, " %8"IVdf, (IV)ps->val.ival); |
d5c6462e DM |
150 | break; |
151 | default: | |
1654d593 | 152 | PerlIO_printf(Perl_debug_log, " %8"UVxf, (UV)ps->val.ival); |
d5c6462e | 153 | } |
21612876 | 154 | } |
9388183f | 155 | PerlIO_printf(Perl_debug_log, "\n\n"); |
0de566d7 DM |
156 | } |
157 | ||
1654d593 DM |
158 | # define YY_STACK_PRINT(parser) \ |
159 | do { \ | |
160 | if (yydebug && DEBUG_v_TEST) \ | |
161 | yy_stack_print (aTHX_ parser); \ | |
0de566d7 DM |
162 | } while (0) |
163 | ||
09bef843 | 164 | |
0de566d7 DM |
165 | /*------------------------------------------------. |
166 | | Report that the YYRULE is going to be reduced. | | |
167 | `------------------------------------------------*/ | |
168 | ||
169 | static void | |
170 | yy_reduce_print (pTHX_ int yyrule) | |
171 | { | |
172 | int yyi; | |
df35152e | 173 | const unsigned int yylineno = yyrline[yyrule]; |
0de566d7 DM |
174 | YYFPRINTF (Perl_debug_log, "Reducing stack by rule %d (line %u), ", |
175 | yyrule - 1, yylineno); | |
176 | /* Print the symbols being reduced, and their result. */ | |
177 | for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++) | |
178 | YYFPRINTF (Perl_debug_log, "%s ", yytname [yyrhs[yyi]]); | |
179 | YYFPRINTF (Perl_debug_log, "-> %s\n", yytname [yyr1[yyrule]]); | |
180 | } | |
181 | ||
182 | # define YY_REDUCE_PRINT(Rule) \ | |
183 | do { \ | |
184 | if (yydebug) \ | |
185 | yy_reduce_print (aTHX_ Rule); \ | |
186 | } while (0) | |
187 | ||
188 | #else /* !DEBUGGING */ | |
189 | # define YYDPRINTF(Args) | |
9388183f | 190 | # define YYDSYMPRINTF(Title, Token, Value) |
1654d593 | 191 | # define YY_STACK_PRINT(parser) |
0de566d7 DM |
192 | # define YY_REDUCE_PRINT(Rule) |
193 | #endif /* !DEBUGGING */ | |
194 | ||
718a7425 DM |
195 | /* called during cleanup (via SAVEDESTRUCTOR_X) to free any items on the |
196 | * parse stack, thus avoiding leaks if we die */ | |
197 | ||
198 | static void | |
22735491 | 199 | S_clear_yystack(pTHX_ const yy_parser *parser) |
718a7425 | 200 | { |
1654d593 | 201 | yy_stack_frame *ps = parser->ps; |
0934c9d9 | 202 | int i = 0; |
718a7425 | 203 | |
28ac2b49 | 204 | if (!parser->stack) |
718a7425 | 205 | return; |
1654d593 | 206 | |
718a7425 | 207 | YYDPRINTF ((Perl_debug_log, "clearing the parse stack\n")); |
670f3923 | 208 | |
8c63ea58 GG |
209 | for (i=0; i< parser->yylen; i++) { |
210 | SvREFCNT_dec(ps[-i].compcv); | |
211 | } | |
0aded6e1 | 212 | ps -= parser->yylen; |
670f3923 DM |
213 | |
214 | /* now free whole the stack, including the just-reduced ops */ | |
215 | ||
22735491 | 216 | while (ps > parser->stack) { |
503de470 | 217 | LEAVE_SCOPE(ps->savestack_ix); |
1654d593 DM |
218 | if (yy_type_tab[yystos[ps->state]] == toketype_opval |
219 | && ps->val.opval) | |
670f3923 | 220 | { |
8c63ea58 GG |
221 | if (ps->compcv != PL_compcv) { |
222 | PL_compcv = ps->compcv; | |
223 | PAD_SET_CUR_NOSAVE(CvPADLIST(PL_compcv), 1); | |
325e1816 | 224 | PL_comppad_name = PadlistNAMES(CvPADLIST(PL_compcv)); |
718a7425 DM |
225 | } |
226 | YYDPRINTF ((Perl_debug_log, "(freeing op)\n")); | |
571a568a | 227 | op_free(ps->val.opval); |
718a7425 | 228 | } |
8c63ea58 | 229 | SvREFCNT_dec(ps->compcv); |
1654d593 | 230 | ps--; |
718a7425 | 231 | } |
28ac2b49 Z |
232 | |
233 | Safefree(parser->stack); | |
718a7425 DM |
234 | } |
235 | ||
718a7425 | 236 | |
0de566d7 DM |
237 | /*----------. |
238 | | yyparse. | | |
239 | `----------*/ | |
240 | ||
79072805 | 241 | int |
bc463c31 | 242 | #ifdef PERL_IN_MADLY_C |
28ac2b49 | 243 | Perl_madparse (pTHX_ int gramtype) |
bc463c31 | 244 | #else |
28ac2b49 | 245 | Perl_yyparse (pTHX_ int gramtype) |
bc463c31 | 246 | #endif |
79072805 | 247 | { |
97aff369 | 248 | dVAR; |
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 | ||
bc463c31 DM |
266 | #ifndef PERL_IN_MADLY_C |
267 | # ifdef PERL_MAD | |
00e74f14 | 268 | if (PL_madskills) |
28ac2b49 | 269 | return madparse(gramtype); |
bc463c31 | 270 | # endif |
81d86705 NC |
271 | #endif |
272 | ||
0de566d7 DM |
273 | YYDPRINTF ((Perl_debug_log, "Starting parse\n")); |
274 | ||
acdf0a21 | 275 | parser = PL_parser; |
1654d593 | 276 | |
28ac2b49 Z |
277 | ENTER; /* force parser state cleanup/restoration before we return */ |
278 | SAVEPPTR(parser->yylval.pval); | |
279 | SAVEINT(parser->yychar); | |
280 | SAVEINT(parser->yyerrstatus); | |
281 | SAVEINT(parser->stack_size); | |
282 | SAVEINT(parser->yylen); | |
283 | SAVEVPTR(parser->stack); | |
284 | SAVEVPTR(parser->ps); | |
285 | ||
286 | /* initialise state for this parse */ | |
287 | parser->yychar = gramtype; | |
288 | parser->yyerrstatus = 0; | |
289 | parser->stack_size = YYINITDEPTH; | |
290 | parser->yylen = 0; | |
291 | Newx(parser->stack, YYINITDEPTH, yy_stack_frame); | |
292 | ps = parser->ps = parser->stack; | |
293 | ps->state = 0; | |
e3abe207 | 294 | SAVEDESTRUCTOR_X(S_clear_yystack, parser); |
0de566d7 | 295 | |
0de566d7 DM |
296 | /*------------------------------------------------------------. |
297 | | yynewstate -- Push a new state, which is found in yystate. | | |
298 | `------------------------------------------------------------*/ | |
299 | yynewstate: | |
0de566d7 | 300 | |
1654d593 | 301 | yystate = ps->state; |
05a03161 | 302 | |
670f3923 | 303 | YYDPRINTF ((Perl_debug_log, "Entering state %d\n", yystate)); |
0de566d7 | 304 | |
5912531f | 305 | parser->yylen = 0; |
0de566d7 | 306 | |
1654d593 | 307 | { |
22735491 | 308 | size_t size = ps - parser->stack + 1; |
0de566d7 | 309 | |
1654d593 DM |
310 | /* grow the stack? We always leave 1 spare slot, |
311 | * in case of a '' -> 'foo' reduction */ | |
0de566d7 | 312 | |
85c508c3 | 313 | if (size >= (size_t)parser->stack_size - 1) { |
1654d593 DM |
314 | /* this will croak on insufficient memory */ |
315 | parser->stack_size *= 2; | |
22735491 DM |
316 | Renew(parser->stack, parser->stack_size, yy_stack_frame); |
317 | ps = parser->ps = parser->stack + size -1; | |
670f3923 | 318 | |
1654d593 DM |
319 | YYDPRINTF((Perl_debug_log, |
320 | "parser stack size increased to %lu frames\n", | |
321 | (unsigned long int)parser->stack_size)); | |
322 | } | |
93a17b20 | 323 | } |
0de566d7 | 324 | |
0de566d7 DM |
325 | /* Do appropriate processing given the current state. */ |
326 | /* Read a lookahead token if we need one and don't already have one. */ | |
0de566d7 DM |
327 | |
328 | /* First try to decide what to do without reference to lookahead token. */ | |
329 | ||
330 | yyn = yypact[yystate]; | |
331 | if (yyn == YYPACT_NINF) | |
332 | goto yydefault; | |
333 | ||
334 | /* Not known => get a lookahead token if don't already have one. */ | |
335 | ||
336 | /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ | |
5912531f | 337 | if (parser->yychar == YYEMPTY) { |
0de566d7 | 338 | YYDPRINTF ((Perl_debug_log, "Reading a token: ")); |
f05e27e5 | 339 | #ifdef PERL_IN_MADLY_C |
5912531f | 340 | parser->yychar = PL_madskills ? madlex() : yylex(); |
f05e27e5 | 341 | #else |
5912531f | 342 | parser->yychar = yylex(); |
81d86705 | 343 | #endif |
bc463c31 | 344 | |
f4cd282c KW |
345 | /* perly.tab is shipped based on an ASCII system; if it were to be regenerated |
346 | * on a platform that doesn't use ASCII, this translation back would need to be | |
347 | * removed */ | |
12fbd33b | 348 | # ifdef EBCDIC |
5912531f | 349 | if (parser->yychar >= 0 && parser->yychar < 255) { |
f4cd282c | 350 | parser->yychar = NATIVE_TO_LATIN1(parser->yychar); |
12fbd33b DM |
351 | } |
352 | # endif | |
0de566d7 DM |
353 | } |
354 | ||
5912531f DM |
355 | if (parser->yychar <= YYEOF) { |
356 | parser->yychar = yytoken = YYEOF; | |
0de566d7 | 357 | YYDPRINTF ((Perl_debug_log, "Now at end of input.\n")); |
93a17b20 | 358 | } |
0de566d7 | 359 | else { |
5912531f DM |
360 | yytoken = YYTRANSLATE (parser->yychar); |
361 | YYDSYMPRINTF ("Next token is", yytoken, &parser->yylval); | |
93a17b20 | 362 | } |
771df094 | 363 | |
0de566d7 DM |
364 | /* If the proper action on seeing token YYTOKEN is to reduce or to |
365 | detect an error, take that action. */ | |
366 | yyn += yytoken; | |
367 | if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) | |
368 | goto yydefault; | |
369 | yyn = yytable[yyn]; | |
370 | if (yyn <= 0) { | |
371 | if (yyn == 0 || yyn == YYTABLE_NINF) | |
372 | goto yyerrlab; | |
373 | yyn = -yyn; | |
374 | goto yyreduce; | |
375 | } | |
7b57b0ea | 376 | |
0de566d7 DM |
377 | if (yyn == YYFINAL) |
378 | YYACCEPT; | |
771df094 | 379 | |
0de566d7 DM |
380 | /* Shift the lookahead token. */ |
381 | YYDPRINTF ((Perl_debug_log, "Shifting token %s, ", yytname[yytoken])); | |
382 | ||
383 | /* Discard the token being shifted unless it is eof. */ | |
5912531f DM |
384 | if (parser->yychar != YYEOF) |
385 | parser->yychar = YYEMPTY; | |
0de566d7 | 386 | |
1654d593 DM |
387 | YYPUSHSTACK; |
388 | ps->state = yyn; | |
5912531f | 389 | ps->val = parser->yylval; |
ec8ec19f | 390 | ps->compcv = (CV*)SvREFCNT_inc(PL_compcv); |
503de470 | 391 | ps->savestack_ix = PL_savestack_ix; |
9388183f | 392 | #ifdef DEBUGGING |
1654d593 | 393 | ps->name = (const char *)(yytname[yytoken]); |
9388183f | 394 | #endif |
0de566d7 | 395 | |
0de566d7 DM |
396 | /* Count tokens shifted since error; after three, turn off error |
397 | status. */ | |
5912531f DM |
398 | if (parser->yyerrstatus) |
399 | parser->yyerrstatus--; | |
0de566d7 | 400 | |
0de566d7 DM |
401 | goto yynewstate; |
402 | ||
403 | ||
404 | /*-----------------------------------------------------------. | |
405 | | yydefault -- do the default action for the current state. | | |
406 | `-----------------------------------------------------------*/ | |
407 | yydefault: | |
408 | yyn = yydefact[yystate]; | |
409 | if (yyn == 0) | |
410 | goto yyerrlab; | |
411 | goto yyreduce; | |
412 | ||
413 | ||
414 | /*-----------------------------. | |
415 | | yyreduce -- Do a reduction. | | |
416 | `-----------------------------*/ | |
417 | yyreduce: | |
418 | /* yyn is the number of a rule to reduce with. */ | |
5912531f | 419 | parser->yylen = yyr2[yyn]; |
0de566d7 DM |
420 | |
421 | /* If YYLEN is nonzero, implement the default value of the action: | |
a0288114 | 422 | "$$ = $1". |
0de566d7 DM |
423 | |
424 | Otherwise, the following line sets YYVAL to garbage. | |
425 | This behavior is undocumented and Bison | |
426 | users should not rely upon it. Assigning to YYVAL | |
427 | unconditionally makes the parser a bit smaller, and it avoids a | |
428 | GCC warning that YYVAL may be used uninitialized. */ | |
5912531f | 429 | yyval = ps[1-parser->yylen].val; |
0de566d7 | 430 | |
1654d593 | 431 | YY_STACK_PRINT(parser); |
0de566d7 | 432 | YY_REDUCE_PRINT (yyn); |
718a7425 | 433 | |
0de566d7 DM |
434 | switch (yyn) { |
435 | ||
bc463c31 | 436 | #ifdef PERL_IN_MADLY_C |
f05e27e5 DM |
437 | # define IVAL(i) (i)->tk_lval.ival |
438 | # define PVAL(p) (p)->tk_lval.pval | |
439 | # define TOKEN_GETMAD(a,b,c) token_getmad((a),(b),(c)) | |
440 | # define TOKEN_FREE(a) token_free(a) | |
441 | # define OP_GETMAD(a,b,c) op_getmad((a),(b),(c)) | |
442 | # define IF_MAD(a,b) (a) | |
443 | # define DO_MAD(a) a | |
444 | # define MAD | |
bc463c31 | 445 | #else |
f05e27e5 DM |
446 | # define IVAL(i) (i) |
447 | # define PVAL(p) (p) | |
448 | # define TOKEN_GETMAD(a,b,c) | |
449 | # define TOKEN_FREE(a) | |
450 | # define OP_GETMAD(a,b,c) | |
451 | # define IF_MAD(a,b) (b) | |
452 | # define DO_MAD(a) | |
453 | # undef MAD | |
bc463c31 | 454 | #endif |
7b57b0ea | 455 | |
f05e27e5 DM |
456 | /* contains all the rule actions; auto-generated from perly.y */ |
457 | #include "perly.act" | |
458 | ||
93a17b20 | 459 | } |
0de566d7 | 460 | |
670f3923 DM |
461 | { |
462 | int i; | |
5912531f | 463 | for (i=0; i< parser->yylen; i++) { |
8c63ea58 | 464 | SvREFCNT_dec(ps[-i].compcv); |
670f3923 DM |
465 | } |
466 | } | |
467 | ||
5912531f | 468 | parser->ps = ps -= (parser->yylen-1); |
0de566d7 | 469 | |
05a03161 DM |
470 | /* Now shift the result of the reduction. Determine what state |
471 | that goes to, based on the state we popped back to and the rule | |
472 | number reduced by. */ | |
473 | ||
1654d593 | 474 | ps->val = yyval; |
ec8ec19f | 475 | ps->compcv = (CV*)SvREFCNT_inc(PL_compcv); |
503de470 | 476 | ps->savestack_ix = PL_savestack_ix; |
9388183f | 477 | #ifdef DEBUGGING |
1654d593 | 478 | ps->name = (const char *)(yytname [yyr1[yyn]]); |
9388183f | 479 | #endif |
0de566d7 DM |
480 | |
481 | yyn = yyr1[yyn]; | |
482 | ||
1654d593 DM |
483 | yystate = yypgoto[yyn - YYNTOKENS] + ps[-1].state; |
484 | if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == ps[-1].state) | |
0de566d7 | 485 | yystate = yytable[yystate]; |
93a17b20 | 486 | else |
0de566d7 | 487 | yystate = yydefgoto[yyn - YYNTOKENS]; |
1654d593 | 488 | ps->state = yystate; |
05a03161 | 489 | |
0de566d7 DM |
490 | goto yynewstate; |
491 | ||
492 | ||
493 | /*------------------------------------. | |
494 | | yyerrlab -- here on detecting error | | |
495 | `------------------------------------*/ | |
496 | yyerrlab: | |
497 | /* If not already recovering from an error, report this error. */ | |
5912531f | 498 | if (!parser->yyerrstatus) { |
07a06489 | 499 | yyerror ("syntax error"); |
93a17b20 | 500 | } |
0de566d7 DM |
501 | |
502 | ||
5912531f | 503 | if (parser->yyerrstatus == 3) { |
0de566d7 DM |
504 | /* If just tried and failed to reuse lookahead token after an |
505 | error, discard it. */ | |
506 | ||
507 | /* Return failure if at end of input. */ | |
5912531f | 508 | if (parser->yychar == YYEOF) { |
0de566d7 | 509 | /* Pop the error token. */ |
8c63ea58 | 510 | SvREFCNT_dec(ps->compcv); |
0de566d7 DM |
511 | YYPOPSTACK; |
512 | /* Pop the rest of the stack. */ | |
22735491 | 513 | while (ps > parser->stack) { |
1654d593 | 514 | YYDSYMPRINTF ("Error: popping", yystos[ps->state], &ps->val); |
503de470 | 515 | LEAVE_SCOPE(ps->savestack_ix); |
1654d593 DM |
516 | if (yy_type_tab[yystos[ps->state]] == toketype_opval |
517 | && ps->val.opval) | |
670f3923 | 518 | { |
0539ab63 | 519 | YYDPRINTF ((Perl_debug_log, "(freeing op)\n")); |
8c63ea58 GG |
520 | if (ps->compcv != PL_compcv) { |
521 | PL_compcv = ps->compcv; | |
522 | PAD_SET_CUR_NOSAVE(CvPADLIST(PL_compcv), 1); | |
718a7425 | 523 | } |
1654d593 | 524 | op_free(ps->val.opval); |
0539ab63 | 525 | } |
8c63ea58 | 526 | SvREFCNT_dec(ps->compcv); |
0de566d7 DM |
527 | YYPOPSTACK; |
528 | } | |
529 | YYABORT; | |
530 | } | |
531 | ||
5912531f DM |
532 | YYDSYMPRINTF ("Error: discarding", yytoken, &parser->yylval); |
533 | parser->yychar = YYEMPTY; | |
0de566d7 | 534 | |
93a17b20 | 535 | } |
0de566d7 DM |
536 | |
537 | /* Else will try to reuse lookahead token after shifting the error | |
538 | token. */ | |
539 | goto yyerrlab1; | |
540 | ||
541 | ||
542 | /*----------------------------------------------------. | |
543 | | yyerrlab1 -- error raised explicitly by an action. | | |
544 | `----------------------------------------------------*/ | |
545 | yyerrlab1: | |
5912531f | 546 | parser->yyerrstatus = 3; /* Each real token shifted decrements this. */ |
0de566d7 DM |
547 | |
548 | for (;;) { | |
549 | yyn = yypact[yystate]; | |
550 | if (yyn != YYPACT_NINF) { | |
551 | yyn += YYTERROR; | |
552 | if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) { | |
553 | yyn = yytable[yyn]; | |
554 | if (0 < yyn) | |
555 | break; | |
556 | } | |
557 | } | |
558 | ||
559 | /* Pop the current state because it cannot handle the error token. */ | |
22735491 | 560 | if (ps == parser->stack) |
0de566d7 DM |
561 | YYABORT; |
562 | ||
1654d593 | 563 | YYDSYMPRINTF ("Error: popping", yystos[ps->state], &ps->val); |
503de470 | 564 | LEAVE_SCOPE(ps->savestack_ix); |
1654d593 | 565 | if (yy_type_tab[yystos[ps->state]] == toketype_opval && ps->val.opval) { |
0539ab63 | 566 | YYDPRINTF ((Perl_debug_log, "(freeing op)\n")); |
8c63ea58 GG |
567 | if (ps->compcv != PL_compcv) { |
568 | PL_compcv = ps->compcv; | |
569 | PAD_SET_CUR_NOSAVE(CvPADLIST(PL_compcv), 1); | |
718a7425 | 570 | } |
1654d593 | 571 | op_free(ps->val.opval); |
0539ab63 | 572 | } |
8c63ea58 | 573 | SvREFCNT_dec(ps->compcv); |
1654d593 DM |
574 | YYPOPSTACK; |
575 | yystate = ps->state; | |
0de566d7 | 576 | |
1654d593 | 577 | YY_STACK_PRINT(parser); |
93a17b20 | 578 | } |
0de566d7 DM |
579 | |
580 | if (yyn == YYFINAL) | |
581 | YYACCEPT; | |
582 | ||
583 | YYDPRINTF ((Perl_debug_log, "Shifting error token, ")); | |
584 | ||
1654d593 DM |
585 | YYPUSHSTACK; |
586 | ps->state = yyn; | |
5912531f | 587 | ps->val = parser->yylval; |
ec8ec19f | 588 | ps->compcv = (CV*)SvREFCNT_inc(PL_compcv); |
503de470 | 589 | ps->savestack_ix = PL_savestack_ix; |
9388183f | 590 | #ifdef DEBUGGING |
1654d593 | 591 | ps->name ="<err>"; |
9388183f | 592 | #endif |
0de566d7 | 593 | |
0de566d7 DM |
594 | goto yynewstate; |
595 | ||
596 | ||
597 | /*-------------------------------------. | |
598 | | yyacceptlab -- YYACCEPT comes here. | | |
599 | `-------------------------------------*/ | |
600 | yyacceptlab: | |
601 | yyresult = 0; | |
8c63ea58 GG |
602 | for (ps=parser->ps; ps > parser->stack; ps--) { |
603 | SvREFCNT_dec(ps->compcv); | |
604 | } | |
22735491 | 605 | parser->ps = parser->stack; /* disable cleanup */ |
0de566d7 DM |
606 | goto yyreturn; |
607 | ||
608 | /*-----------------------------------. | |
609 | | yyabortlab -- YYABORT comes here. | | |
610 | `-----------------------------------*/ | |
611 | yyabortlab: | |
612 | yyresult = 1; | |
613 | goto yyreturn; | |
614 | ||
0de566d7 | 615 | yyreturn: |
e3abe207 | 616 | LEAVE; /* force parser stack cleanup before we return */ |
0de566d7 | 617 | return yyresult; |
e1f15930 | 618 | } |
66610fdd RGS |
619 | |
620 | /* | |
621 | * Local variables: | |
622 | * c-indentation-style: bsd | |
623 | * c-basic-offset: 4 | |
14d04a33 | 624 | * indent-tabs-mode: nil |
66610fdd RGS |
625 | * End: |
626 | * | |
14d04a33 | 627 | * ex: set ts=8 sts=4 sw=4 et: |
37442d52 | 628 | */ |