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