Commit | Line | Data |
0de566d7 |
1 | /* perly.c |
2 | * |
54ca4ee7 |
3 | * Copyright (c) 2004, 2005, 2006 Larry Wall and others |
0de566d7 |
4 | * |
5 | * You may distribute under the terms of either the GNU General Public |
6 | * License or the Artistic License, as specified in the README file. |
7 | * |
8 | * Note that this file was originally generated as an output from |
9 | * GNU bison version 1.875, but now the code is statically maintained |
10 | * and edited; the bits that are dependent on perly.y are now #included |
11 | * from the files perly.tab and perly.act. |
12 | * |
13 | * Here is an important copyright statement from the original, generated |
14 | * file: |
15 | * |
16 | * As a special exception, when this file is copied by Bison into a |
17 | * Bison output file, you may use that output file without |
18 | * restriction. This special exception was added by the Free |
19 | * Software Foundation in version 1.24 of Bison. |
20 | */ |
21 | |
22 | |
23 | /* allow stack size to grow effectively without limit */ |
24 | #define YYMAXDEPTH 10000000 |
25 | |
79072805 |
26 | #include "EXTERN.h" |
864dbfa3 |
27 | #define PERL_IN_PERLY_C |
79072805 |
28 | #include "perl.h" |
09bef843 |
29 | |
0de566d7 |
30 | typedef signed char yysigned_char; |
31 | |
32 | #ifdef DEBUGGING |
33 | # define YYDEBUG 1 |
93a17b20 |
34 | #else |
0de566d7 |
35 | # define YYDEBUG 0 |
93a17b20 |
36 | #endif |
09bef843 |
37 | |
0de566d7 |
38 | /* contains all the parser state tables; auto-generated from perly.y */ |
39 | #include "perly.tab" |
40 | |
41 | # define YYSIZE_T size_t |
42 | |
43 | #define yyerrok (yyerrstatus = 0) |
44 | #define yyclearin (yychar = YYEMPTY) |
45 | #define YYEMPTY (-2) |
46 | #define YYEOF 0 |
47 | |
48 | #define YYACCEPT goto yyacceptlab |
49 | #define YYABORT goto yyabortlab |
50 | #define YYERROR goto yyerrlab1 |
51 | |
52 | |
53 | /* Like YYERROR except do call yyerror. This remains here temporarily |
54 | to ease the transition to the new meaning of YYERROR, for GCC. |
55 | Once GCC version 2 has supplanted version 1, this can go. */ |
56 | |
57 | #define YYFAIL goto yyerrlab |
58 | |
59 | #define YYRECOVERING() (!!yyerrstatus) |
60 | |
61 | #define YYBACKUP(Token, Value) \ |
62 | do \ |
63 | if (yychar == YYEMPTY && yylen == 1) { \ |
64 | yychar = (Token); \ |
65 | yylval = (Value); \ |
66 | yytoken = YYTRANSLATE (yychar); \ |
67 | YYPOPSTACK; \ |
68 | goto yybackup; \ |
69 | } \ |
70 | else { \ |
71 | yyerror ("syntax error: cannot back up"); \ |
72 | YYERROR; \ |
73 | } \ |
74 | while (0) |
75 | |
76 | #define YYTERROR 1 |
77 | #define YYERRCODE 256 |
78 | |
0de566d7 |
79 | /* Enable debugging if requested. */ |
9388183f |
80 | #ifdef DEBUGGING |
0de566d7 |
81 | |
82 | # define yydebug (DEBUG_p_TEST) |
83 | |
84 | # define YYFPRINTF PerlIO_printf |
85 | |
86 | # define YYDPRINTF(Args) \ |
87 | do { \ |
88 | if (yydebug) \ |
89 | YYFPRINTF Args; \ |
90 | } while (0) |
91 | |
9388183f |
92 | # define YYDSYMPRINTF(Title, Token, Value) \ |
0de566d7 |
93 | do { \ |
94 | if (yydebug) { \ |
95 | YYFPRINTF (Perl_debug_log, "%s ", Title); \ |
ac9a0352 |
96 | yysymprint (Perl_debug_log, Token, Value); \ |
0de566d7 |
97 | YYFPRINTF (Perl_debug_log, "\n"); \ |
98 | } \ |
99 | } while (0) |
100 | |
101 | /*--------------------------------. |
102 | | Print this symbol on YYOUTPUT. | |
103 | `--------------------------------*/ |
104 | |
105 | static void |
ac9a0352 |
106 | yysymprint(PerlIO * const yyoutput, int yytype, const YYSTYPE * const yyvaluep) |
0de566d7 |
107 | { |
0de566d7 |
108 | if (yytype < YYNTOKENS) { |
109 | YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); |
110 | # ifdef YYPRINT |
111 | YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); |
9388183f |
112 | # else |
e4584336 |
113 | YYFPRINTF (yyoutput, "0x%"UVxf, (UV)yyvaluep->ival); |
0de566d7 |
114 | # endif |
115 | } |
116 | else |
117 | YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); |
118 | |
0de566d7 |
119 | YYFPRINTF (yyoutput, ")"); |
120 | } |
121 | |
122 | |
9388183f |
123 | /* yy_stack_print() |
124 | * print the top 8 items on the parse stack. The args have the same |
125 | * meanings as the local vars in yyparse() of the same name */ |
0de566d7 |
126 | |
127 | static void |
df35152e |
128 | yy_stack_print (pTHX_ const short *yyss, const short *yyssp, const YYSTYPE *yyvs, const char**yyns) |
0de566d7 |
129 | { |
9388183f |
130 | int i; |
131 | int start = 1; |
132 | int count = (int)(yyssp - yyss); |
133 | |
134 | if (count > 8) { |
135 | start = count - 8 + 1; |
136 | count = 8; |
137 | } |
138 | |
139 | PerlIO_printf(Perl_debug_log, "\nindex:"); |
140 | for (i=0; i < count; i++) |
141 | PerlIO_printf(Perl_debug_log, " %8d", start+i); |
142 | PerlIO_printf(Perl_debug_log, "\nstate:"); |
21612876 |
143 | for (i=0; i < count; i++) |
144 | PerlIO_printf(Perl_debug_log, " %8d", yyss[start+i]); |
9388183f |
145 | PerlIO_printf(Perl_debug_log, "\ntoken:"); |
21612876 |
146 | for (i=0; i < count; i++) |
147 | PerlIO_printf(Perl_debug_log, " %8.8s", yyns[start+i]); |
9388183f |
148 | PerlIO_printf(Perl_debug_log, "\nvalue:"); |
21612876 |
149 | for (i=0; i < count; i++) { |
150 | if (yy_is_opval[yystos[yyss[start+i]]]) { |
151 | PerlIO_printf(Perl_debug_log, " %8.8s", |
152 | yyvs[start+i].opval |
153 | ? PL_op_name[yyvs[start+i].opval->op_type] |
154 | : "NULL" |
155 | ); |
156 | } |
157 | else |
158 | PerlIO_printf(Perl_debug_log, " %8"UVxf, (UV)yyvs[start+i].ival); |
159 | } |
9388183f |
160 | PerlIO_printf(Perl_debug_log, "\n\n"); |
0de566d7 |
161 | } |
162 | |
9388183f |
163 | # define YY_STACK_PRINT(yyss, yyssp, yyvs, yyns) \ |
0de566d7 |
164 | do { \ |
9388183f |
165 | if (yydebug && DEBUG_v_TEST) \ |
166 | yy_stack_print (aTHX_ (yyss), (yyssp), (yyvs), (yyns)); \ |
0de566d7 |
167 | } while (0) |
168 | |
09bef843 |
169 | |
0de566d7 |
170 | /*------------------------------------------------. |
171 | | Report that the YYRULE is going to be reduced. | |
172 | `------------------------------------------------*/ |
173 | |
174 | static void |
175 | yy_reduce_print (pTHX_ int yyrule) |
176 | { |
177 | int yyi; |
df35152e |
178 | const unsigned int yylineno = yyrline[yyrule]; |
0de566d7 |
179 | YYFPRINTF (Perl_debug_log, "Reducing stack by rule %d (line %u), ", |
180 | yyrule - 1, yylineno); |
181 | /* Print the symbols being reduced, and their result. */ |
182 | for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++) |
183 | YYFPRINTF (Perl_debug_log, "%s ", yytname [yyrhs[yyi]]); |
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) |
196 | # define YY_STACK_PRINT(yyss, yyssp, yyvs, yyns) |
0de566d7 |
197 | # define YY_REDUCE_PRINT(Rule) |
198 | #endif /* !DEBUGGING */ |
199 | |
200 | |
201 | /* YYINITDEPTH -- initial size of the parser's stacks. */ |
202 | #ifndef YYINITDEPTH |
203 | # define YYINITDEPTH 200 |
09bef843 |
204 | #endif |
09bef843 |
205 | |
0de566d7 |
206 | |
207 | #if YYERROR_VERBOSE |
208 | # ifndef yystrlen |
209 | # if defined (__GLIBC__) && defined (_STRING_H) |
210 | # define yystrlen strlen |
211 | # else |
212 | /* Return the length of YYSTR. */ |
213 | static YYSIZE_T |
214 | yystrlen (const char *yystr) |
215 | { |
216 | register const char *yys = yystr; |
217 | |
218 | while (*yys++ != '\0') |
219 | continue; |
220 | |
221 | return yys - yystr - 1; |
222 | } |
223 | # endif |
224 | # endif |
225 | |
226 | # ifndef yystpcpy |
227 | # if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE) |
228 | # define yystpcpy stpcpy |
229 | # else |
230 | /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in |
231 | YYDEST. */ |
232 | static char * |
233 | yystpcpy (pTHX_ char *yydest, const char *yysrc) |
234 | { |
235 | register char *yyd = yydest; |
236 | register const char *yys = yysrc; |
237 | |
238 | while ((*yyd++ = *yys++) != '\0') |
239 | continue; |
240 | |
241 | return yyd - 1; |
242 | } |
243 | # endif |
244 | # endif |
245 | |
246 | #endif /* !YYERROR_VERBOSE */ |
247 | |
eb7d7d25 |
248 | |
249 | /* a snapshot of the current stack position variables for use by |
250 | * S_clear_yystack */ |
251 | |
252 | typedef struct { |
253 | short *yyss; |
254 | short *yyssp; |
255 | YYSTYPE *yyvsp; |
256 | int yylen; |
257 | } yystack_positions; |
258 | |
259 | /* called during cleanup (via SAVEDESTRUCTOR_X) to free any items on the |
260 | * parse stack, thus avoiding leaks if we die */ |
261 | |
262 | static void |
263 | S_clear_yystack(pTHX_ const void *p) |
264 | { |
265 | yystack_positions *y = (yystack_positions*) p; |
266 | |
267 | if (!y->yyss) |
268 | return; |
269 | YYDPRINTF ((Perl_debug_log, "clearing the parse stack\n")); |
270 | y->yyvsp -= y->yylen; /* ignore the tokens that have just been reduced */ |
271 | y->yyssp -= y->yylen; |
272 | while (y->yyssp > y->yyss) { |
273 | if (yy_is_opval[yystos[*y->yyssp]]) |
274 | op_free(y->yyvsp->opval); |
275 | y->yyvsp--; |
276 | y->yyssp--; |
277 | } |
278 | } |
279 | |
0de566d7 |
280 | /*----------. |
281 | | yyparse. | |
282 | `----------*/ |
283 | |
79072805 |
284 | int |
0de566d7 |
285 | Perl_yyparse (pTHX) |
79072805 |
286 | { |
97aff369 |
287 | dVAR; |
0de566d7 |
288 | int yychar; /* The lookahead symbol. */ |
289 | YYSTYPE yylval; /* The semantic value of the lookahead symbol. */ |
290 | int yynerrs; /* Number of syntax errors so far. */ |
291 | register int yystate; |
292 | register int yyn; |
293 | int yyresult; |
294 | |
295 | /* Number of tokens to shift before error messages enabled. */ |
296 | int yyerrstatus; |
297 | /* Lookahead token as an internal (translated) token number. */ |
298 | int yytoken = 0; |
299 | |
300 | /* two stacks and their tools: |
a0288114 |
301 | yyss: related to states, |
302 | yyvs: related to semantic values, |
0de566d7 |
303 | |
304 | Refer to the stacks thru separate pointers, to allow yyoverflow |
305 | to reallocate them elsewhere. */ |
306 | |
307 | /* The state stack. */ |
308 | short *yyss; |
93a17b20 |
309 | register short *yyssp; |
0de566d7 |
310 | |
311 | /* The semantic value stack. */ |
312 | YYSTYPE *yyvs; |
93a17b20 |
313 | register YYSTYPE *yyvsp; |
a0d0e21e |
314 | |
0de566d7 |
315 | /* for ease of re-allocation and automatic freeing, have two SVs whose |
316 | * SvPVX points to the stacks */ |
317 | SV *yyss_sv, *yyvs_sv; |
eb7d7d25 |
318 | SV *ss_save_sv; |
319 | yystack_positions *ss_save; |
0de566d7 |
320 | |
9388183f |
321 | #ifdef DEBUGGING |
322 | /* maintain also a stack of token/rule names for debugging with -Dpv */ |
e1ec3a88 |
323 | const char **yyns, **yynsp; |
9388183f |
324 | SV *yyns_sv; |
325 | # define YYPOPSTACK (yyvsp--, yyssp--, yynsp--) |
326 | #else |
327 | # define YYPOPSTACK (yyvsp--, yyssp--) |
328 | #endif |
329 | |
0de566d7 |
330 | |
331 | YYSIZE_T yystacksize = YYINITDEPTH; |
332 | |
333 | /* The variables used to return semantic value and location from the |
334 | action routines. */ |
335 | YYSTYPE yyval; |
336 | |
337 | |
338 | /* When reducing, the number of symbols on the RHS of the reduced |
339 | rule. */ |
340 | int yylen; |
341 | |
81d86705 |
342 | #ifdef PERL_MAD |
00e74f14 |
343 | if (PL_madskills) |
344 | return madparse(); |
81d86705 |
345 | #endif |
346 | |
0de566d7 |
347 | YYDPRINTF ((Perl_debug_log, "Starting parse\n")); |
348 | |
0de566d7 |
349 | ENTER; /* force stack free before we return */ |
12fbd33b |
350 | SAVEVPTR(PL_yycharp); |
351 | SAVEVPTR(PL_yylvalp); |
352 | PL_yycharp = &yychar; /* so PL_yyerror() can access it */ |
353 | PL_yylvalp = &yylval; /* so various functions in toke.c can access it */ |
354 | |
561b68a9 |
355 | yyss_sv = newSV(YYINITDEPTH * sizeof(short)); |
356 | yyvs_sv = newSV(YYINITDEPTH * sizeof(YYSTYPE)); |
eb7d7d25 |
357 | ss_save_sv = newSV(sizeof(yystack_positions)); |
0de566d7 |
358 | SAVEFREESV(yyss_sv); |
359 | SAVEFREESV(yyvs_sv); |
eb7d7d25 |
360 | SAVEFREESV(ss_save_sv); |
0de566d7 |
361 | yyss = (short *) SvPVX(yyss_sv); |
362 | yyvs = (YYSTYPE *) SvPVX(yyvs_sv); |
eb7d7d25 |
363 | ss_save = (yystack_positions *) SvPVX(ss_save_sv); |
364 | |
365 | ss_save->yyss = NULL; /* disarm stack cleanup */ |
366 | /* cleanup the parse stack on premature exit */ |
367 | SAVEDESTRUCTOR_X(S_clear_yystack, (void*) ss_save); |
368 | |
9388183f |
369 | /* note that elements zero of yyvs and yyns are not used */ |
370 | yyssp = yyss; |
371 | yyvsp = yyvs; |
372 | #ifdef DEBUGGING |
561b68a9 |
373 | yyns_sv = newSV(YYINITDEPTH * sizeof(char *)); |
9388183f |
374 | SAVEFREESV(yyns_sv); |
a28509cc |
375 | /* XXX This seems strange to cast char * to char ** */ |
94a11853 |
376 | yyns = (const char **) SvPVX(yyns_sv); |
9388183f |
377 | yynsp = yyns; |
378 | #endif |
79072805 |
379 | |
0de566d7 |
380 | yystate = 0; |
381 | yyerrstatus = 0; |
93a17b20 |
382 | yynerrs = 0; |
0de566d7 |
383 | yychar = YYEMPTY; /* Cause a token to be read. */ |
384 | |
9388183f |
385 | YYDPRINTF ((Perl_debug_log, "Entering state %d\n", yystate)); |
0de566d7 |
386 | |
387 | goto yysetstate; |
388 | |
389 | /*------------------------------------------------------------. |
390 | | yynewstate -- Push a new state, which is found in yystate. | |
391 | `------------------------------------------------------------*/ |
392 | yynewstate: |
393 | /* In all cases, when you get here, the value and location stacks |
394 | have just been pushed. so pushing a state here evens the stacks. |
395 | */ |
396 | yyssp++; |
397 | |
398 | yysetstate: |
399 | *yyssp = yystate; |
400 | |
401 | if (yyss + yystacksize - 1 <= yyssp) { |
402 | /* Get the current used size of the three stacks, in elements. */ |
df35152e |
403 | const YYSIZE_T yysize = yyssp - yyss + 1; |
0de566d7 |
404 | |
405 | /* Extend the stack our own way. */ |
406 | if (YYMAXDEPTH <= yystacksize) |
407 | goto yyoverflowlab; |
408 | yystacksize *= 2; |
409 | if (YYMAXDEPTH < yystacksize) |
410 | yystacksize = YYMAXDEPTH; |
411 | |
412 | SvGROW(yyss_sv, yystacksize * sizeof(short)); |
413 | SvGROW(yyvs_sv, yystacksize * sizeof(YYSTYPE)); |
414 | yyss = (short *) SvPVX(yyss_sv); |
415 | yyvs = (YYSTYPE *) SvPVX(yyvs_sv); |
9388183f |
416 | #ifdef DEBUGGING |
417 | SvGROW(yyns_sv, yystacksize * sizeof(char *)); |
a28509cc |
418 | /* XXX This seems strange to cast char * to char ** */ |
94a11853 |
419 | yyns = (const char **) SvPVX(yyns_sv); |
9388183f |
420 | if (! yyns) |
421 | goto yyoverflowlab; |
422 | yynsp = yyns + yysize - 1; |
423 | #endif |
0de566d7 |
424 | if (!yyss || ! yyvs) |
425 | goto yyoverflowlab; |
426 | |
427 | yyssp = yyss + yysize - 1; |
428 | yyvsp = yyvs + yysize - 1; |
429 | |
430 | |
431 | YYDPRINTF ((Perl_debug_log, "Stack size increased to %lu\n", |
432 | (unsigned long int) yystacksize)); |
433 | |
434 | if (yyss + yystacksize - 1 <= yyssp) |
435 | YYABORT; |
93a17b20 |
436 | } |
0de566d7 |
437 | |
0de566d7 |
438 | goto yybackup; |
439 | |
440 | /*-----------. |
441 | | yybackup. | |
442 | `-----------*/ |
443 | yybackup: |
444 | |
445 | /* Do appropriate processing given the current state. */ |
446 | /* Read a lookahead token if we need one and don't already have one. */ |
447 | /* yyresume: */ |
448 | |
449 | /* First try to decide what to do without reference to lookahead token. */ |
450 | |
451 | yyn = yypact[yystate]; |
452 | if (yyn == YYPACT_NINF) |
453 | goto yydefault; |
454 | |
455 | /* Not known => get a lookahead token if don't already have one. */ |
456 | |
457 | /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ |
458 | if (yychar == YYEMPTY) { |
459 | YYDPRINTF ((Perl_debug_log, "Reading a token: ")); |
81d86705 |
460 | #ifdef PERL_MAD |
00e74f14 |
461 | yychar = PL_madskills ? madlex() : yylex(); |
81d86705 |
462 | #else |
12fbd33b |
463 | yychar = yylex(); |
81d86705 |
464 | #endif |
12fbd33b |
465 | # ifdef EBCDIC |
466 | if (yychar >= 0 && yychar < 255) { |
467 | yychar = NATIVE_TO_ASCII(yychar); |
468 | } |
469 | # endif |
0de566d7 |
470 | } |
471 | |
472 | if (yychar <= YYEOF) { |
473 | yychar = yytoken = YYEOF; |
474 | YYDPRINTF ((Perl_debug_log, "Now at end of input.\n")); |
93a17b20 |
475 | } |
0de566d7 |
476 | else { |
477 | yytoken = YYTRANSLATE (yychar); |
9388183f |
478 | YYDSYMPRINTF ("Next token is", yytoken, &yylval); |
93a17b20 |
479 | } |
771df094 |
480 | |
0de566d7 |
481 | /* If the proper action on seeing token YYTOKEN is to reduce or to |
482 | detect an error, take that action. */ |
483 | yyn += yytoken; |
484 | if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) |
485 | goto yydefault; |
486 | yyn = yytable[yyn]; |
487 | if (yyn <= 0) { |
488 | if (yyn == 0 || yyn == YYTABLE_NINF) |
489 | goto yyerrlab; |
490 | yyn = -yyn; |
491 | goto yyreduce; |
492 | } |
7b57b0ea |
493 | |
0de566d7 |
494 | if (yyn == YYFINAL) |
495 | YYACCEPT; |
771df094 |
496 | |
0de566d7 |
497 | /* Shift the lookahead token. */ |
498 | YYDPRINTF ((Perl_debug_log, "Shifting token %s, ", yytname[yytoken])); |
499 | |
500 | /* Discard the token being shifted unless it is eof. */ |
501 | if (yychar != YYEOF) |
502 | yychar = YYEMPTY; |
503 | |
504 | *++yyvsp = yylval; |
9388183f |
505 | #ifdef DEBUGGING |
e1ec3a88 |
506 | *++yynsp = (const char *)(yytname[yytoken]); |
9388183f |
507 | #endif |
0de566d7 |
508 | |
509 | |
510 | /* Count tokens shifted since error; after three, turn off error |
511 | status. */ |
512 | if (yyerrstatus) |
513 | yyerrstatus--; |
514 | |
515 | yystate = yyn; |
9388183f |
516 | YYDPRINTF ((Perl_debug_log, "Entering state %d\n", yystate)); |
517 | |
0de566d7 |
518 | goto yynewstate; |
519 | |
520 | |
521 | /*-----------------------------------------------------------. |
522 | | yydefault -- do the default action for the current state. | |
523 | `-----------------------------------------------------------*/ |
524 | yydefault: |
525 | yyn = yydefact[yystate]; |
526 | if (yyn == 0) |
527 | goto yyerrlab; |
528 | goto yyreduce; |
529 | |
530 | |
531 | /*-----------------------------. |
532 | | yyreduce -- Do a reduction. | |
533 | `-----------------------------*/ |
534 | yyreduce: |
535 | /* yyn is the number of a rule to reduce with. */ |
536 | yylen = yyr2[yyn]; |
537 | |
538 | /* If YYLEN is nonzero, implement the default value of the action: |
a0288114 |
539 | "$$ = $1". |
0de566d7 |
540 | |
541 | Otherwise, the following line sets YYVAL to garbage. |
542 | This behavior is undocumented and Bison |
543 | users should not rely upon it. Assigning to YYVAL |
544 | unconditionally makes the parser a bit smaller, and it avoids a |
545 | GCC warning that YYVAL may be used uninitialized. */ |
546 | yyval = yyvsp[1-yylen]; |
547 | |
548 | |
549 | YY_REDUCE_PRINT (yyn); |
eb7d7d25 |
550 | |
551 | /* running external code may trigger a die (eg 'use nosuchmodule'): |
552 | * record the current stack state so that an unwind will |
553 | * free all the pesky OPs lounging around on the parse stack */ |
554 | ss_save->yyss = yyss; |
555 | ss_save->yyssp = yyssp; |
556 | ss_save->yyvsp = yyvsp; |
557 | ss_save->yylen = yylen; |
558 | |
0de566d7 |
559 | switch (yyn) { |
560 | |
561 | /* contains all the rule actions; auto-generated from perly.y */ |
562 | |
563 | #define dep() deprecate("\"do\" to call subroutines") |
564 | #include "perly.act" |
7b57b0ea |
565 | |
93a17b20 |
566 | } |
0de566d7 |
567 | |
568 | yyvsp -= yylen; |
569 | yyssp -= yylen; |
9388183f |
570 | #ifdef DEBUGGING |
571 | yynsp -= yylen; |
572 | #endif |
0de566d7 |
573 | |
0de566d7 |
574 | |
575 | *++yyvsp = yyval; |
9388183f |
576 | #ifdef DEBUGGING |
e1ec3a88 |
577 | *++yynsp = (const char *)(yytname [yyr1[yyn]]); |
9388183f |
578 | #endif |
0de566d7 |
579 | |
a0288114 |
580 | /* Now shift the result of the reduction. Determine what state |
0de566d7 |
581 | that goes to, based on the state we popped back to and the rule |
582 | number reduced by. */ |
583 | |
584 | yyn = yyr1[yyn]; |
585 | |
586 | yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; |
587 | if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) |
588 | yystate = yytable[yystate]; |
93a17b20 |
589 | else |
0de566d7 |
590 | yystate = yydefgoto[yyn - YYNTOKENS]; |
591 | |
9388183f |
592 | YYDPRINTF ((Perl_debug_log, "Entering state %d\n", yystate)); |
593 | |
594 | #ifdef DEBUGGING |
595 | /* tmp push yystate for stack print; this is normally pushed later in |
596 | * yynewstate */ |
597 | yyssp++; |
598 | *yyssp = yystate; |
599 | YY_STACK_PRINT (yyss, yyssp, yyvs, yyns); |
600 | yyssp--; |
601 | #endif |
602 | |
0de566d7 |
603 | goto yynewstate; |
604 | |
605 | |
606 | /*------------------------------------. |
607 | | yyerrlab -- here on detecting error | |
608 | `------------------------------------*/ |
609 | yyerrlab: |
610 | /* If not already recovering from an error, report this error. */ |
611 | if (!yyerrstatus) { |
612 | ++yynerrs; |
613 | #if YYERROR_VERBOSE |
614 | yyn = yypact[yystate]; |
615 | |
616 | if (YYPACT_NINF < yyn && yyn < YYLAST) { |
617 | YYSIZE_T yysize = 0; |
df35152e |
618 | const int yytype = YYTRANSLATE (yychar); |
0de566d7 |
619 | char *yymsg; |
620 | int yyx, yycount; |
621 | |
622 | yycount = 0; |
623 | /* Start YYX at -YYN if negative to avoid negative indexes in |
624 | YYCHECK. */ |
625 | for (yyx = yyn < 0 ? -yyn : 0; |
626 | yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++) |
627 | if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) |
628 | yysize += yystrlen (yytname[yyx]) + 15, yycount++; |
629 | yysize += yystrlen ("syntax error, unexpected ") + 1; |
630 | yysize += yystrlen (yytname[yytype]); |
4b711db3 |
631 | Newx(yymsg, yysize, char *); |
0de566d7 |
632 | if (yymsg != 0) { |
df35152e |
633 | const char *yyp = yystpcpy (yymsg, "syntax error, unexpected "); |
0de566d7 |
634 | yyp = yystpcpy (yyp, yytname[yytype]); |
635 | |
636 | if (yycount < 5) { |
637 | yycount = 0; |
638 | for (yyx = yyn < 0 ? -yyn : 0; |
639 | yyx < (int) (sizeof (yytname) / sizeof (char *)); |
640 | yyx++) |
641 | { |
642 | if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) { |
643 | const char *yyq = ! yycount ? |
644 | ", expecting " : " or "; |
645 | yyp = yystpcpy (yyp, yyq); |
646 | yyp = yystpcpy (yyp, yytname[yyx]); |
647 | yycount++; |
648 | } |
649 | } |
ecb2f335 |
650 | } |
0de566d7 |
651 | yyerror (yymsg); |
652 | YYSTACK_FREE (yymsg); |
653 | } |
654 | else |
655 | yyerror ("syntax error; also virtual memory exhausted"); |
656 | } |
657 | else |
658 | #endif /* YYERROR_VERBOSE */ |
659 | yyerror ("syntax error"); |
93a17b20 |
660 | } |
0de566d7 |
661 | |
662 | |
663 | if (yyerrstatus == 3) { |
664 | /* If just tried and failed to reuse lookahead token after an |
665 | error, discard it. */ |
666 | |
667 | /* Return failure if at end of input. */ |
668 | if (yychar == YYEOF) { |
669 | /* Pop the error token. */ |
670 | YYPOPSTACK; |
671 | /* Pop the rest of the stack. */ |
672 | while (yyss < yyssp) { |
9388183f |
673 | YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp); |
0539ab63 |
674 | if (yy_is_opval[yystos[*yyssp]]) { |
675 | YYDPRINTF ((Perl_debug_log, "(freeing op)\n")); |
676 | op_free(yyvsp->opval); |
677 | } |
0de566d7 |
678 | YYPOPSTACK; |
679 | } |
680 | YYABORT; |
681 | } |
682 | |
9388183f |
683 | YYDSYMPRINTF ("Error: discarding", yytoken, &yylval); |
0de566d7 |
684 | yychar = YYEMPTY; |
685 | |
93a17b20 |
686 | } |
0de566d7 |
687 | |
688 | /* Else will try to reuse lookahead token after shifting the error |
689 | token. */ |
690 | goto yyerrlab1; |
691 | |
692 | |
693 | /*----------------------------------------------------. |
694 | | yyerrlab1 -- error raised explicitly by an action. | |
695 | `----------------------------------------------------*/ |
696 | yyerrlab1: |
697 | yyerrstatus = 3; /* Each real token shifted decrements this. */ |
698 | |
699 | for (;;) { |
700 | yyn = yypact[yystate]; |
701 | if (yyn != YYPACT_NINF) { |
702 | yyn += YYTERROR; |
703 | if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) { |
704 | yyn = yytable[yyn]; |
705 | if (0 < yyn) |
706 | break; |
707 | } |
708 | } |
709 | |
710 | /* Pop the current state because it cannot handle the error token. */ |
711 | if (yyssp == yyss) |
712 | YYABORT; |
713 | |
9388183f |
714 | YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp); |
0539ab63 |
715 | if (yy_is_opval[yystos[*yyssp]]) { |
716 | YYDPRINTF ((Perl_debug_log, "(freeing op)\n")); |
717 | op_free(yyvsp->opval); |
718 | } |
0de566d7 |
719 | yyvsp--; |
9388183f |
720 | #ifdef DEBUGGING |
721 | yynsp--; |
722 | #endif |
0de566d7 |
723 | yystate = *--yyssp; |
724 | |
9388183f |
725 | YY_STACK_PRINT (yyss, yyssp, yyvs, yyns); |
93a17b20 |
726 | } |
0de566d7 |
727 | |
728 | if (yyn == YYFINAL) |
729 | YYACCEPT; |
730 | |
731 | YYDPRINTF ((Perl_debug_log, "Shifting error token, ")); |
732 | |
733 | *++yyvsp = yylval; |
9388183f |
734 | #ifdef DEBUGGING |
735 | *++yynsp ="<err>"; |
736 | #endif |
0de566d7 |
737 | |
738 | yystate = yyn; |
9388183f |
739 | YYDPRINTF ((Perl_debug_log, "Entering state %d\n", yystate)); |
740 | |
0de566d7 |
741 | goto yynewstate; |
742 | |
743 | |
744 | /*-------------------------------------. |
745 | | yyacceptlab -- YYACCEPT comes here. | |
746 | `-------------------------------------*/ |
747 | yyacceptlab: |
748 | yyresult = 0; |
749 | goto yyreturn; |
750 | |
751 | /*-----------------------------------. |
752 | | yyabortlab -- YYABORT comes here. | |
753 | `-----------------------------------*/ |
754 | yyabortlab: |
755 | yyresult = 1; |
756 | goto yyreturn; |
757 | |
758 | /*----------------------------------------------. |
759 | | yyoverflowlab -- parser overflow comes here. | |
760 | `----------------------------------------------*/ |
761 | yyoverflowlab: |
762 | yyerror ("parser stack overflow"); |
763 | yyresult = 2; |
764 | /* Fall through. */ |
765 | |
766 | yyreturn: |
767 | |
eb7d7d25 |
768 | ss_save->yyss = NULL; /* disarm parse stack cleanup */ |
769 | LEAVE; /* force stack free before we return */ |
e1f15930 |
770 | |
0de566d7 |
771 | return yyresult; |
e1f15930 |
772 | } |
66610fdd |
773 | |
774 | /* |
775 | * Local variables: |
776 | * c-indentation-style: bsd |
777 | * c-basic-offset: 4 |
778 | * indent-tabs-mode: t |
779 | * End: |
780 | * |
37442d52 |
781 | * ex: set ts=8 sts=4 sw=4 noet: |
782 | */ |