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