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