]>
Commit | Line | Data |
---|---|---|
1 | -*- C -*- | |
2 | # Yacc compatible skeleton for Bison | |
3 | ||
4 | # Copyright (C) 1984, 1989-1990, 2000-2012 Free Software Foundation, | |
5 | # Inc. | |
6 | ||
7 | m4_pushdef([b4_copyright_years], | |
8 | [1984, 1989-1990, 2000-2012]) | |
9 | ||
10 | # This program is free software: you can redistribute it and/or modify | |
11 | # it under the terms of the GNU General Public License as published by | |
12 | # the Free Software Foundation, either version 3 of the License, or | |
13 | # (at your option) any later version. | |
14 | # | |
15 | # This program is distributed in the hope that it will be useful, | |
16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 | # GNU General Public License for more details. | |
19 | # | |
20 | # You should have received a copy of the GNU General Public License | |
21 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
22 | ||
23 | # Check the value of %define api.push-pull. | |
24 | b4_percent_define_default([[api.push-pull]], [[pull]]) | |
25 | b4_percent_define_check_values([[[[api.push-pull]], | |
26 | [[pull]], [[push]], [[both]]]]) | |
27 | b4_define_flag_if([pull]) m4_define([b4_pull_flag], [[1]]) | |
28 | b4_define_flag_if([push]) m4_define([b4_push_flag], [[1]]) | |
29 | m4_case(b4_percent_define_get([[api.push-pull]]), | |
30 | [pull], [m4_define([b4_push_flag], [[0]])], | |
31 | [push], [m4_define([b4_pull_flag], [[0]])]) | |
32 | ||
33 | # Handle BISON_USE_PUSH_FOR_PULL for the test suite. So that push parsing | |
34 | # tests function as written, do not let BISON_USE_PUSH_FOR_PULL modify the | |
35 | # behavior of Bison at all when push parsing is already requested. | |
36 | b4_define_flag_if([use_push_for_pull]) | |
37 | b4_use_push_for_pull_if([ | |
38 | b4_push_if([m4_define([b4_use_push_for_pull_flag], [[0]])], | |
39 | [m4_define([b4_push_flag], [[1]])])]) | |
40 | ||
41 | # Check the value of %define parse.lac and friends, where LAC stands for | |
42 | # lookahead correction. | |
43 | b4_percent_define_default([[parse.lac]], [[none]]) | |
44 | b4_percent_define_default([[parse.lac.es-capacity-initial]], [[20]]) | |
45 | b4_percent_define_default([[parse.lac.memory-trace]], [[failures]]) | |
46 | b4_percent_define_check_values([[[[parse.lac]], [[full]], [[none]]]], | |
47 | [[[[parse.lac.memory-trace]], | |
48 | [[failures]], [[full]]]]) | |
49 | b4_define_flag_if([lac]) | |
50 | m4_define([b4_lac_flag], | |
51 | [m4_if(b4_percent_define_get([[parse.lac]]), | |
52 | [none], [[0]], [[1]])]) | |
53 | ||
54 | m4_include(b4_pkgdatadir/[c.m4]) | |
55 | ||
56 | ## ---------------- ## | |
57 | ## Default values. ## | |
58 | ## ---------------- ## | |
59 | ||
60 | # Stack parameters. | |
61 | m4_define_default([b4_stack_depth_max], [10000]) | |
62 | m4_define_default([b4_stack_depth_init], [200]) | |
63 | ||
64 | ||
65 | ## ------------------------ ## | |
66 | ## Pure/impure interfaces. ## | |
67 | ## ------------------------ ## | |
68 | ||
69 | b4_percent_define_default([[api.pure]], [[false]]) | |
70 | b4_define_flag_if([pure]) | |
71 | m4_define([b4_pure_flag], | |
72 | [b4_percent_define_flag_if([[api.pure]], [[1]], [[0]])]) | |
73 | ||
74 | # b4_yacc_pure_if(IF-TRUE, IF-FALSE) | |
75 | # ---------------------------------- | |
76 | # Expand IF-TRUE, if %pure-parser and %parse-param, IF-FALSE otherwise. | |
77 | m4_define([b4_yacc_pure_if], | |
78 | [b4_pure_if([m4_ifset([b4_parse_param], | |
79 | [$1], [$2])], | |
80 | [$2])]) | |
81 | ||
82 | ||
83 | # b4_yyerror_args | |
84 | # --------------- | |
85 | # Arguments passed to yyerror: user args plus yylloc. | |
86 | m4_define([b4_yyerror_args], | |
87 | [b4_yacc_pure_if([b4_locations_if([&yylloc, ])])dnl | |
88 | m4_ifset([b4_parse_param], [b4_c_args(b4_parse_param), ])]) | |
89 | ||
90 | ||
91 | # b4_lex_param | |
92 | # ------------ | |
93 | # Accumulate in b4_lex_param all the yylex arguments. | |
94 | # b4_lex_param arrives quoted twice, but we want to keep only one level. | |
95 | m4_define([b4_lex_param], | |
96 | m4_dquote(b4_pure_if([[[[YYSTYPE *]], [[&yylval]]][]dnl | |
97 | b4_locations_if([, [[YYLTYPE *], [&yylloc]]])m4_ifdef([b4_lex_param], [, ])])dnl | |
98 | m4_ifdef([b4_lex_param], b4_lex_param))) | |
99 | ||
100 | ||
101 | ## ------------ ## | |
102 | ## Data Types. ## | |
103 | ## ------------ ## | |
104 | ||
105 | # b4_int_type(MIN, MAX) | |
106 | # --------------------- | |
107 | # Return the smallest int type able to handle numbers ranging from | |
108 | # MIN to MAX (included). Overwrite the version from c.m4, which | |
109 | # uses only C89 types, so that the user can override the shorter | |
110 | # types, and so that pre-C89 compilers are handled correctly. | |
111 | m4_define([b4_int_type], | |
112 | [m4_if(b4_ints_in($@, [0], [255]), [1], [yytype_uint8], | |
113 | b4_ints_in($@, [-128], [127]), [1], [yytype_int8], | |
114 | ||
115 | b4_ints_in($@, [0], [65535]), [1], [yytype_uint16], | |
116 | b4_ints_in($@, [-32768], [32767]), [1], [yytype_int16], | |
117 | ||
118 | m4_eval([0 <= $1]), [1], [unsigned int], | |
119 | ||
120 | [int])]) | |
121 | ||
122 | ||
123 | ## ----------------- ## | |
124 | ## Semantic Values. ## | |
125 | ## ----------------- ## | |
126 | ||
127 | ||
128 | # b4_lhs_value([TYPE]) | |
129 | # -------------------- | |
130 | # Expansion of $<TYPE>$. | |
131 | m4_define([b4_lhs_value], | |
132 | [b4_symbol_value(yyval, [$1])]) | |
133 | ||
134 | ||
135 | # b4_rhs_value(RULE-LENGTH, NUM, [TYPE]) | |
136 | # -------------------------------------- | |
137 | # Expansion of $<TYPE>NUM, where the current rule has RULE-LENGTH | |
138 | # symbols on RHS. | |
139 | m4_define([b4_rhs_value], | |
140 | [b4_symbol_value([yyvsp@{b4_subtract([$2], [$1])@}], [$3])]) | |
141 | ||
142 | ||
143 | ||
144 | ## ----------- ## | |
145 | ## Locations. ## | |
146 | ## ----------- ## | |
147 | ||
148 | # b4_lhs_location() | |
149 | # ----------------- | |
150 | # Expansion of @$. | |
151 | m4_define([b4_lhs_location], | |
152 | [(yyloc)]) | |
153 | ||
154 | ||
155 | # b4_rhs_location(RULE-LENGTH, NUM) | |
156 | # --------------------------------- | |
157 | # Expansion of @NUM, where the current rule has RULE-LENGTH symbols | |
158 | # on RHS. | |
159 | m4_define([b4_rhs_location], | |
160 | [(yylsp@{b4_subtract([$2], [$1])@})]) | |
161 | ||
162 | ||
163 | ## -------------- ## | |
164 | ## Declarations. ## | |
165 | ## -------------- ## | |
166 | ||
167 | # b4_declare_scanner_communication_variables | |
168 | # ------------------------------------------ | |
169 | # Declare the variables that are global, or local to YYPARSE if | |
170 | # pure-parser. | |
171 | m4_define([b4_declare_scanner_communication_variables], [[ | |
172 | /* The lookahead symbol. */ | |
173 | int yychar; | |
174 | ||
175 | /* The semantic value of the lookahead symbol. */ | |
176 | YYSTYPE yylval;]b4_locations_if([[ | |
177 | ||
178 | /* Location data for the lookahead symbol. */ | |
179 | YYLTYPE yylloc;]])b4_pure_if([], [[ | |
180 | ||
181 | /* Number of syntax errors so far. */ | |
182 | int yynerrs;]])]) | |
183 | ||
184 | ||
185 | # b4_declare_parser_state_variables | |
186 | # --------------------------------- | |
187 | # Declare all the variables that are needed to maintain the parser state | |
188 | # between calls to yypush_parse. | |
189 | m4_define([b4_declare_parser_state_variables], [b4_pure_if([[ | |
190 | /* Number of syntax errors so far. */ | |
191 | int yynerrs; | |
192 | ]])[ | |
193 | int yystate; | |
194 | /* Number of tokens to shift before error messages enabled. */ | |
195 | int yyerrstatus; | |
196 | ||
197 | /* The stacks and their tools: | |
198 | `yyss': related to states. | |
199 | `yyvs': related to semantic values.]b4_locations_if([[ | |
200 | `yyls': related to locations.]])[ | |
201 | ||
202 | Refer to the stacks through separate pointers, to allow yyoverflow | |
203 | to reallocate them elsewhere. */ | |
204 | ||
205 | /* The state stack. */ | |
206 | yytype_int16 yyssa[YYINITDEPTH]; | |
207 | yytype_int16 *yyss; | |
208 | yytype_int16 *yyssp; | |
209 | ||
210 | /* The semantic value stack. */ | |
211 | YYSTYPE yyvsa[YYINITDEPTH]; | |
212 | YYSTYPE *yyvs; | |
213 | YYSTYPE *yyvsp;]b4_locations_if([[ | |
214 | ||
215 | /* The location stack. */ | |
216 | YYLTYPE yylsa[YYINITDEPTH]; | |
217 | YYLTYPE *yyls; | |
218 | YYLTYPE *yylsp; | |
219 | ||
220 | /* The locations where the error started and ended. */ | |
221 | YYLTYPE yyerror_range[3];]])[ | |
222 | ||
223 | YYSIZE_T yystacksize;]b4_lac_if([[ | |
224 | ||
225 | yytype_int16 yyesa@{]b4_percent_define_get([[parse.lac.es-capacity-initial]])[@}; | |
226 | yytype_int16 *yyes; | |
227 | YYSIZE_T yyes_capacity;]])]) | |
228 | ||
229 | ||
230 | # b4_declare_yyparse_push_ | |
231 | # ------------------------ | |
232 | # Declaration of yyparse (and dependencies) when using the push parser | |
233 | # (including in pull mode). | |
234 | m4_define([b4_declare_yyparse_push_], | |
235 | [[#ifndef YYPUSH_MORE_DEFINED | |
236 | # define YYPUSH_MORE_DEFINED | |
237 | enum { YYPUSH_MORE = 4 }; | |
238 | #endif | |
239 | ||
240 | typedef struct ]b4_prefix[pstate ]b4_prefix[pstate; | |
241 | ||
242 | ]b4_pull_if([b4_c_function_decl([b4_prefix[parse]], [[int]], b4_parse_param) | |
243 | ])b4_c_function_decl([b4_prefix[push_parse]], [[int]], | |
244 | [[b4_prefix[pstate *ps]], [[ps]]]b4_pure_if([, | |
245 | [[[int pushed_char]], [[pushed_char]]], | |
246 | [[b4_api_PREFIX[STYPE const *pushed_val]], [[pushed_val]]]b4_locations_if([, | |
247 | [[b4_api_PREFIX[LTYPE const *pushed_loc]], [[pushed_loc]]]])])m4_ifset([b4_parse_param], [, | |
248 | b4_parse_param])) | |
249 | b4_pull_if([b4_c_function_decl([b4_prefix[pull_parse]], [[int]], | |
250 | [[b4_prefix[pstate *ps]], [[ps]]]m4_ifset([b4_parse_param], [, | |
251 | b4_parse_param]))]) | |
252 | b4_c_function_decl([b4_prefix[pstate_new]], [b4_prefix[pstate *]], | |
253 | [[[void]], []]) | |
254 | b4_c_function_decl([b4_prefix[pstate_delete]], [[void]], | |
255 | [[b4_prefix[pstate *ps]], [[ps]]])dnl | |
256 | ]) | |
257 | ||
258 | # b4_declare_yyparse_ | |
259 | # ------------------- | |
260 | # When not the push parser. | |
261 | m4_define([b4_declare_yyparse_], | |
262 | [[#ifdef YYPARSE_PARAM | |
263 | ]b4_c_function_decl(b4_prefix[parse], [int], | |
264 | [[void *YYPARSE_PARAM], [YYPARSE_PARAM]])[ | |
265 | #else /* ! YYPARSE_PARAM */ | |
266 | ]b4_c_function_decl(b4_prefix[parse], [int], b4_parse_param)[ | |
267 | #endif /* ! YYPARSE_PARAM */]dnl | |
268 | ]) | |
269 | ||
270 | ||
271 | # b4_declare_yyparse | |
272 | # ------------------ | |
273 | m4_define([b4_declare_yyparse], | |
274 | [b4_push_if([b4_declare_yyparse_push_], | |
275 | [b4_declare_yyparse_])[]dnl | |
276 | ]) | |
277 | ||
278 | ||
279 | # b4_shared_declarations | |
280 | # ---------------------- | |
281 | # Declaration that might either go into the header (if --defines) | |
282 | # or open coded in the parser body. | |
283 | m4_define([b4_shared_declarations], | |
284 | [b4_cpp_guard_open([b4_spec_defines_file])[ | |
285 | ]b4_declare_yydebug[ | |
286 | ]b4_percent_code_get([[requires]])[ | |
287 | ]b4_token_enums_defines(b4_tokens)[ | |
288 | ]b4_declare_yylstype[ | |
289 | ]b4_declare_yyparse[ | |
290 | ]b4_percent_code_get([[provides]])[ | |
291 | ]b4_cpp_guard_close([b4_spec_defines_file])[]dnl | |
292 | ]) | |
293 | ||
294 | ## -------------- ## | |
295 | ## Output files. ## | |
296 | ## -------------- ## | |
297 | ||
298 | # We do want M4 expansion after # for CPP macros. | |
299 | m4_changecom() | |
300 | m4_divert_push(0)dnl | |
301 | @output(b4_parser_file_name@)@ | |
302 | b4_copyright([Bison implementation for Yacc-like parsers in C])[ | |
303 | ||
304 | /* C LALR(1) parser skeleton written by Richard Stallman, by | |
305 | simplifying the original so-called "semantic" parser. */ | |
306 | ||
307 | /* All symbols defined below should begin with yy or YY, to avoid | |
308 | infringing on user name space. This should be done even for local | |
309 | variables, as they might otherwise be expanded by user macros. | |
310 | There are some unavoidable exceptions within include files to | |
311 | define necessary library symbols; they are noted "INFRINGES ON | |
312 | USER NAME SPACE" below. */ | |
313 | ||
314 | ]b4_identification | |
315 | b4_percent_code_get([[top]])[]dnl | |
316 | m4_if(b4_api_prefix, [yy], [], | |
317 | [[/* Substitute the type names. */ | |
318 | #define YYSTYPE ]b4_api_PREFIX[STYPE]b4_locations_if([[ | |
319 | #define YYLTYPE ]b4_api_PREFIX[LTYPE]])])[ | |
320 | ]m4_if(b4_prefix, [yy], [], | |
321 | [[/* Substitute the variable and function names. */]b4_pull_if([[ | |
322 | #define yyparse ]b4_prefix[parse]])b4_push_if([[ | |
323 | #define yypush_parse ]b4_prefix[push_parse]b4_pull_if([[ | |
324 | #define yypull_parse ]b4_prefix[pull_parse]])[ | |
325 | #define yypstate_new ]b4_prefix[pstate_new | |
326 | #define yypstate_delete ]b4_prefix[pstate_delete | |
327 | #define yypstate ]b4_prefix[pstate]])[ | |
328 | #define yylex ]b4_prefix[lex | |
329 | #define yyerror ]b4_prefix[error | |
330 | #define yylval ]b4_prefix[lval | |
331 | #define yychar ]b4_prefix[char | |
332 | #define yydebug ]b4_prefix[debug | |
333 | #define yynerrs ]b4_prefix[nerrs]b4_locations_if([[ | |
334 | #define yylloc ]b4_prefix[lloc]])])[ | |
335 | ||
336 | /* Copy the first part of user declarations. */ | |
337 | ]b4_user_pre_prologue[ | |
338 | ||
339 | ]b4_null_define[ | |
340 | ||
341 | /* Enabling verbose error messages. */ | |
342 | #ifdef YYERROR_VERBOSE | |
343 | # undef YYERROR_VERBOSE | |
344 | # define YYERROR_VERBOSE 1 | |
345 | #else | |
346 | # define YYERROR_VERBOSE ]b4_error_verbose_if([1], [0])[ | |
347 | #endif | |
348 | ||
349 | /* In a future release of Bison, this section will be replaced | |
350 | by #include "@basename(]b4_spec_defines_file[@)". */ | |
351 | ]b4_shared_declarations[ | |
352 | ||
353 | /* Copy the second part of user declarations. */ | |
354 | ]b4_user_post_prologue | |
355 | b4_percent_code_get[]dnl | |
356 | ||
357 | [#ifdef short | |
358 | # undef short | |
359 | #endif | |
360 | ||
361 | #ifdef YYTYPE_UINT8 | |
362 | typedef YYTYPE_UINT8 yytype_uint8; | |
363 | #else | |
364 | typedef unsigned char yytype_uint8; | |
365 | #endif | |
366 | ||
367 | #ifdef YYTYPE_INT8 | |
368 | typedef YYTYPE_INT8 yytype_int8; | |
369 | #elif ]b4_c_modern[ | |
370 | typedef signed char yytype_int8; | |
371 | #else | |
372 | typedef short int yytype_int8; | |
373 | #endif | |
374 | ||
375 | #ifdef YYTYPE_UINT16 | |
376 | typedef YYTYPE_UINT16 yytype_uint16; | |
377 | #else | |
378 | typedef unsigned short int yytype_uint16; | |
379 | #endif | |
380 | ||
381 | #ifdef YYTYPE_INT16 | |
382 | typedef YYTYPE_INT16 yytype_int16; | |
383 | #else | |
384 | typedef short int yytype_int16; | |
385 | #endif | |
386 | ||
387 | #ifndef YYSIZE_T | |
388 | # ifdef __SIZE_TYPE__ | |
389 | # define YYSIZE_T __SIZE_TYPE__ | |
390 | # elif defined size_t | |
391 | # define YYSIZE_T size_t | |
392 | # elif ! defined YYSIZE_T && ]b4_c_modern[ | |
393 | # include <stddef.h> /* INFRINGES ON USER NAME SPACE */ | |
394 | # define YYSIZE_T size_t | |
395 | # else | |
396 | # define YYSIZE_T unsigned int | |
397 | # endif | |
398 | #endif | |
399 | ||
400 | #define YYSIZE_MAXIMUM ((YYSIZE_T) -1) | |
401 | ||
402 | #ifndef YY_ | |
403 | # if defined YYENABLE_NLS && YYENABLE_NLS | |
404 | # if ENABLE_NLS | |
405 | # include <libintl.h> /* INFRINGES ON USER NAME SPACE */ | |
406 | # define YY_(msgid) dgettext ("bison-runtime", msgid) | |
407 | # endif | |
408 | # endif | |
409 | # ifndef YY_ | |
410 | # define YY_(msgid) msgid | |
411 | # endif | |
412 | #endif | |
413 | ||
414 | /* Suppress unused-variable warnings by "using" E. */ | |
415 | #if ! defined lint || defined __GNUC__ | |
416 | # define YYUSE(e) ((void) (e)) | |
417 | #else | |
418 | # define YYUSE(e) /* empty */ | |
419 | #endif | |
420 | ||
421 | /* Identity function, used to suppress warnings about constant conditions. */ | |
422 | #ifndef lint | |
423 | # define YYID(n) (n) | |
424 | #else | |
425 | ]b4_c_function_def([YYID], [static int], [[int yyi], [yyi]])[ | |
426 | { | |
427 | return yyi; | |
428 | } | |
429 | #endif | |
430 | ||
431 | #if ]b4_lac_if([[1]], [[! defined yyoverflow || YYERROR_VERBOSE]])[ | |
432 | ||
433 | /* The parser invokes alloca or malloc; define the necessary symbols. */]dnl | |
434 | b4_push_if([], [b4_lac_if([], [[ | |
435 | ||
436 | # ifdef YYSTACK_USE_ALLOCA | |
437 | # if YYSTACK_USE_ALLOCA | |
438 | # ifdef __GNUC__ | |
439 | # define YYSTACK_ALLOC __builtin_alloca | |
440 | # elif defined __BUILTIN_VA_ARG_INCR | |
441 | # include <alloca.h> /* INFRINGES ON USER NAME SPACE */ | |
442 | # elif defined _AIX | |
443 | # define YYSTACK_ALLOC __alloca | |
444 | # elif defined _MSC_VER | |
445 | # include <malloc.h> /* INFRINGES ON USER NAME SPACE */ | |
446 | # define alloca _alloca | |
447 | # else | |
448 | # define YYSTACK_ALLOC alloca | |
449 | # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS && ]b4_c_modern[ | |
450 | # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ | |
451 | /* Use EXIT_SUCCESS as a witness for stdlib.h. */ | |
452 | # ifndef EXIT_SUCCESS | |
453 | # define EXIT_SUCCESS 0 | |
454 | # endif | |
455 | # endif | |
456 | # endif | |
457 | # endif | |
458 | # endif]])])[ | |
459 | ||
460 | # ifdef YYSTACK_ALLOC | |
461 | /* Pacify GCC's `empty if-body' warning. */ | |
462 | # define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) | |
463 | # ifndef YYSTACK_ALLOC_MAXIMUM | |
464 | /* The OS might guarantee only one guard page at the bottom of the stack, | |
465 | and a page size can be as small as 4096 bytes. So we cannot safely | |
466 | invoke alloca (N) if N exceeds 4096. Use a slightly smaller number | |
467 | to allow for a few compiler-allocated temporary stack slots. */ | |
468 | # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ | |
469 | # endif | |
470 | # else | |
471 | # define YYSTACK_ALLOC YYMALLOC | |
472 | # define YYSTACK_FREE YYFREE | |
473 | # ifndef YYSTACK_ALLOC_MAXIMUM | |
474 | # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM | |
475 | # endif | |
476 | # if (defined __cplusplus && ! defined EXIT_SUCCESS \ | |
477 | && ! ((defined YYMALLOC || defined malloc) \ | |
478 | && (defined YYFREE || defined free))) | |
479 | # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ | |
480 | # ifndef EXIT_SUCCESS | |
481 | # define EXIT_SUCCESS 0 | |
482 | # endif | |
483 | # endif | |
484 | # ifndef YYMALLOC | |
485 | # define YYMALLOC malloc | |
486 | # if ! defined malloc && ! defined EXIT_SUCCESS && ]b4_c_modern[ | |
487 | void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ | |
488 | # endif | |
489 | # endif | |
490 | # ifndef YYFREE | |
491 | # define YYFREE free | |
492 | # if ! defined free && ! defined EXIT_SUCCESS && ]b4_c_modern[ | |
493 | void free (void *); /* INFRINGES ON USER NAME SPACE */ | |
494 | # endif | |
495 | # endif | |
496 | # endif]b4_lac_if([[ | |
497 | # define YYCOPY_NEEDED 1]])[ | |
498 | #endif]b4_lac_if([], [[ /* ! defined yyoverflow || YYERROR_VERBOSE */]])[ | |
499 | ||
500 | ||
501 | #if (! defined yyoverflow \ | |
502 | && (! defined __cplusplus \ | |
503 | || (]b4_locations_if([[defined ]b4_api_PREFIX[LTYPE_IS_TRIVIAL && ]b4_api_PREFIX[LTYPE_IS_TRIVIAL \ | |
504 | && ]])[defined ]b4_api_PREFIX[STYPE_IS_TRIVIAL && ]b4_api_PREFIX[STYPE_IS_TRIVIAL))) | |
505 | ||
506 | /* A type that is properly aligned for any stack member. */ | |
507 | union yyalloc | |
508 | { | |
509 | yytype_int16 yyss_alloc; | |
510 | YYSTYPE yyvs_alloc;]b4_locations_if([ | |
511 | YYLTYPE yyls_alloc;])[ | |
512 | }; | |
513 | ||
514 | /* The size of the maximum gap between one aligned stack and the next. */ | |
515 | # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) | |
516 | ||
517 | /* The size of an array large to enough to hold all stacks, each with | |
518 | N elements. */ | |
519 | ]b4_locations_if( | |
520 | [# define YYSTACK_BYTES(N) \ | |
521 | ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \ | |
522 | + 2 * YYSTACK_GAP_MAXIMUM)], | |
523 | [# define YYSTACK_BYTES(N) \ | |
524 | ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ | |
525 | + YYSTACK_GAP_MAXIMUM)])[ | |
526 | ||
527 | # define YYCOPY_NEEDED 1 | |
528 | ||
529 | /* Relocate STACK from its old location to the new one. The | |
530 | local variables YYSIZE and YYSTACKSIZE give the old and new number of | |
531 | elements in the stack, and YYPTR gives the new location of the | |
532 | stack. Advance YYPTR to a properly aligned location for the next | |
533 | stack. */ | |
534 | # define YYSTACK_RELOCATE(Stack_alloc, Stack) \ | |
535 | do \ | |
536 | { \ | |
537 | YYSIZE_T yynewbytes; \ | |
538 | YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ | |
539 | Stack = &yyptr->Stack_alloc; \ | |
540 | yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ | |
541 | yyptr += yynewbytes / sizeof (*yyptr); \ | |
542 | } \ | |
543 | while (YYID (0)) | |
544 | ||
545 | #endif | |
546 | ||
547 | #if defined YYCOPY_NEEDED && YYCOPY_NEEDED | |
548 | /* Copy COUNT objects from SRC to DST. The source and destination do | |
549 | not overlap. */ | |
550 | # ifndef YYCOPY | |
551 | # if defined __GNUC__ && 1 < __GNUC__ | |
552 | # define YYCOPY(Dst, Src, Count) \ | |
553 | __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src))) | |
554 | # else | |
555 | # define YYCOPY(Dst, Src, Count) \ | |
556 | do \ | |
557 | { \ | |
558 | YYSIZE_T yyi; \ | |
559 | for (yyi = 0; yyi < (Count); yyi++) \ | |
560 | (Dst)[yyi] = (Src)[yyi]; \ | |
561 | } \ | |
562 | while (YYID (0)) | |
563 | # endif | |
564 | # endif | |
565 | #endif /* !YYCOPY_NEEDED */ | |
566 | ||
567 | /* YYFINAL -- State number of the termination state. */ | |
568 | #define YYFINAL ]b4_final_state_number[ | |
569 | /* YYLAST -- Last index in YYTABLE. */ | |
570 | #define YYLAST ]b4_last[ | |
571 | ||
572 | /* YYNTOKENS -- Number of terminals. */ | |
573 | #define YYNTOKENS ]b4_tokens_number[ | |
574 | /* YYNNTS -- Number of nonterminals. */ | |
575 | #define YYNNTS ]b4_nterms_number[ | |
576 | /* YYNRULES -- Number of rules. */ | |
577 | #define YYNRULES ]b4_rules_number[ | |
578 | /* YYNSTATES -- Number of states. */ | |
579 | #define YYNSTATES ]b4_states_number[ | |
580 | ||
581 | /* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned | |
582 | by yylex, with out-of-bounds checking. */ | |
583 | #define YYUNDEFTOK ]b4_undef_token_number[ | |
584 | #define YYMAXUTOK ]b4_user_token_number_max[ | |
585 | ||
586 | #define YYTRANSLATE(YYX) \ | |
587 | ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) | |
588 | ||
589 | /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM | |
590 | as returned by yylex, without out-of-bounds checking. */ | |
591 | static const ]b4_int_type_for([b4_translate])[ yytranslate[] = | |
592 | { | |
593 | ]b4_translate[ | |
594 | }; | |
595 | ||
596 | #if ]b4_api_PREFIX[DEBUG | |
597 | ]b4_integral_parser_table_define([rline], [b4_rline], | |
598 | [YYRLINE[YYN] -- Source line where rule number YYN was defined.])[ | |
599 | #endif | |
600 | ||
601 | #if ]b4_api_PREFIX[DEBUG || YYERROR_VERBOSE || ]b4_token_table_flag[ | |
602 | /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. | |
603 | First, the terminals, then, starting at YYNTOKENS, nonterminals. */ | |
604 | static const char *const yytname[] = | |
605 | { | |
606 | ]b4_tname[ | |
607 | }; | |
608 | #endif | |
609 | ||
610 | # ifdef YYPRINT | |
611 | /* YYTOKNUM[NUM] -- (External) token number corresponding to the | |
612 | (internal) symbol number NUM (which must be that of a token). */ | |
613 | static const ]b4_int_type_for([b4_toknum])[ yytoknum[] = | |
614 | { | |
615 | ]b4_toknum[ | |
616 | }; | |
617 | # endif | |
618 | ||
619 | #define YYPACT_NINF ]b4_pact_ninf[ | |
620 | ||
621 | #define yypact_value_is_default(yystate) \ | |
622 | ]b4_table_value_equals([[pact]], [[yystate]], [b4_pact_ninf])[ | |
623 | ||
624 | #define YYTABLE_NINF ]b4_table_ninf[ | |
625 | ||
626 | #define yytable_value_is_error(yytable_value) \ | |
627 | ]b4_table_value_equals([[table]], [[yytable_value]], [b4_table_ninf])[ | |
628 | ||
629 | ]b4_parser_tables_define[ | |
630 | ||
631 | #define yyerrok (yyerrstatus = 0) | |
632 | #define yyclearin (yychar = YYEMPTY) | |
633 | #define YYEMPTY (-2) | |
634 | #define YYEOF 0 | |
635 | ||
636 | #define YYACCEPT goto yyacceptlab | |
637 | #define YYABORT goto yyabortlab | |
638 | #define YYERROR goto yyerrorlab | |
639 | ||
640 | ||
641 | /* Like YYERROR except do call yyerror. This remains here temporarily | |
642 | to ease the transition to the new meaning of YYERROR, for GCC. | |
643 | Once GCC version 2 has supplanted version 1, this can go. However, | |
644 | YYFAIL appears to be in use. Nevertheless, it is formally deprecated | |
645 | in Bison 2.4.2's NEWS entry, where a plan to phase it out is | |
646 | discussed. */ | |
647 | ||
648 | #define YYFAIL goto yyerrlab | |
649 | #if defined YYFAIL | |
650 | /* This is here to suppress warnings from the GCC cpp's | |
651 | -Wunused-macros. Normally we don't worry about that warning, but | |
652 | some users do, and we want to make it easy for users to remove | |
653 | YYFAIL uses, which will produce warnings from Bison 2.5. */ | |
654 | #endif | |
655 | ||
656 | #define YYRECOVERING() (!!yyerrstatus) | |
657 | ||
658 | #define YYBACKUP(Token, Value) \ | |
659 | do \ | |
660 | if (yychar == YYEMPTY) \ | |
661 | { \ | |
662 | yychar = (Token); \ | |
663 | yylval = (Value); \ | |
664 | YYPOPSTACK (yylen); \ | |
665 | yystate = *yyssp; \]b4_lac_if([[ | |
666 | YY_LAC_DISCARD ("YYBACKUP"); \]])[ | |
667 | goto yybackup; \ | |
668 | } \ | |
669 | else \ | |
670 | { \ | |
671 | yyerror (]b4_yyerror_args[YY_("syntax error: cannot back up")); \ | |
672 | YYERROR; \ | |
673 | } \ | |
674 | while (YYID (0)) | |
675 | ||
676 | ||
677 | #define YYTERROR 1 | |
678 | #define YYERRCODE 256 | |
679 | ||
680 | ]b4_locations_if([[ | |
681 | ]b4_yylloc_default_define[ | |
682 | #define YYRHSLOC(Rhs, K) ((Rhs)[K]) | |
683 | ||
684 | /* YY_LOCATION_PRINT -- Print the location on the stream. | |
685 | This macro was not mandated originally: define only if we know | |
686 | we won't break user code: when these are the locations we know. */ | |
687 | ||
688 | #ifndef YY_LOCATION_PRINT | |
689 | # if defined ]b4_api_PREFIX[LTYPE_IS_TRIVIAL && ]b4_api_PREFIX[LTYPE_IS_TRIVIAL | |
690 | # define YY_LOCATION_PRINT(File, Loc) \ | |
691 | fprintf (File, "%d.%d-%d.%d", \ | |
692 | (Loc).first_line, (Loc).first_column, \ | |
693 | (Loc).last_line, (Loc).last_column) | |
694 | # else | |
695 | # define YY_LOCATION_PRINT(File, Loc) ((void) 0) | |
696 | # endif | |
697 | #endif]], [[ | |
698 | ||
699 | ||
700 | /* This macro is provided for backward compatibility. */ | |
701 | ||
702 | #ifndef YY_LOCATION_PRINT | |
703 | # define YY_LOCATION_PRINT(File, Loc) ((void) 0) | |
704 | #endif]])[ | |
705 | ||
706 | ||
707 | /* YYLEX -- calling `yylex' with the right arguments. */ | |
708 | ||
709 | #ifdef YYLEX_PARAM | |
710 | # define YYLEX yylex (]b4_pure_if([&yylval[]b4_locations_if([, &yylloc]), ])[YYLEX_PARAM) | |
711 | #else | |
712 | # define YYLEX ]b4_c_function_call([yylex], [int], b4_lex_param)[ | |
713 | #endif | |
714 | ||
715 | /* Enable debugging if requested. */ | |
716 | #if ]b4_api_PREFIX[DEBUG | |
717 | ||
718 | # ifndef YYFPRINTF | |
719 | # include <stdio.h> /* INFRINGES ON USER NAME SPACE */ | |
720 | # define YYFPRINTF fprintf | |
721 | # endif | |
722 | ||
723 | # define YYDPRINTF(Args) \ | |
724 | do { \ | |
725 | if (yydebug) \ | |
726 | YYFPRINTF Args; \ | |
727 | } while (YYID (0)) | |
728 | ||
729 | # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ | |
730 | do { \ | |
731 | if (yydebug) \ | |
732 | { \ | |
733 | YYFPRINTF (stderr, "%s ", Title); \ | |
734 | yy_symbol_print (stderr, \ | |
735 | Type, Value]b4_locations_if([, Location])[]b4_user_args[); \ | |
736 | YYFPRINTF (stderr, "\n"); \ | |
737 | } \ | |
738 | } while (YYID (0)) | |
739 | ||
740 | ]b4_yy_symbol_print_generate([b4_c_function_def])[ | |
741 | ||
742 | /*------------------------------------------------------------------. | |
743 | | yy_stack_print -- Print the state stack from its BOTTOM up to its | | |
744 | | TOP (included). | | |
745 | `------------------------------------------------------------------*/ | |
746 | ||
747 | ]b4_c_function_def([yy_stack_print], [static void], | |
748 | [[yytype_int16 *yybottom], [yybottom]], | |
749 | [[yytype_int16 *yytop], [yytop]])[ | |
750 | { | |
751 | YYFPRINTF (stderr, "Stack now"); | |
752 | for (; yybottom <= yytop; yybottom++) | |
753 | { | |
754 | int yybot = *yybottom; | |
755 | YYFPRINTF (stderr, " %d", yybot); | |
756 | } | |
757 | YYFPRINTF (stderr, "\n"); | |
758 | } | |
759 | ||
760 | # define YY_STACK_PRINT(Bottom, Top) \ | |
761 | do { \ | |
762 | if (yydebug) \ | |
763 | yy_stack_print ((Bottom), (Top)); \ | |
764 | } while (YYID (0)) | |
765 | ||
766 | ||
767 | /*------------------------------------------------. | |
768 | | Report that the YYRULE is going to be reduced. | | |
769 | `------------------------------------------------*/ | |
770 | ||
771 | ]b4_c_function_def([yy_reduce_print], [static void], | |
772 | [[yytype_int16 *yyssp], [yyssp]], | |
773 | [[YYSTYPE *yyvsp], [yyvsp]], | |
774 | b4_locations_if([[[YYLTYPE *yylsp], [yylsp]], | |
775 | ])[[int yyrule], [yyrule]]m4_ifset([b4_parse_param], [, | |
776 | b4_parse_param]))[ | |
777 | { | |
778 | unsigned long int yylno = yyrline[yyrule]; | |
779 | int yynrhs = yyr2[yyrule]; | |
780 | int yyi; | |
781 | YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", | |
782 | yyrule - 1, yylno); | |
783 | /* The symbols being reduced. */ | |
784 | for (yyi = 0; yyi < yynrhs; yyi++) | |
785 | { | |
786 | YYFPRINTF (stderr, " $%d = ", yyi + 1); | |
787 | yy_symbol_print (stderr, | |
788 | yystos[yyssp[yyi + 1 - yynrhs]], | |
789 | &]b4_rhs_value(yynrhs, yyi + 1)[ | |
790 | ]b4_locations_if([, &]b4_rhs_location(yynrhs, yyi + 1))[]dnl | |
791 | b4_user_args[); | |
792 | YYFPRINTF (stderr, "\n"); | |
793 | } | |
794 | } | |
795 | ||
796 | # define YY_REDUCE_PRINT(Rule) \ | |
797 | do { \ | |
798 | if (yydebug) \ | |
799 | yy_reduce_print (yyssp, yyvsp, ]b4_locations_if([yylsp, ])[Rule]b4_user_args[); \ | |
800 | } while (YYID (0)) | |
801 | ||
802 | /* Nonzero means print parse trace. It is left uninitialized so that | |
803 | multiple parsers can coexist. */ | |
804 | int yydebug; | |
805 | #else /* !]b4_api_PREFIX[DEBUG */ | |
806 | # define YYDPRINTF(Args) | |
807 | # define YY_SYMBOL_PRINT(Title, Type, Value, Location) | |
808 | # define YY_STACK_PRINT(Bottom, Top) | |
809 | # define YY_REDUCE_PRINT(Rule) | |
810 | #endif /* !]b4_api_PREFIX[DEBUG */ | |
811 | ||
812 | ||
813 | /* YYINITDEPTH -- initial size of the parser's stacks. */ | |
814 | #ifndef YYINITDEPTH | |
815 | # define YYINITDEPTH ]b4_stack_depth_init[ | |
816 | #endif | |
817 | ||
818 | /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only | |
819 | if the built-in stack extension method is used). | |
820 | ||
821 | Do not make this value too large; the results are undefined if | |
822 | YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) | |
823 | evaluated with infinite-precision integer arithmetic. */ | |
824 | ||
825 | #ifndef YYMAXDEPTH | |
826 | # define YYMAXDEPTH ]b4_stack_depth_max[ | |
827 | #endif]b4_lac_if([[ | |
828 | ||
829 | /* Given a state stack such that *YYBOTTOM is its bottom, such that | |
830 | *YYTOP is either its top or is YYTOP_EMPTY to indicate an empty | |
831 | stack, and such that *YYCAPACITY is the maximum number of elements it | |
832 | can hold without a reallocation, make sure there is enough room to | |
833 | store YYADD more elements. If not, allocate a new stack using | |
834 | YYSTACK_ALLOC, copy the existing elements, and adjust *YYBOTTOM, | |
835 | *YYTOP, and *YYCAPACITY to reflect the new capacity and memory | |
836 | location. If *YYBOTTOM != YYBOTTOM_NO_FREE, then free the old stack | |
837 | using YYSTACK_FREE. Return 0 if successful or if no reallocation is | |
838 | required. Return 1 if memory is exhausted. */ | |
839 | static int | |
840 | yy_lac_stack_realloc (YYSIZE_T *yycapacity, YYSIZE_T yyadd, | |
841 | #if ]b4_api_PREFIX[DEBUG | |
842 | char const *yydebug_prefix, | |
843 | char const *yydebug_suffix, | |
844 | #endif | |
845 | yytype_int16 **yybottom, | |
846 | yytype_int16 *yybottom_no_free, | |
847 | yytype_int16 **yytop, yytype_int16 *yytop_empty) | |
848 | { | |
849 | YYSIZE_T yysize_old = | |
850 | *yytop == yytop_empty ? 0 : *yytop - *yybottom + 1; | |
851 | YYSIZE_T yysize_new = yysize_old + yyadd; | |
852 | if (*yycapacity < yysize_new) | |
853 | { | |
854 | YYSIZE_T yyalloc = 2 * yysize_new; | |
855 | yytype_int16 *yybottom_new; | |
856 | /* Use YYMAXDEPTH for maximum stack size given that the stack | |
857 | should never need to grow larger than the main state stack | |
858 | needs to grow without LAC. */ | |
859 | if (YYMAXDEPTH < yysize_new) | |
860 | { | |
861 | YYDPRINTF ((stderr, "%smax size exceeded%s", yydebug_prefix, | |
862 | yydebug_suffix)); | |
863 | return 1; | |
864 | } | |
865 | if (YYMAXDEPTH < yyalloc) | |
866 | yyalloc = YYMAXDEPTH; | |
867 | yybottom_new = | |
868 | (yytype_int16*) YYSTACK_ALLOC (yyalloc * sizeof *yybottom_new); | |
869 | if (!yybottom_new) | |
870 | { | |
871 | YYDPRINTF ((stderr, "%srealloc failed%s", yydebug_prefix, | |
872 | yydebug_suffix)); | |
873 | return 1; | |
874 | } | |
875 | if (*yytop != yytop_empty) | |
876 | { | |
877 | YYCOPY (yybottom_new, *yybottom, yysize_old); | |
878 | *yytop = yybottom_new + (yysize_old - 1); | |
879 | } | |
880 | if (*yybottom != yybottom_no_free) | |
881 | YYSTACK_FREE (*yybottom); | |
882 | *yybottom = yybottom_new; | |
883 | *yycapacity = yyalloc;]m4_if(b4_percent_define_get([[parse.lac.memory-trace]]), | |
884 | [full], [[ | |
885 | YYDPRINTF ((stderr, "%srealloc to %lu%s", yydebug_prefix, | |
886 | (unsigned long int) yyalloc, yydebug_suffix));]])[ | |
887 | } | |
888 | return 0; | |
889 | } | |
890 | ||
891 | /* Establish the initial context for the current lookahead if no initial | |
892 | context is currently established. | |
893 | ||
894 | We define a context as a snapshot of the parser stacks. We define | |
895 | the initial context for a lookahead as the context in which the | |
896 | parser initially examines that lookahead in order to select a | |
897 | syntactic action. Thus, if the lookahead eventually proves | |
898 | syntactically unacceptable (possibly in a later context reached via a | |
899 | series of reductions), the initial context can be used to determine | |
900 | the exact set of tokens that would be syntactically acceptable in the | |
901 | lookahead's place. Moreover, it is the context after which any | |
902 | further semantic actions would be erroneous because they would be | |
903 | determined by a syntactically unacceptable token. | |
904 | ||
905 | YY_LAC_ESTABLISH should be invoked when a reduction is about to be | |
906 | performed in an inconsistent state (which, for the purposes of LAC, | |
907 | includes consistent states that don't know they're consistent because | |
908 | their default reductions have been disabled). Iff there is a | |
909 | lookahead token, it should also be invoked before reporting a syntax | |
910 | error. This latter case is for the sake of the debugging output. | |
911 | ||
912 | For parse.lac=full, the implementation of YY_LAC_ESTABLISH is as | |
913 | follows. If no initial context is currently established for the | |
914 | current lookahead, then check if that lookahead can eventually be | |
915 | shifted if syntactic actions continue from the current context. | |
916 | Report a syntax error if it cannot. */ | |
917 | #define YY_LAC_ESTABLISH \ | |
918 | do { \ | |
919 | if (!yy_lac_established) \ | |
920 | { \ | |
921 | YYDPRINTF ((stderr, \ | |
922 | "LAC: initial context established for %s\n", \ | |
923 | yytname[yytoken])); \ | |
924 | yy_lac_established = 1; \ | |
925 | { \ | |
926 | int yy_lac_status = \ | |
927 | yy_lac (yyesa, &yyes, &yyes_capacity, yyssp, yytoken); \ | |
928 | if (yy_lac_status == 2) \ | |
929 | goto yyexhaustedlab; \ | |
930 | if (yy_lac_status == 1) \ | |
931 | goto yyerrlab; \ | |
932 | } \ | |
933 | } \ | |
934 | } while (YYID (0)) | |
935 | ||
936 | /* Discard any previous initial lookahead context because of Event, | |
937 | which may be a lookahead change or an invalidation of the currently | |
938 | established initial context for the current lookahead. | |
939 | ||
940 | The most common example of a lookahead change is a shift. An example | |
941 | of both cases is syntax error recovery. That is, a syntax error | |
942 | occurs when the lookahead is syntactically erroneous for the | |
943 | currently established initial context, so error recovery manipulates | |
944 | the parser stacks to try to find a new initial context in which the | |
945 | current lookahead is syntactically acceptable. If it fails to find | |
946 | such a context, it discards the lookahead. */ | |
947 | #if ]b4_api_PREFIX[DEBUG | |
948 | # define YY_LAC_DISCARD(Event) \ | |
949 | do { \ | |
950 | if (yy_lac_established) \ | |
951 | { \ | |
952 | if (yydebug) \ | |
953 | YYFPRINTF (stderr, "LAC: initial context discarded due to " \ | |
954 | Event "\n"); \ | |
955 | yy_lac_established = 0; \ | |
956 | } \ | |
957 | } while (YYID (0)) | |
958 | #else | |
959 | # define YY_LAC_DISCARD(Event) yy_lac_established = 0 | |
960 | #endif | |
961 | ||
962 | /* Given the stack whose top is *YYSSP, return 0 iff YYTOKEN can | |
963 | eventually (after perhaps some reductions) be shifted, return 1 if | |
964 | not, or return 2 if memory is exhausted. As preconditions and | |
965 | postconditions: *YYES_CAPACITY is the allocated size of the array to | |
966 | which *YYES points, and either *YYES = YYESA or *YYES points to an | |
967 | array allocated with YYSTACK_ALLOC. yy_lac may overwrite the | |
968 | contents of either array, alter *YYES and *YYES_CAPACITY, and free | |
969 | any old *YYES other than YYESA. */ | |
970 | static int | |
971 | yy_lac (yytype_int16 *yyesa, yytype_int16 **yyes, | |
972 | YYSIZE_T *yyes_capacity, yytype_int16 *yyssp, int yytoken) | |
973 | { | |
974 | yytype_int16 *yyes_prev = yyssp; | |
975 | yytype_int16 *yyesp = yyes_prev; | |
976 | YYDPRINTF ((stderr, "LAC: checking lookahead %s:", yytname[yytoken])); | |
977 | if (yytoken == YYUNDEFTOK) | |
978 | { | |
979 | YYDPRINTF ((stderr, " Always Err\n")); | |
980 | return 1; | |
981 | } | |
982 | while (1) | |
983 | { | |
984 | int yyrule = yypact[*yyesp]; | |
985 | if (yypact_value_is_default (yyrule) | |
986 | || (yyrule += yytoken) < 0 || YYLAST < yyrule | |
987 | || yycheck[yyrule] != yytoken) | |
988 | { | |
989 | yyrule = yydefact[*yyesp]; | |
990 | if (yyrule == 0) | |
991 | { | |
992 | YYDPRINTF ((stderr, " Err\n")); | |
993 | return 1; | |
994 | } | |
995 | } | |
996 | else | |
997 | { | |
998 | yyrule = yytable[yyrule]; | |
999 | if (yytable_value_is_error (yyrule)) | |
1000 | { | |
1001 | YYDPRINTF ((stderr, " Err\n")); | |
1002 | return 1; | |
1003 | } | |
1004 | if (0 < yyrule) | |
1005 | { | |
1006 | YYDPRINTF ((stderr, " S%d\n", yyrule)); | |
1007 | return 0; | |
1008 | } | |
1009 | yyrule = -yyrule; | |
1010 | } | |
1011 | { | |
1012 | YYSIZE_T yylen = yyr2[yyrule]; | |
1013 | YYDPRINTF ((stderr, " R%d", yyrule - 1)); | |
1014 | if (yyesp != yyes_prev) | |
1015 | { | |
1016 | YYSIZE_T yysize = yyesp - *yyes + 1; | |
1017 | if (yylen < yysize) | |
1018 | { | |
1019 | yyesp -= yylen; | |
1020 | yylen = 0; | |
1021 | } | |
1022 | else | |
1023 | { | |
1024 | yylen -= yysize; | |
1025 | yyesp = yyes_prev; | |
1026 | } | |
1027 | } | |
1028 | if (yylen) | |
1029 | yyesp = yyes_prev -= yylen; | |
1030 | } | |
1031 | { | |
1032 | int yystate; | |
1033 | { | |
1034 | int yylhs = yyr1[yyrule] - YYNTOKENS; | |
1035 | yystate = yypgoto[yylhs] + *yyesp; | |
1036 | if (yystate < 0 || YYLAST < yystate | |
1037 | || yycheck[yystate] != *yyesp) | |
1038 | yystate = yydefgoto[yylhs]; | |
1039 | else | |
1040 | yystate = yytable[yystate]; | |
1041 | } | |
1042 | if (yyesp == yyes_prev) | |
1043 | { | |
1044 | yyesp = *yyes; | |
1045 | *yyesp = yystate; | |
1046 | } | |
1047 | else | |
1048 | { | |
1049 | if (yy_lac_stack_realloc (yyes_capacity, 1, | |
1050 | #if ]b4_api_PREFIX[DEBUG | |
1051 | " (", ")", | |
1052 | #endif | |
1053 | yyes, yyesa, &yyesp, yyes_prev)) | |
1054 | { | |
1055 | YYDPRINTF ((stderr, "\n")); | |
1056 | return 2; | |
1057 | } | |
1058 | *++yyesp = yystate; | |
1059 | } | |
1060 | YYDPRINTF ((stderr, " G%d", yystate)); | |
1061 | } | |
1062 | } | |
1063 | }]])[ | |
1064 | ||
1065 | ||
1066 | #if YYERROR_VERBOSE | |
1067 | ||
1068 | # ifndef yystrlen | |
1069 | # if defined __GLIBC__ && defined _STRING_H | |
1070 | # define yystrlen strlen | |
1071 | # else | |
1072 | /* Return the length of YYSTR. */ | |
1073 | ]b4_c_function_def([yystrlen], [static YYSIZE_T], | |
1074 | [[const char *yystr], [yystr]])[ | |
1075 | { | |
1076 | YYSIZE_T yylen; | |
1077 | for (yylen = 0; yystr[yylen]; yylen++) | |
1078 | continue; | |
1079 | return yylen; | |
1080 | } | |
1081 | # endif | |
1082 | # endif | |
1083 | ||
1084 | # ifndef yystpcpy | |
1085 | # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE | |
1086 | # define yystpcpy stpcpy | |
1087 | # else | |
1088 | /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in | |
1089 | YYDEST. */ | |
1090 | ]b4_c_function_def([yystpcpy], [static char *], | |
1091 | [[char *yydest], [yydest]], [[const char *yysrc], [yysrc]])[ | |
1092 | { | |
1093 | char *yyd = yydest; | |
1094 | const char *yys = yysrc; | |
1095 | ||
1096 | while ((*yyd++ = *yys++) != '\0') | |
1097 | continue; | |
1098 | ||
1099 | return yyd - 1; | |
1100 | } | |
1101 | # endif | |
1102 | # endif | |
1103 | ||
1104 | # ifndef yytnamerr | |
1105 | /* Copy to YYRES the contents of YYSTR after stripping away unnecessary | |
1106 | quotes and backslashes, so that it's suitable for yyerror. The | |
1107 | heuristic is that double-quoting is unnecessary unless the string | |
1108 | contains an apostrophe, a comma, or backslash (other than | |
1109 | backslash-backslash). YYSTR is taken from yytname. If YYRES is | |
1110 | null, do not copy; instead, return the length of what the result | |
1111 | would have been. */ | |
1112 | static YYSIZE_T | |
1113 | yytnamerr (char *yyres, const char *yystr) | |
1114 | { | |
1115 | if (*yystr == '"') | |
1116 | { | |
1117 | YYSIZE_T yyn = 0; | |
1118 | char const *yyp = yystr; | |
1119 | ||
1120 | for (;;) | |
1121 | switch (*++yyp) | |
1122 | { | |
1123 | case '\'': | |
1124 | case ',': | |
1125 | goto do_not_strip_quotes; | |
1126 | ||
1127 | case '\\': | |
1128 | if (*++yyp != '\\') | |
1129 | goto do_not_strip_quotes; | |
1130 | /* Fall through. */ | |
1131 | default: | |
1132 | if (yyres) | |
1133 | yyres[yyn] = *yyp; | |
1134 | yyn++; | |
1135 | break; | |
1136 | ||
1137 | case '"': | |
1138 | if (yyres) | |
1139 | yyres[yyn] = '\0'; | |
1140 | return yyn; | |
1141 | } | |
1142 | do_not_strip_quotes: ; | |
1143 | } | |
1144 | ||
1145 | if (! yyres) | |
1146 | return yystrlen (yystr); | |
1147 | ||
1148 | return yystpcpy (yyres, yystr) - yyres; | |
1149 | } | |
1150 | # endif | |
1151 | ||
1152 | /* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message | |
1153 | about the unexpected token YYTOKEN for the state stack whose top is | |
1154 | YYSSP.]b4_lac_if([[ In order to see if a particular token T is a | |
1155 | valid looakhead, invoke yy_lac (YYESA, YYES, YYES_CAPACITY, YYSSP, T).]])[ | |
1156 | ||
1157 | Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is | |
1158 | not large enough to hold the message. In that case, also set | |
1159 | *YYMSG_ALLOC to the required number of bytes. Return 2 if the | |
1160 | required number of bytes is too large to store]b4_lac_if([[ or if | |
1161 | yy_lac returned 2]])[. */ | |
1162 | static int | |
1163 | yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, | |
1164 | ]b4_lac_if([[yytype_int16 *yyesa, yytype_int16 **yyes, | |
1165 | YYSIZE_T *yyes_capacity, ]])[yytype_int16 *yyssp, int yytoken) | |
1166 | { | |
1167 | YYSIZE_T yysize0 = yytnamerr (YY_NULL, yytname[yytoken]); | |
1168 | YYSIZE_T yysize = yysize0; | |
1169 | YYSIZE_T yysize1; | |
1170 | enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; | |
1171 | /* Internationalized format string. */ | |
1172 | const char *yyformat = YY_NULL; | |
1173 | /* Arguments of yyformat. */ | |
1174 | char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; | |
1175 | /* Number of reported tokens (one for the "unexpected", one per | |
1176 | "expected"). */ | |
1177 | int yycount = 0; | |
1178 | ||
1179 | /* There are many possibilities here to consider: | |
1180 | - Assume YYFAIL is not used. It's too flawed to consider. See | |
1181 | <http://lists.gnu.org/archive/html/bison-patches/2009-12/msg00024.html> | |
1182 | for details. YYERROR is fine as it does not invoke this | |
1183 | function. | |
1184 | - If this state is a consistent state with a default action, then | |
1185 | the only way this function was invoked is if the default action | |
1186 | is an error action. In that case, don't check for expected | |
1187 | tokens because there are none. | |
1188 | - The only way there can be no lookahead present (in yychar) is if | |
1189 | this state is a consistent state with a default action. Thus, | |
1190 | detecting the absence of a lookahead is sufficient to determine | |
1191 | that there is no unexpected or expected token to report. In that | |
1192 | case, just report a simple "syntax error". | |
1193 | - Don't assume there isn't a lookahead just because this state is a | |
1194 | consistent state with a default action. There might have been a | |
1195 | previous inconsistent state, consistent state with a non-default | |
1196 | action, or user semantic action that manipulated yychar.]b4_lac_if([[ | |
1197 | In the first two cases, it might appear that the current syntax | |
1198 | error should have been detected in the previous state when yy_lac | |
1199 | was invoked. However, at that time, there might have been a | |
1200 | different syntax error that discarded a different initial context | |
1201 | during error recovery, leaving behind the current lookahead.]], [[ | |
1202 | - Of course, the expected token list depends on states to have | |
1203 | correct lookahead information, and it depends on the parser not | |
1204 | to perform extra reductions after fetching a lookahead from the | |
1205 | scanner and before detecting a syntax error. Thus, state merging | |
1206 | (from LALR or IELR) and default reductions corrupt the expected | |
1207 | token list. However, the list is correct for canonical LR with | |
1208 | one exception: it will still contain any token that will not be | |
1209 | accepted due to an error action in a later state.]])[ | |
1210 | */ | |
1211 | if (yytoken != YYEMPTY) | |
1212 | { | |
1213 | int yyn = yypact[*yyssp];]b4_lac_if([[ | |
1214 | YYDPRINTF ((stderr, "Constructing syntax error message\n"));]])[ | |
1215 | yyarg[yycount++] = yytname[yytoken]; | |
1216 | if (!yypact_value_is_default (yyn)) | |
1217 | {]b4_lac_if([], [[ | |
1218 | /* Start YYX at -YYN if negative to avoid negative indexes in | |
1219 | YYCHECK. In other words, skip the first -YYN actions for | |
1220 | this state because they are default actions. */ | |
1221 | int yyxbegin = yyn < 0 ? -yyn : 0; | |
1222 | /* Stay within bounds of both yycheck and yytname. */ | |
1223 | int yychecklim = YYLAST - yyn + 1; | |
1224 | int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;]])[ | |
1225 | int yyx;]b4_lac_if([[ | |
1226 | ||
1227 | for (yyx = 0; yyx < YYNTOKENS; ++yyx) | |
1228 | if (yyx != YYTERROR && yyx != YYUNDEFTOK) | |
1229 | { | |
1230 | { | |
1231 | int yy_lac_status = yy_lac (yyesa, yyes, yyes_capacity, | |
1232 | yyssp, yyx); | |
1233 | if (yy_lac_status == 2) | |
1234 | return 2; | |
1235 | if (yy_lac_status == 1) | |
1236 | continue; | |
1237 | }]], [[ | |
1238 | ||
1239 | for (yyx = yyxbegin; yyx < yyxend; ++yyx) | |
1240 | if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR | |
1241 | && !yytable_value_is_error (yytable[yyx + yyn])) | |
1242 | {]])[ | |
1243 | if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) | |
1244 | { | |
1245 | yycount = 1; | |
1246 | yysize = yysize0; | |
1247 | break; | |
1248 | } | |
1249 | yyarg[yycount++] = yytname[yyx]; | |
1250 | yysize1 = yysize + yytnamerr (YY_NULL, yytname[yyx]); | |
1251 | if (! (yysize <= yysize1 | |
1252 | && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) | |
1253 | return 2; | |
1254 | yysize = yysize1; | |
1255 | } | |
1256 | }]b4_lac_if([[ | |
1257 | # if ]b4_api_PREFIX[DEBUG | |
1258 | else if (yydebug) | |
1259 | YYFPRINTF (stderr, "No expected tokens.\n"); | |
1260 | # endif]])[ | |
1261 | } | |
1262 | ||
1263 | switch (yycount) | |
1264 | { | |
1265 | # define YYCASE_(N, S) \ | |
1266 | case N: \ | |
1267 | yyformat = S; \ | |
1268 | break | |
1269 | YYCASE_(0, YY_("syntax error")); | |
1270 | YYCASE_(1, YY_("syntax error, unexpected %s")); | |
1271 | YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s")); | |
1272 | YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s")); | |
1273 | YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s")); | |
1274 | YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s")); | |
1275 | # undef YYCASE_ | |
1276 | } | |
1277 | ||
1278 | yysize1 = yysize + yystrlen (yyformat); | |
1279 | if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) | |
1280 | return 2; | |
1281 | yysize = yysize1; | |
1282 | ||
1283 | if (*yymsg_alloc < yysize) | |
1284 | { | |
1285 | *yymsg_alloc = 2 * yysize; | |
1286 | if (! (yysize <= *yymsg_alloc | |
1287 | && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM)) | |
1288 | *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM; | |
1289 | return 1; | |
1290 | } | |
1291 | ||
1292 | /* Avoid sprintf, as that infringes on the user's name space. | |
1293 | Don't have undefined behavior even if the translation | |
1294 | produced a string with the wrong number of "%s"s. */ | |
1295 | { | |
1296 | char *yyp = *yymsg; | |
1297 | int yyi = 0; | |
1298 | while ((*yyp = *yyformat) != '\0') | |
1299 | if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount) | |
1300 | { | |
1301 | yyp += yytnamerr (yyp, yyarg[yyi++]); | |
1302 | yyformat += 2; | |
1303 | } | |
1304 | else | |
1305 | { | |
1306 | yyp++; | |
1307 | yyformat++; | |
1308 | } | |
1309 | } | |
1310 | return 0; | |
1311 | } | |
1312 | #endif /* YYERROR_VERBOSE */ | |
1313 | ||
1314 | ]b4_yydestruct_generate([b4_c_function_def])[ | |
1315 | ||
1316 | ]b4_pure_if([], [ | |
1317 | ||
1318 | b4_declare_scanner_communication_variables])[]b4_push_if([[ | |
1319 | ||
1320 | struct yypstate | |
1321 | {]b4_declare_parser_state_variables[ | |
1322 | /* Used to determine if this is the first time this instance has | |
1323 | been used. */ | |
1324 | int yynew; | |
1325 | };]b4_pure_if([], [[ | |
1326 | ||
1327 | static char yypstate_allocated = 0;]])b4_pull_if([ | |
1328 | ||
1329 | b4_c_function_def([[yyparse]], [[int]], b4_parse_param)[ | |
1330 | { | |
1331 | return yypull_parse (YY_NULL]m4_ifset([b4_parse_param], | |
1332 | [[, ]b4_c_args(b4_parse_param)])[); | |
1333 | } | |
1334 | ||
1335 | ]b4_c_function_def([[yypull_parse]], [[int]], | |
1336 | [[[yypstate *yyps]], [[yyps]]]m4_ifset([b4_parse_param], [, | |
1337 | b4_parse_param]))[ | |
1338 | { | |
1339 | int yystatus; | |
1340 | yypstate *yyps_local;]b4_pure_if([[ | |
1341 | int yychar; | |
1342 | YYSTYPE yylval;]b4_locations_if([[ | |
1343 | YYLTYPE yylloc;]])])[ | |
1344 | if (yyps) | |
1345 | yyps_local = yyps; | |
1346 | else | |
1347 | { | |
1348 | yyps_local = yypstate_new (); | |
1349 | if (!yyps_local) | |
1350 | {]b4_pure_if([[ | |
1351 | yyerror (]b4_yyerror_args[YY_("memory exhausted"));]], [[ | |
1352 | if (!yypstate_allocated) | |
1353 | yyerror (]b4_yyerror_args[YY_("memory exhausted"));]])[ | |
1354 | return 2; | |
1355 | } | |
1356 | } | |
1357 | do { | |
1358 | yychar = YYLEX; | |
1359 | yystatus = | |
1360 | yypush_parse (yyps_local]b4_pure_if([[, yychar, &yylval]b4_locations_if([[, &yylloc]])])m4_ifset([b4_parse_param], [, b4_c_args(b4_parse_param)])[); | |
1361 | } while (yystatus == YYPUSH_MORE); | |
1362 | if (!yyps) | |
1363 | yypstate_delete (yyps_local); | |
1364 | return yystatus; | |
1365 | }]])[ | |
1366 | ||
1367 | /* Initialize the parser data structure. */ | |
1368 | ]b4_c_function_def([[yypstate_new]], [[yypstate *]])[ | |
1369 | { | |
1370 | yypstate *yyps;]b4_pure_if([], [[ | |
1371 | if (yypstate_allocated) | |
1372 | return YY_NULL;]])[ | |
1373 | yyps = (yypstate *) malloc (sizeof *yyps); | |
1374 | if (!yyps) | |
1375 | return YY_NULL; | |
1376 | yyps->yynew = 1;]b4_pure_if([], [[ | |
1377 | yypstate_allocated = 1;]])[ | |
1378 | return yyps; | |
1379 | } | |
1380 | ||
1381 | ]b4_c_function_def([[yypstate_delete]], [[void]], | |
1382 | [[[yypstate *yyps]], [[yyps]]])[ | |
1383 | { | |
1384 | #ifndef yyoverflow | |
1385 | /* If the stack was reallocated but the parse did not complete, then the | |
1386 | stack still needs to be freed. */ | |
1387 | if (!yyps->yynew && yyps->yyss != yyps->yyssa) | |
1388 | YYSTACK_FREE (yyps->yyss); | |
1389 | #endif]b4_lac_if([[ | |
1390 | if (!yyps->yynew && yyps->yyes != yyps->yyesa) | |
1391 | YYSTACK_FREE (yyps->yyes);]])[ | |
1392 | free (yyps);]b4_pure_if([], [[ | |
1393 | yypstate_allocated = 0;]])[ | |
1394 | } | |
1395 | ]b4_pure_if([[ | |
1396 | #define ]b4_prefix[nerrs yyps->]b4_prefix[nerrs]])[ | |
1397 | #define yystate yyps->yystate | |
1398 | #define yyerrstatus yyps->yyerrstatus | |
1399 | #define yyssa yyps->yyssa | |
1400 | #define yyss yyps->yyss | |
1401 | #define yyssp yyps->yyssp | |
1402 | #define yyvsa yyps->yyvsa | |
1403 | #define yyvs yyps->yyvs | |
1404 | #define yyvsp yyps->yyvsp]b4_locations_if([[ | |
1405 | #define yylsa yyps->yylsa | |
1406 | #define yyls yyps->yyls | |
1407 | #define yylsp yyps->yylsp | |
1408 | #define yyerror_range yyps->yyerror_range]])[ | |
1409 | #define yystacksize yyps->yystacksize]b4_lac_if([[ | |
1410 | #define yyesa yyps->yyesa | |
1411 | #define yyes yyps->yyes | |
1412 | #define yyes_capacity yyps->yyes_capacity]])[ | |
1413 | ||
1414 | ||
1415 | /*---------------. | |
1416 | | yypush_parse. | | |
1417 | `---------------*/ | |
1418 | ||
1419 | ]b4_c_function_def([[yypush_parse]], [[int]], | |
1420 | [[[yypstate *yyps]], [[yyps]]]b4_pure_if([, | |
1421 | [[[int yypushed_char]], [[yypushed_char]]], | |
1422 | [[[YYSTYPE const *yypushed_val]], [[yypushed_val]]]b4_locations_if([, | |
1423 | [[[YYLTYPE const *yypushed_loc]], [[yypushed_loc]]]])])m4_ifset([b4_parse_param], [, | |
1424 | b4_parse_param]))], [[ | |
1425 | ||
1426 | ||
1427 | /*----------. | |
1428 | | yyparse. | | |
1429 | `----------*/ | |
1430 | ||
1431 | #ifdef YYPARSE_PARAM | |
1432 | ]b4_c_function_def([yyparse], [int], | |
1433 | [[void *YYPARSE_PARAM], [YYPARSE_PARAM]])[ | |
1434 | #else /* ! YYPARSE_PARAM */ | |
1435 | ]b4_c_function_def([yyparse], [int], b4_parse_param)[ | |
1436 | #endif]])[ | |
1437 | {]b4_pure_if([b4_declare_scanner_communication_variables | |
1438 | ])b4_push_if([b4_pure_if([], [[ | |
1439 | int yypushed_char = yychar; | |
1440 | YYSTYPE yypushed_val = yylval;]b4_locations_if([[ | |
1441 | YYLTYPE yypushed_loc = yylloc;]]) | |
1442 | ])], | |
1443 | [b4_declare_parser_state_variables | |
1444 | ])b4_lac_if([[ | |
1445 | int yy_lac_established = 0;]])[ | |
1446 | int yyn; | |
1447 | int yyresult; | |
1448 | /* Lookahead token as an internal (translated) token number. */ | |
1449 | int yytoken; | |
1450 | /* The variables used to return semantic value and location from the | |
1451 | action routines. */ | |
1452 | YYSTYPE yyval;]b4_locations_if([[ | |
1453 | YYLTYPE yyloc;]])[ | |
1454 | ||
1455 | #if YYERROR_VERBOSE | |
1456 | /* Buffer for error messages, and its allocated size. */ | |
1457 | char yymsgbuf[128]; | |
1458 | char *yymsg = yymsgbuf; | |
1459 | YYSIZE_T yymsg_alloc = sizeof yymsgbuf; | |
1460 | #endif | |
1461 | ||
1462 | #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)]b4_locations_if([, yylsp -= (N)])[) | |
1463 | ||
1464 | /* The number of symbols on the RHS of the reduced rule. | |
1465 | Keep to zero when no symbol should be popped. */ | |
1466 | int yylen = 0;]b4_push_if([[ | |
1467 | ||
1468 | if (!yyps->yynew) | |
1469 | { | |
1470 | yyn = yypact[yystate]; | |
1471 | goto yyread_pushed_token; | |
1472 | }]])[ | |
1473 | ||
1474 | yytoken = 0; | |
1475 | yyss = yyssa; | |
1476 | yyvs = yyvsa;]b4_locations_if([[ | |
1477 | yyls = yylsa;]])[ | |
1478 | yystacksize = YYINITDEPTH;]b4_lac_if([[ | |
1479 | ||
1480 | yyes = yyesa; | |
1481 | yyes_capacity = sizeof yyesa / sizeof *yyes; | |
1482 | if (YYMAXDEPTH < yyes_capacity) | |
1483 | yyes_capacity = YYMAXDEPTH;]])[ | |
1484 | ||
1485 | YYDPRINTF ((stderr, "Starting parse\n")); | |
1486 | ||
1487 | yystate = 0; | |
1488 | yyerrstatus = 0; | |
1489 | yynerrs = 0; | |
1490 | yychar = YYEMPTY; /* Cause a token to be read. */ | |
1491 | ||
1492 | /* Initialize stack pointers. | |
1493 | Waste one element of value and location stack | |
1494 | so that they stay on the same level as the state stack. | |
1495 | The wasted elements are never initialized. */ | |
1496 | yyssp = yyss; | |
1497 | yyvsp = yyvs;]b4_locations_if([[ | |
1498 | yylsp = yyls; | |
1499 | ||
1500 | #if defined ]b4_api_PREFIX[LTYPE_IS_TRIVIAL && ]b4_api_PREFIX[LTYPE_IS_TRIVIAL | |
1501 | /* Initialize the default location before parsing starts. */ | |
1502 | yylloc.first_line = yylloc.last_line = ]b4_location_initial_line[; | |
1503 | yylloc.first_column = yylloc.last_column = ]b4_location_initial_column[; | |
1504 | #endif]]) | |
1505 | m4_ifdef([b4_initial_action],[ | |
1506 | m4_pushdef([b4_at_dollar], [m4_define([b4_at_dollar_used])yylloc])dnl | |
1507 | m4_pushdef([b4_dollar_dollar], [m4_define([b4_dollar_dollar_used])yylval])dnl | |
1508 | /* User initialization code. */ | |
1509 | b4_user_initial_action | |
1510 | m4_popdef([b4_dollar_dollar])dnl | |
1511 | m4_popdef([b4_at_dollar])])dnl | |
1512 | m4_ifdef([b4_dollar_dollar_used],[[ yyvsp[0] = yylval; | |
1513 | ]])dnl | |
1514 | m4_ifdef([b4_at_dollar_used], [[ yylsp[0] = yylloc; | |
1515 | ]])[ | |
1516 | goto yysetstate; | |
1517 | ||
1518 | /*------------------------------------------------------------. | |
1519 | | yynewstate -- Push a new state, which is found in yystate. | | |
1520 | `------------------------------------------------------------*/ | |
1521 | yynewstate: | |
1522 | /* In all cases, when you get here, the value and location stacks | |
1523 | have just been pushed. So pushing a state here evens the stacks. */ | |
1524 | yyssp++; | |
1525 | ||
1526 | yysetstate: | |
1527 | *yyssp = yystate; | |
1528 | ||
1529 | if (yyss + yystacksize - 1 <= yyssp) | |
1530 | { | |
1531 | /* Get the current used size of the three stacks, in elements. */ | |
1532 | YYSIZE_T yysize = yyssp - yyss + 1; | |
1533 | ||
1534 | #ifdef yyoverflow | |
1535 | { | |
1536 | /* Give user a chance to reallocate the stack. Use copies of | |
1537 | these so that the &'s don't force the real ones into | |
1538 | memory. */ | |
1539 | YYSTYPE *yyvs1 = yyvs; | |
1540 | yytype_int16 *yyss1 = yyss;]b4_locations_if([ | |
1541 | YYLTYPE *yyls1 = yyls;])[ | |
1542 | ||
1543 | /* Each stack pointer address is followed by the size of the | |
1544 | data in use in that stack, in bytes. This used to be a | |
1545 | conditional around just the two extra args, but that might | |
1546 | be undefined if yyoverflow is a macro. */ | |
1547 | yyoverflow (YY_("memory exhausted"), | |
1548 | &yyss1, yysize * sizeof (*yyssp), | |
1549 | &yyvs1, yysize * sizeof (*yyvsp),]b4_locations_if([ | |
1550 | &yyls1, yysize * sizeof (*yylsp),])[ | |
1551 | &yystacksize); | |
1552 | ]b4_locations_if([ | |
1553 | yyls = yyls1;])[ | |
1554 | yyss = yyss1; | |
1555 | yyvs = yyvs1; | |
1556 | } | |
1557 | #else /* no yyoverflow */ | |
1558 | # ifndef YYSTACK_RELOCATE | |
1559 | goto yyexhaustedlab; | |
1560 | # else | |
1561 | /* Extend the stack our own way. */ | |
1562 | if (YYMAXDEPTH <= yystacksize) | |
1563 | goto yyexhaustedlab; | |
1564 | yystacksize *= 2; | |
1565 | if (YYMAXDEPTH < yystacksize) | |
1566 | yystacksize = YYMAXDEPTH; | |
1567 | ||
1568 | { | |
1569 | yytype_int16 *yyss1 = yyss; | |
1570 | union yyalloc *yyptr = | |
1571 | (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); | |
1572 | if (! yyptr) | |
1573 | goto yyexhaustedlab; | |
1574 | YYSTACK_RELOCATE (yyss_alloc, yyss); | |
1575 | YYSTACK_RELOCATE (yyvs_alloc, yyvs);]b4_locations_if([ | |
1576 | YYSTACK_RELOCATE (yyls_alloc, yyls);])[ | |
1577 | # undef YYSTACK_RELOCATE | |
1578 | if (yyss1 != yyssa) | |
1579 | YYSTACK_FREE (yyss1); | |
1580 | } | |
1581 | # endif | |
1582 | #endif /* no yyoverflow */ | |
1583 | ||
1584 | yyssp = yyss + yysize - 1; | |
1585 | yyvsp = yyvs + yysize - 1;]b4_locations_if([ | |
1586 | yylsp = yyls + yysize - 1;])[ | |
1587 | ||
1588 | YYDPRINTF ((stderr, "Stack size increased to %lu\n", | |
1589 | (unsigned long int) yystacksize)); | |
1590 | ||
1591 | if (yyss + yystacksize - 1 <= yyssp) | |
1592 | YYABORT; | |
1593 | } | |
1594 | ||
1595 | YYDPRINTF ((stderr, "Entering state %d\n", yystate)); | |
1596 | ||
1597 | if (yystate == YYFINAL) | |
1598 | YYACCEPT; | |
1599 | ||
1600 | goto yybackup; | |
1601 | ||
1602 | /*-----------. | |
1603 | | yybackup. | | |
1604 | `-----------*/ | |
1605 | yybackup: | |
1606 | ||
1607 | /* Do appropriate processing given the current state. Read a | |
1608 | lookahead token if we need one and don't already have one. */ | |
1609 | ||
1610 | /* First try to decide what to do without reference to lookahead token. */ | |
1611 | yyn = yypact[yystate]; | |
1612 | if (yypact_value_is_default (yyn)) | |
1613 | goto yydefault; | |
1614 | ||
1615 | /* Not known => get a lookahead token if don't already have one. */ | |
1616 | ||
1617 | /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ | |
1618 | if (yychar == YYEMPTY) | |
1619 | {]b4_push_if([[ | |
1620 | if (!yyps->yynew) | |
1621 | {]b4_use_push_for_pull_if([], [[ | |
1622 | YYDPRINTF ((stderr, "Return for a new token:\n"));]])[ | |
1623 | yyresult = YYPUSH_MORE; | |
1624 | goto yypushreturn; | |
1625 | } | |
1626 | yyps->yynew = 0;]b4_pure_if([], [[ | |
1627 | /* Restoring the pushed token is only necessary for the first | |
1628 | yypush_parse invocation since subsequent invocations don't overwrite | |
1629 | it before jumping to yyread_pushed_token. */ | |
1630 | yychar = yypushed_char; | |
1631 | yylval = yypushed_val;]b4_locations_if([[ | |
1632 | yylloc = yypushed_loc;]])])[ | |
1633 | yyread_pushed_token:]])[ | |
1634 | YYDPRINTF ((stderr, "Reading a token: "));]b4_push_if([b4_pure_if([[ | |
1635 | yychar = yypushed_char; | |
1636 | if (yypushed_val) | |
1637 | yylval = *yypushed_val;]b4_locations_if([[ | |
1638 | if (yypushed_loc) | |
1639 | yylloc = *yypushed_loc;]])])], [[ | |
1640 | yychar = YYLEX;]])[ | |
1641 | } | |
1642 | ||
1643 | if (yychar <= YYEOF) | |
1644 | { | |
1645 | yychar = yytoken = YYEOF; | |
1646 | YYDPRINTF ((stderr, "Now at end of input.\n")); | |
1647 | } | |
1648 | else | |
1649 | { | |
1650 | yytoken = YYTRANSLATE (yychar); | |
1651 | YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); | |
1652 | } | |
1653 | ||
1654 | /* If the proper action on seeing token YYTOKEN is to reduce or to | |
1655 | detect an error, take that action. */ | |
1656 | yyn += yytoken; | |
1657 | if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)]b4_lac_if([[ | |
1658 | { | |
1659 | YY_LAC_ESTABLISH; | |
1660 | goto yydefault; | |
1661 | }]], [[ | |
1662 | goto yydefault;]])[ | |
1663 | yyn = yytable[yyn]; | |
1664 | if (yyn <= 0) | |
1665 | { | |
1666 | if (yytable_value_is_error (yyn)) | |
1667 | goto yyerrlab;]b4_lac_if([[ | |
1668 | YY_LAC_ESTABLISH;]])[ | |
1669 | yyn = -yyn; | |
1670 | goto yyreduce; | |
1671 | } | |
1672 | ||
1673 | /* Count tokens shifted since error; after three, turn off error | |
1674 | status. */ | |
1675 | if (yyerrstatus) | |
1676 | yyerrstatus--; | |
1677 | ||
1678 | /* Shift the lookahead token. */ | |
1679 | YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); | |
1680 | ||
1681 | /* Discard the shifted token. */ | |
1682 | yychar = YYEMPTY;]b4_lac_if([[ | |
1683 | YY_LAC_DISCARD ("shift");]])[ | |
1684 | ||
1685 | yystate = yyn; | |
1686 | *++yyvsp = yylval; | |
1687 | ]b4_locations_if([ *++yylsp = yylloc;])[ | |
1688 | goto yynewstate; | |
1689 | ||
1690 | ||
1691 | /*-----------------------------------------------------------. | |
1692 | | yydefault -- do the default action for the current state. | | |
1693 | `-----------------------------------------------------------*/ | |
1694 | yydefault: | |
1695 | yyn = yydefact[yystate]; | |
1696 | if (yyn == 0) | |
1697 | goto yyerrlab; | |
1698 | goto yyreduce; | |
1699 | ||
1700 | ||
1701 | /*-----------------------------. | |
1702 | | yyreduce -- Do a reduction. | | |
1703 | `-----------------------------*/ | |
1704 | yyreduce: | |
1705 | /* yyn is the number of a rule to reduce with. */ | |
1706 | yylen = yyr2[yyn]; | |
1707 | ||
1708 | /* If YYLEN is nonzero, implement the default value of the action: | |
1709 | `$$ = $1'. | |
1710 | ||
1711 | Otherwise, the following line sets YYVAL to garbage. | |
1712 | This behavior is undocumented and Bison | |
1713 | users should not rely upon it. Assigning to YYVAL | |
1714 | unconditionally makes the parser a bit smaller, and it avoids a | |
1715 | GCC warning that YYVAL may be used uninitialized. */ | |
1716 | yyval = yyvsp[1-yylen]; | |
1717 | ||
1718 | ]b4_locations_if( | |
1719 | [[ /* Default location. */ | |
1720 | YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);]])[ | |
1721 | YY_REDUCE_PRINT (yyn);]b4_lac_if([[ | |
1722 | { | |
1723 | int yychar_backup = yychar; | |
1724 | switch (yyn) | |
1725 | { | |
1726 | ]b4_user_actions[ | |
1727 | default: break; | |
1728 | } | |
1729 | if (yychar_backup != yychar) | |
1730 | YY_LAC_DISCARD ("yychar change"); | |
1731 | }]], [[ | |
1732 | switch (yyn) | |
1733 | { | |
1734 | ]b4_user_actions[ | |
1735 | default: break; | |
1736 | }]])[ | |
1737 | /* User semantic actions sometimes alter yychar, and that requires | |
1738 | that yytoken be updated with the new translation. We take the | |
1739 | approach of translating immediately before every use of yytoken. | |
1740 | One alternative is translating here after every semantic action, | |
1741 | but that translation would be missed if the semantic action invokes | |
1742 | YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or | |
1743 | if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an | |
1744 | incorrect destructor might then be invoked immediately. In the | |
1745 | case of YYERROR or YYBACKUP, subsequent parser actions might lead | |
1746 | to an incorrect destructor call or verbose syntax error message | |
1747 | before the lookahead is translated. */ | |
1748 | YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); | |
1749 | ||
1750 | YYPOPSTACK (yylen); | |
1751 | yylen = 0; | |
1752 | YY_STACK_PRINT (yyss, yyssp); | |
1753 | ||
1754 | *++yyvsp = yyval;]b4_locations_if([ | |
1755 | *++yylsp = yyloc;])[ | |
1756 | ||
1757 | /* Now `shift' the result of the reduction. Determine what state | |
1758 | that goes to, based on the state we popped back to and the rule | |
1759 | number reduced by. */ | |
1760 | ||
1761 | yyn = yyr1[yyn]; | |
1762 | ||
1763 | yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; | |
1764 | if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) | |
1765 | yystate = yytable[yystate]; | |
1766 | else | |
1767 | yystate = yydefgoto[yyn - YYNTOKENS]; | |
1768 | ||
1769 | goto yynewstate; | |
1770 | ||
1771 | ||
1772 | /*------------------------------------. | |
1773 | | yyerrlab -- here on detecting error | | |
1774 | `------------------------------------*/ | |
1775 | yyerrlab: | |
1776 | /* Make sure we have latest lookahead translation. See comments at | |
1777 | user semantic actions for why this is necessary. */ | |
1778 | yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar); | |
1779 | ||
1780 | /* If not already recovering from an error, report this error. */ | |
1781 | if (!yyerrstatus) | |
1782 | { | |
1783 | ++yynerrs; | |
1784 | #if ! YYERROR_VERBOSE | |
1785 | yyerror (]b4_yyerror_args[YY_("syntax error")); | |
1786 | #else | |
1787 | # define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \]b4_lac_if([[ | |
1788 | yyesa, &yyes, &yyes_capacity, \]])[ | |
1789 | yyssp, yytoken) | |
1790 | { | |
1791 | char const *yymsgp = YY_("syntax error"); | |
1792 | int yysyntax_error_status;]b4_lac_if([[ | |
1793 | if (yychar != YYEMPTY) | |
1794 | YY_LAC_ESTABLISH;]])[ | |
1795 | yysyntax_error_status = YYSYNTAX_ERROR; | |
1796 | if (yysyntax_error_status == 0) | |
1797 | yymsgp = yymsg; | |
1798 | else if (yysyntax_error_status == 1) | |
1799 | { | |
1800 | if (yymsg != yymsgbuf) | |
1801 | YYSTACK_FREE (yymsg); | |
1802 | yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc); | |
1803 | if (!yymsg) | |
1804 | { | |
1805 | yymsg = yymsgbuf; | |
1806 | yymsg_alloc = sizeof yymsgbuf; | |
1807 | yysyntax_error_status = 2; | |
1808 | } | |
1809 | else | |
1810 | { | |
1811 | yysyntax_error_status = YYSYNTAX_ERROR; | |
1812 | yymsgp = yymsg; | |
1813 | } | |
1814 | } | |
1815 | yyerror (]b4_yyerror_args[yymsgp); | |
1816 | if (yysyntax_error_status == 2) | |
1817 | goto yyexhaustedlab; | |
1818 | } | |
1819 | # undef YYSYNTAX_ERROR | |
1820 | #endif | |
1821 | } | |
1822 | ||
1823 | ]b4_locations_if([[ yyerror_range[1] = yylloc;]])[ | |
1824 | ||
1825 | if (yyerrstatus == 3) | |
1826 | { | |
1827 | /* If just tried and failed to reuse lookahead token after an | |
1828 | error, discard it. */ | |
1829 | ||
1830 | if (yychar <= YYEOF) | |
1831 | { | |
1832 | /* Return failure if at end of input. */ | |
1833 | if (yychar == YYEOF) | |
1834 | YYABORT; | |
1835 | } | |
1836 | else | |
1837 | { | |
1838 | yydestruct ("Error: discarding", | |
1839 | yytoken, &yylval]b4_locations_if([, &yylloc])[]b4_user_args[); | |
1840 | yychar = YYEMPTY; | |
1841 | } | |
1842 | } | |
1843 | ||
1844 | /* Else will try to reuse lookahead token after shifting the error | |
1845 | token. */ | |
1846 | goto yyerrlab1; | |
1847 | ||
1848 | ||
1849 | /*---------------------------------------------------. | |
1850 | | yyerrorlab -- error raised explicitly by YYERROR. | | |
1851 | `---------------------------------------------------*/ | |
1852 | yyerrorlab: | |
1853 | ||
1854 | /* Pacify compilers like GCC when the user code never invokes | |
1855 | YYERROR and the label yyerrorlab therefore never appears in user | |
1856 | code. */ | |
1857 | if (/*CONSTCOND*/ 0) | |
1858 | goto yyerrorlab; | |
1859 | ||
1860 | ]b4_locations_if([[ yyerror_range[1] = yylsp[1-yylen]; | |
1861 | ]])[ /* Do not reclaim the symbols of the rule which action triggered | |
1862 | this YYERROR. */ | |
1863 | YYPOPSTACK (yylen); | |
1864 | yylen = 0; | |
1865 | YY_STACK_PRINT (yyss, yyssp); | |
1866 | yystate = *yyssp; | |
1867 | goto yyerrlab1; | |
1868 | ||
1869 | ||
1870 | /*-------------------------------------------------------------. | |
1871 | | yyerrlab1 -- common code for both syntax error and YYERROR. | | |
1872 | `-------------------------------------------------------------*/ | |
1873 | yyerrlab1: | |
1874 | yyerrstatus = 3; /* Each real token shifted decrements this. */ | |
1875 | ||
1876 | for (;;) | |
1877 | { | |
1878 | yyn = yypact[yystate]; | |
1879 | if (!yypact_value_is_default (yyn)) | |
1880 | { | |
1881 | yyn += YYTERROR; | |
1882 | if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) | |
1883 | { | |
1884 | yyn = yytable[yyn]; | |
1885 | if (0 < yyn) | |
1886 | break; | |
1887 | } | |
1888 | } | |
1889 | ||
1890 | /* Pop the current state because it cannot handle the error token. */ | |
1891 | if (yyssp == yyss) | |
1892 | YYABORT; | |
1893 | ||
1894 | ]b4_locations_if([[ yyerror_range[1] = *yylsp;]])[ | |
1895 | yydestruct ("Error: popping", | |
1896 | yystos[yystate], yyvsp]b4_locations_if([, yylsp])[]b4_user_args[); | |
1897 | YYPOPSTACK (1); | |
1898 | yystate = *yyssp; | |
1899 | YY_STACK_PRINT (yyss, yyssp); | |
1900 | }]b4_lac_if([[ | |
1901 | ||
1902 | /* If the stack popping above didn't lose the initial context for the | |
1903 | current lookahead token, the shift below will for sure. */ | |
1904 | YY_LAC_DISCARD ("error recovery");]])[ | |
1905 | ||
1906 | *++yyvsp = yylval; | |
1907 | ]b4_locations_if([[ | |
1908 | yyerror_range[2] = yylloc; | |
1909 | /* Using YYLLOC is tempting, but would change the location of | |
1910 | the lookahead. YYLOC is available though. */ | |
1911 | YYLLOC_DEFAULT (yyloc, yyerror_range, 2); | |
1912 | *++yylsp = yyloc;]])[ | |
1913 | ||
1914 | /* Shift the error token. */ | |
1915 | YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); | |
1916 | ||
1917 | yystate = yyn; | |
1918 | goto yynewstate; | |
1919 | ||
1920 | ||
1921 | /*-------------------------------------. | |
1922 | | yyacceptlab -- YYACCEPT comes here. | | |
1923 | `-------------------------------------*/ | |
1924 | yyacceptlab: | |
1925 | yyresult = 0; | |
1926 | goto yyreturn; | |
1927 | ||
1928 | /*-----------------------------------. | |
1929 | | yyabortlab -- YYABORT comes here. | | |
1930 | `-----------------------------------*/ | |
1931 | yyabortlab: | |
1932 | yyresult = 1; | |
1933 | goto yyreturn; | |
1934 | ||
1935 | #if ]b4_lac_if([[1]], [[!defined yyoverflow || YYERROR_VERBOSE]])[ | |
1936 | /*-------------------------------------------------. | |
1937 | | yyexhaustedlab -- memory exhaustion comes here. | | |
1938 | `-------------------------------------------------*/ | |
1939 | yyexhaustedlab: | |
1940 | yyerror (]b4_yyerror_args[YY_("memory exhausted")); | |
1941 | yyresult = 2; | |
1942 | /* Fall through. */ | |
1943 | #endif | |
1944 | ||
1945 | yyreturn: | |
1946 | if (yychar != YYEMPTY) | |
1947 | { | |
1948 | /* Make sure we have latest lookahead translation. See comments at | |
1949 | user semantic actions for why this is necessary. */ | |
1950 | yytoken = YYTRANSLATE (yychar); | |
1951 | yydestruct ("Cleanup: discarding lookahead", | |
1952 | yytoken, &yylval]b4_locations_if([, &yylloc])[]b4_user_args[); | |
1953 | } | |
1954 | /* Do not reclaim the symbols of the rule which action triggered | |
1955 | this YYABORT or YYACCEPT. */ | |
1956 | YYPOPSTACK (yylen); | |
1957 | YY_STACK_PRINT (yyss, yyssp); | |
1958 | while (yyssp != yyss) | |
1959 | { | |
1960 | yydestruct ("Cleanup: popping", | |
1961 | yystos[*yyssp], yyvsp]b4_locations_if([, yylsp])[]b4_user_args[); | |
1962 | YYPOPSTACK (1); | |
1963 | } | |
1964 | #ifndef yyoverflow | |
1965 | if (yyss != yyssa) | |
1966 | YYSTACK_FREE (yyss); | |
1967 | #endif]b4_lac_if([[ | |
1968 | if (yyes != yyesa) | |
1969 | YYSTACK_FREE (yyes);]])b4_push_if([[ | |
1970 | yyps->yynew = 1; | |
1971 | ||
1972 | yypushreturn:]])[ | |
1973 | #if YYERROR_VERBOSE | |
1974 | if (yymsg != yymsgbuf) | |
1975 | YYSTACK_FREE (yymsg); | |
1976 | #endif | |
1977 | /* Make sure YYID is used. */ | |
1978 | return YYID (yyresult); | |
1979 | } | |
1980 | ||
1981 | ]b4_epilogue[]dnl | |
1982 | b4_defines_if( | |
1983 | [@output(b4_spec_defines_file@)@ | |
1984 | b4_copyright([Bison interface for Yacc-like parsers in C])[ | |
1985 | ||
1986 | ]b4_shared_declarations[ | |
1987 | ]])dnl b4_defines_if | |
1988 | m4_divert_pop(0) | |
1989 | m4_popdef([b4_copyright_years]) |