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