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