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