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