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