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