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