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 | |
0de566d7 |
248 | /*----------. |
249 | | yyparse. | |
250 | `----------*/ |
251 | |
79072805 |
252 | int |
0de566d7 |
253 | Perl_yyparse (pTHX) |
79072805 |
254 | { |
97aff369 |
255 | dVAR; |
0de566d7 |
256 | int yychar; /* The lookahead symbol. */ |
257 | YYSTYPE yylval; /* The semantic value of the lookahead symbol. */ |
258 | int yynerrs; /* Number of syntax errors so far. */ |
259 | register int yystate; |
260 | register int yyn; |
261 | int yyresult; |
262 | |
263 | /* Number of tokens to shift before error messages enabled. */ |
264 | int yyerrstatus; |
265 | /* Lookahead token as an internal (translated) token number. */ |
266 | int yytoken = 0; |
267 | |
268 | /* two stacks and their tools: |
a0288114 |
269 | yyss: related to states, |
270 | yyvs: related to semantic values, |
0de566d7 |
271 | |
272 | Refer to the stacks thru separate pointers, to allow yyoverflow |
273 | to reallocate them elsewhere. */ |
274 | |
275 | /* The state stack. */ |
276 | short *yyss; |
93a17b20 |
277 | register short *yyssp; |
0de566d7 |
278 | |
279 | /* The semantic value stack. */ |
280 | YYSTYPE *yyvs; |
93a17b20 |
281 | register YYSTYPE *yyvsp; |
a0d0e21e |
282 | |
0de566d7 |
283 | /* for ease of re-allocation and automatic freeing, have two SVs whose |
284 | * SvPVX points to the stacks */ |
285 | SV *yyss_sv, *yyvs_sv; |
286 | |
9388183f |
287 | #ifdef DEBUGGING |
288 | /* maintain also a stack of token/rule names for debugging with -Dpv */ |
e1ec3a88 |
289 | const char **yyns, **yynsp; |
9388183f |
290 | SV *yyns_sv; |
291 | # define YYPOPSTACK (yyvsp--, yyssp--, yynsp--) |
292 | #else |
293 | # define YYPOPSTACK (yyvsp--, yyssp--) |
294 | #endif |
295 | |
0de566d7 |
296 | |
297 | YYSIZE_T yystacksize = YYINITDEPTH; |
298 | |
299 | /* The variables used to return semantic value and location from the |
300 | action routines. */ |
301 | YYSTYPE yyval; |
302 | |
303 | |
304 | /* When reducing, the number of symbols on the RHS of the reduced |
305 | rule. */ |
306 | int yylen; |
307 | |
81d86705 |
308 | #ifdef PERL_MAD |
00e74f14 |
309 | if (PL_madskills) |
310 | return madparse(); |
81d86705 |
311 | #endif |
312 | |
0de566d7 |
313 | YYDPRINTF ((Perl_debug_log, "Starting parse\n")); |
314 | |
0de566d7 |
315 | ENTER; /* force stack free before we return */ |
12fbd33b |
316 | SAVEVPTR(PL_yycharp); |
317 | SAVEVPTR(PL_yylvalp); |
318 | PL_yycharp = &yychar; /* so PL_yyerror() can access it */ |
319 | PL_yylvalp = &yylval; /* so various functions in toke.c can access it */ |
320 | |
561b68a9 |
321 | yyss_sv = newSV(YYINITDEPTH * sizeof(short)); |
322 | yyvs_sv = newSV(YYINITDEPTH * sizeof(YYSTYPE)); |
0de566d7 |
323 | SAVEFREESV(yyss_sv); |
324 | SAVEFREESV(yyvs_sv); |
325 | yyss = (short *) SvPVX(yyss_sv); |
326 | yyvs = (YYSTYPE *) SvPVX(yyvs_sv); |
9388183f |
327 | /* note that elements zero of yyvs and yyns are not used */ |
328 | yyssp = yyss; |
329 | yyvsp = yyvs; |
330 | #ifdef DEBUGGING |
561b68a9 |
331 | yyns_sv = newSV(YYINITDEPTH * sizeof(char *)); |
9388183f |
332 | SAVEFREESV(yyns_sv); |
a28509cc |
333 | /* XXX This seems strange to cast char * to char ** */ |
94a11853 |
334 | yyns = (const char **) SvPVX(yyns_sv); |
9388183f |
335 | yynsp = yyns; |
336 | #endif |
79072805 |
337 | |
0de566d7 |
338 | yystate = 0; |
339 | yyerrstatus = 0; |
93a17b20 |
340 | yynerrs = 0; |
0de566d7 |
341 | yychar = YYEMPTY; /* Cause a token to be read. */ |
342 | |
9388183f |
343 | YYDPRINTF ((Perl_debug_log, "Entering state %d\n", yystate)); |
0de566d7 |
344 | |
345 | goto yysetstate; |
346 | |
347 | /*------------------------------------------------------------. |
348 | | yynewstate -- Push a new state, which is found in yystate. | |
349 | `------------------------------------------------------------*/ |
350 | yynewstate: |
351 | /* In all cases, when you get here, the value and location stacks |
352 | have just been pushed. so pushing a state here evens the stacks. |
353 | */ |
354 | yyssp++; |
355 | |
356 | yysetstate: |
357 | *yyssp = yystate; |
358 | |
359 | if (yyss + yystacksize - 1 <= yyssp) { |
360 | /* Get the current used size of the three stacks, in elements. */ |
df35152e |
361 | const YYSIZE_T yysize = yyssp - yyss + 1; |
0de566d7 |
362 | |
363 | /* Extend the stack our own way. */ |
364 | if (YYMAXDEPTH <= yystacksize) |
365 | goto yyoverflowlab; |
366 | yystacksize *= 2; |
367 | if (YYMAXDEPTH < yystacksize) |
368 | yystacksize = YYMAXDEPTH; |
369 | |
370 | SvGROW(yyss_sv, yystacksize * sizeof(short)); |
371 | SvGROW(yyvs_sv, yystacksize * sizeof(YYSTYPE)); |
372 | yyss = (short *) SvPVX(yyss_sv); |
373 | yyvs = (YYSTYPE *) SvPVX(yyvs_sv); |
9388183f |
374 | #ifdef DEBUGGING |
375 | SvGROW(yyns_sv, yystacksize * sizeof(char *)); |
a28509cc |
376 | /* XXX This seems strange to cast char * to char ** */ |
94a11853 |
377 | yyns = (const char **) SvPVX(yyns_sv); |
9388183f |
378 | if (! yyns) |
379 | goto yyoverflowlab; |
380 | yynsp = yyns + yysize - 1; |
381 | #endif |
0de566d7 |
382 | if (!yyss || ! yyvs) |
383 | goto yyoverflowlab; |
384 | |
385 | yyssp = yyss + yysize - 1; |
386 | yyvsp = yyvs + yysize - 1; |
387 | |
388 | |
389 | YYDPRINTF ((Perl_debug_log, "Stack size increased to %lu\n", |
390 | (unsigned long int) yystacksize)); |
391 | |
392 | if (yyss + yystacksize - 1 <= yyssp) |
393 | YYABORT; |
93a17b20 |
394 | } |
0de566d7 |
395 | |
0de566d7 |
396 | goto yybackup; |
397 | |
398 | /*-----------. |
399 | | yybackup. | |
400 | `-----------*/ |
401 | yybackup: |
402 | |
403 | /* Do appropriate processing given the current state. */ |
404 | /* Read a lookahead token if we need one and don't already have one. */ |
405 | /* yyresume: */ |
406 | |
407 | /* First try to decide what to do without reference to lookahead token. */ |
408 | |
409 | yyn = yypact[yystate]; |
410 | if (yyn == YYPACT_NINF) |
411 | goto yydefault; |
412 | |
413 | /* Not known => get a lookahead token if don't already have one. */ |
414 | |
415 | /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ |
416 | if (yychar == YYEMPTY) { |
417 | YYDPRINTF ((Perl_debug_log, "Reading a token: ")); |
81d86705 |
418 | #ifdef PERL_MAD |
00e74f14 |
419 | yychar = PL_madskills ? madlex() : yylex(); |
81d86705 |
420 | #else |
12fbd33b |
421 | yychar = yylex(); |
81d86705 |
422 | #endif |
12fbd33b |
423 | # ifdef EBCDIC |
424 | if (yychar >= 0 && yychar < 255) { |
425 | yychar = NATIVE_TO_ASCII(yychar); |
426 | } |
427 | # endif |
0de566d7 |
428 | } |
429 | |
430 | if (yychar <= YYEOF) { |
431 | yychar = yytoken = YYEOF; |
432 | YYDPRINTF ((Perl_debug_log, "Now at end of input.\n")); |
93a17b20 |
433 | } |
0de566d7 |
434 | else { |
435 | yytoken = YYTRANSLATE (yychar); |
9388183f |
436 | YYDSYMPRINTF ("Next token is", yytoken, &yylval); |
93a17b20 |
437 | } |
771df094 |
438 | |
0de566d7 |
439 | /* If the proper action on seeing token YYTOKEN is to reduce or to |
440 | detect an error, take that action. */ |
441 | yyn += yytoken; |
442 | if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) |
443 | goto yydefault; |
444 | yyn = yytable[yyn]; |
445 | if (yyn <= 0) { |
446 | if (yyn == 0 || yyn == YYTABLE_NINF) |
447 | goto yyerrlab; |
448 | yyn = -yyn; |
449 | goto yyreduce; |
450 | } |
7b57b0ea |
451 | |
0de566d7 |
452 | if (yyn == YYFINAL) |
453 | YYACCEPT; |
771df094 |
454 | |
0de566d7 |
455 | /* Shift the lookahead token. */ |
456 | YYDPRINTF ((Perl_debug_log, "Shifting token %s, ", yytname[yytoken])); |
457 | |
458 | /* Discard the token being shifted unless it is eof. */ |
459 | if (yychar != YYEOF) |
460 | yychar = YYEMPTY; |
461 | |
462 | *++yyvsp = yylval; |
9388183f |
463 | #ifdef DEBUGGING |
e1ec3a88 |
464 | *++yynsp = (const char *)(yytname[yytoken]); |
9388183f |
465 | #endif |
0de566d7 |
466 | |
467 | |
468 | /* Count tokens shifted since error; after three, turn off error |
469 | status. */ |
470 | if (yyerrstatus) |
471 | yyerrstatus--; |
472 | |
473 | yystate = yyn; |
9388183f |
474 | YYDPRINTF ((Perl_debug_log, "Entering state %d\n", yystate)); |
475 | |
0de566d7 |
476 | goto yynewstate; |
477 | |
478 | |
479 | /*-----------------------------------------------------------. |
480 | | yydefault -- do the default action for the current state. | |
481 | `-----------------------------------------------------------*/ |
482 | yydefault: |
483 | yyn = yydefact[yystate]; |
484 | if (yyn == 0) |
485 | goto yyerrlab; |
486 | goto yyreduce; |
487 | |
488 | |
489 | /*-----------------------------. |
490 | | yyreduce -- Do a reduction. | |
491 | `-----------------------------*/ |
492 | yyreduce: |
493 | /* yyn is the number of a rule to reduce with. */ |
494 | yylen = yyr2[yyn]; |
495 | |
496 | /* If YYLEN is nonzero, implement the default value of the action: |
a0288114 |
497 | "$$ = $1". |
0de566d7 |
498 | |
499 | Otherwise, the following line sets YYVAL to garbage. |
500 | This behavior is undocumented and Bison |
501 | users should not rely upon it. Assigning to YYVAL |
502 | unconditionally makes the parser a bit smaller, and it avoids a |
503 | GCC warning that YYVAL may be used uninitialized. */ |
504 | yyval = yyvsp[1-yylen]; |
505 | |
506 | |
507 | YY_REDUCE_PRINT (yyn); |
508 | switch (yyn) { |
509 | |
510 | /* contains all the rule actions; auto-generated from perly.y */ |
511 | |
512 | #define dep() deprecate("\"do\" to call subroutines") |
513 | #include "perly.act" |
7b57b0ea |
514 | |
93a17b20 |
515 | } |
0de566d7 |
516 | |
517 | yyvsp -= yylen; |
518 | yyssp -= yylen; |
9388183f |
519 | #ifdef DEBUGGING |
520 | yynsp -= yylen; |
521 | #endif |
0de566d7 |
522 | |
0de566d7 |
523 | |
524 | *++yyvsp = yyval; |
9388183f |
525 | #ifdef DEBUGGING |
e1ec3a88 |
526 | *++yynsp = (const char *)(yytname [yyr1[yyn]]); |
9388183f |
527 | #endif |
0de566d7 |
528 | |
a0288114 |
529 | /* Now shift the result of the reduction. Determine what state |
0de566d7 |
530 | that goes to, based on the state we popped back to and the rule |
531 | number reduced by. */ |
532 | |
533 | yyn = yyr1[yyn]; |
534 | |
535 | yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; |
536 | if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) |
537 | yystate = yytable[yystate]; |
93a17b20 |
538 | else |
0de566d7 |
539 | yystate = yydefgoto[yyn - YYNTOKENS]; |
540 | |
9388183f |
541 | YYDPRINTF ((Perl_debug_log, "Entering state %d\n", yystate)); |
542 | |
543 | #ifdef DEBUGGING |
544 | /* tmp push yystate for stack print; this is normally pushed later in |
545 | * yynewstate */ |
546 | yyssp++; |
547 | *yyssp = yystate; |
548 | YY_STACK_PRINT (yyss, yyssp, yyvs, yyns); |
549 | yyssp--; |
550 | #endif |
551 | |
0de566d7 |
552 | goto yynewstate; |
553 | |
554 | |
555 | /*------------------------------------. |
556 | | yyerrlab -- here on detecting error | |
557 | `------------------------------------*/ |
558 | yyerrlab: |
559 | /* If not already recovering from an error, report this error. */ |
560 | if (!yyerrstatus) { |
561 | ++yynerrs; |
562 | #if YYERROR_VERBOSE |
563 | yyn = yypact[yystate]; |
564 | |
565 | if (YYPACT_NINF < yyn && yyn < YYLAST) { |
566 | YYSIZE_T yysize = 0; |
df35152e |
567 | const int yytype = YYTRANSLATE (yychar); |
0de566d7 |
568 | char *yymsg; |
569 | int yyx, yycount; |
570 | |
571 | yycount = 0; |
572 | /* Start YYX at -YYN if negative to avoid negative indexes in |
573 | YYCHECK. */ |
574 | for (yyx = yyn < 0 ? -yyn : 0; |
575 | yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++) |
576 | if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) |
577 | yysize += yystrlen (yytname[yyx]) + 15, yycount++; |
578 | yysize += yystrlen ("syntax error, unexpected ") + 1; |
579 | yysize += yystrlen (yytname[yytype]); |
4b711db3 |
580 | Newx(yymsg, yysize, char *); |
0de566d7 |
581 | if (yymsg != 0) { |
df35152e |
582 | const char *yyp = yystpcpy (yymsg, "syntax error, unexpected "); |
0de566d7 |
583 | yyp = yystpcpy (yyp, yytname[yytype]); |
584 | |
585 | if (yycount < 5) { |
586 | yycount = 0; |
587 | for (yyx = yyn < 0 ? -yyn : 0; |
588 | yyx < (int) (sizeof (yytname) / sizeof (char *)); |
589 | yyx++) |
590 | { |
591 | if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) { |
592 | const char *yyq = ! yycount ? |
593 | ", expecting " : " or "; |
594 | yyp = yystpcpy (yyp, yyq); |
595 | yyp = yystpcpy (yyp, yytname[yyx]); |
596 | yycount++; |
597 | } |
598 | } |
ecb2f335 |
599 | } |
0de566d7 |
600 | yyerror (yymsg); |
601 | YYSTACK_FREE (yymsg); |
602 | } |
603 | else |
604 | yyerror ("syntax error; also virtual memory exhausted"); |
605 | } |
606 | else |
607 | #endif /* YYERROR_VERBOSE */ |
608 | yyerror ("syntax error"); |
93a17b20 |
609 | } |
0de566d7 |
610 | |
611 | |
612 | if (yyerrstatus == 3) { |
613 | /* If just tried and failed to reuse lookahead token after an |
614 | error, discard it. */ |
615 | |
616 | /* Return failure if at end of input. */ |
617 | if (yychar == YYEOF) { |
618 | /* Pop the error token. */ |
619 | YYPOPSTACK; |
620 | /* Pop the rest of the stack. */ |
621 | while (yyss < yyssp) { |
9388183f |
622 | YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp); |
0539ab63 |
623 | if (yy_is_opval[yystos[*yyssp]]) { |
624 | YYDPRINTF ((Perl_debug_log, "(freeing op)\n")); |
625 | op_free(yyvsp->opval); |
626 | } |
0de566d7 |
627 | YYPOPSTACK; |
628 | } |
629 | YYABORT; |
630 | } |
631 | |
9388183f |
632 | YYDSYMPRINTF ("Error: discarding", yytoken, &yylval); |
0de566d7 |
633 | yychar = YYEMPTY; |
634 | |
93a17b20 |
635 | } |
0de566d7 |
636 | |
637 | /* Else will try to reuse lookahead token after shifting the error |
638 | token. */ |
639 | goto yyerrlab1; |
640 | |
641 | |
642 | /*----------------------------------------------------. |
643 | | yyerrlab1 -- error raised explicitly by an action. | |
644 | `----------------------------------------------------*/ |
645 | yyerrlab1: |
646 | yyerrstatus = 3; /* Each real token shifted decrements this. */ |
647 | |
648 | for (;;) { |
649 | yyn = yypact[yystate]; |
650 | if (yyn != YYPACT_NINF) { |
651 | yyn += YYTERROR; |
652 | if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) { |
653 | yyn = yytable[yyn]; |
654 | if (0 < yyn) |
655 | break; |
656 | } |
657 | } |
658 | |
659 | /* Pop the current state because it cannot handle the error token. */ |
660 | if (yyssp == yyss) |
661 | YYABORT; |
662 | |
9388183f |
663 | YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp); |
0539ab63 |
664 | if (yy_is_opval[yystos[*yyssp]]) { |
665 | YYDPRINTF ((Perl_debug_log, "(freeing op)\n")); |
666 | op_free(yyvsp->opval); |
667 | } |
0de566d7 |
668 | yyvsp--; |
9388183f |
669 | #ifdef DEBUGGING |
670 | yynsp--; |
671 | #endif |
0de566d7 |
672 | yystate = *--yyssp; |
673 | |
9388183f |
674 | YY_STACK_PRINT (yyss, yyssp, yyvs, yyns); |
93a17b20 |
675 | } |
0de566d7 |
676 | |
677 | if (yyn == YYFINAL) |
678 | YYACCEPT; |
679 | |
680 | YYDPRINTF ((Perl_debug_log, "Shifting error token, ")); |
681 | |
682 | *++yyvsp = yylval; |
9388183f |
683 | #ifdef DEBUGGING |
684 | *++yynsp ="<err>"; |
685 | #endif |
0de566d7 |
686 | |
687 | yystate = yyn; |
9388183f |
688 | YYDPRINTF ((Perl_debug_log, "Entering state %d\n", yystate)); |
689 | |
0de566d7 |
690 | goto yynewstate; |
691 | |
692 | |
693 | /*-------------------------------------. |
694 | | yyacceptlab -- YYACCEPT comes here. | |
695 | `-------------------------------------*/ |
696 | yyacceptlab: |
697 | yyresult = 0; |
698 | goto yyreturn; |
699 | |
700 | /*-----------------------------------. |
701 | | yyabortlab -- YYABORT comes here. | |
702 | `-----------------------------------*/ |
703 | yyabortlab: |
704 | yyresult = 1; |
705 | goto yyreturn; |
706 | |
707 | /*----------------------------------------------. |
708 | | yyoverflowlab -- parser overflow comes here. | |
709 | `----------------------------------------------*/ |
710 | yyoverflowlab: |
711 | yyerror ("parser stack overflow"); |
712 | yyresult = 2; |
713 | /* Fall through. */ |
714 | |
715 | yyreturn: |
716 | |
c86b7e91 |
717 | LEAVE; /* force stack free before we return */ |
e1f15930 |
718 | |
0de566d7 |
719 | return yyresult; |
e1f15930 |
720 | } |
66610fdd |
721 | |
722 | /* |
723 | * Local variables: |
724 | * c-indentation-style: bsd |
725 | * c-basic-offset: 4 |
726 | * indent-tabs-mode: t |
727 | * End: |
728 | * |
37442d52 |
729 | * ex: set ts=8 sts=4 sw=4 noet: |
730 | */ |