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