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