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