]> git.saurik.com Git - bison.git/blob - data/yacc.c
* src/state.h, src/state.c (shift_t, SHIFT_SYMBOL, SHIFT_IS_SHIFT)
[bison.git] / data / yacc.c
1 m4_divert(-1) -*- C -*-
2 m4_include([c.m4])
3
4 # Yacc compatible skeleton for Bison
5 # Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002 Free Software Foundation, Inc.
6
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
11
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
16
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
20 # 02111-1307 USA
21
22 # b4_lhs_value([TYPE])
23 # --------------------
24 # Expansion of $<TYPE>$.
25 m4_define([b4_lhs_value],
26 [yyval[]m4_ifval([$1], [.$1])])
27
28
29 # b4_rhs_value(RULE-LENGTH, NUM, [TYPE])
30 # --------------------------------------
31 # Expansion of $<TYPE>NUM, where the current rule has RULE-LENGTH
32 # symbols on RHS.
33 m4_define([b4_rhs_value],
34 [yyvsp@<:@m4_eval([$2 - $1])@:>@m4_ifval([$3], [.$3])])
35
36
37
38 ## ----------- ##
39 ## Locations. ##
40 ## ----------- ##
41
42 # b4_location_if(IF-TRUE, IF-FALSE)
43 # ---------------------------------
44 # Expand IF-TRUE, if locations are used, IF-FALSE otherwise.
45 m4_define([b4_location_if],
46 [m4_if(b4_locations_flag, [1],
47 [$1],
48 [$2])])
49
50
51 # b4_lhs_location()
52 # -----------------
53 # Expansion of @$.
54 m4_define([b4_lhs_location],
55 [yyloc])
56
57
58 # b4_rhs_location(RULE-LENGTH, NUM)
59 # ---------------------------------
60 # Expansion of @NUM, where the current rule has RULE-LENGTH symbols
61 # on RHS.
62 m4_define([b4_rhs_location],
63 [yylsp@<:@m4_eval([$2 - $1])@:>@])
64
65
66
67 ## -------------- ##
68 ## %pure-parser. ##
69 ## -------------- ##
70
71 # b4_pure_if(IF-TRUE, IF-FALSE)
72 # -----------------------------
73 # Expand IF-TRUE, if %pure-parser, IF-FALSE otherwise.
74 m4_define([b4_pure_if],
75 [m4_if(b4_pure, [1],
76 [$1],
77 [$2])])
78
79
80 ## ------------------- ##
81 ## Output file names. ##
82 ## ------------------- ##
83
84 m4_define_default([b4_input_suffix], [.y])
85
86 m4_define_default([b4_output_parser_suffix],
87 [m4_translit(b4_input_suffix, [yY], [cC])])
88
89 m4_define_default([b4_output_parser_name],
90 [b4_output_prefix[]b4_output_infix[]b4_output_parser_suffix[]])
91
92
93 m4_define_default([b4_output_header_suffix],
94 [m4_translit(b4_input_suffix, [yY], [hH])])
95
96 m4_define_default([b4_output_header_name],
97 [b4_output_prefix[]b4_output_infix[]b4_output_header_suffix[]])
98
99 m4_define_default([b4_header_guard],
100 [m4_bpatsubst(m4_toupper([BISON_]b4_output_header_name),
101 [[^ABCDEFGHIJKLMNOPQRSTUVWXYZ]], [_])])
102
103
104
105 ## --------------------------------------------------------- ##
106 ## Defining symbol actions, e.g., printers and destructors. ##
107 ## --------------------------------------------------------- ##
108
109 # b4_symbol_actions(FILENAME, LINENO,
110 # SYMBOL-TAG, SYMBOL-NUM,
111 # SYMBOL-ACTION, SYMBOL-TYPENAME)
112 # -------------------------------------------------
113 m4_define([b4_symbol_actions],
114 [m4_pushdef([b4_dollar_dollar], [yyvalue.$6])dnl
115 m4_pushdef([b4_at_dollar], [yylocation])dnl
116 case $4: /* $3 */
117 #line $2 "$1"
118 $5;
119 #line __oline__ "__ofile__"
120 break;
121 m4_popdef([b4_at_dollar])dnl
122 m4_popdef([b4_dollar_dollar])dnl
123 ])
124
125
126
127 m4_divert(0)dnl
128 #output "b4_output_parser_name"
129 b4_copyright([Skeleton parser for Yacc-like parsing with Bison],
130 [1984, 1989, 1990, 2000, 2001, 2002])
131
132 /* Written by Richard Stallman by simplifying the original so called
133 ``semantic'' parser. */
134
135 /* All symbols defined below should begin with yy or YY, to avoid
136 infringing on user name space. This should be done even for local
137 variables, as they might otherwise be expanded by user macros.
138 There are some unavoidable exceptions within include files to
139 define necessary library symbols; they are noted "INFRINGES ON
140 USER NAME SPACE" below. */
141
142 /* Identify Bison output. */
143 #define YYBISON 1
144
145 /* Pure parsers. */
146 #define YYPURE b4_pure
147
148 /* Using locations. */
149 #define YYLSP_NEEDED b4_locations_flag
150
151 m4_if(b4_prefix[], [yy], [],
152 [/* If NAME_PREFIX is specified substitute the variables and functions
153 names. */
154 #define yyparse b4_prefix[]parse
155 #define yylex b4_prefix[]lex
156 #define yyerror b4_prefix[]error
157 #define yylval b4_prefix[]lval
158 #define yychar b4_prefix[]char
159 #define yydebug b4_prefix[]debug
160 #define yynerrs b4_prefix[]nerrs
161 b4_location_if([#define yylloc b4_prefix[]lloc])])
162
163 /* Copy the first part of user declarations. */
164 b4_pre_prologue
165
166 b4_token_defines(b4_tokens)
167
168 /* Enabling traces. */
169 #ifndef YYDEBUG
170 # define YYDEBUG b4_debug
171 #endif
172
173 /* Enabling verbose error messages. */
174 #ifdef YYERROR_VERBOSE
175 # undef YYERROR_VERBOSE
176 # define YYERROR_VERBOSE 1
177 #else
178 # define YYERROR_VERBOSE b4_error_verbose
179 #endif
180
181 #ifndef YYSTYPE
182 m4_ifdef([b4_stype],
183 [#line b4_stype_line "b4_filename"
184 typedef union b4_stype yystype;
185 /* Line __line__ of __file__. */
186 #line __oline__ "__ofile__"],
187 [typedef int yystype;])
188 # define YYSTYPE yystype
189 # define YYSTYPE_IS_TRIVIAL 1
190 #endif
191
192 #ifndef YYLTYPE
193 typedef struct yyltype
194 {
195 int first_line;
196 int first_column;
197 int last_line;
198 int last_column;
199 } yyltype;
200 # define YYLTYPE b4_ltype
201 # define YYLTYPE_IS_TRIVIAL 1
202 #endif
203
204 /* Copy the second part of user declarations. */
205 b4_post_prologue
206
207 /* Line __line__ of __file__. */
208 #line __oline__ "__ofile__"
209
210 #if ! defined (yyoverflow) || YYERROR_VERBOSE
211
212 /* The parser invokes alloca or malloc; define the necessary symbols. */
213
214 # if YYSTACK_USE_ALLOCA
215 # define YYSTACK_ALLOC alloca
216 # else
217 # ifndef YYSTACK_USE_ALLOCA
218 # if defined (alloca) || defined (_ALLOCA_H)
219 # define YYSTACK_ALLOC alloca
220 # else
221 # ifdef __GNUC__
222 # define YYSTACK_ALLOC __builtin_alloca
223 # endif
224 # endif
225 # endif
226 # endif
227
228 # ifdef YYSTACK_ALLOC
229 /* Pacify GCC's `empty if-body' warning. */
230 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
231 # else
232 # if defined (__STDC__) || defined (__cplusplus)
233 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
234 # define YYSIZE_T size_t
235 # endif
236 # define YYSTACK_ALLOC malloc
237 # define YYSTACK_FREE free
238 # endif
239 #endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
240
241
242 #if (! defined (yyoverflow) \
243 && (! defined (__cplusplus) \
244 || (YYLTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
245
246 /* A type that is properly aligned for any stack member. */
247 union yyalloc
248 {
249 short yyss;
250 YYSTYPE yyvs;
251 b4_location_if([ YYLTYPE yyls;
252 ])dnl
253 };
254
255 /* The size of the maximum gap between one aligned stack and the next. */
256 # define YYSTACK_GAP_MAX (sizeof (union yyalloc) - 1)
257
258 /* The size of an array large to enough to hold all stacks, each with
259 N elements. */
260 b4_location_if(
261 [# define YYSTACK_BYTES(N) \
262 ((N) * (sizeof (short) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \
263 + 2 * YYSTACK_GAP_MAX)],
264 [# define YYSTACK_BYTES(N) \
265 ((N) * (sizeof (short) + sizeof (YYSTYPE)) \
266 + YYSTACK_GAP_MAX)])
267
268 /* Copy COUNT objects from FROM to TO. The source and destination do
269 not overlap. */
270 # ifndef YYCOPY
271 # if 1 < __GNUC__
272 # define YYCOPY(To, From, Count) \
273 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
274 # else
275 # define YYCOPY(To, From, Count) \
276 do \
277 { \
278 register YYSIZE_T yyi; \
279 for (yyi = 0; yyi < (Count); yyi++) \
280 (To)[[yyi]] = (From)[[yyi]]; \
281 } \
282 while (0)
283 # endif
284 # endif
285
286 /* Relocate STACK from its old location to the new one. The
287 local variables YYSIZE and YYSTACKSIZE give the old and new number of
288 elements in the stack, and YYPTR gives the new location of the
289 stack. Advance YYPTR to a properly aligned location for the next
290 stack. */
291 # define YYSTACK_RELOCATE(Stack) \
292 do \
293 { \
294 YYSIZE_T yynewbytes; \
295 YYCOPY (&yyptr->Stack, Stack, yysize); \
296 Stack = &yyptr->Stack; \
297 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAX; \
298 yyptr += yynewbytes / sizeof (*yyptr); \
299 } \
300 while (0)
301
302 #endif
303
304 /* YYFINAL -- State number of the termination state. */
305 #define YYFINAL b4_final
306 #define YYFLAG b4_flag
307 #define YYLAST b4_last
308
309 /* YYNTOKENS -- Number of terminals. */
310 #define YYNTOKENS b4_ntokens
311 /* YYNNTS -- Number of nonterminals. */
312 #define YYNNTS b4_nnts
313 /* YYNRULES -- Number of rules. */
314 #define YYNRULES b4_nrules
315 /* YYNRULES -- Number of states. */
316 #define YYNSTATES b4_nstates
317
318 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
319 #define YYUNDEFTOK b4_undef_token_number
320 #define YYMAXUTOK b4_user_token_number_max
321
322 #define YYTRANSLATE(X) \
323 ((unsigned)(X) <= YYMAXUTOK ? yytranslate[[X]] : YYUNDEFTOK)
324
325 /* YYTRANSLATE[[YYLEX]] -- Bison symbol number corresponding to YYLEX. */
326 static const b4_uint_type(b4_translate_max) yytranslate[[]] =
327 {
328 b4_translate
329 };
330
331 #if YYDEBUG
332 /* YYPRHS[[YYN]] -- Index of the first RHS symbol of rule number YYN in
333 YYRHS. */
334 static const b4_uint_type(b4_prhs_max) yyprhs[[]] =
335 {
336 b4_prhs
337 };
338
339 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
340 static const b4_sint_type(b4_rhs_max) yyrhs[[]] =
341 {
342 b4_rhs
343 };
344
345 /* YYRLINE[[YYN]] -- source line where rule number YYN was defined. */
346 static const b4_uint_type(b4_rline_max) yyrline[[]] =
347 {
348 b4_rline
349 };
350 #endif
351
352 #if YYDEBUG || YYERROR_VERBOSE
353 /* YYTNME[[SYMBOL-NUM]] -- String name of the symbol SYMBOL-NUM.
354 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
355 static const char *const yytname[[]] =
356 {
357 b4_tname
358 };
359 #endif
360
361 /* YYTOKNUM[[YYLEX-NUM]] -- Internal token number corresponding to
362 token YYLEX-NUM. */
363 static const short yytoknum[[]] =
364 {
365 b4_toknum
366 };
367
368 /* YYR1[[YYN]] -- Symbol number of symbol that rule YYN derives. */
369 static const b4_uint_type(b4_r1_max) yyr1[[]] =
370 {
371 b4_r1
372 };
373
374 /* YYR2[[YYN]] -- Number of symbols composing right hand side of rule YYN. */
375 static const b4_uint_type(b4_r2_max) yyr2[[]] =
376 {
377 b4_r2
378 };
379
380 /* YYDEFACT[[STATE-NAME]] -- Default rule to reduce with in state
381 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
382 means the default is an error. */
383 static const short yydefact[[]] =
384 {
385 b4_defact
386 };
387
388 /* YYPGOTO[[NTERM-NUM]]. */
389 static const short yydefgoto[[]] =
390 {
391 b4_defgoto
392 };
393
394 /* YYPACT[[STATE-NUM]] -- Index in YYTABLE of the portion describing
395 STATE-NUM. */
396 static const short yypact[[]] =
397 {
398 b4_pact
399 };
400
401 /* YYPGOTO[[NTERM-NUM]]. */
402 static const short yypgoto[[]] =
403 {
404 b4_pgoto
405 };
406
407 /* YYTABLE[[YYPACT[STATE-NUM]]]. What to do in state STATE-NUM. If
408 positive, shift that token. If negative, reduce the rule which
409 number is the opposite. If zero, do what YYDEFACT says. */
410 static const short yytable[[]] =
411 {
412 b4_table
413 };
414
415 static const short yycheck[[]] =
416 {
417 b4_check
418 };
419
420 /* YYSTOS[[STATE-NUM]] -- The (internal number of the) accessing
421 symbol of state STATE-NUM. */
422 static const b4_uint_type(b4_stos_max) yystos[[]] =
423 {
424 b4_stos
425 };
426
427 #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
428 # define YYSIZE_T __SIZE_TYPE__
429 #endif
430 #if ! defined (YYSIZE_T) && defined (size_t)
431 # define YYSIZE_T size_t
432 #endif
433 #if ! defined (YYSIZE_T)
434 # if defined (__STDC__) || defined (__cplusplus)
435 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
436 # define YYSIZE_T size_t
437 # endif
438 #endif
439 #if ! defined (YYSIZE_T)
440 # define YYSIZE_T unsigned int
441 #endif
442
443 #define yyerrok (yyerrstatus = 0)
444 #define yyclearin (yychar = YYEMPTY)
445 #define YYEMPTY -2
446 #define YYEOF 0
447
448 #define YYACCEPT goto yyacceptlab
449 #define YYABORT goto yyabortlab
450 #define YYERROR goto yyerrlab1
451
452 /* Like YYERROR except do call yyerror. This remains here temporarily
453 to ease the transition to the new meaning of YYERROR, for GCC.
454 Once GCC version 2 has supplanted version 1, this can go. */
455
456 #define YYFAIL goto yyerrlab
457
458 #define YYRECOVERING() (!!yyerrstatus)
459
460 #define YYBACKUP(Token, Value) \
461 do \
462 if (yychar == YYEMPTY && yylen == 1) \
463 { \
464 yychar = (Token); \
465 yylval = (Value); \
466 yychar1 = YYTRANSLATE (yychar); \
467 YYPOPSTACK; \
468 goto yybackup; \
469 } \
470 else \
471 { \
472 yyerror ("syntax error: cannot back up"); \
473 YYERROR; \
474 } \
475 while (0)
476
477 #define YYTERROR 1
478 #define YYERRCODE 256
479
480 /* YYLLOC_DEFAULT -- Compute the default location (before the actions
481 are run). */
482
483 #ifndef YYLLOC_DEFAULT
484 # define YYLLOC_DEFAULT(Current, Rhs, N) \
485 Current.first_line = Rhs[[1]].first_line; \
486 Current.first_column = Rhs[[1]].first_column; \
487 Current.last_line = Rhs[[N]].last_line; \
488 Current.last_column = Rhs[[N]].last_column;
489 #endif
490
491 /* YYLEX -- calling `yylex' with the right arguments. */
492
493 b4_pure_if(
494 [#ifdef YYLEX_PARAM
495 # define YYLEX yylex (&yylval[]b4_location_if([, &yylloc]), YYLEX_PARAM)
496 #else
497 # define YYLEX yylex (&yylval[]b4_location_if([, &yylloc]))
498 #endif],
499 [#define YYLEX yylex ()])
500
501 /* Enable debugging if requested. */
502 #if YYDEBUG
503
504 # ifndef YYFPRINTF
505 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
506 # define YYFPRINTF fprintf
507 # endif
508
509 # define YYDPRINTF(Args) \
510 do { \
511 if (yydebug) \
512 YYFPRINTF Args; \
513 } while (0)
514 # define YYDSYMPRINT(Args) \
515 do { \
516 if (yydebug) \
517 yysymprint Args; \
518 } while (0)
519 /* Nonzero means print parse trace. It is left uninitialized so that
520 multiple parsers can coexist. */
521 int yydebug;
522 #else /* !YYDEBUG */
523 # define YYDPRINTF(Args)
524 # define YYDSYMPRINT(Args)
525 #endif /* !YYDEBUG */
526
527 /* YYINITDEPTH -- initial size of the parser's stacks. */
528 #ifndef YYINITDEPTH
529 # define YYINITDEPTH b4_initdepth
530 #endif
531
532 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
533 if the built-in stack extension method is used).
534
535 Do not make this value too large; the results are undefined if
536 SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH)
537 evaluated with infinite-precision integer arithmetic. */
538
539 #if YYMAXDEPTH == 0
540 # undef YYMAXDEPTH
541 #endif
542
543 #ifndef YYMAXDEPTH
544 # define YYMAXDEPTH b4_maxdepth
545 #endif
546
547 \f
548
549 #if YYERROR_VERBOSE
550
551 # ifndef yystrlen
552 # if defined (__GLIBC__) && defined (_STRING_H)
553 # define yystrlen strlen
554 # else
555 /* Return the length of YYSTR. */
556 static YYSIZE_T
557 # if defined (__STDC__) || defined (__cplusplus)
558 yystrlen (const char *yystr)
559 # else
560 yystrlen (yystr)
561 const char *yystr;
562 # endif
563 {
564 register const char *yys = yystr;
565
566 while (*yys++ != '\0')
567 continue;
568
569 return yys - yystr - 1;
570 }
571 # endif
572 # endif
573
574 # ifndef yystpcpy
575 # if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
576 # define yystpcpy stpcpy
577 # else
578 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
579 YYDEST. */
580 static char *
581 # if defined (__STDC__) || defined (__cplusplus)
582 yystpcpy (char *yydest, const char *yysrc)
583 # else
584 yystpcpy (yydest, yysrc)
585 char *yydest;
586 const char *yysrc;
587 # endif
588 {
589 register char *yyd = yydest;
590 register const char *yys = yysrc;
591
592 while ((*yyd++ = *yys++) != '\0')
593 continue;
594
595 return yyd - 1;
596 }
597 # endif
598 # endif
599
600 #endif /* !YYERROR_VERBOSE */
601
602 \f
603
604 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
605 into yyparse. The argument should have type void *.
606 It should actually point to an object.
607 Grammar actions can access the variable by casting it
608 to the proper pointer type. */
609
610 #ifdef YYPARSE_PARAM
611 # if defined (__STDC__) || defined (__cplusplus)
612 # define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
613 # define YYPARSE_PARAM_DECL
614 # else
615 # define YYPARSE_PARAM_ARG YYPARSE_PARAM
616 # define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
617 # endif
618 #else /* !YYPARSE_PARAM */
619 # define YYPARSE_PARAM_ARG
620 # define YYPARSE_PARAM_DECL
621 #endif /* !YYPARSE_PARAM */
622
623 /* Prevent warning if -Wstrict-prototypes. */
624 #ifdef __GNUC__
625 # ifdef YYPARSE_PARAM
626 int yyparse (void *);
627 # else
628 int yyparse (void);
629 # endif
630 #endif
631
632 #if defined (__STDC__) || defined (__cplusplus)
633 static void yydestruct (int yytype,
634 YYSTYPE yyvalue[]b4_location_if([, YYLTYPE yylocation]));
635 # if YYDEBUG
636 static void yysymprint (FILE* out, int yytype,
637 YYSTYPE yyvalue[]b4_location_if([, YYLTYPE yylocation]));
638 # endif
639 #endif
640
641 m4_divert_push([KILL])# ======================== M4 code.
642 # b4_declare_parser_variables
643 # ---------------------------
644 # Declare the variables that are global, or local to YYPARSE if
645 # pure-parser
646 m4_define([b4_declare_parser_variables],
647 [/* The lookahead symbol. */
648 int yychar;
649
650 /* The semantic value of the lookahead symbol. */
651 YYSTYPE yylval;
652
653 /* Number of parse errors so far. */
654 int yynerrs;b4_location_if([
655 /* Location data for the lookahead symbol. */
656 YYLTYPE yylloc;])
657 ])
658 m4_divert_pop([KILL])dnl# ====================== End of M4 code.
659
660 b4_pure_if([],
661 [b4_declare_parser_variables])
662
663 int
664 yyparse (YYPARSE_PARAM_ARG)
665 YYPARSE_PARAM_DECL
666 {[
667 ]b4_pure_if([b4_declare_parser_variables])[
668 register int yystate;
669 register int yyn;
670 int yyresult;
671 /* Number of tokens to shift before error messages enabled. */
672 int yyerrstatus;
673 /* Lookahead token as an internal (translated) token number. */
674 int yychar1 = 0;
675
676 /* Three stacks and their tools:
677 `yyss': related to states,
678 `yyvs': related to semantic values,
679 `yyls': related to locations.
680
681 Refer to the stacks thru separate pointers, to allow yyoverflow
682 to reallocate them elsewhere. */
683
684 /* The state stack. */
685 short yyssa[YYINITDEPTH];
686 short *yyss = yyssa;
687 register short *yyssp;
688
689 /* The semantic value stack. */
690 YYSTYPE yyvsa[YYINITDEPTH];
691 YYSTYPE *yyvs = yyvsa;
692 register YYSTYPE *yyvsp;
693
694 ]b4_location_if(
695 [[ /* The location stack. */
696 YYLTYPE yylsa[YYINITDEPTH];
697 YYLTYPE *yyls = yylsa;
698 YYLTYPE *yylsp;]])[
699
700 #define YYPOPSTACK (yyvsp--, yyssp--]b4_location_if([, yylsp--])[)
701
702 YYSIZE_T yystacksize = YYINITDEPTH;
703
704 /* The variables used to return semantic value and location from the
705 action routines. */
706 YYSTYPE yyval;
707 ]b4_location_if([ YYLTYPE yyloc;])[
708
709 /* When reducing, the number of symbols on the RHS of the reduced
710 rule. */
711 int yylen;
712
713 YYDPRINTF ((stderr, "Starting parse\n"));
714
715 yystate = 0;
716 yyerrstatus = 0;
717 yynerrs = 0;
718 yychar = YYEMPTY; /* Cause a token to be read. */
719
720 /* Initialize stack pointers.
721 Waste one element of value and location stack
722 so that they stay on the same level as the state stack.
723 The wasted elements are never initialized. */
724
725 yyssp = yyss;
726 yyvsp = yyvs;
727 ]b4_location_if([ yylsp = yyls;])[
728 goto yysetstate;
729
730 /*------------------------------------------------------------.
731 | yynewstate -- Push a new state, which is found in yystate. |
732 `------------------------------------------------------------*/
733 yynewstate:
734 /* In all cases, when you get here, the value and location stacks
735 have just been pushed. so pushing a state here evens the stacks.
736 */
737 yyssp++;
738
739 yysetstate:
740 *yyssp = yystate;
741
742 if (yyssp >= yyss + yystacksize - 1)
743 {
744 /* Get the current used size of the three stacks, in elements. */
745 YYSIZE_T yysize = yyssp - yyss + 1;
746
747 #ifdef yyoverflow
748 {
749 /* Give user a chance to reallocate the stack. Use copies of
750 these so that the &'s don't force the real ones into
751 memory. */
752 YYSTYPE *yyvs1 = yyvs;
753 short *yyss1 = yyss;
754 ]b4_location_if([ YYLTYPE *yyls1 = yyls;])[
755
756 /* Each stack pointer address is followed by the size of the
757 data in use in that stack, in bytes. This used to be a
758 conditional around just the two extra args, but that might
759 be undefined if yyoverflow is a macro. */
760 yyoverflow ("parser stack overflow",
761 &yyss1, yysize * sizeof (*yyssp),
762 &yyvs1, yysize * sizeof (*yyvsp),
763 ]b4_location_if([ &yyls1, yysize * sizeof (*yylsp),])[
764 &yystacksize);
765 ]b4_location_if([ yyls = yyls1;])[
766 yyss = yyss1;
767 yyvs = yyvs1;
768 }
769 #else /* no yyoverflow */
770 # ifndef YYSTACK_RELOCATE
771 goto yyoverflowlab;
772 # else
773 /* Extend the stack our own way. */
774 if (yystacksize >= YYMAXDEPTH)
775 goto yyoverflowlab;
776 yystacksize *= 2;
777 if (yystacksize > YYMAXDEPTH)
778 yystacksize = YYMAXDEPTH;
779
780 {
781 short *yyss1 = yyss;
782 union yyalloc *yyptr =
783 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
784 if (! yyptr)
785 goto yyoverflowlab;
786 YYSTACK_RELOCATE (yyss);
787 YYSTACK_RELOCATE (yyvs);
788 ]b4_location_if([ YYSTACK_RELOCATE (yyls);])[
789 # undef YYSTACK_RELOCATE
790 if (yyss1 != yyssa)
791 YYSTACK_FREE (yyss1);
792 }
793 # endif
794 #endif /* no yyoverflow */
795
796 yyssp = yyss + yysize - 1;
797 yyvsp = yyvs + yysize - 1;
798 ]b4_location_if([ yylsp = yyls + yysize - 1;])[
799
800 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
801 (unsigned long int) yystacksize));
802
803 if (yyssp >= yyss + yystacksize - 1)
804 YYABORT;
805 }
806
807 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
808
809 goto yybackup;
810
811 /*-----------.
812 | yybackup. |
813 `-----------*/
814 yybackup:
815
816 /* Do appropriate processing given the current state. */
817 /* Read a lookahead token if we need one and don't already have one. */
818 /* yyresume: */
819
820 /* First try to decide what to do without reference to lookahead token. */
821
822 yyn = yypact[yystate];
823 if (yyn == YYFLAG)
824 goto yydefault;
825
826 /* Not known => get a lookahead token if don't already have one. */
827
828 /* yychar is either YYEMPTY or YYEOF
829 or a valid token in external form. */
830
831 if (yychar == YYEMPTY)
832 {
833 YYDPRINTF ((stderr, "Reading a token: "));
834 yychar = YYLEX;
835 }
836
837 /* Convert token to internal form (in yychar1) for indexing tables with. */
838
839 if (yychar <= 0) /* This means end of input. */
840 {
841 yychar1 = 0;
842 yychar = YYEOF; /* Don't call YYLEX any more. */
843
844 YYDPRINTF ((stderr, "Now at end of input.\n"));
845 }
846 else
847 {
848 yychar1 = YYTRANSLATE (yychar);
849
850 /* We have to keep this `#if YYDEBUG', since we use variables
851 which are defined only if `YYDEBUG' is set. */
852 YYDPRINTF ((stderr, "Next token is "));
853 YYDSYMPRINT ((stderr, yychar1, yylval]b4_location_if([, yyloc])[));
854 YYDPRINTF ((stderr, "\n"));
855 }
856
857 yyn += yychar1;
858 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
859 goto yydefault;
860
861 yyn = yytable[yyn];
862
863 /* yyn is what to do for this token type in this state.
864 Negative => reduce, -yyn is rule number.
865 Positive => shift, yyn is new state.
866 New state is final state => don't bother to shift,
867 just return success.
868 0, or most negative number => error. */
869
870 if (yyn < 0)
871 {
872 if (yyn == YYFLAG)
873 goto yyerrlab;
874 yyn = -yyn;
875 goto yyreduce;
876 }
877 else if (yyn == 0)
878 goto yyerrlab;
879
880 if (yyn == YYFINAL)
881 YYACCEPT;
882
883 /* Shift the lookahead token. */
884 YYDPRINTF ((stderr, "Shifting token %d (%s), ",
885 yychar, yytname[yychar1]));
886
887 /* Discard the token being shifted unless it is eof. */
888 if (yychar != YYEOF)
889 yychar = YYEMPTY;
890
891 *++yyvsp = yylval;
892 ]b4_location_if([ *++yylsp = yylloc;])[
893
894 /* Count tokens shifted since error; after three, turn off error
895 status. */
896 if (yyerrstatus)
897 yyerrstatus--;
898
899 yystate = yyn;
900 goto yynewstate;
901
902
903 /*-----------------------------------------------------------.
904 | yydefault -- do the default action for the current state. |
905 `-----------------------------------------------------------*/
906 yydefault:
907 yyn = yydefact[yystate];
908 if (yyn == 0)
909 goto yyerrlab;
910 goto yyreduce;
911
912
913 /*-----------------------------.
914 | yyreduce -- Do a reduction. |
915 `-----------------------------*/
916 yyreduce:
917 /* yyn is the number of a rule to reduce with. */
918 yylen = yyr2[yyn];
919
920 /* If YYLEN is nonzero, implement the default value of the action:
921 `$$ = $1'.
922
923 Otherwise, the following line sets YYVAL to the semantic value of
924 the lookahead token. This behavior is undocumented and Bison
925 users should not rely upon it. Assigning to YYVAL
926 unconditionally makes the parser a bit smaller, and it avoids a
927 GCC warning that YYVAL may be used uninitialized. */
928 yyval = yyvsp[1-yylen];
929
930 ]b4_location_if(
931 [ /* Default location. */
932 YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);])[
933
934 #if YYDEBUG
935 /* We have to keep this `#if YYDEBUG', since we use variables which
936 are defined only if `YYDEBUG' is set. */
937 if (yydebug)
938 {
939 int yyi;
940
941 YYFPRINTF (stderr, "Reducing via rule %d (line %d), ",
942 yyn - 1, yyrline[yyn]);
943
944 /* Print the symbols being reduced, and their result. */
945 for (yyi = yyprhs[yyn]; yyrhs[yyi] >= 0; yyi++)
946 YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]);
947 YYFPRINTF (stderr, " -> %s\n", yytname[yyr1[yyn]]);
948 }
949 #endif
950 switch (yyn)
951 ]{
952 b4_actions
953 }
954
955 /* Line __line__ of __file__. */
956 #line __oline__ "__ofile__"
957 \f
958 [ yyvsp -= yylen;
959 yyssp -= yylen;
960 ]b4_location_if([ yylsp -= yylen;])[
961
962 #if YYDEBUG
963 if (yydebug)
964 {
965 short *yyssp1 = yyss - 1;
966 YYFPRINTF (stderr, "state stack now");
967 while (yyssp1 != yyssp)
968 YYFPRINTF (stderr, " %d", *++yyssp1);
969 YYFPRINTF (stderr, "\n");
970 }
971 #endif
972
973 *++yyvsp = yyval;
974 ]b4_location_if([ *++yylsp = yyloc;])[
975
976 /* Now `shift' the result of the reduction. Determine what state
977 that goes to, based on the state we popped back to and the rule
978 number reduced by. */
979
980 yyn = yyr1[yyn];
981
982 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
983 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
984 yystate = yytable[yystate];
985 else
986 yystate = yydefgoto[yyn - YYNTOKENS];
987
988 goto yynewstate;
989
990
991 /*------------------------------------.
992 | yyerrlab -- here on detecting error |
993 `------------------------------------*/
994 yyerrlab:
995 /* If not already recovering from an error, report this error. */
996 if (!yyerrstatus)
997 {
998 ++yynerrs;
999
1000 #if YYERROR_VERBOSE
1001 yyn = yypact[yystate];
1002
1003 if (yyn > YYFLAG && yyn < YYLAST)
1004 {
1005 YYSIZE_T yysize = 0;
1006 char *yymsg;
1007 int yyx, yycount;
1008
1009 yycount = 0;
1010 /* Start YYX at -YYN if negative to avoid negative indexes in
1011 YYCHECK. */
1012 for (yyx = yyn < 0 ? -yyn : 0;
1013 yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++)
1014 if (yycheck[yyx + yyn] == yyx)
1015 yysize += yystrlen (yytname[yyx]) + 15, yycount++;
1016 yysize += yystrlen ("parse error, unexpected ") + 1;
1017 yysize += yystrlen (yytname[YYTRANSLATE (yychar)]);
1018 yymsg = (char *) YYSTACK_ALLOC (yysize);
1019 if (yymsg != 0)
1020 {
1021 char *yyp = yystpcpy (yymsg, "parse error, unexpected ");
1022 yyp = yystpcpy (yyp, yytname[YYTRANSLATE (yychar)]);
1023
1024 if (yycount < 5)
1025 {
1026 yycount = 0;
1027 for (yyx = yyn < 0 ? -yyn : 0;
1028 yyx < (int) (sizeof (yytname) / sizeof (char *));
1029 yyx++)
1030 if (yycheck[yyx + yyn] == yyx)
1031 {
1032 const char *yyq = ! yycount ? ", expecting " : " or ";
1033 yyp = yystpcpy (yyp, yyq);
1034 yyp = yystpcpy (yyp, yytname[yyx]);
1035 yycount++;
1036 }
1037 }
1038 yyerror (yymsg);
1039 YYSTACK_FREE (yymsg);
1040 }
1041 else
1042 yyerror ("parse error; also virtual memory exhausted");
1043 }
1044 else
1045 #endif /* YYERROR_VERBOSE */
1046 yyerror ("parse error");
1047 }
1048 goto yyerrlab1;
1049
1050
1051 /*----------------------------------------------------.
1052 | yyerrlab1 -- error raised explicitly by an action. |
1053 `----------------------------------------------------*/
1054 yyerrlab1:
1055 if (yyerrstatus == 3)
1056 {
1057 /* If just tried and failed to reuse lookahead token after an
1058 error, discard it. */
1059
1060 /* Return failure if at end of input. */
1061 if (yychar == YYEOF)
1062 {
1063 /* Pop the error token. */
1064 YYPOPSTACK;
1065 /* Pop the rest of the stack. */
1066 while (yyssp > yyss)
1067 {
1068 YYDPRINTF ((stderr, "Error: popping "));
1069 YYDSYMPRINT ((stderr,
1070 yystos[*yyssp],
1071 *yyvsp]b4_location_if([, *yylsp])[));
1072 YYDPRINTF ((stderr, "\n"));
1073 yydestruct (yystos[*yyssp], *yyvsp]b4_location_if([, *yylsp])[);
1074 YYPOPSTACK;
1075 }
1076 YYABORT;
1077 }
1078
1079 YYDPRINTF ((stderr, "Discarding token %d (%s).\n",
1080 yychar, yytname[yychar1]));
1081 yydestruct (yychar1, yylval]b4_location_if([, yylloc])[);
1082 yychar = YYEMPTY;
1083 }
1084
1085 /* Else will try to reuse lookahead token after shifting the error
1086 token. */
1087
1088 yyerrstatus = 3; /* Each real token shifted decrements this. */
1089
1090 for (;;)
1091 {
1092 yyn = yypact[yystate];
1093 if (yyn != YYFLAG)
1094 {
1095 yyn += YYTERROR;
1096 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
1097 {
1098 yyn = yytable[yyn];
1099 if (0 < yyn)
1100 break;
1101 }
1102 }
1103
1104 /* Pop the current state because it cannot handle the error token. */
1105 if (yyssp == yyss)
1106 YYABORT;
1107
1108 YYDPRINTF ((stderr, "Error: popping "));
1109 YYDSYMPRINT ((stderr,
1110 yystos[*yyssp], *yyvsp]b4_location_if([, *yylsp])[));
1111 YYDPRINTF ((stderr, "\n"));
1112
1113 yydestruct (yystos[yystate], *yyvsp]b4_location_if([, *yylsp])[);
1114 yyvsp--;
1115 yystate = *--yyssp;
1116 ]b4_location_if([ yylsp--;])[
1117
1118 #if YYDEBUG
1119 if (yydebug)
1120 {
1121 short *yyssp1 = yyss - 1;
1122 YYFPRINTF (stderr, "Error: state stack now");
1123 while (yyssp1 != yyssp)
1124 YYFPRINTF (stderr, " %d", *++yyssp1);
1125 YYFPRINTF (stderr, "\n");
1126 }
1127 #endif
1128 }
1129
1130 if (yyn == YYFINAL)
1131 YYACCEPT;
1132
1133 YYDPRINTF ((stderr, "Shifting error token, "));
1134
1135 *++yyvsp = yylval;
1136 ]b4_location_if([ *++yylsp = yylloc;])[
1137
1138 yystate = yyn;
1139 goto yynewstate;
1140
1141
1142 /*-------------------------------------.
1143 | yyacceptlab -- YYACCEPT comes here. |
1144 `-------------------------------------*/
1145 yyacceptlab:
1146 yyresult = 0;
1147 goto yyreturn;
1148
1149 /*-----------------------------------.
1150 | yyabortlab -- YYABORT comes here. |
1151 `-----------------------------------*/
1152 yyabortlab:
1153 yyresult = 1;
1154 goto yyreturn;
1155
1156 #ifndef yyoverflow
1157 /*----------------------------------------------.
1158 | yyoverflowlab -- parser overflow comes here. |
1159 `----------------------------------------------*/
1160 yyoverflowlab:
1161 yyerror ("parser stack overflow");
1162 yyresult = 2;
1163 /* Fall through. */
1164 #endif
1165
1166 yyreturn:
1167 #ifndef yyoverflow
1168 if (yyss != yyssa)
1169 YYSTACK_FREE (yyss);
1170 #endif
1171 return yyresult;
1172 ]}
1173
1174
1175 /*-----------------------------------------------.
1176 | Release the memory associated to this symbol. |
1177 `-----------------------------------------------*/
1178
1179 static void
1180 yydestruct (int yytype,
1181 YYSTYPE yyvalue[]b4_location_if([, YYLTYPE yylocation]))
1182 {
1183 /* Pacify ``unused variable'' warnings. */
1184 (void) yyvalue;
1185 b4_location_if([ (void) yylocation;
1186 ])dnl
1187
1188 switch (yytype)
1189 {
1190 m4_map([b4_symbol_actions], m4_defn([b4_symbol_destructors]))dnl
1191 default:
1192 break;
1193 }
1194 }
1195
1196
1197 #if YYDEBUG
1198 /*-----------------------------.
1199 | Print this symbol on YYOUT. |
1200 `-----------------------------*/
1201
1202 static void
1203 yysymprint (FILE* yyout, int yytype,
1204 YYSTYPE yyvalue[]b4_location_if([, YYLTYPE yylocation]))
1205 {
1206 /* Pacify ``unused variable'' warnings. */
1207 (void) yyvalue;
1208 b4_location_if([ (void) yylocation;
1209 ])dnl
1210
1211 if (yytype < YYNTOKENS)
1212 {
1213 YYFPRINTF (yyout, "token %s (", yytname[[yytype]]);
1214 # ifdef YYPRINT
1215 YYPRINT (yyout, yytoknum[[yytype]], yyvalue);
1216 # endif
1217 }
1218 else
1219 YYFPRINTF (yyout, "nterm %s (", yytname[[yytype]]);
1220
1221 switch (yytype)
1222 {
1223 m4_map([b4_symbol_actions], m4_defn([b4_symbol_printers]))dnl
1224 default:
1225 break;
1226 }
1227 YYFPRINTF (yyout, ")");
1228 }
1229 #endif /* YYDEBUG. */
1230
1231 b4_epilogue
1232 m4_if(b4_defines_flag, 0, [],
1233 [b4_copyright([Skeleton parser for Yacc-like parsing with Bison],
1234 [1984, 1989, 1990, 2000, 2001, 2002])
1235 #output "b4_output_header_name"
1236 #ifndef b4_header_guard
1237 # define b4_header_guard
1238
1239 b4_token_defines(b4_tokens)
1240
1241 #ifndef YYSTYPE
1242 m4_ifdef([b4_stype],
1243 [#line b4_stype_line "b4_filename"
1244 typedef union b4_stype yystype;
1245 /* Line __line__ of __file__. */
1246 #line __oline__ "__ofile__"],
1247 [typedef int yystype;])
1248 # define YYSTYPE yystype
1249 #endif
1250
1251 b4_pure_if([],
1252 [extern YYSTYPE b4_prefix[]lval;])
1253
1254 b4_location_if(
1255 [#ifndef YYLTYPE
1256 typedef struct yyltype
1257 {
1258 int first_line;
1259 int first_column;
1260 int last_line;
1261 int last_column;
1262 } yyltype;
1263 # define YYLTYPE yyltype
1264 #endif
1265
1266 m4_if(b4_pure, [0],
1267 [extern YYLTYPE b4_prefix[]lloc;])
1268 ])
1269 #endif /* not b4_header_guard */
1270 ])