]> git.saurik.com Git - bison.git/blob - data/yacc.c
29e13e9feb12d67f619140279a5212da2863e095
[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 # Accumule in b4_lex_param all the yylex arguments.
37 # Yes, this is quite ugly...
38 m4_define([b4_lex_param],
39 m4_dquote(b4_pure_if([[[[YYSTYPE *]], [[&yylval]]][]dnl
40 b4_location_if([, [[YYLTYPE *], [&yylloc]]])])dnl
41 m4_ifdef([b4_lex_param], [, ]b4_lex_param)))
42
43 # Yes, this is quite ugly...
44 m4_define_default([b4_parse_param])
45 m4_ifdef([b4_parse_param],
46 [m4_define([b4_parse_param],
47 b4_parse_param)])
48
49
50 ## ----------------- ##
51 ## Semantic Values. ##
52 ## ----------------- ##
53
54
55 # b4_lhs_value([TYPE])
56 # --------------------
57 # Expansion of $<TYPE>$.
58 m4_define([b4_lhs_value],
59 [yyval[]m4_ifval([$1], [.$1])])
60
61
62 # b4_rhs_value(RULE-LENGTH, NUM, [TYPE])
63 # --------------------------------------
64 # Expansion of $<TYPE>NUM, where the current rule has RULE-LENGTH
65 # symbols on RHS.
66 m4_define([b4_rhs_value],
67 [yyvsp@<:@m4_eval([$2 - $1])@:>@m4_ifval([$3], [.$3])])
68
69
70
71 ## ----------- ##
72 ## Locations. ##
73 ## ----------- ##
74
75 # b4_lhs_location()
76 # -----------------
77 # Expansion of @$.
78 m4_define([b4_lhs_location],
79 [yyloc])
80
81
82 # b4_rhs_location(RULE-LENGTH, NUM)
83 # ---------------------------------
84 # Expansion of @NUM, where the current rule has RULE-LENGTH symbols
85 # on RHS.
86 m4_define([b4_rhs_location],
87 [yylsp@<:@m4_eval([$2 - $1])@:>@])
88
89
90
91 ## ------------------- ##
92 ## Output file names. ##
93 ## ------------------- ##
94
95 m4_define_default([b4_input_suffix], [.y])
96
97 m4_define_default([b4_output_parser_suffix],
98 [m4_translit(b4_input_suffix, [yY], [cC])])
99
100 m4_define_default([b4_output_parser_name],
101 [b4_output_prefix[]b4_output_infix[]b4_output_parser_suffix[]])
102
103
104 m4_define_default([b4_output_header_suffix],
105 [m4_translit(b4_input_suffix, [yY], [hH])])
106
107 m4_define_default([b4_output_header_name],
108 [b4_output_prefix[]b4_output_infix[]b4_output_header_suffix[]])
109
110 m4_define_default([b4_header_guard],
111 [m4_bpatsubst(m4_toupper([BISON_]b4_output_header_name),
112 [[^ABCDEFGHIJKLMNOPQRSTUVWXYZ]], [_])])
113
114
115
116 ## --------------------------------------------------------- ##
117 ## Defining symbol actions, e.g., printers and destructors. ##
118 ## --------------------------------------------------------- ##
119
120 # b4_symbol_actions(FILENAME, LINENO,
121 # SYMBOL-TAG, SYMBOL-NUM,
122 # SYMBOL-ACTION, SYMBOL-TYPENAME)
123 # -------------------------------------------------
124 m4_define([b4_symbol_actions],
125 [m4_pushdef([b4_dollar_dollar], [yyvalue.$6])dnl
126 m4_pushdef([b4_at_dollar], [yylocation])dnl
127 case $4: /* $3 */
128 #line $2 "$1"
129 $5;
130 #line __oline__ "__ofile__"
131 break;
132 m4_popdef([b4_at_dollar])dnl
133 m4_popdef([b4_dollar_dollar])dnl
134 ])
135
136
137
138 m4_divert(0)dnl
139 #output "b4_output_parser_name"
140 b4_copyright([Skeleton parser for Yacc-like parsing with Bison],
141 [1984, 1989, 1990, 2000, 2001, 2002])
142
143 /* As a special exception, when this file is copied by Bison into a
144 Bison output file, you may use that output file without restriction.
145 This special exception was added by the Free Software Foundation
146 in version 1.24 of Bison. */
147
148 /* Written by Richard Stallman by simplifying the original so called
149 ``semantic'' parser. */
150
151 /* All symbols defined below should begin with yy or YY, to avoid
152 infringing on user name space. This should be done even for local
153 variables, as they might otherwise be expanded by user macros.
154 There are some unavoidable exceptions within include files to
155 define necessary library symbols; they are noted "INFRINGES ON
156 USER NAME SPACE" below. */
157
158 /* Identify Bison output. */
159 #define YYBISON 1
160
161 /* Pure parsers. */
162 #define YYPURE b4_pure
163
164 /* Using locations. */
165 #define YYLSP_NEEDED b4_locations_flag
166
167 m4_if(b4_prefix[], [yy], [],
168 [/* If NAME_PREFIX is specified substitute the variables and functions
169 names. */
170 #define yyparse b4_prefix[]parse
171 #define yylex b4_prefix[]lex
172 #define yyerror b4_prefix[]error
173 #define yylval b4_prefix[]lval
174 #define yychar b4_prefix[]char
175 #define yydebug b4_prefix[]debug
176 #define yynerrs b4_prefix[]nerrs
177 b4_location_if([#define yylloc b4_prefix[]lloc])])
178
179 b4_token_defines(b4_tokens)
180
181 /* Copy the first part of user declarations. */
182 b4_pre_prologue
183
184 /* Enabling traces. */
185 #ifndef YYDEBUG
186 # define YYDEBUG b4_debug
187 #endif
188
189 /* Enabling verbose error messages. */
190 #ifdef YYERROR_VERBOSE
191 # undef YYERROR_VERBOSE
192 # define YYERROR_VERBOSE 1
193 #else
194 # define YYERROR_VERBOSE b4_error_verbose
195 #endif
196
197 #ifndef YYSTYPE
198 m4_ifdef([b4_stype],
199 [#line b4_stype_line "b4_filename"
200 typedef union b4_stype yystype;
201 /* Line __line__ of __file__. */
202 #line __oline__ "__ofile__"],
203 [typedef int yystype;])
204 # define YYSTYPE yystype
205 # define YYSTYPE_IS_TRIVIAL 1
206 #endif
207
208 #ifndef YYLTYPE
209 typedef struct yyltype
210 {
211 int first_line;
212 int first_column;
213 int last_line;
214 int last_column;
215 } yyltype;
216 # define YYLTYPE b4_location_type
217 # define YYLTYPE_IS_TRIVIAL 1
218 #endif
219
220 /* Copy the second part of user declarations. */
221 b4_post_prologue
222
223 /* Line __line__ of __file__. */
224 #line __oline__ "__ofile__"
225
226 #if ! defined (yyoverflow) || YYERROR_VERBOSE
227
228 /* The parser invokes alloca or malloc; define the necessary symbols. */
229
230 # if YYSTACK_USE_ALLOCA
231 # define YYSTACK_ALLOC alloca
232 # else
233 # ifndef YYSTACK_USE_ALLOCA
234 # if defined (alloca) || defined (_ALLOCA_H)
235 # define YYSTACK_ALLOC alloca
236 # else
237 # ifdef __GNUC__
238 # define YYSTACK_ALLOC __builtin_alloca
239 # endif
240 # endif
241 # endif
242 # endif
243
244 # ifdef YYSTACK_ALLOC
245 /* Pacify GCC's `empty if-body' warning. */
246 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
247 # else
248 # if defined (__STDC__) || defined (__cplusplus)
249 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
250 # define YYSIZE_T size_t
251 # endif
252 # define YYSTACK_ALLOC malloc
253 # define YYSTACK_FREE free
254 # endif
255 #endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
256
257
258 #if (! defined (yyoverflow) \
259 && (! defined (__cplusplus) \
260 || (YYLTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
261
262 /* A type that is properly aligned for any stack member. */
263 union yyalloc
264 {
265 short yyss;
266 YYSTYPE yyvs;
267 b4_location_if([ YYLTYPE yyls;
268 ])dnl
269 };
270
271 /* The size of the maximum gap between one aligned stack and the next. */
272 # define YYSTACK_GAP_MAX (sizeof (union yyalloc) - 1)
273
274 /* The size of an array large to enough to hold all stacks, each with
275 N elements. */
276 b4_location_if(
277 [# define YYSTACK_BYTES(N) \
278 ((N) * (sizeof (short) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \
279 + 2 * YYSTACK_GAP_MAX)],
280 [# define YYSTACK_BYTES(N) \
281 ((N) * (sizeof (short) + sizeof (YYSTYPE)) \
282 + YYSTACK_GAP_MAX)])
283
284 /* Copy COUNT objects from FROM to TO. The source and destination do
285 not overlap. */
286 # ifndef YYCOPY
287 # if 1 < __GNUC__
288 # define YYCOPY(To, From, Count) \
289 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
290 # else
291 # define YYCOPY(To, From, Count) \
292 do \
293 { \
294 register YYSIZE_T yyi; \
295 for (yyi = 0; yyi < (Count); yyi++) \
296 (To)[[yyi]] = (From)[[yyi]]; \
297 } \
298 while (0)
299 # endif
300 # endif
301
302 /* Relocate STACK from its old location to the new one. The
303 local variables YYSIZE and YYSTACKSIZE give the old and new number of
304 elements in the stack, and YYPTR gives the new location of the
305 stack. Advance YYPTR to a properly aligned location for the next
306 stack. */
307 # define YYSTACK_RELOCATE(Stack) \
308 do \
309 { \
310 YYSIZE_T yynewbytes; \
311 YYCOPY (&yyptr->Stack, Stack, yysize); \
312 Stack = &yyptr->Stack; \
313 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAX; \
314 yyptr += yynewbytes / sizeof (*yyptr); \
315 } \
316 while (0)
317
318 #endif
319
320 #if defined (__STDC__) || defined (__cplusplus)
321 typedef signed char yysigned_char;
322 #else
323 typedef short yysigned_char;
324 #endif
325
326 /* YYFINAL -- State number of the termination state. */
327 #define YYFINAL b4_final_state_number
328 /* YYLAST -- Last index in YYTABLE. */
329 #define YYLAST b4_last
330
331 /* YYNTOKENS -- Number of terminals. */
332 #define YYNTOKENS b4_tokens_number
333 /* YYNNTS -- Number of nonterminals. */
334 #define YYNNTS b4_nterms_number
335 /* YYNRULES -- Number of rules. */
336 #define YYNRULES b4_rules_number
337 /* YYNRULES -- Number of states. */
338 #define YYNSTATES b4_states_number
339
340 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
341 #define YYUNDEFTOK b4_undef_token_number
342 #define YYMAXUTOK b4_user_token_number_max
343
344 #define YYTRANSLATE(X) \
345 ((unsigned)(X) <= YYMAXUTOK ? yytranslate[[X]] : YYUNDEFTOK)
346
347 /* YYTRANSLATE[[YYLEX]] -- Bison symbol number corresponding to YYLEX. */
348 static const b4_int_type_for([b4_translate]) yytranslate[[]] =
349 {
350 b4_translate
351 };
352
353 #if YYDEBUG
354 /* YYPRHS[[YYN]] -- Index of the first RHS symbol of rule number YYN in
355 YYRHS. */
356 static const b4_int_type_for([b4_prhs]) yyprhs[[]] =
357 {
358 b4_prhs
359 };
360
361 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
362 static const b4_int_type_for([b4_rhs]) yyrhs[[]] =
363 {
364 b4_rhs
365 };
366
367 /* YYRLINE[[YYN]] -- source line where rule number YYN was defined. */
368 static const b4_int_type_for([b4_rline]) yyrline[[]] =
369 {
370 b4_rline
371 };
372 #endif
373
374 #if YYDEBUG || YYERROR_VERBOSE
375 /* YYTNME[[SYMBOL-NUM]] -- String name of the symbol SYMBOL-NUM.
376 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
377 static const char *const yytname[[]] =
378 {
379 b4_tname
380 };
381 #endif
382
383 # ifdef YYPRINT
384 /* YYTOKNUM[[YYLEX-NUM]] -- Internal token number corresponding to
385 token YYLEX-NUM. */
386 static const b4_int_type_for([b4_toknum]) yytoknum[[]] =
387 {
388 b4_toknum
389 };
390 # endif
391
392 /* YYR1[[YYN]] -- Symbol number of symbol that rule YYN derives. */
393 static const b4_int_type_for([b4_r1]) yyr1[[]] =
394 {
395 b4_r1
396 };
397
398 /* YYR2[[YYN]] -- Number of symbols composing right hand side of rule YYN. */
399 static const b4_int_type_for([b4_r2]) yyr2[[]] =
400 {
401 b4_r2
402 };
403
404 /* YYDEFACT[[STATE-NAME]] -- Default rule to reduce with in state
405 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
406 means the default is an error. */
407 static const b4_int_type_for([b4_defact]) yydefact[[]] =
408 {
409 b4_defact
410 };
411
412 /* YYDEFGOTO[[NTERM-NUM]]. */
413 static const b4_int_type_for([b4_defgoto]) yydefgoto[[]] =
414 {
415 b4_defgoto
416 };
417
418 /* YYPACT[[STATE-NUM]] -- Index in YYTABLE of the portion describing
419 STATE-NUM. */
420 #define YYPACT_NINF b4_pact_ninf
421 static const b4_int_type_for([b4_pact]) yypact[[]] =
422 {
423 b4_pact
424 };
425
426 /* YYPGOTO[[NTERM-NUM]]. */
427 static const b4_int_type_for([b4_pgoto]) yypgoto[[]] =
428 {
429 b4_pgoto
430 };
431
432 /* YYTABLE[[YYPACT[STATE-NUM]]]. What to do in state STATE-NUM. If
433 positive, shift that token. If negative, reduce the rule which
434 number is the opposite. If zero, do what YYDEFACT says.
435 If YYTABLE_NINF, parse error. */
436 #define YYTABLE_NINF b4_table_ninf
437 static const b4_int_type_for([b4_table]) yytable[[]] =
438 {
439 b4_table
440 };
441
442 static const b4_int_type_for([b4_check]) yycheck[[]] =
443 {
444 b4_check
445 };
446
447 /* YYSTOS[[STATE-NUM]] -- The (internal number of the) accessing
448 symbol of state STATE-NUM. */
449 static const b4_int_type_for([b4_stos]) yystos[[]] =
450 {
451 b4_stos
452 };
453
454 #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
455 # define YYSIZE_T __SIZE_TYPE__
456 #endif
457 #if ! defined (YYSIZE_T) && defined (size_t)
458 # define YYSIZE_T size_t
459 #endif
460 #if ! defined (YYSIZE_T)
461 # if defined (__STDC__) || defined (__cplusplus)
462 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
463 # define YYSIZE_T size_t
464 # endif
465 #endif
466 #if ! defined (YYSIZE_T)
467 # define YYSIZE_T unsigned int
468 #endif
469
470 #define yyerrok (yyerrstatus = 0)
471 #define yyclearin (yychar = YYEMPTY)
472 #define YYEMPTY -2
473 #define YYEOF 0
474
475 #define YYACCEPT goto yyacceptlab
476 #define YYABORT goto yyabortlab
477 #define YYERROR goto yyerrlab1
478
479 /* Like YYERROR except do call yyerror. This remains here temporarily
480 to ease the transition to the new meaning of YYERROR, for GCC.
481 Once GCC version 2 has supplanted version 1, this can go. */
482
483 #define YYFAIL goto yyerrlab
484
485 #define YYRECOVERING() (!!yyerrstatus)
486
487 #define YYBACKUP(Token, Value) \
488 do \
489 if (yychar == YYEMPTY && yylen == 1) \
490 { \
491 yychar = (Token); \
492 yylval = (Value); \
493 yychar1 = YYTRANSLATE (yychar); \
494 YYPOPSTACK; \
495 goto yybackup; \
496 } \
497 else \
498 { \
499 yyerror ("syntax error: cannot back up"); \
500 YYERROR; \
501 } \
502 while (0)
503
504 #define YYTERROR 1
505 #define YYERRCODE 256
506
507 /* YYLLOC_DEFAULT -- Compute the default location (before the actions
508 are run). */
509
510 #ifndef YYLLOC_DEFAULT
511 # define YYLLOC_DEFAULT(Current, Rhs, N) \
512 Current.first_line = Rhs[[1]].first_line; \
513 Current.first_column = Rhs[[1]].first_column; \
514 Current.last_line = Rhs[[N]].last_line; \
515 Current.last_column = Rhs[[N]].last_column;
516 #endif
517
518 /* YYLEX -- calling `yylex' with the right arguments. */
519
520 #ifdef YYLEX_PARAM
521 # define YYLEX yylex (b4_pure_if([&yylval[]b4_location_if([, &yylloc]), ])YYLEX_PARAM)
522 #else
523 # define YYLEX b4_c_function_call([yylex], [int], b4_lex_param)
524 #endif
525
526 /* Enable debugging if requested. */
527 #if YYDEBUG
528
529 # ifndef YYFPRINTF
530 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
531 # define YYFPRINTF fprintf
532 # endif
533
534 # define YYDPRINTF(Args) \
535 do { \
536 if (yydebug) \
537 YYFPRINTF Args; \
538 } while (0)
539 # define YYDSYMPRINT(Args) \
540 do { \
541 if (yydebug) \
542 yysymprint Args; \
543 } while (0)
544 /* Nonzero means print parse trace. It is left uninitialized so that
545 multiple parsers can coexist. */
546 int yydebug;
547 #else /* !YYDEBUG */
548 # define YYDPRINTF(Args)
549 # define YYDSYMPRINT(Args)
550 #endif /* !YYDEBUG */
551
552 /* YYINITDEPTH -- initial size of the parser's stacks. */
553 #ifndef YYINITDEPTH
554 # define YYINITDEPTH b4_stack_depth_init
555 #endif
556
557 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
558 if the built-in stack extension method is used).
559
560 Do not make this value too large; the results are undefined if
561 SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH)
562 evaluated with infinite-precision integer arithmetic. */
563
564 #if YYMAXDEPTH == 0
565 # undef YYMAXDEPTH
566 #endif
567
568 #ifndef YYMAXDEPTH
569 # define YYMAXDEPTH b4_stack_depth_max
570 #endif
571
572 \f
573
574 #if YYERROR_VERBOSE
575
576 # ifndef yystrlen
577 # if defined (__GLIBC__) && defined (_STRING_H)
578 # define yystrlen strlen
579 # else
580 /* Return the length of YYSTR. */
581 static YYSIZE_T
582 # if defined (__STDC__) || defined (__cplusplus)
583 yystrlen (const char *yystr)
584 # else
585 yystrlen (yystr)
586 const char *yystr;
587 # endif
588 {
589 register const char *yys = yystr;
590
591 while (*yys++ != '\0')
592 continue;
593
594 return yys - yystr - 1;
595 }
596 # endif
597 # endif
598
599 # ifndef yystpcpy
600 # if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
601 # define yystpcpy stpcpy
602 # else
603 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
604 YYDEST. */
605 static char *
606 # if defined (__STDC__) || defined (__cplusplus)
607 yystpcpy (char *yydest, const char *yysrc)
608 # else
609 yystpcpy (yydest, yysrc)
610 char *yydest;
611 const char *yysrc;
612 # endif
613 {
614 register char *yyd = yydest;
615 register const char *yys = yysrc;
616
617 while ((*yyd++ = *yys++) != '\0')
618 continue;
619
620 return yyd - 1;
621 }
622 # endif
623 # endif
624
625 #endif /* !YYERROR_VERBOSE */
626
627 \f
628
629 #if YYDEBUG
630 /*-----------------------------.
631 | Print this symbol on YYOUT. |
632 `-----------------------------*/
633
634 b4_c_function_def([yysymprint],
635 [static void],
636 [[FILE *yyout], [yyout]],
637 [[int yytype], [yytype]],
638 [[YYSTYPE yyvalue], [yyvalue]]b4_location_if([,
639 [[YYLTYPE yylocation], [yylocation]]]))
640 {
641 /* Pacify ``unused variable'' warnings. */
642 (void) yyvalue;
643 b4_location_if([ (void) yylocation;
644 ])dnl
645
646 if (yytype < YYNTOKENS)
647 {
648 YYFPRINTF (yyout, "token %s (", yytname[[yytype]]);
649 # ifdef YYPRINT
650 YYPRINT (yyout, yytoknum[[yytype]], yyvalue);
651 # endif
652 }
653 else
654 YYFPRINTF (yyout, "nterm %s (", yytname[[yytype]]);
655
656 switch (yytype)
657 {
658 m4_map([b4_symbol_actions], m4_defn([b4_symbol_printers]))dnl
659 default:
660 break;
661 }
662 YYFPRINTF (yyout, ")");
663 }
664 #endif /* YYDEBUG. */
665
666
667 /*-----------------------------------------------.
668 | Release the memory associated to this symbol. |
669 `-----------------------------------------------*/
670
671 b4_c_function_def([yydestruct],
672 [static void],
673 [[int yytype], [yytype]],
674 [[YYSTYPE yyvalue], [yyvalue]]b4_location_if([,
675 [[YYLTYPE yylocation], [yylocation]]]))
676 {
677 /* Pacify ``unused variable'' warnings. */
678 (void) yyvalue;
679 b4_location_if([ (void) yylocation;
680 ])dnl
681
682 switch (yytype)
683 {
684 m4_map([b4_symbol_actions], m4_defn([b4_symbol_destructors]))dnl
685 default:
686 break;
687 }
688 }
689
690 \f
691
692 /* Prevent warnings from -Wmissing-prototypes. */
693
694 #ifdef YYPARSE_PARAM
695 # if defined (__STDC__) || defined (__cplusplus)
696 int yyparse (void *YYPARSE_PARAM);
697 # else
698 int yyparse ();
699 # endif
700 #else /* ! YYPARSE_PARAM */
701 b4_c_function_decl([yyparse], [int], b4_parse_param)
702 #endif
703
704
705 m4_divert_push([KILL])# ======================== M4 code.
706 # b4_declare_parser_variables
707 # ---------------------------
708 # Declare the variables that are global, or local to YYPARSE if
709 # pure-parser.
710 m4_define([b4_declare_parser_variables],
711 [/* The lookahead symbol. */
712 int yychar;
713
714 /* The semantic value of the lookahead symbol. */
715 YYSTYPE yylval;
716
717 /* Number of parse errors so far. */
718 int yynerrs;b4_location_if([
719 /* Location data for the lookahead symbol. */
720 YYLTYPE yylloc;])
721 ])
722 m4_divert_pop([KILL])dnl# ====================== End of M4 code.
723
724 b4_pure_if([],
725 [b4_declare_parser_variables])
726
727
728 /*----------.
729 | yyparse. |
730 `----------*/
731
732 #ifdef YYPARSE_PARAM
733 # if defined (__STDC__) || defined (__cplusplus)
734 int yyparse (void *YYPARSE_PARAM)
735 # else
736 int yyparse (YYPARSE_PARAM)
737 void *YYPARSE_PARAM;
738 # endif
739 #else /* ! YYPARSE_PARAM */
740 b4_c_function_def([yyparse], [int], b4_parse_param)
741 #endif
742 {[
743 ]b4_pure_if([b4_declare_parser_variables])[
744 register int yystate;
745 register int yyn;
746 int yyresult;
747 /* Number of tokens to shift before error messages enabled. */
748 int yyerrstatus;
749 /* Lookahead token as an internal (translated) token number. */
750 int yychar1 = 0;
751
752 /* Three stacks and their tools:
753 `yyss': related to states,
754 `yyvs': related to semantic values,
755 `yyls': related to locations.
756
757 Refer to the stacks thru separate pointers, to allow yyoverflow
758 to reallocate them elsewhere. */
759
760 /* The state stack. */
761 short yyssa[YYINITDEPTH];
762 short *yyss = yyssa;
763 register short *yyssp;
764
765 /* The semantic value stack. */
766 YYSTYPE yyvsa[YYINITDEPTH];
767 YYSTYPE *yyvs = yyvsa;
768 register YYSTYPE *yyvsp;
769
770 ]b4_location_if(
771 [[ /* The location stack. */
772 YYLTYPE yylsa[YYINITDEPTH];
773 YYLTYPE *yyls = yylsa;
774 YYLTYPE *yylsp;]])[
775
776 #define YYPOPSTACK (yyvsp--, yyssp--]b4_location_if([, yylsp--])[)
777
778 YYSIZE_T yystacksize = YYINITDEPTH;
779
780 /* The variables used to return semantic value and location from the
781 action routines. */
782 YYSTYPE yyval;
783 ]b4_location_if([ YYLTYPE yyloc;])[
784
785 /* When reducing, the number of symbols on the RHS of the reduced
786 rule. */
787 int yylen;
788
789 YYDPRINTF ((stderr, "Starting parse\n"));
790
791 yystate = 0;
792 yyerrstatus = 0;
793 yynerrs = 0;
794 yychar = YYEMPTY; /* Cause a token to be read. */
795
796 /* Initialize stack pointers.
797 Waste one element of value and location stack
798 so that they stay on the same level as the state stack.
799 The wasted elements are never initialized. */
800
801 yyssp = yyss;
802 yyvsp = yyvs;
803 ]b4_location_if([ yylsp = yyls;])[
804 goto yysetstate;
805
806 /*------------------------------------------------------------.
807 | yynewstate -- Push a new state, which is found in yystate. |
808 `------------------------------------------------------------*/
809 yynewstate:
810 /* In all cases, when you get here, the value and location stacks
811 have just been pushed. so pushing a state here evens the stacks.
812 */
813 yyssp++;
814
815 yysetstate:
816 *yyssp = yystate;
817
818 if (yyss + yystacksize - 1 <= yyssp)
819 {
820 /* Get the current used size of the three stacks, in elements. */
821 YYSIZE_T yysize = yyssp - yyss + 1;
822
823 #ifdef yyoverflow
824 {
825 /* Give user a chance to reallocate the stack. Use copies of
826 these so that the &'s don't force the real ones into
827 memory. */
828 YYSTYPE *yyvs1 = yyvs;
829 short *yyss1 = yyss;
830 ]b4_location_if([ YYLTYPE *yyls1 = yyls;])[
831
832 /* Each stack pointer address is followed by the size of the
833 data in use in that stack, in bytes. This used to be a
834 conditional around just the two extra args, but that might
835 be undefined if yyoverflow is a macro. */
836 yyoverflow ("parser stack overflow",
837 &yyss1, yysize * sizeof (*yyssp),
838 &yyvs1, yysize * sizeof (*yyvsp),
839 ]b4_location_if([ &yyls1, yysize * sizeof (*yylsp),])[
840 &yystacksize);
841 ]b4_location_if([ yyls = yyls1;])[
842 yyss = yyss1;
843 yyvs = yyvs1;
844 }
845 #else /* no yyoverflow */
846 # ifndef YYSTACK_RELOCATE
847 goto yyoverflowlab;
848 # else
849 /* Extend the stack our own way. */
850 if (YYMAXDEPTH <= yystacksize)
851 goto yyoverflowlab;
852 yystacksize *= 2;
853 if (YYMAXDEPTH < yystacksize)
854 yystacksize = YYMAXDEPTH;
855
856 {
857 short *yyss1 = yyss;
858 union yyalloc *yyptr =
859 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
860 if (! yyptr)
861 goto yyoverflowlab;
862 YYSTACK_RELOCATE (yyss);
863 YYSTACK_RELOCATE (yyvs);
864 ]b4_location_if([ YYSTACK_RELOCATE (yyls);])[
865 # undef YYSTACK_RELOCATE
866 if (yyss1 != yyssa)
867 YYSTACK_FREE (yyss1);
868 }
869 # endif
870 #endif /* no yyoverflow */
871
872 yyssp = yyss + yysize - 1;
873 yyvsp = yyvs + yysize - 1;
874 ]b4_location_if([ yylsp = yyls + yysize - 1;])[
875
876 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
877 (unsigned long int) yystacksize));
878
879 if (yyss + yystacksize - 1 <= yyssp)
880 YYABORT;
881 }
882
883 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
884
885 goto yybackup;
886
887 /*-----------.
888 | yybackup. |
889 `-----------*/
890 yybackup:
891
892 /* Do appropriate processing given the current state. */
893 /* Read a lookahead token if we need one and don't already have one. */
894 /* yyresume: */
895
896 /* First try to decide what to do without reference to lookahead token. */
897
898 yyn = yypact[yystate];
899 if (yyn == YYPACT_NINF)
900 goto yydefault;
901
902 /* Not known => get a lookahead token if don't already have one. */
903
904 /* yychar is either YYEMPTY or YYEOF
905 or a valid token in external form. */
906
907 if (yychar == YYEMPTY)
908 {
909 YYDPRINTF ((stderr, "Reading a token: "));
910 yychar = YYLEX;
911 }
912
913 /* Convert token to internal form (in yychar1) for indexing tables with. */
914
915 if (yychar <= 0) /* This means end of input. */
916 {
917 yychar1 = 0;
918 yychar = YYEOF; /* Don't call YYLEX any more. */
919
920 YYDPRINTF ((stderr, "Now at end of input.\n"));
921 }
922 else
923 {
924 yychar1 = YYTRANSLATE (yychar);
925
926 /* We have to keep this `#if YYDEBUG', since we use variables
927 which are defined only if `YYDEBUG' is set. */
928 YYDPRINTF ((stderr, "Next token is "));
929 YYDSYMPRINT ((stderr, yychar1, yylval]b4_location_if([, yyloc])[));
930 YYDPRINTF ((stderr, "\n"));
931 }
932
933 /* If the proper action on seeing token YYCHAR1 is to reduce or to
934 detect an error, take that action. */
935 yyn += yychar1;
936 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yychar1)
937 goto yydefault;
938 yyn = yytable[yyn];
939 if (yyn <= 0)
940 {
941 if (yyn == 0 || yyn == YYTABLE_NINF)
942 goto yyerrlab;
943 yyn = -yyn;
944 goto yyreduce;
945 }
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 garbage.
991 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]; 0 <= yyrhs[yyi]; 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 (0 <= yystate && 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 #if YYERROR_VERBOSE
1067 yyn = yypact[yystate];
1068
1069 if (YYPACT_NINF < yyn && yyn < YYLAST)
1070 {
1071 YYSIZE_T yysize = 0;
1072 int yytype = YYTRANSLATE (yychar);
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 && yyx != YYTERROR)
1082 yysize += yystrlen (yytname[yyx]) + 15, yycount++;
1083 yysize += yystrlen ("parse error, unexpected ") + 1;
1084 yysize += yystrlen (yytname[yytype]);
1085 yymsg = (char *) YYSTACK_ALLOC (yysize);
1086 if (yymsg != 0)
1087 {
1088 char *yyp = yystpcpy (yymsg, "parse error, unexpected ");
1089 yyp = yystpcpy (yyp, yytname[yytype]);
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 && yyx != YYTERROR)
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 (yyss < yyssp)
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 != YYPACT_NINF)
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 b4_epilogue
1243 m4_if(b4_defines_flag, 0, [],
1244 [#output "b4_output_header_name"
1245 b4_copyright([Skeleton parser for Yacc-like parsing with Bison],
1246 [1984, 1989, 1990, 2000, 2001, 2002])
1247
1248 /* As a special exception, when this file is copied by Bison into a
1249 Bison output file, you may use that output file without restriction.
1250 This special exception was added by the Free Software Foundation
1251 in version 1.24 of Bison. */
1252
1253 #ifndef b4_header_guard
1254 # define b4_header_guard
1255
1256 b4_token_defines(b4_tokens)
1257
1258 #ifndef YYSTYPE
1259 m4_ifdef([b4_stype],
1260 [#line b4_stype_line "b4_filename"
1261 typedef union b4_stype yystype;
1262 /* Line __line__ of __file__. */
1263 #line __oline__ "__ofile__"],
1264 [typedef int yystype;])
1265 # define YYSTYPE yystype
1266 #endif
1267
1268 b4_pure_if([],
1269 [extern YYSTYPE b4_prefix[]lval;])
1270
1271 b4_location_if(
1272 [#ifndef YYLTYPE
1273 typedef struct yyltype
1274 {
1275 int first_line;
1276 int first_column;
1277 int last_line;
1278 int last_column;
1279 } yyltype;
1280 # define YYLTYPE yyltype
1281 #endif
1282
1283 m4_if(b4_pure, [0],
1284 [extern YYLTYPE b4_prefix[]lloc;])
1285 ])
1286 #endif /* not b4_header_guard */
1287 ])