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