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