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