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