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