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