]> git.saurik.com Git - bison.git/blob - data/push.c
dbbdb1137e7c7f8f1f5618b8ac18ff586b4e74a6
[bison.git] / data / push.c
1 -*- C -*-
2
3 # Yacc compatible skeleton for Bison
4
5 # Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
6 # 2007 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., 51 Franklin Street, Fifth Floor, Boston, MA
21 # 02110-1301 USA
22
23 # Handle BISON_USE_PUSH_FOR_PULL for the test suite. So that push parsing
24 # tests function as written, don't let BISON_USE_PUSH_FOR_PULL modify Bison's
25 # behavior at all when push parsing is already requested.
26 b4_use_push_for_pull_if([
27 b4_push_if([
28 m4_define([b4_use_push_for_pull_flag], [[0]])
29 b4_define_flag_if([use_push_for_pull])
30 ], [
31 m4_define([b4_push_flag], [[1]])
32 b4_define_flag_if([push])
33 ])])
34
35 m4_include(b4_pkgdatadir/[c.m4])
36
37 b4_check_percent_define_variables
38
39 b4_check_percent_code_qualifiers([[requires]],
40 [[provides]],
41 [[top]])
42
43 ## ---------------- ##
44 ## Default values. ##
45 ## ---------------- ##
46
47 # Stack parameters.
48 m4_define_default([b4_stack_depth_max], [10000])
49 m4_define_default([b4_stack_depth_init], [200])
50
51
52 ## ------------------------ ##
53 ## Pure/impure interfaces. ##
54 ## ------------------------ ##
55
56
57 # b4_yacc_pure_if(IF-TRUE, IF-FALSE)
58 # ----------------------------------
59 # Expand IF-TRUE, if %pure-parser and %parse-param, IF-FALSE otherwise.
60 m4_define([b4_yacc_pure_if],
61 [b4_pure_if([m4_ifset([b4_parse_param],
62 [$1], [$2])],
63 [$2])])
64
65
66 # b4_yyerror_args
67 # ---------------
68 # Arguments passed to yyerror: user args plus yylloc.
69 m4_define([b4_yyerror_args],
70 [b4_yacc_pure_if([b4_locations_if([&yylloc, ])])dnl
71 m4_ifset([b4_parse_param], [b4_c_args(b4_parse_param), ])])
72
73
74 # b4_lex_param
75 # ------------
76 # Accumulate in b4_lex_param all the yylex arguments.
77 # b4_lex_param arrives quoted twice, but we want to keep only one level.
78 m4_define([b4_lex_param],
79 m4_dquote(b4_pure_if([[[[YYSTYPE *]], [[&yylval]]][]dnl
80 b4_locations_if([, [[YYLTYPE *], [&yylloc]]])m4_ifdef([b4_lex_param], [, ])])dnl
81 m4_ifdef([b4_lex_param], b4_lex_param)))
82
83
84 ## ------------ ##
85 ## Data Types. ##
86 ## ------------ ##
87
88 # b4_int_type(MIN, MAX)
89 # ---------------------
90 # Return the smallest int type able to handle numbers ranging from
91 # MIN to MAX (included). Overwrite the version from c.m4, which
92 # uses only C89 types, so that the user can override the shorter
93 # types, and so that pre-C89 compilers are handled correctly.
94 m4_define([b4_int_type],
95 [m4_if(b4_ints_in($@, [0], [255]), [1], [yytype_uint8],
96 b4_ints_in($@, [-128], [127]), [1], [yytype_int8],
97
98 b4_ints_in($@, [0], [65535]), [1], [yytype_uint16],
99 b4_ints_in($@, [-32768], [32767]), [1], [yytype_int16],
100
101 m4_eval([0 <= $1]), [1], [unsigned int],
102
103 [int])])
104
105
106 ## ----------------- ##
107 ## Semantic Values. ##
108 ## ----------------- ##
109
110
111 # b4_lhs_value([TYPE])
112 # --------------------
113 # Expansion of $<TYPE>$.
114 m4_define([b4_lhs_value],
115 [(yyval[]m4_ifval([$1], [.$1]))])
116
117
118 # b4_rhs_value(RULE-LENGTH, NUM, [TYPE])
119 # --------------------------------------
120 # Expansion of $<TYPE>NUM, where the current rule has RULE-LENGTH
121 # symbols on RHS.
122 m4_define([b4_rhs_value],
123 [(yyvsp@{($2) - ($1)@}m4_ifval([$3], [.$3]))])
124
125
126
127 ## ----------- ##
128 ## Locations. ##
129 ## ----------- ##
130
131 # b4_lhs_location()
132 # -----------------
133 # Expansion of @$.
134 m4_define([b4_lhs_location],
135 [(yyloc)])
136
137
138 # b4_rhs_location(RULE-LENGTH, NUM)
139 # ---------------------------------
140 # Expansion of @NUM, where the current rule has RULE-LENGTH symbols
141 # on RHS.
142 m4_define([b4_rhs_location],
143 [(yylsp@{($2) - ($1)@})])
144
145
146
147 ## --------------------------------------------------------- ##
148 ## Defining symbol actions, e.g., printers and destructors. ##
149 ## --------------------------------------------------------- ##
150
151 # We do want M4 expansion after # for CPP macros.
152 m4_changecom()
153 m4_divert_push(0)dnl
154 @output(b4_parser_file_name@)
155 b4_copyright([Skeleton implementation for Bison's Yacc-like parsers in C],dnl '
156 [1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006])[
157
158 /* C LALR(1) parser skeleton written by Richard Stallman, by
159 simplifying the original so-called "semantic" parser. */
160
161 /* All symbols defined below should begin with yy or YY, to avoid
162 infringing on user name space. This should be done even for local
163 variables, as they might otherwise be expanded by user macros.
164 There are some unavoidable exceptions within include files to
165 define necessary library symbols; they are noted "INFRINGES ON
166 USER NAME SPACE" below. */
167
168 ]b4_identification
169 m4_ifdef([b4_percent_code_top],
170 [[/* Copy the %code "top" blocks. */
171 ]b4_user_code([b4_percent_code_top])])[]dnl
172 m4_if(b4_prefix, [yy], [],
173 [[/* Substitute the variable and function names. */
174 ]b4_pull_if([[#define yyparse ]b4_prefix[parse
175 ]])b4_push_if([[#define yypush_parse ]b4_prefix[push_parse
176 ]b4_pull_if([[#define yypull_parse ]b4_prefix[pull_parse
177 ]])[#define yypstate_new ]b4_prefix[pstate_new
178 #define yypstate_delete ]b4_prefix[pstate_delete
179 #define yypstate ]b4_prefix[pstate
180 ]])[#define yylex ]b4_prefix[lex
181 #define yyerror ]b4_prefix[error
182 #define yylval ]b4_prefix[lval
183 #define yychar ]b4_prefix[char
184 #define yydebug ]b4_prefix[debug
185 #define yynerrs ]b4_prefix[nerrs
186 ]b4_locations_if([[#define yylloc ]b4_prefix[lloc]])])[
187
188 /* Copy the first part of user declarations. */
189 ]b4_user_pre_prologue[
190
191 /* Enabling traces. */
192 #ifndef YYDEBUG
193 # define YYDEBUG ]b4_debug_flag[
194 #endif
195
196 /* Enabling verbose error messages. */
197 #ifdef YYERROR_VERBOSE
198 # undef YYERROR_VERBOSE
199 # define YYERROR_VERBOSE 1
200 #else
201 # define YYERROR_VERBOSE ]b4_error_verbose_flag[
202 #endif
203
204 /* Enabling the token table. */
205 #ifndef YYTOKEN_TABLE
206 # define YYTOKEN_TABLE ]b4_token_table[
207 #endif
208
209 ]m4_ifdef([b4_percent_code_requires],
210 [[/* Copy the %code "requires" blocks. */
211 ]b4_user_code([b4_percent_code_requires])])[]dnl
212
213 b4_token_enums_defines(b4_tokens)[
214
215 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
216 ]m4_ifdef([b4_stype],
217 [[typedef union ]b4_union_name[
218 ]b4_user_stype[
219 YYSTYPE;
220 # define YYSTYPE_IS_TRIVIAL 1]],
221 [m4_if(b4_tag_seen_flag, 0,
222 [[typedef int YYSTYPE;
223 # define YYSTYPE_IS_TRIVIAL 1]])])[
224 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
225 # define YYSTYPE_IS_DECLARED 1
226 #endif
227
228 ]b4_locations_if([#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED
229 typedef struct YYLTYPE
230 {
231 int first_line;
232 int first_column;
233 int last_line;
234 int last_column;
235 } YYLTYPE;
236 # define yyltype YYLTYPE /* obsolescent; will be withdrawn */
237 # define YYLTYPE_IS_DECLARED 1
238 # define YYLTYPE_IS_TRIVIAL 1
239 #endif])
240
241 b4_push_if([[#ifndef YYPUSH_DECLS
242 # define YYPUSH_DECLS
243 struct yypstate;
244 typedef struct yypstate yypstate;
245 enum { YYPUSH_MORE = 4 };
246
247 ]b4_pull_if([b4_c_function_decl([[yyparse]], [[int]], b4_parse_param)
248 ])b4_c_function_decl([[yypush_parse]], [[int]],
249 [[[yypstate *yyps]], [[yyps]]]b4_pure_if([,
250 [[[int yypushed_char]], [[yypushed_char]]],
251 [[[YYSTYPE const *yypushed_val]], [[yypushed_val]]]b4_locations_if([,
252 [[[YYLTYPE const *yypushed_loc]], [[yypushed_loc]]]])])m4_ifset([b4_parse_param], [,
253 b4_parse_param]))
254 b4_pull_if([b4_c_function_decl([[yypull_parse]], [[int]],
255 [[[yypstate *yyps]], [[yyps]]]m4_ifset([b4_parse_param], [,
256 b4_parse_param]))])
257 b4_c_function_decl([[yypstate_new]], [[yypstate *]], [[[void]], []])
258 b4_c_function_decl([[yypstate_delete]], [[void]],
259 [[[yypstate *yyps]], [[yyps]]])[
260 #endif
261 ]])
262 m4_ifdef([b4_percent_code_provides],
263 [[/* Copy the %code "provides" blocks. */
264 ]b4_user_code([b4_percent_code_provides])])[]dnl
265
266 [/* Copy the second part of user declarations. */
267 ]b4_user_post_prologue
268 m4_ifdef([b4_percent_code],
269 [[/* Copy the unqualified %code blocks. */
270 ]b4_user_code([b4_percent_code])
271 ])[]dnl
272
273 [#ifdef short
274 # undef short
275 #endif
276
277 #ifdef YYTYPE_UINT8
278 typedef YYTYPE_UINT8 yytype_uint8;
279 #else
280 typedef unsigned char yytype_uint8;
281 #endif
282
283 #ifdef YYTYPE_INT8
284 typedef YYTYPE_INT8 yytype_int8;
285 #elif ]b4_c_modern[
286 typedef signed char yytype_int8;
287 #else
288 typedef short int yytype_int8;
289 #endif
290
291 #ifdef YYTYPE_UINT16
292 typedef YYTYPE_UINT16 yytype_uint16;
293 #else
294 typedef unsigned short int yytype_uint16;
295 #endif
296
297 #ifdef YYTYPE_INT16
298 typedef YYTYPE_INT16 yytype_int16;
299 #else
300 typedef short int yytype_int16;
301 #endif
302
303 #ifndef YYSIZE_T
304 # ifdef __SIZE_TYPE__
305 # define YYSIZE_T __SIZE_TYPE__
306 # elif defined size_t
307 # define YYSIZE_T size_t
308 # elif ! defined YYSIZE_T && ]b4_c_modern[
309 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
310 # define YYSIZE_T size_t
311 # else
312 # define YYSIZE_T unsigned int
313 # endif
314 #endif
315
316 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
317
318 #ifndef YY_
319 # if YYENABLE_NLS
320 # if ENABLE_NLS
321 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
322 # define YY_(msgid) dgettext ("bison-runtime", msgid)
323 # endif
324 # endif
325 # ifndef YY_
326 # define YY_(msgid) msgid
327 # endif
328 #endif
329
330 /* Suppress unused-variable warnings by "using" E. */
331 #if ! defined lint || defined __GNUC__
332 # define YYUSE(e) ((void) (e))
333 #else
334 # define YYUSE(e) /* empty */
335 #endif
336
337 /* Identity function, used to suppress warnings about constant conditions. */
338 #ifndef lint
339 # define YYID(n) (n)
340 #else
341 ]b4_c_function_def([YYID], [static int], [[int yyi], [yyi]])[
342 {
343 return yyi;
344 }
345 #endif
346
347 #if ! defined yyoverflow || YYERROR_VERBOSE
348
349 /* The parser invokes alloca or malloc; define the necessary symbols. */
350
351 # ifdef YYSTACK_USE_ALLOCA
352 # if YYSTACK_USE_ALLOCA
353 # ifdef __GNUC__
354 # define YYSTACK_ALLOC __builtin_alloca
355 # elif defined __BUILTIN_VA_ARG_INCR
356 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
357 # elif defined _AIX
358 # define YYSTACK_ALLOC __alloca
359 # elif defined _MSC_VER
360 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
361 # define alloca _alloca
362 # else
363 # define YYSTACK_ALLOC alloca
364 # if ! defined _ALLOCA_H && ! defined _STDLIB_H && ]b4_c_modern[
365 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
366 # ifndef _STDLIB_H
367 # define _STDLIB_H 1
368 # endif
369 # endif
370 # endif
371 # endif
372 # endif
373
374 # ifdef YYSTACK_ALLOC
375 /* Pacify GCC's `empty if-body' warning. */
376 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
377 # ifndef YYSTACK_ALLOC_MAXIMUM
378 /* The OS might guarantee only one guard page at the bottom of the stack,
379 and a page size can be as small as 4096 bytes. So we cannot safely
380 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
381 to allow for a few compiler-allocated temporary stack slots. */
382 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
383 # endif
384 # else
385 # define YYSTACK_ALLOC YYMALLOC
386 # define YYSTACK_FREE YYFREE
387 # ifndef YYSTACK_ALLOC_MAXIMUM
388 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
389 # endif
390 # if (defined __cplusplus && ! defined _STDLIB_H \
391 && ! ((defined YYMALLOC || defined malloc) \
392 && (defined YYFREE || defined free)))
393 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
394 # ifndef _STDLIB_H
395 # define _STDLIB_H 1
396 # endif
397 # endif
398 # ifndef YYMALLOC
399 # define YYMALLOC malloc
400 # if ! defined malloc && ! defined _STDLIB_H && ]b4_c_modern[
401 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
402 # endif
403 # endif
404 # ifndef YYFREE
405 # define YYFREE free
406 # if ! defined free && ! defined _STDLIB_H && ]b4_c_modern[
407 void free (void *); /* INFRINGES ON USER NAME SPACE */
408 # endif
409 # endif
410 # endif
411 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
412
413
414 #if (! defined yyoverflow \
415 && (! defined __cplusplus \
416 || (]b4_locations_if([[defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL \
417 && ]])[defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
418
419 /* A type that is properly aligned for any stack member. */
420 union yyalloc
421 {
422 yytype_int16 yyss_alloc;
423 YYSTYPE yyvs_alloc;
424 ]b4_locations_if([ YYLTYPE yyls_alloc;
425 ])dnl
426 [};
427
428 /* The size of the maximum gap between one aligned stack and the next. */
429 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
430
431 /* The size of an array large to enough to hold all stacks, each with
432 N elements. */
433 ]b4_locations_if(
434 [# define YYSTACK_BYTES(N) \
435 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \
436 + 2 * YYSTACK_GAP_MAXIMUM)],
437 [# define YYSTACK_BYTES(N) \
438 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
439 + YYSTACK_GAP_MAXIMUM)])[
440
441 /* Copy COUNT objects from FROM to TO. The source and destination do
442 not overlap. */
443 # ifndef YYCOPY
444 # if defined __GNUC__ && 1 < __GNUC__
445 # define YYCOPY(To, From, Count) \
446 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
447 # else
448 # define YYCOPY(To, From, Count) \
449 do \
450 { \
451 YYSIZE_T yyi; \
452 for (yyi = 0; yyi < (Count); yyi++) \
453 (To)[yyi] = (From)[yyi]; \
454 } \
455 while (YYID (0))
456 # endif
457 # endif
458
459 /* Relocate STACK from its old location to the new one. The
460 local variables YYSIZE and YYSTACKSIZE give the old and new number of
461 elements in the stack, and YYPTR gives the new location of the
462 stack. Advance YYPTR to a properly aligned location for the next
463 stack. */
464 # define YYSTACK_RELOCATE(Stack_alloc, Stack) \
465 do \
466 { \
467 YYSIZE_T yynewbytes; \
468 YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
469 Stack = &yyptr->Stack_alloc; \
470 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
471 yyptr += yynewbytes / sizeof (*yyptr); \
472 } \
473 while (YYID (0))
474
475 #endif
476
477 /* YYFINAL -- State number of the termination state. */
478 #define YYFINAL ]b4_final_state_number[
479 /* YYLAST -- Last index in YYTABLE. */
480 #define YYLAST ]b4_last[
481
482 /* YYNTOKENS -- Number of terminals. */
483 #define YYNTOKENS ]b4_tokens_number[
484 /* YYNNTS -- Number of nonterminals. */
485 #define YYNNTS ]b4_nterms_number[
486 /* YYNRULES -- Number of rules. */
487 #define YYNRULES ]b4_rules_number[
488 /* YYNRULES -- Number of states. */
489 #define YYNSTATES ]b4_states_number[
490
491 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
492 #define YYUNDEFTOK ]b4_undef_token_number[
493 #define YYMAXUTOK ]b4_user_token_number_max[
494
495 #define YYTRANSLATE(YYX) \
496 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
497
498 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
499 static const ]b4_int_type_for([b4_translate])[ yytranslate[] =
500 {
501 ]b4_translate[
502 };
503
504 #if YYDEBUG
505 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
506 YYRHS. */
507 static const ]b4_int_type_for([b4_prhs])[ yyprhs[] =
508 {
509 ]b4_prhs[
510 };
511
512 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
513 static const ]b4_int_type_for([b4_rhs])[ yyrhs[] =
514 {
515 ]b4_rhs[
516 };
517
518 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
519 static const ]b4_int_type_for([b4_rline])[ yyrline[] =
520 {
521 ]b4_rline[
522 };
523 #endif
524
525 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
526 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
527 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
528 static const char *const yytname[] =
529 {
530 ]b4_tname[
531 };
532 #endif
533
534 # ifdef YYPRINT
535 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
536 token YYLEX-NUM. */
537 static const ]b4_int_type_for([b4_toknum])[ yytoknum[] =
538 {
539 ]b4_toknum[
540 };
541 # endif
542
543 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
544 static const ]b4_int_type_for([b4_r1])[ yyr1[] =
545 {
546 ]b4_r1[
547 };
548
549 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
550 static const ]b4_int_type_for([b4_r2])[ yyr2[] =
551 {
552 ]b4_r2[
553 };
554
555 /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
556 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
557 means the default is an error. */
558 static const ]b4_int_type_for([b4_defact])[ yydefact[] =
559 {
560 ]b4_defact[
561 };
562
563 /* YYDEFGOTO[NTERM-NUM]. */
564 static const ]b4_int_type_for([b4_defgoto])[ yydefgoto[] =
565 {
566 ]b4_defgoto[
567 };
568
569 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
570 STATE-NUM. */
571 #define YYPACT_NINF ]b4_pact_ninf[
572 static const ]b4_int_type_for([b4_pact])[ yypact[] =
573 {
574 ]b4_pact[
575 };
576
577 /* YYPGOTO[NTERM-NUM]. */
578 static const ]b4_int_type_for([b4_pgoto])[ yypgoto[] =
579 {
580 ]b4_pgoto[
581 };
582
583 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
584 positive, shift that token. If negative, reduce the rule which
585 number is the opposite. If zero, do what YYDEFACT says.
586 If YYTABLE_NINF, syntax error. */
587 #define YYTABLE_NINF ]b4_table_ninf[
588 static const ]b4_int_type_for([b4_table])[ yytable[] =
589 {
590 ]b4_table[
591 };
592
593 static const ]b4_int_type_for([b4_check])[ yycheck[] =
594 {
595 ]b4_check[
596 };
597
598 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
599 symbol of state STATE-NUM. */
600 static const ]b4_int_type_for([b4_stos])[ yystos[] =
601 {
602 ]b4_stos[
603 };
604
605 #define yyerrok (yyerrstatus = 0)
606 #define yyclearin (yychar = YYEMPTY)
607 #define YYEMPTY (-2)
608 #define YYEOF 0
609
610 #define YYACCEPT goto yyacceptlab
611 #define YYABORT goto yyabortlab
612 #define YYERROR goto yyerrorlab
613
614
615 /* Like YYERROR except do call yyerror. This remains here temporarily
616 to ease the transition to the new meaning of YYERROR, for GCC.
617 Once GCC version 2 has supplanted version 1, this can go. */
618
619 #define YYFAIL goto yyerrlab
620
621 #define YYRECOVERING() (!!yyerrstatus)
622
623 #define YYBACKUP(Token, Value) \
624 do \
625 if (yychar == YYEMPTY && yylen == 1) \
626 { \
627 yychar = (Token); \
628 yylval = (Value); \
629 yytoken = YYTRANSLATE (yychar); \
630 YYPOPSTACK (1); \
631 goto yybackup; \
632 } \
633 else \
634 { \
635 yyerror (]b4_yyerror_args[YY_("syntax error: cannot back up")); \
636 YYERROR; \
637 } \
638 while (YYID (0))
639
640
641 #define YYTERROR 1
642 #define YYERRCODE 256
643
644
645 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
646 If N is 0, then set CURRENT to the empty location which ends
647 the previous symbol: RHS[0] (always defined). */
648
649 #define YYRHSLOC(Rhs, K) ((Rhs)[K])
650 #ifndef YYLLOC_DEFAULT
651 # define YYLLOC_DEFAULT(Current, Rhs, N) \
652 do \
653 if (YYID (N)) \
654 { \
655 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
656 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
657 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
658 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
659 } \
660 else \
661 { \
662 (Current).first_line = (Current).last_line = \
663 YYRHSLOC (Rhs, 0).last_line; \
664 (Current).first_column = (Current).last_column = \
665 YYRHSLOC (Rhs, 0).last_column; \
666 } \
667 while (YYID (0))
668 #endif
669
670
671 /* YY_LOCATION_PRINT -- Print the location on the stream.
672 This macro was not mandated originally: define only if we know
673 we won't break user code: when these are the locations we know. */
674
675 #ifndef YY_LOCATION_PRINT
676 # if YYLTYPE_IS_TRIVIAL
677 # define YY_LOCATION_PRINT(File, Loc) \
678 fprintf (File, "%d.%d-%d.%d", \
679 (Loc).first_line, (Loc).first_column, \
680 (Loc).last_line, (Loc).last_column)
681 # else
682 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
683 # endif
684 #endif
685
686
687 /* YYLEX -- calling `yylex' with the right arguments. */
688
689 #ifdef YYLEX_PARAM
690 # define YYLEX yylex (]b4_pure_if([&yylval[]b4_locations_if([, &yylloc]), ])[YYLEX_PARAM)
691 #else
692 # define YYLEX ]b4_c_function_call([yylex], [int], b4_lex_param)[
693 #endif
694
695 /* Enable debugging if requested. */
696 #if YYDEBUG
697
698 # ifndef YYFPRINTF
699 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
700 # define YYFPRINTF fprintf
701 # endif
702
703 # define YYDPRINTF(Args) \
704 do { \
705 if (yydebug) \
706 YYFPRINTF Args; \
707 } while (YYID (0))
708
709 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
710 do { \
711 if (yydebug) \
712 { \
713 YYFPRINTF (stderr, "%s ", Title); \
714 yy_symbol_print (stderr, \
715 Type, Value]b4_locations_if([, Location])[]b4_user_args[); \
716 YYFPRINTF (stderr, "\n"); \
717 } \
718 } while (YYID (0))
719
720 ]b4_yy_symbol_print_generate([b4_c_function_def])[
721
722 /*------------------------------------------------------------------.
723 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
724 | TOP (included). |
725 `------------------------------------------------------------------*/
726
727 ]b4_c_function_def([yy_stack_print], [static void],
728 [[yytype_int16 *yybottom], [yybottom]],
729 [[yytype_int16 *yytop], [yytop]])[
730 {
731 YYFPRINTF (stderr, "Stack now");
732 for (; yybottom <= yytop; yybottom++)
733 {
734 int yybot = *yybottom;
735 YYFPRINTF (stderr, " %d", yybot);
736 }
737 YYFPRINTF (stderr, "\n");
738 }
739
740 # define YY_STACK_PRINT(Bottom, Top) \
741 do { \
742 if (yydebug) \
743 yy_stack_print ((Bottom), (Top)); \
744 } while (YYID (0))
745
746
747 /*------------------------------------------------.
748 | Report that the YYRULE is going to be reduced. |
749 `------------------------------------------------*/
750
751 ]b4_c_function_def([yy_reduce_print], [static void],
752 [[YYSTYPE *yyvsp], [yyvsp]],
753 b4_locations_if([[[YYLTYPE *yylsp], [yylsp]],
754 ])[[int yyrule], [yyrule]]m4_ifset([b4_parse_param], [,
755 b4_parse_param]))[
756 {
757 int yynrhs = yyr2[yyrule];
758 int yyi;
759 unsigned long int yylno = yyrline[yyrule];
760 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
761 yyrule - 1, yylno);
762 /* The symbols being reduced. */
763 for (yyi = 0; yyi < yynrhs; yyi++)
764 {
765 fprintf (stderr, " $%d = ", yyi + 1);
766 yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
767 &]b4_rhs_value(yynrhs, yyi + 1)[
768 ]b4_locations_if([, &]b4_rhs_location(yynrhs, yyi + 1))[]dnl
769 b4_user_args[);
770 fprintf (stderr, "\n");
771 }
772 }
773
774 # define YY_REDUCE_PRINT(Rule) \
775 do { \
776 if (yydebug) \
777 yy_reduce_print (yyvsp, ]b4_locations_if([yylsp, ])[Rule]b4_user_args[); \
778 } while (YYID (0))
779
780 /* Nonzero means print parse trace. It is left uninitialized so that
781 multiple parsers can coexist. */
782 int yydebug;
783 #else /* !YYDEBUG */
784 # define YYDPRINTF(Args)
785 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
786 # define YY_STACK_PRINT(Bottom, Top)
787 # define YY_REDUCE_PRINT(Rule)
788 #endif /* !YYDEBUG */
789
790
791 /* YYINITDEPTH -- initial size of the parser's stacks. */
792 #ifndef YYINITDEPTH
793 # define YYINITDEPTH ]b4_stack_depth_init[
794 #endif
795
796 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
797 if the built-in stack extension method is used).
798
799 Do not make this value too large; the results are undefined if
800 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
801 evaluated with infinite-precision integer arithmetic. */
802
803 #ifndef YYMAXDEPTH
804 # define YYMAXDEPTH ]b4_stack_depth_max[
805 #endif
806
807 \f
808
809 #if YYERROR_VERBOSE
810
811 # ifndef yystrlen
812 # if defined __GLIBC__ && defined _STRING_H
813 # define yystrlen strlen
814 # else
815 /* Return the length of YYSTR. */
816 ]b4_c_function_def([yystrlen], [static YYSIZE_T],
817 [[const char *yystr], [yystr]])[
818 {
819 YYSIZE_T yylen;
820 for (yylen = 0; yystr[yylen]; yylen++)
821 continue;
822 return yylen;
823 }
824 # endif
825 # endif
826
827 # ifndef yystpcpy
828 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
829 # define yystpcpy stpcpy
830 # else
831 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
832 YYDEST. */
833 ]b4_c_function_def([yystpcpy], [static char *],
834 [[char *yydest], [yydest]], [[const char *yysrc], [yysrc]])[
835 {
836 char *yyd = yydest;
837 const char *yys = yysrc;
838
839 while ((*yyd++ = *yys++) != '\0')
840 continue;
841
842 return yyd - 1;
843 }
844 # endif
845 # endif
846
847 # ifndef yytnamerr
848 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
849 quotes and backslashes, so that it's suitable for yyerror. The
850 heuristic is that double-quoting is unnecessary unless the string
851 contains an apostrophe, a comma, or backslash (other than
852 backslash-backslash). YYSTR is taken from yytname. If YYRES is
853 null, do not copy; instead, return the length of what the result
854 would have been. */
855 static YYSIZE_T
856 yytnamerr (char *yyres, const char *yystr)
857 {
858 if (*yystr == '"')
859 {
860 YYSIZE_T yyn = 0;
861 char const *yyp = yystr;
862
863 for (;;)
864 switch (*++yyp)
865 {
866 case '\'':
867 case ',':
868 goto do_not_strip_quotes;
869
870 case '\\':
871 if (*++yyp != '\\')
872 goto do_not_strip_quotes;
873 /* Fall through. */
874 default:
875 if (yyres)
876 yyres[yyn] = *yyp;
877 yyn++;
878 break;
879
880 case '"':
881 if (yyres)
882 yyres[yyn] = '\0';
883 return yyn;
884 }
885 do_not_strip_quotes: ;
886 }
887
888 if (! yyres)
889 return yystrlen (yystr);
890
891 return yystpcpy (yyres, yystr) - yyres;
892 }
893 # endif
894
895 /* Copy into YYRESULT an error message about the unexpected token
896 YYCHAR while in state YYSTATE. Return the number of bytes copied,
897 including the terminating null byte. If YYRESULT is null, do not
898 copy anything; just return the number of bytes that would be
899 copied. As a special case, return 0 if an ordinary "syntax error"
900 message will do. Return YYSIZE_MAXIMUM if overflow occurs during
901 size calculation. */
902 static YYSIZE_T
903 yysyntax_error (char *yyresult, int yystate, int yychar)
904 {
905 int yyn = yypact[yystate];
906
907 if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
908 return 0;
909 else
910 {
911 int yytype = YYTRANSLATE (yychar);
912 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
913 YYSIZE_T yysize = yysize0;
914 YYSIZE_T yysize1;
915 int yysize_overflow = 0;
916 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
917 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
918 int yyx;
919
920 # if 0
921 /* This is so xgettext sees the translatable formats that are
922 constructed on the fly. */
923 YY_("syntax error, unexpected %s");
924 YY_("syntax error, unexpected %s, expecting %s");
925 YY_("syntax error, unexpected %s, expecting %s or %s");
926 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
927 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
928 # endif
929 char *yyfmt;
930 char const *yyf;
931 static char const yyunexpected[] = "syntax error, unexpected %s";
932 static char const yyexpecting[] = ", expecting %s";
933 static char const yyor[] = " or %s";
934 char yyformat[sizeof yyunexpected
935 + sizeof yyexpecting - 1
936 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
937 * (sizeof yyor - 1))];
938 char const *yyprefix = yyexpecting;
939
940 /* Start YYX at -YYN if negative to avoid negative indexes in
941 YYCHECK. */
942 int yyxbegin = yyn < 0 ? -yyn : 0;
943
944 /* Stay within bounds of both yycheck and yytname. */
945 int yychecklim = YYLAST - yyn + 1;
946 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
947 int yycount = 1;
948
949 yyarg[0] = yytname[yytype];
950 yyfmt = yystpcpy (yyformat, yyunexpected);
951
952 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
953 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
954 {
955 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
956 {
957 yycount = 1;
958 yysize = yysize0;
959 yyformat[sizeof yyunexpected - 1] = '\0';
960 break;
961 }
962 yyarg[yycount++] = yytname[yyx];
963 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
964 yysize_overflow |= (yysize1 < yysize);
965 yysize = yysize1;
966 yyfmt = yystpcpy (yyfmt, yyprefix);
967 yyprefix = yyor;
968 }
969
970 yyf = YY_(yyformat);
971 yysize1 = yysize + yystrlen (yyf);
972 yysize_overflow |= (yysize1 < yysize);
973 yysize = yysize1;
974
975 if (yysize_overflow)
976 return YYSIZE_MAXIMUM;
977
978 if (yyresult)
979 {
980 /* Avoid sprintf, as that infringes on the user's name space.
981 Don't have undefined behavior even if the translation
982 produced a string with the wrong number of "%s"s. */
983 char *yyp = yyresult;
984 int yyi = 0;
985 while ((*yyp = *yyf) != '\0')
986 {
987 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
988 {
989 yyp += yytnamerr (yyp, yyarg[yyi++]);
990 yyf += 2;
991 }
992 else
993 {
994 yyp++;
995 yyf++;
996 }
997 }
998 }
999 return yysize;
1000 }
1001 }
1002 #endif /* YYERROR_VERBOSE */
1003 \f
1004
1005 ]b4_yydestruct_generate([b4_c_function_def])[
1006
1007 ]b4_push_if([],
1008 [[/* Prevent warnings from -Wmissing-prototypes. */
1009 #ifdef YYPARSE_PARAM
1010 ]b4_c_function_decl([yyparse], [int],
1011 [[void *YYPARSE_PARAM], [YYPARSE_PARAM]])[
1012 #else /* ! YYPARSE_PARAM */
1013 ]b4_c_function_decl([yyparse], [int], b4_parse_param)[
1014 #endif /* ! YYPARSE_PARAM */]])
1015
1016 m4_divert_push([KILL])# ======================== M4 code.
1017 # b4_declare_scanner_communication_variables
1018 # ------------------------------------------
1019 # Declare the variables that are global, or local to YYPARSE if
1020 # pure-parser.
1021 m4_define([b4_declare_scanner_communication_variables],
1022 [[/* The lookahead symbol. */
1023 int yychar;
1024
1025 /* The semantic value of the lookahead symbol. */
1026 YYSTYPE yylval;
1027 ]b4_locations_if([[
1028 /* Location data for the lookahead symbol. */
1029 YYLTYPE yylloc;
1030 ]])b4_pure_if([], [[
1031 /* Number of syntax errors so far. */
1032 int yynerrs;
1033 ]])])
1034
1035 # b4_declare_parser_state_variables
1036 # ---------------------------------
1037 # Declare all the variables that are needed to maintain the parser state
1038 # between calls to yypush_parse.
1039 m4_define([b4_declare_parser_state_variables],
1040 [b4_pure_if([[ /* Number of syntax errors so far. */
1041 int yynerrs;
1042 ]])[
1043 int yystate;
1044 /* Number of tokens to shift before error messages enabled. */
1045 int yyerrstatus;
1046
1047 /* Three stacks and their tools:
1048 `yyss': related to states,
1049 `yyvs': related to semantic values,
1050 `yyls': related to locations.
1051
1052 Refer to the stacks thru separate pointers, to allow yyoverflow
1053 to reallocate them elsewhere. */
1054
1055 /* The state stack. */
1056 yytype_int16 yyssa[YYINITDEPTH];
1057 yytype_int16 *yyss;
1058 yytype_int16 *yyssp;
1059
1060 /* The semantic value stack. */
1061 YYSTYPE yyvsa[YYINITDEPTH];
1062 YYSTYPE *yyvs;
1063 YYSTYPE *yyvsp;
1064 ]b4_locations_if([[
1065 /* The location stack. */
1066 YYLTYPE yylsa[YYINITDEPTH];
1067 YYLTYPE *yyls;
1068 YYLTYPE *yylsp;
1069
1070 /* The locations where the error started and ended. */
1071 YYLTYPE yyerror_range[2];
1072 ]])[
1073 YYSIZE_T yystacksize;
1074 ]])
1075
1076 m4_divert_pop([KILL])dnl# ====================== End of M4 code.
1077
1078 b4_pure_if([], [b4_declare_scanner_communication_variables])
1079
1080 b4_push_if(
1081 [[struct yypstate
1082 {
1083 ]b4_declare_parser_state_variables[
1084 /* Used to determine if this is the first time this instance has
1085 been used. */
1086 int yynew;
1087 };
1088
1089 ]b4_pull_if([b4_c_function_def([[yyparse]], [[int]], b4_parse_param)[
1090 {
1091 return yypull_parse (0]m4_ifset([b4_parse_param],
1092 [[, ]b4_c_args(b4_parse_param)])[);
1093 }
1094
1095 ]b4_c_function_def([[yypull_parse]], [[int]],
1096 [[[yypstate *yyps]], [[yyps]]]m4_ifset([b4_parse_param], [,
1097 b4_parse_param]))[
1098 {
1099 int yystatus;
1100 yypstate *yyps_local;
1101 ]b4_pure_if([[ int yychar;
1102 YYSTYPE yylval;
1103 ]b4_locations_if([[ YYLTYPE yylloc;
1104 ]])])[
1105 if (yyps == 0)
1106 yyps_local = yypstate_new ();
1107 else
1108 yyps_local = yyps;
1109 do {
1110 yychar = YYLEX;
1111 yystatus =
1112 yypush_parse (yyps_local]b4_pure_if([[, yychar, &yylval]b4_locations_if([[, &yylloc]])])m4_ifset([b4_parse_param], [, b4_c_args(b4_parse_param)])[);
1113 } while (yystatus == YYPUSH_MORE);
1114 if (yyps == 0)
1115 yypstate_delete (yyps_local);
1116 return yystatus;
1117 }
1118 ]])[
1119 /* Initialize the parser data structure. */
1120 ]b4_c_function_def([[yypstate_new]], [[yypstate *]])[
1121 {
1122 yypstate *yyps = (yypstate *) malloc (sizeof *yyps);
1123 yyps->yynew = 1;
1124 return yyps;
1125 }
1126
1127 ]b4_c_function_def([[yypstate_delete]], [[void]],
1128 [[[yypstate *yyps]], [[yyps]]])[
1129 {
1130 free (yyps);
1131 }
1132
1133 ]b4_pure_if([[#define ]b4_prefix[nerrs yyps->]b4_prefix[nerrs
1134 ]])[#define yystate yyps->yystate
1135 #define yyerrstatus yyps->yyerrstatus
1136 #define yyssa yyps->yyssa
1137 #define yyss yyps->yyss
1138 #define yyssp yyps->yyssp
1139 #define yyvsa yyps->yyvsa
1140 #define yyvs yyps->yyvs
1141 #define yyvsp yyps->yyvsp
1142 ]b4_locations_if([[#define yylsa yyps->yylsa
1143 #define yyls yyps->yyls
1144 #define yylsp yyps->yylsp
1145 #define yyerror_range yyps->yyerror_range
1146 ]])[#define yystacksize yyps->yystacksize
1147 ]])[
1148
1149 /*-------------------------.
1150 | yyparse or yypush_parse. |
1151 `-------------------------*/
1152
1153 ]b4_push_if([
1154 b4_c_function_def([[yypush_parse]], [[int]],
1155 [[[yypstate *yyps]], [[yyps]]]b4_pure_if([,
1156 [[[int yypushed_char]], [[yypushed_char]]],
1157 [[[YYSTYPE const *yypushed_val]], [[yypushed_val]]]b4_locations_if([,
1158 [[[YYLTYPE const *yypushed_loc]], [[yypushed_loc]]]])])m4_ifset([b4_parse_param], [,
1159 b4_parse_param]))], [
1160 #ifdef YYPARSE_PARAM
1161 b4_c_function_def([yyparse], [int], [[void *YYPARSE_PARAM], [YYPARSE_PARAM]])
1162 #else /* ! YYPARSE_PARAM */
1163 b4_c_function_def([yyparse], [int], b4_parse_param)
1164 #endif])[
1165 {
1166 ]b4_pure_if([b4_declare_scanner_communication_variables])
1167 b4_push_if([b4_pure_if([], [[ int yypushed_char = yychar;
1168 YYSTYPE yypushed_val = yylval;
1169 ]b4_locations_if([[YYLTYPE yypushed_loc = yylloc;
1170 ]])])],
1171 [b4_declare_parser_state_variables])[
1172 int yyn;
1173 int yyresult;
1174 /* Look-ahead token as an internal (translated) token number. */
1175 int yytoken;
1176 /* The variables used to return semantic value and location from the
1177 action routines. */
1178 YYSTYPE yyval;
1179 ]b4_locations_if([[ YYLTYPE yyloc;
1180 ]])[
1181 #if YYERROR_VERBOSE
1182 /* Buffer for error messages, and its allocated size. */
1183 char yymsgbuf[128];
1184 char *yymsg = yymsgbuf;
1185 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1186 #endif
1187
1188 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)]b4_locations_if([, yylsp -= (N)])[)
1189
1190 /* The number of symbols on the RHS of the reduced rule.
1191 Keep to zero when no symbol should be popped. */
1192 int yylen = 0;
1193 ]b4_push_if([[
1194 if (!yyps->yynew)
1195 {
1196 yyn = yypact[yystate];
1197 goto yyread_pushed_token;
1198 }
1199 ]])[
1200 yytoken = 0;
1201 yyss = yyssa;
1202 yyvs = yyvsa;
1203 ]b4_locations_if([[ yyls = yylsa;
1204 ]])[
1205 yystacksize = YYINITDEPTH;
1206
1207 YYDPRINTF ((stderr, "Starting parse\n"));
1208
1209 yystate = 0;
1210 yyerrstatus = 0;
1211 yynerrs = 0;
1212 yychar = YYEMPTY; /* Cause a token to be read. */
1213
1214 /* Initialize stack pointers.
1215 Waste one element of value and location stack
1216 so that they stay on the same level as the state stack.
1217 The wasted elements are never initialized. */
1218 yyssp = yyss;
1219 yyvsp = yyvs;
1220 ]b4_locations_if([[ yylsp = yyls;
1221
1222 #if YYLTYPE_IS_TRIVIAL
1223 /* Initialize the default location before parsing starts. */
1224 yylloc.first_line = yylloc.last_line = ]b4_location_initial_line[;
1225 yylloc.first_column = yylloc.last_column = ]b4_location_initial_column[;
1226 #endif
1227 ]])
1228 m4_ifdef([b4_initial_action], [
1229 m4_pushdef([b4_at_dollar], [m4_define([b4_at_dollar_used])yylloc])dnl
1230 m4_pushdef([b4_dollar_dollar], [m4_define([b4_dollar_dollar_used])yylval])dnl
1231 /* User initialization code. */
1232 b4_user_initial_action
1233 m4_popdef([b4_dollar_dollar])dnl
1234 m4_popdef([b4_at_dollar])])dnl
1235 m4_ifdef([b4_dollar_dollar_used],[[ yyvsp[0] = yylval;
1236 ]])dnl
1237 m4_ifdef([b4_at_dollar_used], [[ yylsp[0] = yylloc;
1238 ]])dnl
1239 [
1240 goto yysetstate;
1241
1242 /*------------------------------------------------------------.
1243 | yynewstate -- Push a new state, which is found in yystate. |
1244 `------------------------------------------------------------*/
1245 yynewstate:
1246 /* In all cases, when you get here, the value and location stacks
1247 have just been pushed. So pushing a state here evens the stacks. */
1248 yyssp++;
1249
1250 yysetstate:
1251 *yyssp = yystate;
1252
1253 if (yyss + yystacksize - 1 <= yyssp)
1254 {
1255 /* Get the current used size of the three stacks, in elements. */
1256 YYSIZE_T yysize = yyssp - yyss + 1;
1257
1258 #ifdef yyoverflow
1259 {
1260 /* Give user a chance to reallocate the stack. Use copies of
1261 these so that the &'s don't force the real ones into
1262 memory. */
1263 YYSTYPE *yyvs1 = yyvs;
1264 yytype_int16 *yyss1 = yyss;
1265 ]b4_locations_if([ YYLTYPE *yyls1 = yyls;])[
1266
1267 /* Each stack pointer address is followed by the size of the
1268 data in use in that stack, in bytes. This used to be a
1269 conditional around just the two extra args, but that might
1270 be undefined if yyoverflow is a macro. */
1271 yyoverflow (YY_("memory exhausted"),
1272 &yyss1, yysize * sizeof (*yyssp),
1273 &yyvs1, yysize * sizeof (*yyvsp),
1274 ]b4_locations_if([ &yyls1, yysize * sizeof (*yylsp),])[
1275 &yystacksize);
1276 ]b4_locations_if([ yyls = yyls1;])[
1277 yyss = yyss1;
1278 yyvs = yyvs1;
1279 }
1280 #else /* no yyoverflow */
1281 # ifndef YYSTACK_RELOCATE
1282 goto yyexhaustedlab;
1283 # else
1284 /* Extend the stack our own way. */
1285 if (YYMAXDEPTH <= yystacksize)
1286 goto yyexhaustedlab;
1287 yystacksize *= 2;
1288 if (YYMAXDEPTH < yystacksize)
1289 yystacksize = YYMAXDEPTH;
1290
1291 {
1292 yytype_int16 *yyss1 = yyss;
1293 union yyalloc *yyptr =
1294 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1295 if (! yyptr)
1296 goto yyexhaustedlab;
1297 YYSTACK_RELOCATE (yyss_alloc, yyss);
1298 YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1299 ]b4_locations_if([ YYSTACK_RELOCATE (yyls_alloc, yyls);])[
1300 # undef YYSTACK_RELOCATE
1301 if (yyss1 != yyssa)
1302 YYSTACK_FREE (yyss1);
1303 }
1304 # endif
1305 #endif /* no yyoverflow */
1306
1307 yyssp = yyss + yysize - 1;
1308 yyvsp = yyvs + yysize - 1;
1309 ]b4_locations_if([ yylsp = yyls + yysize - 1;])[
1310
1311 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1312 (unsigned long int) yystacksize));
1313
1314 if (yyss + yystacksize - 1 <= yyssp)
1315 YYABORT;
1316 }
1317
1318 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1319
1320 if (yystate == YYFINAL)
1321 YYACCEPT;
1322
1323 goto yybackup;
1324
1325 /*-----------.
1326 | yybackup. |
1327 `-----------*/
1328 yybackup:
1329
1330 /* Do appropriate processing given the current state. Read a
1331 lookahead token if we need one and don't already have one. */
1332
1333 /* First try to decide what to do without reference to lookahead token. */
1334 yyn = yypact[yystate];
1335 if (yyn == YYPACT_NINF)
1336 goto yydefault;
1337
1338 /* Not known => get a lookahead token if don't already have one. */
1339
1340 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1341 if (yychar == YYEMPTY)
1342 {
1343 ]b4_push_if([[ if (!yyps->yynew)
1344 {
1345 ]b4_use_push_for_pull_if([],
1346 [[ YYDPRINTF ((stderr, "Return for a new token:\n"));
1347 ]])[ yyresult = YYPUSH_MORE;
1348 goto yypushreturn;
1349 }
1350 yyps->yynew = 0;
1351 ]b4_pure_if([], [[
1352 /* Restoring the pushed token is only necessary for the first
1353 yypush_parse invocation since subsequent invocations don't overwrite
1354 it before jumping to yyread_pushed_token. */
1355 yychar = yypushed_char;
1356 yylval = yypushed_val;
1357 ]b4_locations_if([[yylloc = yypushed_loc;
1358 ]])])[
1359 yyread_pushed_token:
1360 ]])[ YYDPRINTF ((stderr, "Reading a token: "));
1361 ]b4_push_if([b4_pure_if([[ yychar = yypushed_char;
1362 if (yypushed_val)
1363 yylval = *yypushed_val;
1364 ]b4_locations_if([[ if (yypushed_loc)
1365 yylloc = *yypushed_loc;
1366 ]])])],
1367 [[ yychar = YYLEX;
1368 ]])[ }
1369
1370 if (yychar <= YYEOF)
1371 {
1372 yychar = yytoken = YYEOF;
1373 YYDPRINTF ((stderr, "Now at end of input.\n"));
1374 }
1375 else
1376 {
1377 yytoken = YYTRANSLATE (yychar);
1378 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1379 }
1380
1381 /* If the proper action on seeing token YYTOKEN is to reduce or to
1382 detect an error, take that action. */
1383 yyn += yytoken;
1384 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1385 goto yydefault;
1386 yyn = yytable[yyn];
1387 if (yyn <= 0)
1388 {
1389 if (yyn == 0 || yyn == YYTABLE_NINF)
1390 goto yyerrlab;
1391 yyn = -yyn;
1392 goto yyreduce;
1393 }
1394
1395 /* Count tokens shifted since error; after three, turn off error
1396 status. */
1397 if (yyerrstatus)
1398 yyerrstatus--;
1399
1400 /* Shift the lookahead token. */
1401 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1402
1403 /* Discard the shifted token. */
1404 yychar = YYEMPTY;
1405
1406 yystate = yyn;
1407 *++yyvsp = yylval;
1408 ]b4_locations_if([ *++yylsp = yylloc;])[
1409 goto yynewstate;
1410
1411
1412 /*-----------------------------------------------------------.
1413 | yydefault -- do the default action for the current state. |
1414 `-----------------------------------------------------------*/
1415 yydefault:
1416 yyn = yydefact[yystate];
1417 if (yyn == 0)
1418 goto yyerrlab;
1419 goto yyreduce;
1420
1421
1422 /*-----------------------------.
1423 | yyreduce -- Do a reduction. |
1424 `-----------------------------*/
1425 yyreduce:
1426 /* yyn is the number of a rule to reduce with. */
1427 yylen = yyr2[yyn];
1428
1429 /* If YYLEN is nonzero, implement the default value of the action:
1430 `$$ = $1'.
1431
1432 Otherwise, the following line sets YYVAL to garbage.
1433 This behavior is undocumented and Bison
1434 users should not rely upon it. Assigning to YYVAL
1435 unconditionally makes the parser a bit smaller, and it avoids a
1436 GCC warning that YYVAL may be used uninitialized. */
1437 yyval = yyvsp[1-yylen];
1438
1439 ]b4_locations_if(
1440 [[ /* Default location. */
1441 YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);]])[
1442 YY_REDUCE_PRINT (yyn);
1443 switch (yyn)
1444 {
1445 ]b4_user_actions[
1446 default: break;
1447 }
1448 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
1449
1450 YYPOPSTACK (yylen);
1451 yylen = 0;
1452 YY_STACK_PRINT (yyss, yyssp);
1453
1454 *++yyvsp = yyval;
1455 ]b4_locations_if([ *++yylsp = yyloc;])[
1456
1457 /* Now `shift' the result of the reduction. Determine what state
1458 that goes to, based on the state we popped back to and the rule
1459 number reduced by. */
1460
1461 yyn = yyr1[yyn];
1462
1463 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1464 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1465 yystate = yytable[yystate];
1466 else
1467 yystate = yydefgoto[yyn - YYNTOKENS];
1468
1469 goto yynewstate;
1470
1471
1472 /*------------------------------------.
1473 | yyerrlab -- here on detecting error |
1474 `------------------------------------*/
1475 yyerrlab:
1476 /* If not already recovering from an error, report this error. */
1477 if (!yyerrstatus)
1478 {
1479 ++yynerrs;
1480 #if ! YYERROR_VERBOSE
1481 yyerror (]b4_yyerror_args[YY_("syntax error"));
1482 #else
1483 {
1484 YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
1485 if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
1486 {
1487 YYSIZE_T yyalloc = 2 * yysize;
1488 if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
1489 yyalloc = YYSTACK_ALLOC_MAXIMUM;
1490 if (yymsg != yymsgbuf)
1491 YYSTACK_FREE (yymsg);
1492 yymsg = (char *) YYSTACK_ALLOC (yyalloc);
1493 if (yymsg)
1494 yymsg_alloc = yyalloc;
1495 else
1496 {
1497 yymsg = yymsgbuf;
1498 yymsg_alloc = sizeof yymsgbuf;
1499 }
1500 }
1501
1502 if (0 < yysize && yysize <= yymsg_alloc)
1503 {
1504 (void) yysyntax_error (yymsg, yystate, yychar);
1505 yyerror (]b4_yyerror_args[yymsg);
1506 }
1507 else
1508 {
1509 yyerror (]b4_yyerror_args[YY_("syntax error"));
1510 if (yysize != 0)
1511 goto yyexhaustedlab;
1512 }
1513 }
1514 #endif
1515 }
1516
1517 ]b4_locations_if([[ yyerror_range[0] = yylloc;]])[
1518
1519 if (yyerrstatus == 3)
1520 {
1521 /* If just tried and failed to reuse lookahead token after an
1522 error, discard it. */
1523
1524 if (yychar <= YYEOF)
1525 {
1526 /* Return failure if at end of input. */
1527 if (yychar == YYEOF)
1528 YYABORT;
1529 }
1530 else
1531 {
1532 yydestruct ("Error: discarding",
1533 yytoken, &yylval]b4_locations_if([, &yylloc])[]b4_user_args[);
1534 yychar = YYEMPTY;
1535 }
1536 }
1537
1538 /* Else will try to reuse lookahead token after shifting the error
1539 token. */
1540 goto yyerrlab1;
1541
1542
1543 /*---------------------------------------------------.
1544 | yyerrorlab -- error raised explicitly by YYERROR. |
1545 `---------------------------------------------------*/
1546 yyerrorlab:
1547
1548 /* Pacify compilers like GCC when the user code never invokes
1549 YYERROR and the label yyerrorlab therefore never appears in user
1550 code. */
1551 if (/*CONSTCOND*/ 0)
1552 goto yyerrorlab;
1553
1554 ]b4_locations_if([[ yyerror_range[0] = yylsp[1-yylen];
1555 ]])[ /* Do not reclaim the symbols of the rule which action triggered
1556 this YYERROR. */
1557 YYPOPSTACK (yylen);
1558 yylen = 0;
1559 YY_STACK_PRINT (yyss, yyssp);
1560 yystate = *yyssp;
1561 goto yyerrlab1;
1562
1563
1564 /*-------------------------------------------------------------.
1565 | yyerrlab1 -- common code for both syntax error and YYERROR. |
1566 `-------------------------------------------------------------*/
1567 yyerrlab1:
1568 yyerrstatus = 3; /* Each real token shifted decrements this. */
1569
1570 for (;;)
1571 {
1572 yyn = yypact[yystate];
1573 if (yyn != YYPACT_NINF)
1574 {
1575 yyn += YYTERROR;
1576 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
1577 {
1578 yyn = yytable[yyn];
1579 if (0 < yyn)
1580 break;
1581 }
1582 }
1583
1584 /* Pop the current state because it cannot handle the error token. */
1585 if (yyssp == yyss)
1586 YYABORT;
1587
1588 ]b4_locations_if([[ yyerror_range[0] = *yylsp;]])[
1589 yydestruct ("Error: popping",
1590 yystos[yystate], yyvsp]b4_locations_if([, yylsp])[]b4_user_args[);
1591 YYPOPSTACK (1);
1592 yystate = *yyssp;
1593 YY_STACK_PRINT (yyss, yyssp);
1594 }
1595
1596 *++yyvsp = yylval;
1597 ]b4_locations_if([[
1598 yyerror_range[1] = yylloc;
1599 /* Using YYLLOC is tempting, but would change the location of
1600 the lookahead. YYLOC is available though. */
1601 YYLLOC_DEFAULT (yyloc, (yyerror_range - 1), 2);
1602 *++yylsp = yyloc;]])[
1603
1604 /* Shift the error token. */
1605 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
1606
1607 yystate = yyn;
1608 goto yynewstate;
1609
1610
1611 /*-------------------------------------.
1612 | yyacceptlab -- YYACCEPT comes here. |
1613 `-------------------------------------*/
1614 yyacceptlab:
1615 yyresult = 0;
1616 goto yyreturn;
1617
1618 /*-----------------------------------.
1619 | yyabortlab -- YYABORT comes here. |
1620 `-----------------------------------*/
1621 yyabortlab:
1622 yyresult = 1;
1623 goto yyreturn;
1624
1625 #ifndef yyoverflow
1626 /*-------------------------------------------------.
1627 | yyexhaustedlab -- memory exhaustion comes here. |
1628 `-------------------------------------------------*/
1629 yyexhaustedlab:
1630 yyerror (]b4_yyerror_args[YY_("memory exhausted"));
1631 yyresult = 2;
1632 /* Fall through. */
1633 #endif
1634
1635 yyreturn:
1636 if (yychar != YYEMPTY)
1637 yydestruct ("Cleanup: discarding lookahead",
1638 yytoken, &yylval]b4_locations_if([, &yylloc])[]b4_user_args[);
1639 /* Do not reclaim the symbols of the rule which action triggered
1640 this YYABORT or YYACCEPT. */
1641 YYPOPSTACK (yylen);
1642 YY_STACK_PRINT (yyss, yyssp);
1643 while (yyssp != yyss)
1644 {
1645 yydestruct ("Cleanup: popping",
1646 yystos[*yyssp], yyvsp]b4_locations_if([, yylsp])[]b4_user_args[);
1647 YYPOPSTACK (1);
1648 }
1649 #ifndef yyoverflow
1650 if (yyss != yyssa)
1651 YYSTACK_FREE (yyss);
1652 #endif
1653 ]b4_push_if([[ yyps->yynew = 1;
1654
1655 yypushreturn:
1656 ]])[#if YYERROR_VERBOSE
1657 if (yymsg != yymsgbuf)
1658 YYSTACK_FREE (yymsg);
1659 #endif
1660 /* Make sure YYID is used. */
1661 return YYID (yyresult);
1662 }
1663
1664
1665 ]b4_epilogue
1666 b4_defines_if(
1667 [@output(b4_spec_defines_file@)
1668 b4_copyright([Skeleton interface for Bison's Yacc-like parsers in C],dnl '
1669 [1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006])
1670
1671 m4_ifdef([b4_percent_code_requires],
1672 [[/* Copy the %code "requires" blocks. */
1673 ]b4_user_code([b4_percent_code_requires])])[]dnl
1674
1675 b4_token_enums_defines(b4_tokens)
1676
1677 [#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
1678 ]m4_ifdef([b4_stype],
1679 [[typedef union ]b4_union_name[
1680 ]b4_user_stype[
1681 YYSTYPE;
1682 # define YYSTYPE_IS_TRIVIAL 1]],
1683 [m4_if(b4_tag_seen_flag, 0,
1684 [[typedef int YYSTYPE;
1685 # define YYSTYPE_IS_TRIVIAL 1]])])[
1686 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
1687 # define YYSTYPE_IS_DECLARED 1
1688 #endif
1689
1690 ]b4_pure_if([], [[extern YYSTYPE ]b4_prefix[lval;]])
1691
1692 b4_locations_if(
1693 [#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED
1694 typedef struct YYLTYPE
1695 {
1696 int first_line;
1697 int first_column;
1698 int last_line;
1699 int last_column;
1700 } YYLTYPE;
1701 # define yyltype YYLTYPE /* obsolescent; will be withdrawn */
1702 # define YYLTYPE_IS_DECLARED 1
1703 # define YYLTYPE_IS_TRIVIAL 1
1704 #endif
1705
1706 ]b4_pure_if([], [[extern YYLTYPE ]b4_prefix[lloc;]])
1707 )dnl b4_locations_if
1708
1709 b4_push_if([[#ifndef YYPUSH_DECLS
1710 # define YYPUSH_DECLS
1711 struct ]b4_prefix[pstate;
1712 typedef struct ]b4_prefix[pstate ]b4_prefix[pstate;
1713 enum { YYPUSH_MORE = 4 };
1714 ]b4_pull_if([b4_c_function_decl([b4_prefix[parse]], [[int]], b4_parse_param)
1715 ])b4_c_function_decl([b4_prefix[push_parse]], [[int]],
1716 [[b4_prefix[pstate *yyps]], [[yyps]]]b4_pure_if([,
1717 [[[int yypushed_char]], [[yypushed_char]]],
1718 [[[YYSTYPE const *yypushed_val]], [[yypushed_val]]]b4_locations_if([,
1719 [[[YYLTYPE const *yypushed_loc]], [[yypushed_loc]]]])])m4_ifset([b4_parse_param], [,
1720 b4_parse_param]))
1721 b4_pull_if([b4_c_function_decl([b4_prefix[pull_parse]], [[int]],
1722 [[b4_prefix[pstate *yyps]], [[yyps]]]m4_ifset([b4_parse_param], [,
1723 b4_parse_param]))])
1724 b4_c_function_decl([b4_prefix[pstate_new]], [b4_prefix[pstate *]],
1725 [[[void]], []])
1726 b4_c_function_decl([b4_prefix[pstate_delete]], [[void]],
1727 [[b4_prefix[pstate *yyps]], [[yyps]]])[
1728 #endif
1729 ]])
1730 m4_ifdef([b4_percent_code_provides],
1731 [[/* Copy the %code "provides" blocks. */
1732 ]b4_user_code([b4_percent_code_provides])])[]
1733 ])dnl b4_defines_if
1734 m4_divert_pop(0)