[270] | 1 | -*- C -*-
|
---|
| 2 |
|
---|
| 3 | # GLR skeleton for Bison
|
---|
| 4 | # Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software
|
---|
| 5 | # Foundation, Inc.
|
---|
| 6 |
|
---|
| 7 | # This program is free software: you can redistribute it and/or modify
|
---|
| 8 | # it under the terms of the GNU General Public License as published by
|
---|
| 9 | # the Free Software Foundation, either version 3 of the License, or
|
---|
| 10 | # (at your option) any later version.
|
---|
| 11 | #
|
---|
| 12 | # This program is distributed in the hope that it will be useful,
|
---|
| 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 15 | # GNU General Public License for more details.
|
---|
| 16 | #
|
---|
| 17 | # You should have received a copy of the GNU General Public License
|
---|
| 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>.
|
---|
| 19 |
|
---|
| 20 |
|
---|
| 21 | m4_include(b4_pkgdatadir/[c.m4])
|
---|
| 22 |
|
---|
| 23 | ## ---------------- ##
|
---|
| 24 | ## Default values. ##
|
---|
| 25 | ## ---------------- ##
|
---|
| 26 |
|
---|
| 27 | # Stack parameters.
|
---|
| 28 | m4_define_default([b4_stack_depth_max], [10000])
|
---|
| 29 | m4_define_default([b4_stack_depth_init], [200])
|
---|
| 30 |
|
---|
| 31 |
|
---|
| 32 |
|
---|
| 33 | ## ------------------------ ##
|
---|
| 34 | ## Pure/impure interfaces. ##
|
---|
| 35 | ## ------------------------ ##
|
---|
| 36 |
|
---|
| 37 | b4_define_flag_if([pure])
|
---|
| 38 | # If glr.cc is including this file and thus has already set b4_pure_flag, don't
|
---|
| 39 | # change the value of b4_pure_flag, and don't record a use of api.pure.
|
---|
| 40 | m4_ifndef([b4_pure_flag],
|
---|
| 41 | [b4_percent_define_default([[api.pure]], [[false]])
|
---|
| 42 | m4_define([b4_pure_flag],
|
---|
| 43 | [b4_percent_define_flag_if([[api.pure]], [[1]], [[0]])])])
|
---|
| 44 |
|
---|
| 45 | # b4_user_formals
|
---|
| 46 | # ---------------
|
---|
| 47 | # The possible parse-params formal arguments preceded by a comma.
|
---|
| 48 | #
|
---|
| 49 | # This is not shared with yacc.c in c.m4 because GLR relies on ISO C
|
---|
| 50 | # formal argument declarations.
|
---|
| 51 | m4_define([b4_user_formals],
|
---|
| 52 | [m4_ifset([b4_parse_param], [, b4_c_ansi_formals(b4_parse_param)])])
|
---|
| 53 |
|
---|
| 54 |
|
---|
| 55 | # b4_lex_param
|
---|
| 56 | # ------------
|
---|
| 57 | # Accumule in b4_lex_param all the yylex arguments.
|
---|
| 58 | # Yes, this is quite ugly...
|
---|
| 59 | m4_define([b4_lex_param],
|
---|
| 60 | m4_dquote(b4_pure_if([[[[YYSTYPE *]], [[&yylval]]][]dnl
|
---|
| 61 | b4_locations_if([, [[YYLTYPE *], [&yylloc]]])])dnl
|
---|
| 62 | m4_ifdef([b4_lex_param], [, ]b4_lex_param)))
|
---|
| 63 |
|
---|
| 64 |
|
---|
| 65 | # b4_yyerror_args
|
---|
| 66 | # ---------------
|
---|
| 67 | # Optional effective arguments passed to yyerror: user args plus yylloc, and
|
---|
| 68 | # a trailing comma.
|
---|
| 69 | m4_define([b4_yyerror_args],
|
---|
| 70 | [b4_pure_if([b4_locations_if([yylocp, ])])dnl
|
---|
| 71 | m4_ifset([b4_parse_param], [b4_c_args(b4_parse_param), ])])
|
---|
| 72 |
|
---|
| 73 |
|
---|
| 74 | # b4_lyyerror_args
|
---|
| 75 | # ----------------
|
---|
| 76 | # Same as above, but on the lookahead, hence &yylloc instead of yylocp.
|
---|
| 77 | m4_define([b4_lyyerror_args],
|
---|
| 78 | [b4_pure_if([b4_locations_if([&yylloc, ])])dnl
|
---|
| 79 | m4_ifset([b4_parse_param], [b4_c_args(b4_parse_param), ])])
|
---|
| 80 |
|
---|
| 81 |
|
---|
| 82 | # b4_pure_args
|
---|
| 83 | # ------------
|
---|
| 84 | # Same as b4_yyerror_args, but with a leading comma.
|
---|
| 85 | m4_define([b4_pure_args],
|
---|
| 86 | [b4_pure_if([b4_locations_if([, yylocp])])[]b4_user_args])
|
---|
| 87 |
|
---|
| 88 |
|
---|
| 89 | # b4_lpure_args
|
---|
| 90 | # -------------
|
---|
| 91 | # Same as above, but on the lookahead, hence &yylloc instead of yylocp.
|
---|
| 92 | m4_define([b4_lpure_args],
|
---|
| 93 | [b4_pure_if([b4_locations_if([, &yylloc])])[]b4_user_args])
|
---|
| 94 |
|
---|
| 95 |
|
---|
| 96 | # b4_pure_formals
|
---|
| 97 | # ---------------
|
---|
| 98 | # Arguments passed to yyerror: user formals plus yylocp.
|
---|
| 99 | m4_define([b4_pure_formals],
|
---|
| 100 | [b4_pure_if([b4_locations_if([, YYLTYPE *yylocp])])[]b4_user_formals])
|
---|
| 101 |
|
---|
| 102 |
|
---|
| 103 | ## ----------------- ##
|
---|
| 104 | ## Semantic Values. ##
|
---|
| 105 | ## ----------------- ##
|
---|
| 106 |
|
---|
| 107 |
|
---|
| 108 | # b4_lhs_value([TYPE])
|
---|
| 109 | # --------------------
|
---|
| 110 | # Expansion of $<TYPE>$.
|
---|
| 111 | m4_define([b4_lhs_value],
|
---|
| 112 | [((*yyvalp)[]m4_ifval([$1], [.$1]))])
|
---|
| 113 |
|
---|
| 114 |
|
---|
| 115 | # b4_rhs_value(RULE-LENGTH, NUM, [TYPE])
|
---|
| 116 | # --------------------------------------
|
---|
| 117 | # Expansion of $<TYPE>NUM, where the current rule has RULE-LENGTH
|
---|
| 118 | # symbols on RHS.
|
---|
| 119 | m4_define([b4_rhs_value],
|
---|
| 120 | [(((yyGLRStackItem const *)yyvsp)@{YYFILL (($2) - ($1))@}.yystate.yysemantics.yysval[]m4_ifval([$3], [.$3]))])
|
---|
| 121 |
|
---|
| 122 |
|
---|
| 123 |
|
---|
| 124 | ## ----------- ##
|
---|
| 125 | ## Locations. ##
|
---|
| 126 | ## ----------- ##
|
---|
| 127 |
|
---|
| 128 | # b4_lhs_location()
|
---|
| 129 | # -----------------
|
---|
| 130 | # Expansion of @$.
|
---|
| 131 | m4_define([b4_lhs_location],
|
---|
| 132 | [(*yylocp)])
|
---|
| 133 |
|
---|
| 134 |
|
---|
| 135 | # b4_rhs_location(RULE-LENGTH, NUM)
|
---|
| 136 | # ---------------------------------
|
---|
| 137 | # Expansion of @NUM, where the current rule has RULE-LENGTH symbols
|
---|
| 138 | # on RHS.
|
---|
| 139 | m4_define([b4_rhs_location],
|
---|
| 140 | [(((yyGLRStackItem const *)yyvsp)@{YYFILL (($2) - ($1))@}.yystate.yyloc)])
|
---|
| 141 |
|
---|
| 142 |
|
---|
| 143 |
|
---|
| 144 | ## -------------- ##
|
---|
| 145 | ## Output files. ##
|
---|
| 146 | ## -------------- ##
|
---|
| 147 |
|
---|
| 148 | # We do want M4 expansion after # for CPP macros.
|
---|
| 149 | m4_changecom()
|
---|
| 150 | m4_divert_push(0)dnl
|
---|
| 151 | @output(b4_parser_file_name@)
|
---|
| 152 | b4_copyright([Skeleton implementation for Bison GLR parsers in C],
|
---|
| 153 | [2002, 2003, 2004, 2005, 2006])
|
---|
| 154 | [
|
---|
| 155 | /* C GLR parser skeleton written by Paul Hilfinger. */
|
---|
| 156 |
|
---|
| 157 | ]b4_identification
|
---|
| 158 |
|
---|
| 159 | b4_percent_code_get([[top]])[]dnl
|
---|
| 160 | m4_if(b4_prefix, [yy], [],
|
---|
| 161 | [/* Substitute the variable and function names. */
|
---|
| 162 | #define yyparse b4_prefix[]parse
|
---|
| 163 | #define yylex b4_prefix[]lex
|
---|
| 164 | #define yyerror b4_prefix[]error
|
---|
| 165 | #define yylval b4_prefix[]lval
|
---|
| 166 | #define yychar b4_prefix[]char
|
---|
| 167 | #define yydebug b4_prefix[]debug
|
---|
| 168 | #define yynerrs b4_prefix[]nerrs
|
---|
| 169 | #define yylloc b4_prefix[]lloc])[
|
---|
| 170 |
|
---|
| 171 | /* Copy the first part of user declarations. */
|
---|
| 172 | ]b4_user_pre_prologue
|
---|
| 173 |
|
---|
| 174 | dnl # b4_shared_declarations
|
---|
| 175 | dnl # ----------------------
|
---|
| 176 | dnl # Declaration that might either go into the header (if --defines)
|
---|
| 177 | dnl # or open coded in the parser body.
|
---|
| 178 | m4_define([b4_shared_declarations],
|
---|
| 179 | [b4_percent_code_get([[requires]])[]dnl
|
---|
| 180 |
|
---|
| 181 | b4_token_enums(b4_tokens)
|
---|
| 182 |
|
---|
| 183 | [#ifndef YYSTYPE
|
---|
| 184 | ]m4_ifdef([b4_stype],
|
---|
| 185 | [[typedef union ]b4_union_name[
|
---|
| 186 | {
|
---|
| 187 | ]b4_user_stype[
|
---|
| 188 | } YYSTYPE;
|
---|
| 189 | # define YYSTYPE_IS_TRIVIAL 1]],
|
---|
| 190 | [m4_if(b4_tag_seen_flag, 0,
|
---|
| 191 | [[typedef int YYSTYPE;
|
---|
| 192 | # define YYSTYPE_IS_TRIVIAL 1]])])[
|
---|
| 193 | #endif
|
---|
| 194 |
|
---|
| 195 | #if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED
|
---|
| 196 | typedef struct YYLTYPE
|
---|
| 197 | {
|
---|
| 198 | ]b4_locations_if([
|
---|
| 199 | int first_line;
|
---|
| 200 | int first_column;
|
---|
| 201 | int last_line;
|
---|
| 202 | int last_column;
|
---|
| 203 | ],[
|
---|
| 204 | char yydummy;
|
---|
| 205 | ])[
|
---|
| 206 | } YYLTYPE;
|
---|
| 207 | # define YYLTYPE_IS_DECLARED 1
|
---|
| 208 | # define YYLTYPE_IS_TRIVIAL 1
|
---|
| 209 | #endif
|
---|
| 210 |
|
---|
| 211 | ]b4_percent_code_get([[provides]])[]dnl
|
---|
| 212 | ])
|
---|
| 213 |
|
---|
| 214 | b4_defines_if([[#include "@basename(]b4_spec_defines_file[@)"]],
|
---|
| 215 | [b4_shared_declarations])[
|
---|
| 216 |
|
---|
| 217 | /* Enabling traces. */
|
---|
| 218 | #ifndef YYDEBUG
|
---|
| 219 | # define YYDEBUG ]b4_debug_flag[
|
---|
| 220 | #endif
|
---|
| 221 |
|
---|
| 222 | /* Enabling verbose error messages. */
|
---|
| 223 | #ifdef YYERROR_VERBOSE
|
---|
| 224 | # undef YYERROR_VERBOSE
|
---|
| 225 | # define YYERROR_VERBOSE 1
|
---|
| 226 | #else
|
---|
| 227 | # define YYERROR_VERBOSE ]b4_error_verbose_flag[
|
---|
| 228 | #endif
|
---|
| 229 |
|
---|
| 230 | /* Enabling the token table. */
|
---|
| 231 | #ifndef YYTOKEN_TABLE
|
---|
| 232 | # define YYTOKEN_TABLE ]b4_token_table[
|
---|
| 233 | #endif
|
---|
| 234 |
|
---|
| 235 | /* Default (constant) value used for initialization for null
|
---|
| 236 | right-hand sides. Unlike the standard yacc.c template,
|
---|
| 237 | here we set the default value of $$ to a zeroed-out value.
|
---|
| 238 | Since the default value is undefined, this behavior is
|
---|
| 239 | technically correct. */
|
---|
| 240 | static YYSTYPE yyval_default;
|
---|
| 241 |
|
---|
| 242 | /* Copy the second part of user declarations. */
|
---|
| 243 | ]b4_user_post_prologue
|
---|
| 244 | b4_percent_code_get[]dnl
|
---|
| 245 |
|
---|
| 246 | [#include <stdio.h>
|
---|
| 247 | #include <stdlib.h>
|
---|
| 248 | #include <string.h>
|
---|
| 249 |
|
---|
| 250 | #ifndef YY_
|
---|
| 251 | # if YYENABLE_NLS
|
---|
| 252 | # if ENABLE_NLS
|
---|
| 253 | # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
|
---|
| 254 | # define YY_(msgid) dgettext ("bison-runtime", msgid)
|
---|
| 255 | # endif
|
---|
| 256 | # endif
|
---|
| 257 | # ifndef YY_
|
---|
| 258 | # define YY_(msgid) msgid
|
---|
| 259 | # endif
|
---|
| 260 | #endif
|
---|
| 261 |
|
---|
| 262 | /* Suppress unused-variable warnings by "using" E. */
|
---|
| 263 | #if ! defined lint || defined __GNUC__
|
---|
| 264 | # define YYUSE(e) ((void) (e))
|
---|
| 265 | #else
|
---|
| 266 | # define YYUSE(e) /* empty */
|
---|
| 267 | #endif
|
---|
| 268 |
|
---|
| 269 | /* Identity function, used to suppress warnings about constant conditions. */
|
---|
| 270 | #ifndef lint
|
---|
| 271 | # define YYID(n) (n)
|
---|
| 272 | #else
|
---|
| 273 | ]b4_c_function_def([YYID], [static int], [[int i], [i]])[
|
---|
| 274 | {
|
---|
| 275 | return i;
|
---|
| 276 | }
|
---|
| 277 | #endif
|
---|
| 278 |
|
---|
| 279 | #ifndef YYFREE
|
---|
| 280 | # define YYFREE free
|
---|
| 281 | #endif
|
---|
| 282 | #ifndef YYMALLOC
|
---|
| 283 | # define YYMALLOC malloc
|
---|
| 284 | #endif
|
---|
| 285 | #ifndef YYREALLOC
|
---|
| 286 | # define YYREALLOC realloc
|
---|
| 287 | #endif
|
---|
| 288 |
|
---|
| 289 | #define YYSIZEMAX ((size_t) -1)
|
---|
| 290 |
|
---|
| 291 | #ifdef __cplusplus
|
---|
| 292 | typedef bool yybool;
|
---|
| 293 | #else
|
---|
| 294 | typedef unsigned char yybool;
|
---|
| 295 | #endif
|
---|
| 296 | #define yytrue 1
|
---|
| 297 | #define yyfalse 0
|
---|
| 298 |
|
---|
| 299 | #ifndef YYSETJMP
|
---|
| 300 | # include <setjmp.h>
|
---|
| 301 | # define YYJMP_BUF jmp_buf
|
---|
| 302 | # define YYSETJMP(env) setjmp (env)
|
---|
| 303 | # define YYLONGJMP(env, val) longjmp (env, val)
|
---|
| 304 | #endif
|
---|
| 305 |
|
---|
| 306 | /*-----------------.
|
---|
| 307 | | GCC extensions. |
|
---|
| 308 | `-----------------*/
|
---|
| 309 |
|
---|
| 310 | #ifndef __attribute__
|
---|
| 311 | /* This feature is available in gcc versions 2.5 and later. */
|
---|
| 312 | # if (! defined __GNUC__ || __GNUC__ < 2 \
|
---|
| 313 | || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__)
|
---|
| 314 | # define __attribute__(Spec) /* empty */
|
---|
| 315 | # endif
|
---|
| 316 | #endif
|
---|
| 317 |
|
---|
| 318 | ]b4_locations_if([#define YYOPTIONAL_LOC(Name) Name],[
|
---|
| 319 | #ifdef __cplusplus
|
---|
| 320 | # define YYOPTIONAL_LOC(Name) /* empty */
|
---|
| 321 | #else
|
---|
| 322 | # define YYOPTIONAL_LOC(Name) Name __attribute__ ((__unused__))
|
---|
| 323 | #endif])[
|
---|
| 324 |
|
---|
| 325 | #ifndef YYASSERT
|
---|
| 326 | # define YYASSERT(condition) ((void) ((condition) || (abort (), 0)))
|
---|
| 327 | #endif
|
---|
| 328 |
|
---|
| 329 | /* YYFINAL -- State number of the termination state. */
|
---|
| 330 | #define YYFINAL ]b4_final_state_number[
|
---|
| 331 | /* YYLAST -- Last index in YYTABLE. */
|
---|
| 332 | #define YYLAST ]b4_last[
|
---|
| 333 |
|
---|
| 334 | /* YYNTOKENS -- Number of terminals. */
|
---|
| 335 | #define YYNTOKENS ]b4_tokens_number[
|
---|
| 336 | /* YYNNTS -- Number of nonterminals. */
|
---|
| 337 | #define YYNNTS ]b4_nterms_number[
|
---|
| 338 | /* YYNRULES -- Number of rules. */
|
---|
| 339 | #define YYNRULES ]b4_rules_number[
|
---|
| 340 | /* YYNRULES -- Number of states. */
|
---|
| 341 | #define YYNSTATES ]b4_states_number[
|
---|
| 342 | /* YYMAXRHS -- Maximum number of symbols on right-hand side of rule. */
|
---|
| 343 | #define YYMAXRHS ]b4_r2_max[
|
---|
| 344 | /* YYMAXLEFT -- Maximum number of symbols to the left of a handle
|
---|
| 345 | accessed by $0, $-1, etc., in any rule. */
|
---|
| 346 | #define YYMAXLEFT ]b4_max_left_semantic_context[
|
---|
| 347 |
|
---|
| 348 | /* YYTRANSLATE(X) -- Bison symbol number corresponding to X. */
|
---|
| 349 | #define YYUNDEFTOK ]b4_undef_token_number[
|
---|
| 350 | #define YYMAXUTOK ]b4_user_token_number_max[
|
---|
| 351 |
|
---|
| 352 | #define YYTRANSLATE(YYX) \
|
---|
| 353 | ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
|
---|
| 354 |
|
---|
| 355 | /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
|
---|
| 356 | static const ]b4_int_type_for([b4_translate])[ yytranslate[] =
|
---|
| 357 | {
|
---|
| 358 | ]b4_translate[
|
---|
| 359 | };
|
---|
| 360 |
|
---|
| 361 | #if YYDEBUG
|
---|
| 362 | /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
|
---|
| 363 | YYRHS. */
|
---|
| 364 | static const ]b4_int_type_for([b4_prhs])[ yyprhs[] =
|
---|
| 365 | {
|
---|
| 366 | ]b4_prhs[
|
---|
| 367 | };
|
---|
| 368 |
|
---|
| 369 | /* YYRHS -- A `-1'-separated list of the rules' RHS. */
|
---|
| 370 | static const ]b4_int_type_for([b4_rhs])[ yyrhs[] =
|
---|
| 371 | {
|
---|
| 372 | ]b4_rhs[
|
---|
| 373 | };
|
---|
| 374 |
|
---|
| 375 | /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
|
---|
| 376 | static const ]b4_int_type_for([b4_rline])[ yyrline[] =
|
---|
| 377 | {
|
---|
| 378 | ]b4_rline[
|
---|
| 379 | };
|
---|
| 380 | #endif
|
---|
| 381 |
|
---|
| 382 | #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
|
---|
| 383 | /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
|
---|
| 384 | First, the terminals, then, starting at YYNTOKENS, nonterminals. */
|
---|
| 385 | static const char *const yytname[] =
|
---|
| 386 | {
|
---|
| 387 | ]b4_tname[
|
---|
| 388 | };
|
---|
| 389 | #endif
|
---|
| 390 |
|
---|
| 391 | /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
|
---|
| 392 | static const ]b4_int_type_for([b4_r1])[ yyr1[] =
|
---|
| 393 | {
|
---|
| 394 | ]b4_r1[
|
---|
| 395 | };
|
---|
| 396 |
|
---|
| 397 | /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
|
---|
| 398 | static const ]b4_int_type_for([b4_r2])[ yyr2[] =
|
---|
| 399 | {
|
---|
| 400 | ]b4_r2[
|
---|
| 401 | };
|
---|
| 402 |
|
---|
| 403 | /* YYDPREC[RULE-NUM] -- Dynamic precedence of rule #RULE-NUM (0 if none). */
|
---|
| 404 | static const ]b4_int_type_for([b4_dprec])[ yydprec[] =
|
---|
| 405 | {
|
---|
| 406 | ]b4_dprec[
|
---|
| 407 | };
|
---|
| 408 |
|
---|
| 409 | /* YYMERGER[RULE-NUM] -- Index of merging function for rule #RULE-NUM. */
|
---|
| 410 | static const ]b4_int_type_for([b4_merger])[ yymerger[] =
|
---|
| 411 | {
|
---|
| 412 | ]b4_merger[
|
---|
| 413 | };
|
---|
| 414 |
|
---|
| 415 | /* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE
|
---|
| 416 | doesn't specify something else to do. Zero means the default is an
|
---|
| 417 | error. */
|
---|
| 418 | static const ]b4_int_type_for([b4_defact])[ yydefact[] =
|
---|
| 419 | {
|
---|
| 420 | ]b4_defact[
|
---|
| 421 | };
|
---|
| 422 |
|
---|
| 423 | /* YYPDEFGOTO[NTERM-NUM]. */
|
---|
| 424 | static const ]b4_int_type_for([b4_defgoto])[ yydefgoto[] =
|
---|
| 425 | {
|
---|
| 426 | ]b4_defgoto[
|
---|
| 427 | };
|
---|
| 428 |
|
---|
| 429 | /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
|
---|
| 430 | STATE-NUM. */
|
---|
| 431 | #define YYPACT_NINF ]b4_pact_ninf[
|
---|
| 432 | static const ]b4_int_type_for([b4_pact])[ yypact[] =
|
---|
| 433 | {
|
---|
| 434 | ]b4_pact[
|
---|
| 435 | };
|
---|
| 436 |
|
---|
| 437 | /* YYPGOTO[NTERM-NUM]. */
|
---|
| 438 | static const ]b4_int_type_for([b4_pgoto])[ yypgoto[] =
|
---|
| 439 | {
|
---|
| 440 | ]b4_pgoto[
|
---|
| 441 | };
|
---|
| 442 |
|
---|
| 443 | /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
|
---|
| 444 | positive, shift that token. If negative, reduce the rule which
|
---|
| 445 | number is the opposite. If zero, do what YYDEFACT says.
|
---|
| 446 | If YYTABLE_NINF, syntax error. */
|
---|
| 447 | #define YYTABLE_NINF ]b4_table_ninf[
|
---|
| 448 | static const ]b4_int_type_for([b4_table])[ yytable[] =
|
---|
| 449 | {
|
---|
| 450 | ]b4_table[
|
---|
| 451 | };
|
---|
| 452 |
|
---|
| 453 | /* YYCONFLP[YYPACT[STATE-NUM]] -- Pointer into YYCONFL of start of
|
---|
| 454 | list of conflicting reductions corresponding to action entry for
|
---|
| 455 | state STATE-NUM in yytable. 0 means no conflicts. The list in
|
---|
| 456 | yyconfl is terminated by a rule number of 0. */
|
---|
| 457 | static const ]b4_int_type_for([b4_conflict_list_heads])[ yyconflp[] =
|
---|
| 458 | {
|
---|
| 459 | ]b4_conflict_list_heads[
|
---|
| 460 | };
|
---|
| 461 |
|
---|
| 462 | /* YYCONFL[I] -- lists of conflicting rule numbers, each terminated by
|
---|
| 463 | 0, pointed into by YYCONFLP. */
|
---|
| 464 | ]dnl Do not use b4_int_type_for here, since there are places where
|
---|
| 465 | dnl pointers onto yyconfl are taken, which type is "short int *".
|
---|
| 466 | dnl We probably ought to introduce a type for confl.
|
---|
| 467 | [static const short int yyconfl[] =
|
---|
| 468 | {
|
---|
| 469 | ]b4_conflicting_rules[
|
---|
| 470 | };
|
---|
| 471 |
|
---|
| 472 | static const ]b4_int_type_for([b4_check])[ yycheck[] =
|
---|
| 473 | {
|
---|
| 474 | ]b4_check[
|
---|
| 475 | };
|
---|
| 476 |
|
---|
| 477 | /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
|
---|
| 478 | symbol of state STATE-NUM. */
|
---|
| 479 | static const ]b4_int_type_for([b4_stos])[ yystos[] =
|
---|
| 480 | {
|
---|
| 481 | ]b4_stos[
|
---|
| 482 | };
|
---|
| 483 |
|
---|
| 484 | |
---|
| 485 |
|
---|
| 486 | /* Prevent warning if -Wmissing-prototypes. */
|
---|
| 487 | ]b4_c_ansi_function_decl([yyparse], [int], b4_parse_param)[
|
---|
| 488 |
|
---|
| 489 | /* Error token number */
|
---|
| 490 | #define YYTERROR 1
|
---|
| 491 |
|
---|
| 492 | /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
|
---|
| 493 | If N is 0, then set CURRENT to the empty location which ends
|
---|
| 494 | the previous symbol: RHS[0] (always defined). */
|
---|
| 495 |
|
---|
| 496 | ]b4_locations_if([[
|
---|
| 497 | #define YYRHSLOC(Rhs, K) ((Rhs)[K].yystate.yyloc)
|
---|
| 498 | #ifndef YYLLOC_DEFAULT
|
---|
| 499 | # define YYLLOC_DEFAULT(Current, Rhs, N) \
|
---|
| 500 | do \
|
---|
| 501 | if (YYID (N)) \
|
---|
| 502 | { \
|
---|
| 503 | (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
|
---|
| 504 | (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
|
---|
| 505 | (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
|
---|
| 506 | (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
|
---|
| 507 | } \
|
---|
| 508 | else \
|
---|
| 509 | { \
|
---|
| 510 | (Current).first_line = (Current).last_line = \
|
---|
| 511 | YYRHSLOC (Rhs, 0).last_line; \
|
---|
| 512 | (Current).first_column = (Current).last_column = \
|
---|
| 513 | YYRHSLOC (Rhs, 0).last_column; \
|
---|
| 514 | } \
|
---|
| 515 | while (YYID (0))
|
---|
| 516 |
|
---|
| 517 | /* YY_LOCATION_PRINT -- Print the location on the stream.
|
---|
| 518 | This macro was not mandated originally: define only if we know
|
---|
| 519 | we won't break user code: when these are the locations we know. */
|
---|
| 520 |
|
---|
| 521 | # define YY_LOCATION_PRINT(File, Loc) \
|
---|
| 522 | fprintf (File, "%d.%d-%d.%d", \
|
---|
| 523 | (Loc).first_line, (Loc).first_column, \
|
---|
| 524 | (Loc).last_line, (Loc).last_column)
|
---|
| 525 | #endif
|
---|
| 526 | ]],[
|
---|
| 527 | #ifndef YYLLOC_DEFAULT
|
---|
| 528 | # define YYLLOC_DEFAULT(Current, Rhs, N) ((void) 0)
|
---|
| 529 | #endif
|
---|
| 530 | ])[
|
---|
| 531 |
|
---|
| 532 | #ifndef YY_LOCATION_PRINT
|
---|
| 533 | # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
|
---|
| 534 | #endif
|
---|
| 535 |
|
---|
| 536 |
|
---|
| 537 | /* YYLEX -- calling `yylex' with the right arguments. */
|
---|
| 538 | #define YYLEX ]b4_c_function_call([yylex], [int], b4_lex_param)[
|
---|
| 539 |
|
---|
| 540 | ]b4_pure_if(
|
---|
| 541 | [
|
---|
| 542 | #undef yynerrs
|
---|
| 543 | #define yynerrs (yystackp->yyerrcnt)
|
---|
| 544 | #undef yychar
|
---|
| 545 | #define yychar (yystackp->yyrawchar)
|
---|
| 546 | #undef yylval
|
---|
| 547 | #define yylval (yystackp->yyval)
|
---|
| 548 | #undef yylloc
|
---|
| 549 | #define yylloc (yystackp->yyloc)
|
---|
| 550 | m4_if(b4_prefix[], [yy], [],
|
---|
| 551 | [#define b4_prefix[]nerrs yynerrs
|
---|
| 552 | #define b4_prefix[]char yychar
|
---|
| 553 | #define b4_prefix[]lval yylval
|
---|
| 554 | #define b4_prefix[]lloc yylloc])],
|
---|
| 555 | [YYSTYPE yylval;
|
---|
| 556 |
|
---|
| 557 | YYLTYPE yylloc;
|
---|
| 558 |
|
---|
| 559 | int yynerrs;
|
---|
| 560 | int yychar;])[
|
---|
| 561 |
|
---|
| 562 | static const int YYEOF = 0;
|
---|
| 563 | static const int YYEMPTY = -2;
|
---|
| 564 |
|
---|
| 565 | typedef enum { yyok, yyaccept, yyabort, yyerr } YYRESULTTAG;
|
---|
| 566 |
|
---|
| 567 | #define YYCHK(YYE) \
|
---|
| 568 | do { YYRESULTTAG yyflag = YYE; if (yyflag != yyok) return yyflag; } \
|
---|
| 569 | while (YYID (0))
|
---|
| 570 |
|
---|
| 571 | #if YYDEBUG
|
---|
| 572 |
|
---|
| 573 | # ifndef YYFPRINTF
|
---|
| 574 | # define YYFPRINTF fprintf
|
---|
| 575 | # endif
|
---|
| 576 |
|
---|
| 577 | # define YYDPRINTF(Args) \
|
---|
| 578 | do { \
|
---|
| 579 | if (yydebug) \
|
---|
| 580 | YYFPRINTF Args; \
|
---|
| 581 | } while (YYID (0))
|
---|
| 582 |
|
---|
| 583 | ]b4_yy_symbol_print_generate([b4_c_ansi_function_def])[
|
---|
| 584 |
|
---|
| 585 | # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
|
---|
| 586 | do { \
|
---|
| 587 | if (yydebug) \
|
---|
| 588 | { \
|
---|
| 589 | YYFPRINTF (stderr, "%s ", Title); \
|
---|
| 590 | yy_symbol_print (stderr, Type, \
|
---|
| 591 | Value]b4_locations_if([, Location])[]b4_user_args[); \
|
---|
| 592 | YYFPRINTF (stderr, "\n"); \
|
---|
| 593 | } \
|
---|
| 594 | } while (YYID (0))
|
---|
| 595 |
|
---|
| 596 | /* Nonzero means print parse trace. It is left uninitialized so that
|
---|
| 597 | multiple parsers can coexist. */
|
---|
| 598 | int yydebug;
|
---|
| 599 |
|
---|
| 600 | #else /* !YYDEBUG */
|
---|
| 601 |
|
---|
| 602 | # define YYDPRINTF(Args)
|
---|
| 603 | # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
|
---|
| 604 |
|
---|
| 605 | #endif /* !YYDEBUG */
|
---|
| 606 |
|
---|
| 607 | /* YYINITDEPTH -- initial size of the parser's stacks. */
|
---|
| 608 | #ifndef YYINITDEPTH
|
---|
| 609 | # define YYINITDEPTH ]b4_stack_depth_init[
|
---|
| 610 | #endif
|
---|
| 611 |
|
---|
| 612 | /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
|
---|
| 613 | if the built-in stack extension method is used).
|
---|
| 614 |
|
---|
| 615 | Do not make this value too large; the results are undefined if
|
---|
| 616 | SIZE_MAX < YYMAXDEPTH * sizeof (GLRStackItem)
|
---|
| 617 | evaluated with infinite-precision integer arithmetic. */
|
---|
| 618 |
|
---|
| 619 | #ifndef YYMAXDEPTH
|
---|
| 620 | # define YYMAXDEPTH ]b4_stack_depth_max[
|
---|
| 621 | #endif
|
---|
| 622 |
|
---|
| 623 | /* Minimum number of free items on the stack allowed after an
|
---|
| 624 | allocation. This is to allow allocation and initialization
|
---|
| 625 | to be completed by functions that call yyexpandGLRStack before the
|
---|
| 626 | stack is expanded, thus insuring that all necessary pointers get
|
---|
| 627 | properly redirected to new data. */
|
---|
| 628 | #define YYHEADROOM 2
|
---|
| 629 |
|
---|
| 630 | #ifndef YYSTACKEXPANDABLE
|
---|
| 631 | # if (! defined __cplusplus \
|
---|
| 632 | || (]b4_locations_if([[defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL \
|
---|
| 633 | && ]])[defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))
|
---|
| 634 | # define YYSTACKEXPANDABLE 1
|
---|
| 635 | # else
|
---|
| 636 | # define YYSTACKEXPANDABLE 0
|
---|
| 637 | # endif
|
---|
| 638 | #endif
|
---|
| 639 |
|
---|
| 640 | #if YYSTACKEXPANDABLE
|
---|
| 641 | # define YY_RESERVE_GLRSTACK(Yystack) \
|
---|
| 642 | do { \
|
---|
| 643 | if (Yystack->yyspaceLeft < YYHEADROOM) \
|
---|
| 644 | yyexpandGLRStack (Yystack); \
|
---|
| 645 | } while (YYID (0))
|
---|
| 646 | #else
|
---|
| 647 | # define YY_RESERVE_GLRSTACK(Yystack) \
|
---|
| 648 | do { \
|
---|
| 649 | if (Yystack->yyspaceLeft < YYHEADROOM) \
|
---|
| 650 | yyMemoryExhausted (Yystack); \
|
---|
| 651 | } while (YYID (0))
|
---|
| 652 | #endif
|
---|
| 653 |
|
---|
| 654 |
|
---|
| 655 | #if YYERROR_VERBOSE
|
---|
| 656 |
|
---|
| 657 | # ifndef yystpcpy
|
---|
| 658 | # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
|
---|
| 659 | # define yystpcpy stpcpy
|
---|
| 660 | # else
|
---|
| 661 | /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
|
---|
| 662 | YYDEST. */
|
---|
| 663 | static char *
|
---|
| 664 | yystpcpy (char *yydest, const char *yysrc)
|
---|
| 665 | {
|
---|
| 666 | char *yyd = yydest;
|
---|
| 667 | const char *yys = yysrc;
|
---|
| 668 |
|
---|
| 669 | while ((*yyd++ = *yys++) != '\0')
|
---|
| 670 | continue;
|
---|
| 671 |
|
---|
| 672 | return yyd - 1;
|
---|
| 673 | }
|
---|
| 674 | # endif
|
---|
| 675 | # endif
|
---|
| 676 |
|
---|
| 677 | # ifndef yytnamerr
|
---|
| 678 | /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
|
---|
| 679 | quotes and backslashes, so that it's suitable for yyerror. The
|
---|
| 680 | heuristic is that double-quoting is unnecessary unless the string
|
---|
| 681 | contains an apostrophe, a comma, or backslash (other than
|
---|
| 682 | backslash-backslash). YYSTR is taken from yytname. If YYRES is
|
---|
| 683 | null, do not copy; instead, return the length of what the result
|
---|
| 684 | would have been. */
|
---|
| 685 | static size_t
|
---|
| 686 | yytnamerr (char *yyres, const char *yystr)
|
---|
| 687 | {
|
---|
| 688 | if (*yystr == '"')
|
---|
| 689 | {
|
---|
| 690 | size_t yyn = 0;
|
---|
| 691 | char const *yyp = yystr;
|
---|
| 692 |
|
---|
| 693 | for (;;)
|
---|
| 694 | switch (*++yyp)
|
---|
| 695 | {
|
---|
| 696 | case '\'':
|
---|
| 697 | case ',':
|
---|
| 698 | goto do_not_strip_quotes;
|
---|
| 699 |
|
---|
| 700 | case '\\':
|
---|
| 701 | if (*++yyp != '\\')
|
---|
| 702 | goto do_not_strip_quotes;
|
---|
| 703 | /* Fall through. */
|
---|
| 704 | default:
|
---|
| 705 | if (yyres)
|
---|
| 706 | yyres[yyn] = *yyp;
|
---|
| 707 | yyn++;
|
---|
| 708 | break;
|
---|
| 709 |
|
---|
| 710 | case '"':
|
---|
| 711 | if (yyres)
|
---|
| 712 | yyres[yyn] = '\0';
|
---|
| 713 | return yyn;
|
---|
| 714 | }
|
---|
| 715 | do_not_strip_quotes: ;
|
---|
| 716 | }
|
---|
| 717 |
|
---|
| 718 | if (! yyres)
|
---|
| 719 | return strlen (yystr);
|
---|
| 720 |
|
---|
| 721 | return yystpcpy (yyres, yystr) - yyres;
|
---|
| 722 | }
|
---|
| 723 | # endif
|
---|
| 724 |
|
---|
| 725 | #endif /* !YYERROR_VERBOSE */
|
---|
| 726 |
|
---|
| 727 | /** State numbers, as in LALR(1) machine */
|
---|
| 728 | typedef int yyStateNum;
|
---|
| 729 |
|
---|
| 730 | /** Rule numbers, as in LALR(1) machine */
|
---|
| 731 | typedef int yyRuleNum;
|
---|
| 732 |
|
---|
| 733 | /** Grammar symbol */
|
---|
| 734 | typedef short int yySymbol;
|
---|
| 735 |
|
---|
| 736 | /** Item references, as in LALR(1) machine */
|
---|
| 737 | typedef short int yyItemNum;
|
---|
| 738 |
|
---|
| 739 | typedef struct yyGLRState yyGLRState;
|
---|
| 740 | typedef struct yyGLRStateSet yyGLRStateSet;
|
---|
| 741 | typedef struct yySemanticOption yySemanticOption;
|
---|
| 742 | typedef union yyGLRStackItem yyGLRStackItem;
|
---|
| 743 | typedef struct yyGLRStack yyGLRStack;
|
---|
| 744 |
|
---|
| 745 | struct yyGLRState {
|
---|
| 746 | /** Type tag: always true. */
|
---|
| 747 | yybool yyisState;
|
---|
| 748 | /** Type tag for yysemantics. If true, yysval applies, otherwise
|
---|
| 749 | * yyfirstVal applies. */
|
---|
| 750 | yybool yyresolved;
|
---|
| 751 | /** Number of corresponding LALR(1) machine state. */
|
---|
| 752 | yyStateNum yylrState;
|
---|
| 753 | /** Preceding state in this stack */
|
---|
| 754 | yyGLRState* yypred;
|
---|
| 755 | /** Source position of the first token produced by my symbol */
|
---|
| 756 | size_t yyposn;
|
---|
| 757 | union {
|
---|
| 758 | /** First in a chain of alternative reductions producing the
|
---|
| 759 | * non-terminal corresponding to this state, threaded through
|
---|
| 760 | * yynext. */
|
---|
| 761 | yySemanticOption* yyfirstVal;
|
---|
| 762 | /** Semantic value for this state. */
|
---|
| 763 | YYSTYPE yysval;
|
---|
| 764 | } yysemantics;
|
---|
| 765 | /** Source location for this state. */
|
---|
| 766 | YYLTYPE yyloc;
|
---|
| 767 | };
|
---|
| 768 |
|
---|
| 769 | struct yyGLRStateSet {
|
---|
| 770 | yyGLRState** yystates;
|
---|
| 771 | /** During nondeterministic operation, yylookaheadNeeds tracks which
|
---|
| 772 | * stacks have actually needed the current lookahead. During deterministic
|
---|
| 773 | * operation, yylookaheadNeeds[0] is not maintained since it would merely
|
---|
| 774 | * duplicate yychar != YYEMPTY. */
|
---|
| 775 | yybool* yylookaheadNeeds;
|
---|
| 776 | size_t yysize, yycapacity;
|
---|
| 777 | };
|
---|
| 778 |
|
---|
| 779 | struct yySemanticOption {
|
---|
| 780 | /** Type tag: always false. */
|
---|
| 781 | yybool yyisState;
|
---|
| 782 | /** Rule number for this reduction */
|
---|
| 783 | yyRuleNum yyrule;
|
---|
| 784 | /** The last RHS state in the list of states to be reduced. */
|
---|
| 785 | yyGLRState* yystate;
|
---|
| 786 | /** The lookahead for this reduction. */
|
---|
| 787 | int yyrawchar;
|
---|
| 788 | YYSTYPE yyval;
|
---|
| 789 | YYLTYPE yyloc;
|
---|
| 790 | /** Next sibling in chain of options. To facilitate merging,
|
---|
| 791 | * options are chained in decreasing order by address. */
|
---|
| 792 | yySemanticOption* yynext;
|
---|
| 793 | };
|
---|
| 794 |
|
---|
| 795 | /** Type of the items in the GLR stack. The yyisState field
|
---|
| 796 | * indicates which item of the union is valid. */
|
---|
| 797 | union yyGLRStackItem {
|
---|
| 798 | yyGLRState yystate;
|
---|
| 799 | yySemanticOption yyoption;
|
---|
| 800 | };
|
---|
| 801 |
|
---|
| 802 | struct yyGLRStack {
|
---|
| 803 | int yyerrState;
|
---|
| 804 | ]b4_locations_if([[ /* To compute the location of the error token. */
|
---|
| 805 | yyGLRStackItem yyerror_range[3];]])[
|
---|
| 806 | ]b4_pure_if(
|
---|
| 807 | [
|
---|
| 808 | int yyerrcnt;
|
---|
| 809 | int yyrawchar;
|
---|
| 810 | YYSTYPE yyval;
|
---|
| 811 | YYLTYPE yyloc;
|
---|
| 812 | ])[
|
---|
| 813 | YYJMP_BUF yyexception_buffer;
|
---|
| 814 | yyGLRStackItem* yyitems;
|
---|
| 815 | yyGLRStackItem* yynextFree;
|
---|
| 816 | size_t yyspaceLeft;
|
---|
| 817 | yyGLRState* yysplitPoint;
|
---|
| 818 | yyGLRState* yylastDeleted;
|
---|
| 819 | yyGLRStateSet yytops;
|
---|
| 820 | };
|
---|
| 821 |
|
---|
| 822 | #if YYSTACKEXPANDABLE
|
---|
| 823 | static void yyexpandGLRStack (yyGLRStack* yystackp);
|
---|
| 824 | #endif
|
---|
| 825 |
|
---|
| 826 | static void yyFail (yyGLRStack* yystackp]b4_pure_formals[, const char* yymsg)
|
---|
| 827 | __attribute__ ((__noreturn__));
|
---|
| 828 | static void
|
---|
| 829 | yyFail (yyGLRStack* yystackp]b4_pure_formals[, const char* yymsg)
|
---|
| 830 | {
|
---|
| 831 | if (yymsg != NULL)
|
---|
| 832 | yyerror (]b4_yyerror_args[yymsg);
|
---|
| 833 | YYLONGJMP (yystackp->yyexception_buffer, 1);
|
---|
| 834 | }
|
---|
| 835 |
|
---|
| 836 | static void yyMemoryExhausted (yyGLRStack* yystackp)
|
---|
| 837 | __attribute__ ((__noreturn__));
|
---|
| 838 | static void
|
---|
| 839 | yyMemoryExhausted (yyGLRStack* yystackp)
|
---|
| 840 | {
|
---|
| 841 | YYLONGJMP (yystackp->yyexception_buffer, 2);
|
---|
| 842 | }
|
---|
| 843 |
|
---|
| 844 | #if YYDEBUG || YYERROR_VERBOSE
|
---|
| 845 | /** A printable representation of TOKEN. */
|
---|
| 846 | static inline const char*
|
---|
| 847 | yytokenName (yySymbol yytoken)
|
---|
| 848 | {
|
---|
| 849 | if (yytoken == YYEMPTY)
|
---|
| 850 | return "";
|
---|
| 851 |
|
---|
| 852 | return yytname[yytoken];
|
---|
| 853 | }
|
---|
| 854 | #endif
|
---|
| 855 |
|
---|
| 856 | /** Fill in YYVSP[YYLOW1 .. YYLOW0-1] from the chain of states starting
|
---|
| 857 | * at YYVSP[YYLOW0].yystate.yypred. Leaves YYVSP[YYLOW1].yystate.yypred
|
---|
| 858 | * containing the pointer to the next state in the chain. */
|
---|
| 859 | static void yyfillin (yyGLRStackItem *, int, int) __attribute__ ((__unused__));
|
---|
| 860 | static void
|
---|
| 861 | yyfillin (yyGLRStackItem *yyvsp, int yylow0, int yylow1)
|
---|
| 862 | {
|
---|
| 863 | yyGLRState* s;
|
---|
| 864 | int i;
|
---|
| 865 | s = yyvsp[yylow0].yystate.yypred;
|
---|
| 866 | for (i = yylow0-1; i >= yylow1; i -= 1)
|
---|
| 867 | {
|
---|
| 868 | YYASSERT (s->yyresolved);
|
---|
| 869 | yyvsp[i].yystate.yyresolved = yytrue;
|
---|
| 870 | yyvsp[i].yystate.yysemantics.yysval = s->yysemantics.yysval;
|
---|
| 871 | yyvsp[i].yystate.yyloc = s->yyloc;
|
---|
| 872 | s = yyvsp[i].yystate.yypred = s->yypred;
|
---|
| 873 | }
|
---|
| 874 | }
|
---|
| 875 |
|
---|
| 876 | /* Do nothing if YYNORMAL or if *YYLOW <= YYLOW1. Otherwise, fill in
|
---|
| 877 | * YYVSP[YYLOW1 .. *YYLOW-1] as in yyfillin and set *YYLOW = YYLOW1.
|
---|
| 878 | * For convenience, always return YYLOW1. */
|
---|
| 879 | static inline int yyfill (yyGLRStackItem *, int *, int, yybool)
|
---|
| 880 | __attribute__ ((__unused__));
|
---|
| 881 | static inline int
|
---|
| 882 | yyfill (yyGLRStackItem *yyvsp, int *yylow, int yylow1, yybool yynormal)
|
---|
| 883 | {
|
---|
| 884 | if (!yynormal && yylow1 < *yylow)
|
---|
| 885 | {
|
---|
| 886 | yyfillin (yyvsp, *yylow, yylow1);
|
---|
| 887 | *yylow = yylow1;
|
---|
| 888 | }
|
---|
| 889 | return yylow1;
|
---|
| 890 | }
|
---|
| 891 |
|
---|
| 892 | /** Perform user action for rule number YYN, with RHS length YYRHSLEN,
|
---|
| 893 | * and top stack item YYVSP. YYLVALP points to place to put semantic
|
---|
| 894 | * value ($$), and yylocp points to place for location information
|
---|
| 895 | * (@@$). Returns yyok for normal return, yyaccept for YYACCEPT,
|
---|
| 896 | * yyerr for YYERROR, yyabort for YYABORT. */
|
---|
| 897 | /*ARGSUSED*/ static YYRESULTTAG
|
---|
| 898 | yyuserAction (yyRuleNum yyn, int yyrhslen, yyGLRStackItem* yyvsp,
|
---|
| 899 | YYSTYPE* yyvalp,
|
---|
| 900 | YYLTYPE* YYOPTIONAL_LOC (yylocp),
|
---|
| 901 | yyGLRStack* yystackp
|
---|
| 902 | ]b4_user_formals[)
|
---|
| 903 | {
|
---|
| 904 | yybool yynormal __attribute__ ((__unused__)) =
|
---|
| 905 | (yystackp->yysplitPoint == NULL);
|
---|
| 906 | int yylow;
|
---|
| 907 | ]b4_parse_param_use[]dnl
|
---|
| 908 | [# undef yyerrok
|
---|
| 909 | # define yyerrok (yystackp->yyerrState = 0)
|
---|
| 910 | # undef YYACCEPT
|
---|
| 911 | # define YYACCEPT return yyaccept
|
---|
| 912 | # undef YYABORT
|
---|
| 913 | # define YYABORT return yyabort
|
---|
| 914 | # undef YYERROR
|
---|
| 915 | # define YYERROR return yyerrok, yyerr
|
---|
| 916 | # undef YYRECOVERING
|
---|
| 917 | # define YYRECOVERING() (yystackp->yyerrState != 0)
|
---|
| 918 | # undef yyclearin
|
---|
| 919 | # define yyclearin (yychar = YYEMPTY)
|
---|
| 920 | # undef YYFILL
|
---|
| 921 | # define YYFILL(N) yyfill (yyvsp, &yylow, N, yynormal)
|
---|
| 922 | # undef YYBACKUP
|
---|
| 923 | # define YYBACKUP(Token, Value) \
|
---|
| 924 | return yyerror (]b4_yyerror_args[YY_("syntax error: cannot back up")), \
|
---|
| 925 | yyerrok, yyerr
|
---|
| 926 |
|
---|
| 927 | yylow = 1;
|
---|
| 928 | if (yyrhslen == 0)
|
---|
| 929 | *yyvalp = yyval_default;
|
---|
| 930 | else
|
---|
| 931 | *yyvalp = yyvsp[YYFILL (1-yyrhslen)].yystate.yysemantics.yysval;
|
---|
| 932 | YYLLOC_DEFAULT ((*yylocp), (yyvsp - yyrhslen), yyrhslen);
|
---|
| 933 | ]b4_locations_if([[ yystackp->yyerror_range[1].yystate.yyloc = *yylocp;
|
---|
| 934 | ]])[
|
---|
| 935 | switch (yyn)
|
---|
| 936 | {
|
---|
| 937 | ]b4_user_actions[
|
---|
| 938 | default: break;
|
---|
| 939 | }
|
---|
| 940 |
|
---|
| 941 | return yyok;
|
---|
| 942 | # undef yyerrok
|
---|
| 943 | # undef YYABORT
|
---|
| 944 | # undef YYACCEPT
|
---|
| 945 | # undef YYERROR
|
---|
| 946 | # undef YYBACKUP
|
---|
| 947 | # undef yyclearin
|
---|
| 948 | # undef YYRECOVERING
|
---|
| 949 | }
|
---|
| 950 | |
---|
| 951 |
|
---|
| 952 |
|
---|
| 953 | /*ARGSUSED*/ static void
|
---|
| 954 | yyuserMerge (int yyn, YYSTYPE* yy0, YYSTYPE* yy1)
|
---|
| 955 | {
|
---|
| 956 | YYUSE (yy0);
|
---|
| 957 | YYUSE (yy1);
|
---|
| 958 |
|
---|
| 959 | switch (yyn)
|
---|
| 960 | {
|
---|
| 961 | ]b4_mergers[
|
---|
| 962 | default: break;
|
---|
| 963 | }
|
---|
| 964 | }
|
---|
| 965 |
|
---|
| 966 | /* Bison grammar-table manipulation. */
|
---|
| 967 |
|
---|
| 968 | ]b4_yydestruct_generate([b4_c_ansi_function_def])[
|
---|
| 969 |
|
---|
| 970 | /** Number of symbols composing the right hand side of rule #RULE. */
|
---|
| 971 | static inline int
|
---|
| 972 | yyrhsLength (yyRuleNum yyrule)
|
---|
| 973 | {
|
---|
| 974 | return yyr2[yyrule];
|
---|
| 975 | }
|
---|
| 976 |
|
---|
| 977 | static void
|
---|
| 978 | yydestroyGLRState (char const *yymsg, yyGLRState *yys]b4_user_formals[)
|
---|
| 979 | {
|
---|
| 980 | if (yys->yyresolved)
|
---|
| 981 | yydestruct (yymsg, yystos[yys->yylrState],
|
---|
| 982 | &yys->yysemantics.yysval]b4_locations_if([, &yys->yyloc])[]b4_user_args[);
|
---|
| 983 | else
|
---|
| 984 | {
|
---|
| 985 | #if YYDEBUG
|
---|
| 986 | if (yydebug)
|
---|
| 987 | {
|
---|
| 988 | if (yys->yysemantics.yyfirstVal)
|
---|
| 989 | YYFPRINTF (stderr, "%s unresolved ", yymsg);
|
---|
| 990 | else
|
---|
| 991 | YYFPRINTF (stderr, "%s incomplete ", yymsg);
|
---|
| 992 | yy_symbol_print (stderr, yystos[yys->yylrState],
|
---|
| 993 | NULL]b4_locations_if([, &yys->yyloc])[]b4_user_args[);
|
---|
| 994 | YYFPRINTF (stderr, "\n");
|
---|
| 995 | }
|
---|
| 996 | #endif
|
---|
| 997 |
|
---|
| 998 | if (yys->yysemantics.yyfirstVal)
|
---|
| 999 | {
|
---|
| 1000 | yySemanticOption *yyoption = yys->yysemantics.yyfirstVal;
|
---|
| 1001 | yyGLRState *yyrh;
|
---|
| 1002 | int yyn;
|
---|
| 1003 | for (yyrh = yyoption->yystate, yyn = yyrhsLength (yyoption->yyrule);
|
---|
| 1004 | yyn > 0;
|
---|
| 1005 | yyrh = yyrh->yypred, yyn -= 1)
|
---|
| 1006 | yydestroyGLRState (yymsg, yyrh]b4_user_args[);
|
---|
| 1007 | }
|
---|
| 1008 | }
|
---|
| 1009 | }
|
---|
| 1010 |
|
---|
| 1011 | /** Left-hand-side symbol for rule #RULE. */
|
---|
| 1012 | static inline yySymbol
|
---|
| 1013 | yylhsNonterm (yyRuleNum yyrule)
|
---|
| 1014 | {
|
---|
| 1015 | return yyr1[yyrule];
|
---|
| 1016 | }
|
---|
| 1017 |
|
---|
| 1018 | #define yyis_pact_ninf(yystate) \
|
---|
| 1019 | ]m4_if(m4_eval(b4_pact_ninf < b4_pact_min), [1],
|
---|
| 1020 | [0],
|
---|
| 1021 | [((yystate) == YYPACT_NINF)])[
|
---|
| 1022 |
|
---|
| 1023 | /** True iff LR state STATE has only a default reduction (regardless
|
---|
| 1024 | * of token). */
|
---|
| 1025 | static inline yybool
|
---|
| 1026 | yyisDefaultedState (yyStateNum yystate)
|
---|
| 1027 | {
|
---|
| 1028 | return yyis_pact_ninf (yypact[yystate]);
|
---|
| 1029 | }
|
---|
| 1030 |
|
---|
| 1031 | /** The default reduction for STATE, assuming it has one. */
|
---|
| 1032 | static inline yyRuleNum
|
---|
| 1033 | yydefaultAction (yyStateNum yystate)
|
---|
| 1034 | {
|
---|
| 1035 | return yydefact[yystate];
|
---|
| 1036 | }
|
---|
| 1037 |
|
---|
| 1038 | #define yyis_table_ninf(yytable_value) \
|
---|
| 1039 | ]m4_if(m4_eval(b4_table_ninf < b4_table_min), [1],
|
---|
| 1040 | [YYID (0)],
|
---|
| 1041 | [((yytable_value) == YYTABLE_NINF)])[
|
---|
| 1042 |
|
---|
| 1043 | /** Set *YYACTION to the action to take in YYSTATE on seeing YYTOKEN.
|
---|
| 1044 | * Result R means
|
---|
| 1045 | * R < 0: Reduce on rule -R.
|
---|
| 1046 | * R = 0: Error.
|
---|
| 1047 | * R > 0: Shift to state R.
|
---|
| 1048 | * Set *CONFLICTS to a pointer into yyconfl to 0-terminated list of
|
---|
| 1049 | * conflicting reductions.
|
---|
| 1050 | */
|
---|
| 1051 | static inline void
|
---|
| 1052 | yygetLRActions (yyStateNum yystate, int yytoken,
|
---|
| 1053 | int* yyaction, const short int** yyconflicts)
|
---|
| 1054 | {
|
---|
| 1055 | int yyindex = yypact[yystate] + yytoken;
|
---|
| 1056 | if (yyindex < 0 || YYLAST < yyindex || yycheck[yyindex] != yytoken)
|
---|
| 1057 | {
|
---|
| 1058 | *yyaction = -yydefact[yystate];
|
---|
| 1059 | *yyconflicts = yyconfl;
|
---|
| 1060 | }
|
---|
| 1061 | else if (! yyis_table_ninf (yytable[yyindex]))
|
---|
| 1062 | {
|
---|
| 1063 | *yyaction = yytable[yyindex];
|
---|
| 1064 | *yyconflicts = yyconfl + yyconflp[yyindex];
|
---|
| 1065 | }
|
---|
| 1066 | else
|
---|
| 1067 | {
|
---|
| 1068 | *yyaction = 0;
|
---|
| 1069 | *yyconflicts = yyconfl + yyconflp[yyindex];
|
---|
| 1070 | }
|
---|
| 1071 | }
|
---|
| 1072 |
|
---|
| 1073 | static inline yyStateNum
|
---|
| 1074 | yyLRgotoState (yyStateNum yystate, yySymbol yylhs)
|
---|
| 1075 | {
|
---|
| 1076 | int yyr;
|
---|
| 1077 | yyr = yypgoto[yylhs - YYNTOKENS] + yystate;
|
---|
| 1078 | if (0 <= yyr && yyr <= YYLAST && yycheck[yyr] == yystate)
|
---|
| 1079 | return yytable[yyr];
|
---|
| 1080 | else
|
---|
| 1081 | return yydefgoto[yylhs - YYNTOKENS];
|
---|
| 1082 | }
|
---|
| 1083 |
|
---|
| 1084 | static inline yybool
|
---|
| 1085 | yyisShiftAction (int yyaction)
|
---|
| 1086 | {
|
---|
| 1087 | return 0 < yyaction;
|
---|
| 1088 | }
|
---|
| 1089 |
|
---|
| 1090 | static inline yybool
|
---|
| 1091 | yyisErrorAction (int yyaction)
|
---|
| 1092 | {
|
---|
| 1093 | return yyaction == 0;
|
---|
| 1094 | }
|
---|
| 1095 |
|
---|
| 1096 | /* GLRStates */
|
---|
| 1097 |
|
---|
| 1098 | /** Return a fresh GLRStackItem. Callers should call
|
---|
| 1099 | * YY_RESERVE_GLRSTACK afterwards to make sure there is sufficient
|
---|
| 1100 | * headroom. */
|
---|
| 1101 |
|
---|
| 1102 | static inline yyGLRStackItem*
|
---|
| 1103 | yynewGLRStackItem (yyGLRStack* yystackp, yybool yyisState)
|
---|
| 1104 | {
|
---|
| 1105 | yyGLRStackItem* yynewItem = yystackp->yynextFree;
|
---|
| 1106 | yystackp->yyspaceLeft -= 1;
|
---|
| 1107 | yystackp->yynextFree += 1;
|
---|
| 1108 | yynewItem->yystate.yyisState = yyisState;
|
---|
| 1109 | return yynewItem;
|
---|
| 1110 | }
|
---|
| 1111 |
|
---|
| 1112 | /** Add a new semantic action that will execute the action for rule
|
---|
| 1113 | * RULENUM on the semantic values in RHS to the list of
|
---|
| 1114 | * alternative actions for STATE. Assumes that RHS comes from
|
---|
| 1115 | * stack #K of *STACKP. */
|
---|
| 1116 | static void
|
---|
| 1117 | yyaddDeferredAction (yyGLRStack* yystackp, size_t yyk, yyGLRState* yystate,
|
---|
| 1118 | yyGLRState* rhs, yyRuleNum yyrule)
|
---|
| 1119 | {
|
---|
| 1120 | yySemanticOption* yynewOption =
|
---|
| 1121 | &yynewGLRStackItem (yystackp, yyfalse)->yyoption;
|
---|
| 1122 | yynewOption->yystate = rhs;
|
---|
| 1123 | yynewOption->yyrule = yyrule;
|
---|
| 1124 | if (yystackp->yytops.yylookaheadNeeds[yyk])
|
---|
| 1125 | {
|
---|
| 1126 | yynewOption->yyrawchar = yychar;
|
---|
| 1127 | yynewOption->yyval = yylval;
|
---|
| 1128 | yynewOption->yyloc = yylloc;
|
---|
| 1129 | }
|
---|
| 1130 | else
|
---|
| 1131 | yynewOption->yyrawchar = YYEMPTY;
|
---|
| 1132 | yynewOption->yynext = yystate->yysemantics.yyfirstVal;
|
---|
| 1133 | yystate->yysemantics.yyfirstVal = yynewOption;
|
---|
| 1134 |
|
---|
| 1135 | YY_RESERVE_GLRSTACK (yystackp);
|
---|
| 1136 | }
|
---|
| 1137 |
|
---|
| 1138 | /* GLRStacks */
|
---|
| 1139 |
|
---|
| 1140 | /** Initialize SET to a singleton set containing an empty stack. */
|
---|
| 1141 | static yybool
|
---|
| 1142 | yyinitStateSet (yyGLRStateSet* yyset)
|
---|
| 1143 | {
|
---|
| 1144 | yyset->yysize = 1;
|
---|
| 1145 | yyset->yycapacity = 16;
|
---|
| 1146 | yyset->yystates = (yyGLRState**) YYMALLOC (16 * sizeof yyset->yystates[0]);
|
---|
| 1147 | if (! yyset->yystates)
|
---|
| 1148 | return yyfalse;
|
---|
| 1149 | yyset->yystates[0] = NULL;
|
---|
| 1150 | yyset->yylookaheadNeeds =
|
---|
| 1151 | (yybool*) YYMALLOC (16 * sizeof yyset->yylookaheadNeeds[0]);
|
---|
| 1152 | if (! yyset->yylookaheadNeeds)
|
---|
| 1153 | {
|
---|
| 1154 | YYFREE (yyset->yystates);
|
---|
| 1155 | return yyfalse;
|
---|
| 1156 | }
|
---|
| 1157 | return yytrue;
|
---|
| 1158 | }
|
---|
| 1159 |
|
---|
| 1160 | static void yyfreeStateSet (yyGLRStateSet* yyset)
|
---|
| 1161 | {
|
---|
| 1162 | YYFREE (yyset->yystates);
|
---|
| 1163 | YYFREE (yyset->yylookaheadNeeds);
|
---|
| 1164 | }
|
---|
| 1165 |
|
---|
| 1166 | /** Initialize STACK to a single empty stack, with total maximum
|
---|
| 1167 | * capacity for all stacks of SIZE. */
|
---|
| 1168 | static yybool
|
---|
| 1169 | yyinitGLRStack (yyGLRStack* yystackp, size_t yysize)
|
---|
| 1170 | {
|
---|
| 1171 | yystackp->yyerrState = 0;
|
---|
| 1172 | yynerrs = 0;
|
---|
| 1173 | yystackp->yyspaceLeft = yysize;
|
---|
| 1174 | yystackp->yyitems =
|
---|
| 1175 | (yyGLRStackItem*) YYMALLOC (yysize * sizeof yystackp->yynextFree[0]);
|
---|
| 1176 | if (!yystackp->yyitems)
|
---|
| 1177 | return yyfalse;
|
---|
| 1178 | yystackp->yynextFree = yystackp->yyitems;
|
---|
| 1179 | yystackp->yysplitPoint = NULL;
|
---|
| 1180 | yystackp->yylastDeleted = NULL;
|
---|
| 1181 | return yyinitStateSet (&yystackp->yytops);
|
---|
| 1182 | }
|
---|
| 1183 |
|
---|
| 1184 |
|
---|
| 1185 | #if YYSTACKEXPANDABLE
|
---|
| 1186 | # define YYRELOC(YYFROMITEMS,YYTOITEMS,YYX,YYTYPE) \
|
---|
| 1187 | &((YYTOITEMS) - ((YYFROMITEMS) - (yyGLRStackItem*) (YYX)))->YYTYPE
|
---|
| 1188 |
|
---|
| 1189 | /** If STACK is expandable, extend it. WARNING: Pointers into the
|
---|
| 1190 | stack from outside should be considered invalid after this call.
|
---|
| 1191 | We always expand when there are 1 or fewer items left AFTER an
|
---|
| 1192 | allocation, so that we can avoid having external pointers exist
|
---|
| 1193 | across an allocation. */
|
---|
| 1194 | static void
|
---|
| 1195 | yyexpandGLRStack (yyGLRStack* yystackp)
|
---|
| 1196 | {
|
---|
| 1197 | yyGLRStackItem* yynewItems;
|
---|
| 1198 | yyGLRStackItem* yyp0, *yyp1;
|
---|
| 1199 | size_t yysize, yynewSize;
|
---|
| 1200 | size_t yyn;
|
---|
| 1201 | yysize = yystackp->yynextFree - yystackp->yyitems;
|
---|
| 1202 | if (YYMAXDEPTH - YYHEADROOM < yysize)
|
---|
| 1203 | yyMemoryExhausted (yystackp);
|
---|
| 1204 | yynewSize = 2*yysize;
|
---|
| 1205 | if (YYMAXDEPTH < yynewSize)
|
---|
| 1206 | yynewSize = YYMAXDEPTH;
|
---|
| 1207 | yynewItems = (yyGLRStackItem*) YYMALLOC (yynewSize * sizeof yynewItems[0]);
|
---|
| 1208 | if (! yynewItems)
|
---|
| 1209 | yyMemoryExhausted (yystackp);
|
---|
| 1210 | for (yyp0 = yystackp->yyitems, yyp1 = yynewItems, yyn = yysize;
|
---|
| 1211 | 0 < yyn;
|
---|
| 1212 | yyn -= 1, yyp0 += 1, yyp1 += 1)
|
---|
| 1213 | {
|
---|
| 1214 | *yyp1 = *yyp0;
|
---|
| 1215 | if (*(yybool *) yyp0)
|
---|
| 1216 | {
|
---|
| 1217 | yyGLRState* yys0 = &yyp0->yystate;
|
---|
| 1218 | yyGLRState* yys1 = &yyp1->yystate;
|
---|
| 1219 | if (yys0->yypred != NULL)
|
---|
| 1220 | yys1->yypred =
|
---|
| 1221 | YYRELOC (yyp0, yyp1, yys0->yypred, yystate);
|
---|
| 1222 | if (! yys0->yyresolved && yys0->yysemantics.yyfirstVal != NULL)
|
---|
| 1223 | yys1->yysemantics.yyfirstVal =
|
---|
| 1224 | YYRELOC(yyp0, yyp1, yys0->yysemantics.yyfirstVal, yyoption);
|
---|
| 1225 | }
|
---|
| 1226 | else
|
---|
| 1227 | {
|
---|
| 1228 | yySemanticOption* yyv0 = &yyp0->yyoption;
|
---|
| 1229 | yySemanticOption* yyv1 = &yyp1->yyoption;
|
---|
| 1230 | if (yyv0->yystate != NULL)
|
---|
| 1231 | yyv1->yystate = YYRELOC (yyp0, yyp1, yyv0->yystate, yystate);
|
---|
| 1232 | if (yyv0->yynext != NULL)
|
---|
| 1233 | yyv1->yynext = YYRELOC (yyp0, yyp1, yyv0->yynext, yyoption);
|
---|
| 1234 | }
|
---|
| 1235 | }
|
---|
| 1236 | if (yystackp->yysplitPoint != NULL)
|
---|
| 1237 | yystackp->yysplitPoint = YYRELOC (yystackp->yyitems, yynewItems,
|
---|
| 1238 | yystackp->yysplitPoint, yystate);
|
---|
| 1239 |
|
---|
| 1240 | for (yyn = 0; yyn < yystackp->yytops.yysize; yyn += 1)
|
---|
| 1241 | if (yystackp->yytops.yystates[yyn] != NULL)
|
---|
| 1242 | yystackp->yytops.yystates[yyn] =
|
---|
| 1243 | YYRELOC (yystackp->yyitems, yynewItems,
|
---|
| 1244 | yystackp->yytops.yystates[yyn], yystate);
|
---|
| 1245 | YYFREE (yystackp->yyitems);
|
---|
| 1246 | yystackp->yyitems = yynewItems;
|
---|
| 1247 | yystackp->yynextFree = yynewItems + yysize;
|
---|
| 1248 | yystackp->yyspaceLeft = yynewSize - yysize;
|
---|
| 1249 | }
|
---|
| 1250 | #endif
|
---|
| 1251 |
|
---|
| 1252 | static void
|
---|
| 1253 | yyfreeGLRStack (yyGLRStack* yystackp)
|
---|
| 1254 | {
|
---|
| 1255 | YYFREE (yystackp->yyitems);
|
---|
| 1256 | yyfreeStateSet (&yystackp->yytops);
|
---|
| 1257 | }
|
---|
| 1258 |
|
---|
| 1259 | /** Assuming that S is a GLRState somewhere on STACK, update the
|
---|
| 1260 | * splitpoint of STACK, if needed, so that it is at least as deep as
|
---|
| 1261 | * S. */
|
---|
| 1262 | static inline void
|
---|
| 1263 | yyupdateSplit (yyGLRStack* yystackp, yyGLRState* yys)
|
---|
| 1264 | {
|
---|
| 1265 | if (yystackp->yysplitPoint != NULL && yystackp->yysplitPoint > yys)
|
---|
| 1266 | yystackp->yysplitPoint = yys;
|
---|
| 1267 | }
|
---|
| 1268 |
|
---|
| 1269 | /** Invalidate stack #K in STACK. */
|
---|
| 1270 | static inline void
|
---|
| 1271 | yymarkStackDeleted (yyGLRStack* yystackp, size_t yyk)
|
---|
| 1272 | {
|
---|
| 1273 | if (yystackp->yytops.yystates[yyk] != NULL)
|
---|
| 1274 | yystackp->yylastDeleted = yystackp->yytops.yystates[yyk];
|
---|
| 1275 | yystackp->yytops.yystates[yyk] = NULL;
|
---|
| 1276 | }
|
---|
| 1277 |
|
---|
| 1278 | /** Undelete the last stack that was marked as deleted. Can only be
|
---|
| 1279 | done once after a deletion, and only when all other stacks have
|
---|
| 1280 | been deleted. */
|
---|
| 1281 | static void
|
---|
| 1282 | yyundeleteLastStack (yyGLRStack* yystackp)
|
---|
| 1283 | {
|
---|
| 1284 | if (yystackp->yylastDeleted == NULL || yystackp->yytops.yysize != 0)
|
---|
| 1285 | return;
|
---|
| 1286 | yystackp->yytops.yystates[0] = yystackp->yylastDeleted;
|
---|
| 1287 | yystackp->yytops.yysize = 1;
|
---|
| 1288 | YYDPRINTF ((stderr, "Restoring last deleted stack as stack #0.\n"));
|
---|
| 1289 | yystackp->yylastDeleted = NULL;
|
---|
| 1290 | }
|
---|
| 1291 |
|
---|
| 1292 | static inline void
|
---|
| 1293 | yyremoveDeletes (yyGLRStack* yystackp)
|
---|
| 1294 | {
|
---|
| 1295 | size_t yyi, yyj;
|
---|
| 1296 | yyi = yyj = 0;
|
---|
| 1297 | while (yyj < yystackp->yytops.yysize)
|
---|
| 1298 | {
|
---|
| 1299 | if (yystackp->yytops.yystates[yyi] == NULL)
|
---|
| 1300 | {
|
---|
| 1301 | if (yyi == yyj)
|
---|
| 1302 | {
|
---|
| 1303 | YYDPRINTF ((stderr, "Removing dead stacks.\n"));
|
---|
| 1304 | }
|
---|
| 1305 | yystackp->yytops.yysize -= 1;
|
---|
| 1306 | }
|
---|
| 1307 | else
|
---|
| 1308 | {
|
---|
| 1309 | yystackp->yytops.yystates[yyj] = yystackp->yytops.yystates[yyi];
|
---|
| 1310 | /* In the current implementation, it's unnecessary to copy
|
---|
| 1311 | yystackp->yytops.yylookaheadNeeds[yyi] since, after
|
---|
| 1312 | yyremoveDeletes returns, the parser immediately either enters
|
---|
| 1313 | deterministic operation or shifts a token. However, it doesn't
|
---|
| 1314 | hurt, and the code might evolve to need it. */
|
---|
| 1315 | yystackp->yytops.yylookaheadNeeds[yyj] =
|
---|
| 1316 | yystackp->yytops.yylookaheadNeeds[yyi];
|
---|
| 1317 | if (yyj != yyi)
|
---|
| 1318 | {
|
---|
| 1319 | YYDPRINTF ((stderr, "Rename stack %lu -> %lu.\n",
|
---|
| 1320 | (unsigned long int) yyi, (unsigned long int) yyj));
|
---|
| 1321 | }
|
---|
| 1322 | yyj += 1;
|
---|
| 1323 | }
|
---|
| 1324 | yyi += 1;
|
---|
| 1325 | }
|
---|
| 1326 | }
|
---|
| 1327 |
|
---|
| 1328 | /** Shift to a new state on stack #K of STACK, corresponding to LR state
|
---|
| 1329 | * LRSTATE, at input position POSN, with (resolved) semantic value SVAL. */
|
---|
| 1330 | static inline void
|
---|
| 1331 | yyglrShift (yyGLRStack* yystackp, size_t yyk, yyStateNum yylrState,
|
---|
| 1332 | size_t yyposn,
|
---|
| 1333 | YYSTYPE* yyvalp, YYLTYPE* yylocp)
|
---|
| 1334 | {
|
---|
| 1335 | yyGLRState* yynewState = &yynewGLRStackItem (yystackp, yytrue)->yystate;
|
---|
| 1336 |
|
---|
| 1337 | yynewState->yylrState = yylrState;
|
---|
| 1338 | yynewState->yyposn = yyposn;
|
---|
| 1339 | yynewState->yyresolved = yytrue;
|
---|
| 1340 | yynewState->yypred = yystackp->yytops.yystates[yyk];
|
---|
| 1341 | yynewState->yysemantics.yysval = *yyvalp;
|
---|
| 1342 | yynewState->yyloc = *yylocp;
|
---|
| 1343 | yystackp->yytops.yystates[yyk] = yynewState;
|
---|
| 1344 |
|
---|
| 1345 | YY_RESERVE_GLRSTACK (yystackp);
|
---|
| 1346 | }
|
---|
| 1347 |
|
---|
| 1348 | /** Shift stack #K of YYSTACK, to a new state corresponding to LR
|
---|
| 1349 | * state YYLRSTATE, at input position YYPOSN, with the (unresolved)
|
---|
| 1350 | * semantic value of YYRHS under the action for YYRULE. */
|
---|
| 1351 | static inline void
|
---|
| 1352 | yyglrShiftDefer (yyGLRStack* yystackp, size_t yyk, yyStateNum yylrState,
|
---|
| 1353 | size_t yyposn, yyGLRState* rhs, yyRuleNum yyrule)
|
---|
| 1354 | {
|
---|
| 1355 | yyGLRState* yynewState = &yynewGLRStackItem (yystackp, yytrue)->yystate;
|
---|
| 1356 |
|
---|
| 1357 | yynewState->yylrState = yylrState;
|
---|
| 1358 | yynewState->yyposn = yyposn;
|
---|
| 1359 | yynewState->yyresolved = yyfalse;
|
---|
| 1360 | yynewState->yypred = yystackp->yytops.yystates[yyk];
|
---|
| 1361 | yynewState->yysemantics.yyfirstVal = NULL;
|
---|
| 1362 | yystackp->yytops.yystates[yyk] = yynewState;
|
---|
| 1363 |
|
---|
| 1364 | /* Invokes YY_RESERVE_GLRSTACK. */
|
---|
| 1365 | yyaddDeferredAction (yystackp, yyk, yynewState, rhs, yyrule);
|
---|
| 1366 | }
|
---|
| 1367 |
|
---|
| 1368 | /** Pop the symbols consumed by reduction #RULE from the top of stack
|
---|
| 1369 | * #K of STACK, and perform the appropriate semantic action on their
|
---|
| 1370 | * semantic values. Assumes that all ambiguities in semantic values
|
---|
| 1371 | * have been previously resolved. Set *VALP to the resulting value,
|
---|
| 1372 | * and *LOCP to the computed location (if any). Return value is as
|
---|
| 1373 | * for userAction. */
|
---|
| 1374 | static inline YYRESULTTAG
|
---|
| 1375 | yydoAction (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule,
|
---|
| 1376 | YYSTYPE* yyvalp, YYLTYPE* yylocp]b4_user_formals[)
|
---|
| 1377 | {
|
---|
| 1378 | int yynrhs = yyrhsLength (yyrule);
|
---|
| 1379 |
|
---|
| 1380 | if (yystackp->yysplitPoint == NULL)
|
---|
| 1381 | {
|
---|
| 1382 | /* Standard special case: single stack. */
|
---|
| 1383 | yyGLRStackItem* rhs = (yyGLRStackItem*) yystackp->yytops.yystates[yyk];
|
---|
| 1384 | YYASSERT (yyk == 0);
|
---|
| 1385 | yystackp->yynextFree -= yynrhs;
|
---|
| 1386 | yystackp->yyspaceLeft += yynrhs;
|
---|
| 1387 | yystackp->yytops.yystates[0] = & yystackp->yynextFree[-1].yystate;
|
---|
| 1388 | return yyuserAction (yyrule, yynrhs, rhs,
|
---|
| 1389 | yyvalp, yylocp, yystackp]b4_user_args[);
|
---|
| 1390 | }
|
---|
| 1391 | else
|
---|
| 1392 | {
|
---|
| 1393 | /* At present, doAction is never called in nondeterministic
|
---|
| 1394 | * mode, so this branch is never taken. It is here in
|
---|
| 1395 | * anticipation of a future feature that will allow immediate
|
---|
| 1396 | * evaluation of selected actions in nondeterministic mode. */
|
---|
| 1397 | int yyi;
|
---|
| 1398 | yyGLRState* yys;
|
---|
| 1399 | yyGLRStackItem yyrhsVals[YYMAXRHS + YYMAXLEFT + 1];
|
---|
| 1400 | yys = yyrhsVals[YYMAXRHS + YYMAXLEFT].yystate.yypred
|
---|
| 1401 | = yystackp->yytops.yystates[yyk];]b4_locations_if([[
|
---|
| 1402 | if (yynrhs == 0)
|
---|
| 1403 | /* Set default location. */
|
---|
| 1404 | yyrhsVals[YYMAXRHS + YYMAXLEFT - 1].yystate.yyloc = yys->yyloc;]])[
|
---|
| 1405 | for (yyi = 0; yyi < yynrhs; yyi += 1)
|
---|
| 1406 | {
|
---|
| 1407 | yys = yys->yypred;
|
---|
| 1408 | YYASSERT (yys);
|
---|
| 1409 | }
|
---|
| 1410 | yyupdateSplit (yystackp, yys);
|
---|
| 1411 | yystackp->yytops.yystates[yyk] = yys;
|
---|
| 1412 | return yyuserAction (yyrule, yynrhs, yyrhsVals + YYMAXRHS + YYMAXLEFT - 1,
|
---|
| 1413 | yyvalp, yylocp, yystackp]b4_user_args[);
|
---|
| 1414 | }
|
---|
| 1415 | }
|
---|
| 1416 |
|
---|
| 1417 | #if !YYDEBUG
|
---|
| 1418 | # define YY_REDUCE_PRINT(Args)
|
---|
| 1419 | #else
|
---|
| 1420 | # define YY_REDUCE_PRINT(Args) \
|
---|
| 1421 | do { \
|
---|
| 1422 | if (yydebug) \
|
---|
| 1423 | yy_reduce_print Args; \
|
---|
| 1424 | } while (YYID (0))
|
---|
| 1425 |
|
---|
| 1426 | /*----------------------------------------------------------.
|
---|
| 1427 | | Report that the RULE is going to be reduced on stack #K. |
|
---|
| 1428 | `----------------------------------------------------------*/
|
---|
| 1429 |
|
---|
| 1430 | /*ARGSUSED*/ static inline void
|
---|
| 1431 | yy_reduce_print (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule,
|
---|
| 1432 | YYSTYPE* yyvalp, YYLTYPE* yylocp]b4_user_formals[)
|
---|
| 1433 | {
|
---|
| 1434 | int yynrhs = yyrhsLength (yyrule);
|
---|
| 1435 | yybool yynormal __attribute__ ((__unused__)) =
|
---|
| 1436 | (yystackp->yysplitPoint == NULL);
|
---|
| 1437 | yyGLRStackItem* yyvsp = (yyGLRStackItem*) yystackp->yytops.yystates[yyk];
|
---|
| 1438 | int yylow = 1;
|
---|
| 1439 | int yyi;
|
---|
| 1440 | YYUSE (yyvalp);
|
---|
| 1441 | YYUSE (yylocp);
|
---|
| 1442 | ]b4_parse_param_use[]dnl
|
---|
| 1443 | [ YYFPRINTF (stderr, "Reducing stack %lu by rule %d (line %lu):\n",
|
---|
| 1444 | (unsigned long int) yyk, yyrule - 1,
|
---|
| 1445 | (unsigned long int) yyrline[yyrule]);
|
---|
| 1446 | /* The symbols being reduced. */
|
---|
| 1447 | for (yyi = 0; yyi < yynrhs; yyi++)
|
---|
| 1448 | {
|
---|
| 1449 | YYFPRINTF (stderr, " $%d = ", yyi + 1);
|
---|
| 1450 | yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
|
---|
| 1451 | &]b4_rhs_value(yynrhs, yyi + 1)[
|
---|
| 1452 | ]b4_locations_if([, &]b4_rhs_location(yynrhs, yyi + 1))[]dnl
|
---|
| 1453 | b4_user_args[);
|
---|
| 1454 | YYFPRINTF (stderr, "\n");
|
---|
| 1455 | }
|
---|
| 1456 | }
|
---|
| 1457 | #endif
|
---|
| 1458 |
|
---|
| 1459 | /** Pop items off stack #K of STACK according to grammar rule RULE,
|
---|
| 1460 | * and push back on the resulting nonterminal symbol. Perform the
|
---|
| 1461 | * semantic action associated with RULE and store its value with the
|
---|
| 1462 | * newly pushed state, if FORCEEVAL or if STACK is currently
|
---|
| 1463 | * unambiguous. Otherwise, store the deferred semantic action with
|
---|
| 1464 | * the new state. If the new state would have an identical input
|
---|
| 1465 | * position, LR state, and predecessor to an existing state on the stack,
|
---|
| 1466 | * it is identified with that existing state, eliminating stack #K from
|
---|
| 1467 | * the STACK. In this case, the (necessarily deferred) semantic value is
|
---|
| 1468 | * added to the options for the existing state's semantic value.
|
---|
| 1469 | */
|
---|
| 1470 | static inline YYRESULTTAG
|
---|
| 1471 | yyglrReduce (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule,
|
---|
| 1472 | yybool yyforceEval]b4_user_formals[)
|
---|
| 1473 | {
|
---|
| 1474 | size_t yyposn = yystackp->yytops.yystates[yyk]->yyposn;
|
---|
| 1475 |
|
---|
| 1476 | if (yyforceEval || yystackp->yysplitPoint == NULL)
|
---|
| 1477 | {
|
---|
| 1478 | YYSTYPE yysval;
|
---|
| 1479 | YYLTYPE yyloc;
|
---|
| 1480 |
|
---|
| 1481 | YY_REDUCE_PRINT ((yystackp, yyk, yyrule, &yysval, &yyloc]b4_user_args[));
|
---|
| 1482 | YYCHK (yydoAction (yystackp, yyk, yyrule, &yysval,
|
---|
| 1483 | &yyloc]b4_user_args[));
|
---|
| 1484 | YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyrule], &yysval, &yyloc);
|
---|
| 1485 | yyglrShift (yystackp, yyk,
|
---|
| 1486 | yyLRgotoState (yystackp->yytops.yystates[yyk]->yylrState,
|
---|
| 1487 | yylhsNonterm (yyrule)),
|
---|
| 1488 | yyposn, &yysval, &yyloc);
|
---|
| 1489 | }
|
---|
| 1490 | else
|
---|
| 1491 | {
|
---|
| 1492 | size_t yyi;
|
---|
| 1493 | int yyn;
|
---|
| 1494 | yyGLRState* yys, *yys0 = yystackp->yytops.yystates[yyk];
|
---|
| 1495 | yyStateNum yynewLRState;
|
---|
| 1496 |
|
---|
| 1497 | for (yys = yystackp->yytops.yystates[yyk], yyn = yyrhsLength (yyrule);
|
---|
| 1498 | 0 < yyn; yyn -= 1)
|
---|
| 1499 | {
|
---|
| 1500 | yys = yys->yypred;
|
---|
| 1501 | YYASSERT (yys);
|
---|
| 1502 | }
|
---|
| 1503 | yyupdateSplit (yystackp, yys);
|
---|
| 1504 | yynewLRState = yyLRgotoState (yys->yylrState, yylhsNonterm (yyrule));
|
---|
| 1505 | YYDPRINTF ((stderr,
|
---|
| 1506 | "Reduced stack %lu by rule #%d; action deferred. Now in state %d.\n",
|
---|
| 1507 | (unsigned long int) yyk, yyrule - 1, yynewLRState));
|
---|
| 1508 | for (yyi = 0; yyi < yystackp->yytops.yysize; yyi += 1)
|
---|
| 1509 | if (yyi != yyk && yystackp->yytops.yystates[yyi] != NULL)
|
---|
| 1510 | {
|
---|
| 1511 | yyGLRState* yyp, *yysplit = yystackp->yysplitPoint;
|
---|
| 1512 | yyp = yystackp->yytops.yystates[yyi];
|
---|
| 1513 | while (yyp != yys && yyp != yysplit && yyp->yyposn >= yyposn)
|
---|
| 1514 | {
|
---|
| 1515 | if (yyp->yylrState == yynewLRState && yyp->yypred == yys)
|
---|
| 1516 | {
|
---|
| 1517 | yyaddDeferredAction (yystackp, yyk, yyp, yys0, yyrule);
|
---|
| 1518 | yymarkStackDeleted (yystackp, yyk);
|
---|
| 1519 | YYDPRINTF ((stderr, "Merging stack %lu into stack %lu.\n",
|
---|
| 1520 | (unsigned long int) yyk,
|
---|
| 1521 | (unsigned long int) yyi));
|
---|
| 1522 | return yyok;
|
---|
| 1523 | }
|
---|
| 1524 | yyp = yyp->yypred;
|
---|
| 1525 | }
|
---|
| 1526 | }
|
---|
| 1527 | yystackp->yytops.yystates[yyk] = yys;
|
---|
| 1528 | yyglrShiftDefer (yystackp, yyk, yynewLRState, yyposn, yys0, yyrule);
|
---|
| 1529 | }
|
---|
| 1530 | return yyok;
|
---|
| 1531 | }
|
---|
| 1532 |
|
---|
| 1533 | static size_t
|
---|
| 1534 | yysplitStack (yyGLRStack* yystackp, size_t yyk)
|
---|
| 1535 | {
|
---|
| 1536 | if (yystackp->yysplitPoint == NULL)
|
---|
| 1537 | {
|
---|
| 1538 | YYASSERT (yyk == 0);
|
---|
| 1539 | yystackp->yysplitPoint = yystackp->yytops.yystates[yyk];
|
---|
| 1540 | }
|
---|
| 1541 | if (yystackp->yytops.yysize >= yystackp->yytops.yycapacity)
|
---|
| 1542 | {
|
---|
| 1543 | yyGLRState** yynewStates;
|
---|
| 1544 | yybool* yynewLookaheadNeeds;
|
---|
| 1545 |
|
---|
| 1546 | yynewStates = NULL;
|
---|
| 1547 |
|
---|
| 1548 | if (yystackp->yytops.yycapacity
|
---|
| 1549 | > (YYSIZEMAX / (2 * sizeof yynewStates[0])))
|
---|
| 1550 | yyMemoryExhausted (yystackp);
|
---|
| 1551 | yystackp->yytops.yycapacity *= 2;
|
---|
| 1552 |
|
---|
| 1553 | yynewStates =
|
---|
| 1554 | (yyGLRState**) YYREALLOC (yystackp->yytops.yystates,
|
---|
| 1555 | (yystackp->yytops.yycapacity
|
---|
| 1556 | * sizeof yynewStates[0]));
|
---|
| 1557 | if (yynewStates == NULL)
|
---|
| 1558 | yyMemoryExhausted (yystackp);
|
---|
| 1559 | yystackp->yytops.yystates = yynewStates;
|
---|
| 1560 |
|
---|
| 1561 | yynewLookaheadNeeds =
|
---|
| 1562 | (yybool*) YYREALLOC (yystackp->yytops.yylookaheadNeeds,
|
---|
| 1563 | (yystackp->yytops.yycapacity
|
---|
| 1564 | * sizeof yynewLookaheadNeeds[0]));
|
---|
| 1565 | if (yynewLookaheadNeeds == NULL)
|
---|
| 1566 | yyMemoryExhausted (yystackp);
|
---|
| 1567 | yystackp->yytops.yylookaheadNeeds = yynewLookaheadNeeds;
|
---|
| 1568 | }
|
---|
| 1569 | yystackp->yytops.yystates[yystackp->yytops.yysize]
|
---|
| 1570 | = yystackp->yytops.yystates[yyk];
|
---|
| 1571 | yystackp->yytops.yylookaheadNeeds[yystackp->yytops.yysize]
|
---|
| 1572 | = yystackp->yytops.yylookaheadNeeds[yyk];
|
---|
| 1573 | yystackp->yytops.yysize += 1;
|
---|
| 1574 | return yystackp->yytops.yysize-1;
|
---|
| 1575 | }
|
---|
| 1576 |
|
---|
| 1577 | /** True iff Y0 and Y1 represent identical options at the top level.
|
---|
| 1578 | * That is, they represent the same rule applied to RHS symbols
|
---|
| 1579 | * that produce the same terminal symbols. */
|
---|
| 1580 | static yybool
|
---|
| 1581 | yyidenticalOptions (yySemanticOption* yyy0, yySemanticOption* yyy1)
|
---|
| 1582 | {
|
---|
| 1583 | if (yyy0->yyrule == yyy1->yyrule)
|
---|
| 1584 | {
|
---|
| 1585 | yyGLRState *yys0, *yys1;
|
---|
| 1586 | int yyn;
|
---|
| 1587 | for (yys0 = yyy0->yystate, yys1 = yyy1->yystate,
|
---|
| 1588 | yyn = yyrhsLength (yyy0->yyrule);
|
---|
| 1589 | yyn > 0;
|
---|
| 1590 | yys0 = yys0->yypred, yys1 = yys1->yypred, yyn -= 1)
|
---|
| 1591 | if (yys0->yyposn != yys1->yyposn)
|
---|
| 1592 | return yyfalse;
|
---|
| 1593 | return yytrue;
|
---|
| 1594 | }
|
---|
| 1595 | else
|
---|
| 1596 | return yyfalse;
|
---|
| 1597 | }
|
---|
| 1598 |
|
---|
| 1599 | /** Assuming identicalOptions (Y0,Y1), destructively merge the
|
---|
| 1600 | * alternative semantic values for the RHS-symbols of Y1 and Y0. */
|
---|
| 1601 | static void
|
---|
| 1602 | yymergeOptionSets (yySemanticOption* yyy0, yySemanticOption* yyy1)
|
---|
| 1603 | {
|
---|
| 1604 | yyGLRState *yys0, *yys1;
|
---|
| 1605 | int yyn;
|
---|
| 1606 | for (yys0 = yyy0->yystate, yys1 = yyy1->yystate,
|
---|
| 1607 | yyn = yyrhsLength (yyy0->yyrule);
|
---|
| 1608 | yyn > 0;
|
---|
| 1609 | yys0 = yys0->yypred, yys1 = yys1->yypred, yyn -= 1)
|
---|
| 1610 | {
|
---|
| 1611 | if (yys0 == yys1)
|
---|
| 1612 | break;
|
---|
| 1613 | else if (yys0->yyresolved)
|
---|
| 1614 | {
|
---|
| 1615 | yys1->yyresolved = yytrue;
|
---|
| 1616 | yys1->yysemantics.yysval = yys0->yysemantics.yysval;
|
---|
| 1617 | }
|
---|
| 1618 | else if (yys1->yyresolved)
|
---|
| 1619 | {
|
---|
| 1620 | yys0->yyresolved = yytrue;
|
---|
| 1621 | yys0->yysemantics.yysval = yys1->yysemantics.yysval;
|
---|
| 1622 | }
|
---|
| 1623 | else
|
---|
| 1624 | {
|
---|
| 1625 | yySemanticOption** yyz0p;
|
---|
| 1626 | yySemanticOption* yyz1;
|
---|
| 1627 | yyz0p = &yys0->yysemantics.yyfirstVal;
|
---|
| 1628 | yyz1 = yys1->yysemantics.yyfirstVal;
|
---|
| 1629 | while (YYID (yytrue))
|
---|
| 1630 | {
|
---|
| 1631 | if (yyz1 == *yyz0p || yyz1 == NULL)
|
---|
| 1632 | break;
|
---|
| 1633 | else if (*yyz0p == NULL)
|
---|
| 1634 | {
|
---|
| 1635 | *yyz0p = yyz1;
|
---|
| 1636 | break;
|
---|
| 1637 | }
|
---|
| 1638 | else if (*yyz0p < yyz1)
|
---|
| 1639 | {
|
---|
| 1640 | yySemanticOption* yyz = *yyz0p;
|
---|
| 1641 | *yyz0p = yyz1;
|
---|
| 1642 | yyz1 = yyz1->yynext;
|
---|
| 1643 | (*yyz0p)->yynext = yyz;
|
---|
| 1644 | }
|
---|
| 1645 | yyz0p = &(*yyz0p)->yynext;
|
---|
| 1646 | }
|
---|
| 1647 | yys1->yysemantics.yyfirstVal = yys0->yysemantics.yyfirstVal;
|
---|
| 1648 | }
|
---|
| 1649 | }
|
---|
| 1650 | }
|
---|
| 1651 |
|
---|
| 1652 | /** Y0 and Y1 represent two possible actions to take in a given
|
---|
| 1653 | * parsing state; return 0 if no combination is possible,
|
---|
| 1654 | * 1 if user-mergeable, 2 if Y0 is preferred, 3 if Y1 is preferred. */
|
---|
| 1655 | static int
|
---|
| 1656 | yypreference (yySemanticOption* y0, yySemanticOption* y1)
|
---|
| 1657 | {
|
---|
| 1658 | yyRuleNum r0 = y0->yyrule, r1 = y1->yyrule;
|
---|
| 1659 | int p0 = yydprec[r0], p1 = yydprec[r1];
|
---|
| 1660 |
|
---|
| 1661 | if (p0 == p1)
|
---|
| 1662 | {
|
---|
| 1663 | if (yymerger[r0] == 0 || yymerger[r0] != yymerger[r1])
|
---|
| 1664 | return 0;
|
---|
| 1665 | else
|
---|
| 1666 | return 1;
|
---|
| 1667 | }
|
---|
| 1668 | if (p0 == 0 || p1 == 0)
|
---|
| 1669 | return 0;
|
---|
| 1670 | if (p0 < p1)
|
---|
| 1671 | return 3;
|
---|
| 1672 | if (p1 < p0)
|
---|
| 1673 | return 2;
|
---|
| 1674 | return 0;
|
---|
| 1675 | }
|
---|
| 1676 |
|
---|
| 1677 | static YYRESULTTAG yyresolveValue (yyGLRState* yys,
|
---|
| 1678 | yyGLRStack* yystackp]b4_user_formals[);
|
---|
| 1679 |
|
---|
| 1680 |
|
---|
| 1681 | /** Resolve the previous N states starting at and including state S. If result
|
---|
| 1682 | * != yyok, some states may have been left unresolved possibly with empty
|
---|
| 1683 | * semantic option chains. Regardless of whether result = yyok, each state
|
---|
| 1684 | * has been left with consistent data so that yydestroyGLRState can be invoked
|
---|
| 1685 | * if necessary. */
|
---|
| 1686 | static YYRESULTTAG
|
---|
| 1687 | yyresolveStates (yyGLRState* yys, int yyn,
|
---|
| 1688 | yyGLRStack* yystackp]b4_user_formals[)
|
---|
| 1689 | {
|
---|
| 1690 | if (0 < yyn)
|
---|
| 1691 | {
|
---|
| 1692 | YYASSERT (yys->yypred);
|
---|
| 1693 | YYCHK (yyresolveStates (yys->yypred, yyn-1, yystackp]b4_user_args[));
|
---|
| 1694 | if (! yys->yyresolved)
|
---|
| 1695 | YYCHK (yyresolveValue (yys, yystackp]b4_user_args[));
|
---|
| 1696 | }
|
---|
| 1697 | return yyok;
|
---|
| 1698 | }
|
---|
| 1699 |
|
---|
| 1700 | /** Resolve the states for the RHS of OPT, perform its user action, and return
|
---|
| 1701 | * the semantic value and location. Regardless of whether result = yyok, all
|
---|
| 1702 | * RHS states have been destroyed (assuming the user action destroys all RHS
|
---|
| 1703 | * semantic values if invoked). */
|
---|
| 1704 | static YYRESULTTAG
|
---|
| 1705 | yyresolveAction (yySemanticOption* yyopt, yyGLRStack* yystackp,
|
---|
| 1706 | YYSTYPE* yyvalp, YYLTYPE* yylocp]b4_user_formals[)
|
---|
| 1707 | {
|
---|
| 1708 | yyGLRStackItem yyrhsVals[YYMAXRHS + YYMAXLEFT + 1];
|
---|
| 1709 | int yynrhs;
|
---|
| 1710 | int yychar_current;
|
---|
| 1711 | YYSTYPE yylval_current;
|
---|
| 1712 | YYLTYPE yylloc_current;
|
---|
| 1713 | YYRESULTTAG yyflag;
|
---|
| 1714 |
|
---|
| 1715 | yynrhs = yyrhsLength (yyopt->yyrule);
|
---|
| 1716 | yyflag = yyresolveStates (yyopt->yystate, yynrhs, yystackp]b4_user_args[);
|
---|
| 1717 | if (yyflag != yyok)
|
---|
| 1718 | {
|
---|
| 1719 | yyGLRState *yys;
|
---|
| 1720 | for (yys = yyopt->yystate; yynrhs > 0; yys = yys->yypred, yynrhs -= 1)
|
---|
| 1721 | yydestroyGLRState ("Cleanup: popping", yys]b4_user_args[);
|
---|
| 1722 | return yyflag;
|
---|
| 1723 | }
|
---|
| 1724 |
|
---|
| 1725 | yyrhsVals[YYMAXRHS + YYMAXLEFT].yystate.yypred = yyopt->yystate;]b4_locations_if([[
|
---|
| 1726 | if (yynrhs == 0)
|
---|
| 1727 | /* Set default location. */
|
---|
| 1728 | yyrhsVals[YYMAXRHS + YYMAXLEFT - 1].yystate.yyloc = yyopt->yystate->yyloc;]])[
|
---|
| 1729 | yychar_current = yychar;
|
---|
| 1730 | yylval_current = yylval;
|
---|
| 1731 | yylloc_current = yylloc;
|
---|
| 1732 | yychar = yyopt->yyrawchar;
|
---|
| 1733 | yylval = yyopt->yyval;
|
---|
| 1734 | yylloc = yyopt->yyloc;
|
---|
| 1735 | yyflag = yyuserAction (yyopt->yyrule, yynrhs,
|
---|
| 1736 | yyrhsVals + YYMAXRHS + YYMAXLEFT - 1,
|
---|
| 1737 | yyvalp, yylocp, yystackp]b4_user_args[);
|
---|
| 1738 | yychar = yychar_current;
|
---|
| 1739 | yylval = yylval_current;
|
---|
| 1740 | yylloc = yylloc_current;
|
---|
| 1741 | return yyflag;
|
---|
| 1742 | }
|
---|
| 1743 |
|
---|
| 1744 | #if YYDEBUG
|
---|
| 1745 | static void
|
---|
| 1746 | yyreportTree (yySemanticOption* yyx, int yyindent)
|
---|
| 1747 | {
|
---|
| 1748 | int yynrhs = yyrhsLength (yyx->yyrule);
|
---|
| 1749 | int yyi;
|
---|
| 1750 | yyGLRState* yys;
|
---|
| 1751 | yyGLRState* yystates[1 + YYMAXRHS];
|
---|
| 1752 | yyGLRState yyleftmost_state;
|
---|
| 1753 |
|
---|
| 1754 | for (yyi = yynrhs, yys = yyx->yystate; 0 < yyi; yyi -= 1, yys = yys->yypred)
|
---|
| 1755 | yystates[yyi] = yys;
|
---|
| 1756 | if (yys == NULL)
|
---|
| 1757 | {
|
---|
| 1758 | yyleftmost_state.yyposn = 0;
|
---|
| 1759 | yystates[0] = &yyleftmost_state;
|
---|
| 1760 | }
|
---|
| 1761 | else
|
---|
| 1762 | yystates[0] = yys;
|
---|
| 1763 |
|
---|
| 1764 | if (yyx->yystate->yyposn < yys->yyposn + 1)
|
---|
| 1765 | YYFPRINTF (stderr, "%*s%s -> <Rule %d, empty>\n",
|
---|
| 1766 | yyindent, "", yytokenName (yylhsNonterm (yyx->yyrule)),
|
---|
| 1767 | yyx->yyrule - 1);
|
---|
| 1768 | else
|
---|
| 1769 | YYFPRINTF (stderr, "%*s%s -> <Rule %d, tokens %lu .. %lu>\n",
|
---|
| 1770 | yyindent, "", yytokenName (yylhsNonterm (yyx->yyrule)),
|
---|
| 1771 | yyx->yyrule - 1, (unsigned long int) (yys->yyposn + 1),
|
---|
| 1772 | (unsigned long int) yyx->yystate->yyposn);
|
---|
| 1773 | for (yyi = 1; yyi <= yynrhs; yyi += 1)
|
---|
| 1774 | {
|
---|
| 1775 | if (yystates[yyi]->yyresolved)
|
---|
| 1776 | {
|
---|
| 1777 | if (yystates[yyi-1]->yyposn+1 > yystates[yyi]->yyposn)
|
---|
| 1778 | YYFPRINTF (stderr, "%*s%s <empty>\n", yyindent+2, "",
|
---|
| 1779 | yytokenName (yyrhs[yyprhs[yyx->yyrule]+yyi-1]));
|
---|
| 1780 | else
|
---|
| 1781 | YYFPRINTF (stderr, "%*s%s <tokens %lu .. %lu>\n", yyindent+2, "",
|
---|
| 1782 | yytokenName (yyrhs[yyprhs[yyx->yyrule]+yyi-1]),
|
---|
| 1783 | (unsigned long int) (yystates[yyi - 1]->yyposn + 1),
|
---|
| 1784 | (unsigned long int) yystates[yyi]->yyposn);
|
---|
| 1785 | }
|
---|
| 1786 | else
|
---|
| 1787 | yyreportTree (yystates[yyi]->yysemantics.yyfirstVal, yyindent+2);
|
---|
| 1788 | }
|
---|
| 1789 | }
|
---|
| 1790 | #endif
|
---|
| 1791 |
|
---|
| 1792 | /*ARGSUSED*/ static YYRESULTTAG
|
---|
| 1793 | yyreportAmbiguity (yySemanticOption* yyx0,
|
---|
| 1794 | yySemanticOption* yyx1]b4_pure_formals[)
|
---|
| 1795 | {
|
---|
| 1796 | YYUSE (yyx0);
|
---|
| 1797 | YYUSE (yyx1);
|
---|
| 1798 |
|
---|
| 1799 | #if YYDEBUG
|
---|
| 1800 | YYFPRINTF (stderr, "Ambiguity detected.\n");
|
---|
| 1801 | YYFPRINTF (stderr, "Option 1,\n");
|
---|
| 1802 | yyreportTree (yyx0, 2);
|
---|
| 1803 | YYFPRINTF (stderr, "\nOption 2,\n");
|
---|
| 1804 | yyreportTree (yyx1, 2);
|
---|
| 1805 | YYFPRINTF (stderr, "\n");
|
---|
| 1806 | #endif
|
---|
| 1807 |
|
---|
| 1808 | yyerror (]b4_yyerror_args[YY_("syntax is ambiguous"));
|
---|
| 1809 | return yyabort;
|
---|
| 1810 | }
|
---|
| 1811 |
|
---|
| 1812 | /** Starting at and including state S1, resolve the location for each of the
|
---|
| 1813 | * previous N1 states that is unresolved. The first semantic option of a state
|
---|
| 1814 | * is always chosen. */
|
---|
| 1815 | static void
|
---|
| 1816 | yyresolveLocations (yyGLRState* yys1, int yyn1,
|
---|
| 1817 | yyGLRStack *yystackp]b4_user_formals[)
|
---|
| 1818 | {
|
---|
| 1819 | if (0 < yyn1)
|
---|
| 1820 | {
|
---|
| 1821 | yyresolveLocations (yys1->yypred, yyn1 - 1, yystackp]b4_user_args[);
|
---|
| 1822 | if (!yys1->yyresolved)
|
---|
| 1823 | {
|
---|
| 1824 | yySemanticOption *yyoption;
|
---|
| 1825 | yyGLRStackItem yyrhsloc[1 + YYMAXRHS];
|
---|
| 1826 | int yynrhs;
|
---|
| 1827 | int yychar_current;
|
---|
| 1828 | YYSTYPE yylval_current;
|
---|
| 1829 | YYLTYPE yylloc_current;
|
---|
| 1830 | yyoption = yys1->yysemantics.yyfirstVal;
|
---|
| 1831 | YYASSERT (yyoption != NULL);
|
---|
| 1832 | yynrhs = yyrhsLength (yyoption->yyrule);
|
---|
| 1833 | if (yynrhs > 0)
|
---|
| 1834 | {
|
---|
| 1835 | yyGLRState *yys;
|
---|
| 1836 | int yyn;
|
---|
| 1837 | yyresolveLocations (yyoption->yystate, yynrhs,
|
---|
| 1838 | yystackp]b4_user_args[);
|
---|
| 1839 | for (yys = yyoption->yystate, yyn = yynrhs;
|
---|
| 1840 | yyn > 0;
|
---|
| 1841 | yys = yys->yypred, yyn -= 1)
|
---|
| 1842 | yyrhsloc[yyn].yystate.yyloc = yys->yyloc;
|
---|
| 1843 | }
|
---|
| 1844 | else
|
---|
| 1845 | {
|
---|
| 1846 | /* Both yyresolveAction and yyresolveLocations traverse the GSS
|
---|
| 1847 | in reverse rightmost order. It is only necessary to invoke
|
---|
| 1848 | yyresolveLocations on a subforest for which yyresolveAction
|
---|
| 1849 | would have been invoked next had an ambiguity not been
|
---|
| 1850 | detected. Thus the location of the previous state (but not
|
---|
| 1851 | necessarily the previous state itself) is guaranteed to be
|
---|
| 1852 | resolved already. */
|
---|
| 1853 | yyGLRState *yyprevious = yyoption->yystate;
|
---|
| 1854 | yyrhsloc[0].yystate.yyloc = yyprevious->yyloc;
|
---|
| 1855 | }
|
---|
| 1856 | yychar_current = yychar;
|
---|
| 1857 | yylval_current = yylval;
|
---|
| 1858 | yylloc_current = yylloc;
|
---|
| 1859 | yychar = yyoption->yyrawchar;
|
---|
| 1860 | yylval = yyoption->yyval;
|
---|
| 1861 | yylloc = yyoption->yyloc;
|
---|
| 1862 | YYLLOC_DEFAULT ((yys1->yyloc), yyrhsloc, yynrhs);
|
---|
| 1863 | yychar = yychar_current;
|
---|
| 1864 | yylval = yylval_current;
|
---|
| 1865 | yylloc = yylloc_current;
|
---|
| 1866 | }
|
---|
| 1867 | }
|
---|
| 1868 | }
|
---|
| 1869 |
|
---|
| 1870 | /** Resolve the ambiguity represented in state S, perform the indicated
|
---|
| 1871 | * actions, and set the semantic value of S. If result != yyok, the chain of
|
---|
| 1872 | * semantic options in S has been cleared instead or it has been left
|
---|
| 1873 | * unmodified except that redundant options may have been removed. Regardless
|
---|
| 1874 | * of whether result = yyok, S has been left with consistent data so that
|
---|
| 1875 | * yydestroyGLRState can be invoked if necessary. */
|
---|
| 1876 | static YYRESULTTAG
|
---|
| 1877 | yyresolveValue (yyGLRState* yys, yyGLRStack* yystackp]b4_user_formals[)
|
---|
| 1878 | {
|
---|
| 1879 | yySemanticOption* yyoptionList = yys->yysemantics.yyfirstVal;
|
---|
| 1880 | yySemanticOption* yybest;
|
---|
| 1881 | yySemanticOption** yypp;
|
---|
| 1882 | yybool yymerge;
|
---|
| 1883 | YYSTYPE yysval;
|
---|
| 1884 | YYRESULTTAG yyflag;
|
---|
| 1885 | YYLTYPE *yylocp = &yys->yyloc;
|
---|
| 1886 |
|
---|
| 1887 | yybest = yyoptionList;
|
---|
| 1888 | yymerge = yyfalse;
|
---|
| 1889 | for (yypp = &yyoptionList->yynext; *yypp != NULL; )
|
---|
| 1890 | {
|
---|
| 1891 | yySemanticOption* yyp = *yypp;
|
---|
| 1892 |
|
---|
| 1893 | if (yyidenticalOptions (yybest, yyp))
|
---|
| 1894 | {
|
---|
| 1895 | yymergeOptionSets (yybest, yyp);
|
---|
| 1896 | *yypp = yyp->yynext;
|
---|
| 1897 | }
|
---|
| 1898 | else
|
---|
| 1899 | {
|
---|
| 1900 | switch (yypreference (yybest, yyp))
|
---|
| 1901 | {
|
---|
| 1902 | case 0:
|
---|
| 1903 | yyresolveLocations (yys, 1, yystackp]b4_user_args[);
|
---|
| 1904 | return yyreportAmbiguity (yybest, yyp]b4_pure_args[);
|
---|
| 1905 | break;
|
---|
| 1906 | case 1:
|
---|
| 1907 | yymerge = yytrue;
|
---|
| 1908 | break;
|
---|
| 1909 | case 2:
|
---|
| 1910 | break;
|
---|
| 1911 | case 3:
|
---|
| 1912 | yybest = yyp;
|
---|
| 1913 | yymerge = yyfalse;
|
---|
| 1914 | break;
|
---|
| 1915 | default:
|
---|
| 1916 | /* This cannot happen so it is not worth a YYASSERT (yyfalse),
|
---|
| 1917 | but some compilers complain if the default case is
|
---|
| 1918 | omitted. */
|
---|
| 1919 | break;
|
---|
| 1920 | }
|
---|
| 1921 | yypp = &yyp->yynext;
|
---|
| 1922 | }
|
---|
| 1923 | }
|
---|
| 1924 |
|
---|
| 1925 | if (yymerge)
|
---|
| 1926 | {
|
---|
| 1927 | yySemanticOption* yyp;
|
---|
| 1928 | int yyprec = yydprec[yybest->yyrule];
|
---|
| 1929 | yyflag = yyresolveAction (yybest, yystackp, &yysval,
|
---|
| 1930 | yylocp]b4_user_args[);
|
---|
| 1931 | if (yyflag == yyok)
|
---|
| 1932 | for (yyp = yybest->yynext; yyp != NULL; yyp = yyp->yynext)
|
---|
| 1933 | {
|
---|
| 1934 | if (yyprec == yydprec[yyp->yyrule])
|
---|
| 1935 | {
|
---|
| 1936 | YYSTYPE yysval_other;
|
---|
| 1937 | YYLTYPE yydummy;
|
---|
| 1938 | yyflag = yyresolveAction (yyp, yystackp, &yysval_other,
|
---|
| 1939 | &yydummy]b4_user_args[);
|
---|
| 1940 | if (yyflag != yyok)
|
---|
| 1941 | {
|
---|
| 1942 | yydestruct ("Cleanup: discarding incompletely merged value for",
|
---|
| 1943 | yystos[yys->yylrState],
|
---|
| 1944 | &yysval]b4_locations_if([, yylocp])[]b4_user_args[);
|
---|
| 1945 | break;
|
---|
| 1946 | }
|
---|
| 1947 | yyuserMerge (yymerger[yyp->yyrule], &yysval, &yysval_other);
|
---|
| 1948 | }
|
---|
| 1949 | }
|
---|
| 1950 | }
|
---|
| 1951 | else
|
---|
| 1952 | yyflag = yyresolveAction (yybest, yystackp, &yysval, yylocp]b4_user_args[);
|
---|
| 1953 |
|
---|
| 1954 | if (yyflag == yyok)
|
---|
| 1955 | {
|
---|
| 1956 | yys->yyresolved = yytrue;
|
---|
| 1957 | yys->yysemantics.yysval = yysval;
|
---|
| 1958 | }
|
---|
| 1959 | else
|
---|
| 1960 | yys->yysemantics.yyfirstVal = NULL;
|
---|
| 1961 | return yyflag;
|
---|
| 1962 | }
|
---|
| 1963 |
|
---|
| 1964 | static YYRESULTTAG
|
---|
| 1965 | yyresolveStack (yyGLRStack* yystackp]b4_user_formals[)
|
---|
| 1966 | {
|
---|
| 1967 | if (yystackp->yysplitPoint != NULL)
|
---|
| 1968 | {
|
---|
| 1969 | yyGLRState* yys;
|
---|
| 1970 | int yyn;
|
---|
| 1971 |
|
---|
| 1972 | for (yyn = 0, yys = yystackp->yytops.yystates[0];
|
---|
| 1973 | yys != yystackp->yysplitPoint;
|
---|
| 1974 | yys = yys->yypred, yyn += 1)
|
---|
| 1975 | continue;
|
---|
| 1976 | YYCHK (yyresolveStates (yystackp->yytops.yystates[0], yyn, yystackp
|
---|
| 1977 | ]b4_user_args[));
|
---|
| 1978 | }
|
---|
| 1979 | return yyok;
|
---|
| 1980 | }
|
---|
| 1981 |
|
---|
| 1982 | static void
|
---|
| 1983 | yycompressStack (yyGLRStack* yystackp)
|
---|
| 1984 | {
|
---|
| 1985 | yyGLRState* yyp, *yyq, *yyr;
|
---|
| 1986 |
|
---|
| 1987 | if (yystackp->yytops.yysize != 1 || yystackp->yysplitPoint == NULL)
|
---|
| 1988 | return;
|
---|
| 1989 |
|
---|
| 1990 | for (yyp = yystackp->yytops.yystates[0], yyq = yyp->yypred, yyr = NULL;
|
---|
| 1991 | yyp != yystackp->yysplitPoint;
|
---|
| 1992 | yyr = yyp, yyp = yyq, yyq = yyp->yypred)
|
---|
| 1993 | yyp->yypred = yyr;
|
---|
| 1994 |
|
---|
| 1995 | yystackp->yyspaceLeft += yystackp->yynextFree - yystackp->yyitems;
|
---|
| 1996 | yystackp->yynextFree = ((yyGLRStackItem*) yystackp->yysplitPoint) + 1;
|
---|
| 1997 | yystackp->yyspaceLeft -= yystackp->yynextFree - yystackp->yyitems;
|
---|
| 1998 | yystackp->yysplitPoint = NULL;
|
---|
| 1999 | yystackp->yylastDeleted = NULL;
|
---|
| 2000 |
|
---|
| 2001 | while (yyr != NULL)
|
---|
| 2002 | {
|
---|
| 2003 | yystackp->yynextFree->yystate = *yyr;
|
---|
| 2004 | yyr = yyr->yypred;
|
---|
| 2005 | yystackp->yynextFree->yystate.yypred = &yystackp->yynextFree[-1].yystate;
|
---|
| 2006 | yystackp->yytops.yystates[0] = &yystackp->yynextFree->yystate;
|
---|
| 2007 | yystackp->yynextFree += 1;
|
---|
| 2008 | yystackp->yyspaceLeft -= 1;
|
---|
| 2009 | }
|
---|
| 2010 | }
|
---|
| 2011 |
|
---|
| 2012 | static YYRESULTTAG
|
---|
| 2013 | yyprocessOneStack (yyGLRStack* yystackp, size_t yyk,
|
---|
| 2014 | size_t yyposn]b4_pure_formals[)
|
---|
| 2015 | {
|
---|
| 2016 | int yyaction;
|
---|
| 2017 | const short int* yyconflicts;
|
---|
| 2018 | yyRuleNum yyrule;
|
---|
| 2019 |
|
---|
| 2020 | while (yystackp->yytops.yystates[yyk] != NULL)
|
---|
| 2021 | {
|
---|
| 2022 | yyStateNum yystate = yystackp->yytops.yystates[yyk]->yylrState;
|
---|
| 2023 | YYDPRINTF ((stderr, "Stack %lu Entering state %d\n",
|
---|
| 2024 | (unsigned long int) yyk, yystate));
|
---|
| 2025 |
|
---|
| 2026 | YYASSERT (yystate != YYFINAL);
|
---|
| 2027 |
|
---|
| 2028 | if (yyisDefaultedState (yystate))
|
---|
| 2029 | {
|
---|
| 2030 | yyrule = yydefaultAction (yystate);
|
---|
| 2031 | if (yyrule == 0)
|
---|
| 2032 | {
|
---|
| 2033 | YYDPRINTF ((stderr, "Stack %lu dies.\n",
|
---|
| 2034 | (unsigned long int) yyk));
|
---|
| 2035 | yymarkStackDeleted (yystackp, yyk);
|
---|
| 2036 | return yyok;
|
---|
| 2037 | }
|
---|
| 2038 | YYCHK (yyglrReduce (yystackp, yyk, yyrule, yyfalse]b4_user_args[));
|
---|
| 2039 | }
|
---|
| 2040 | else
|
---|
| 2041 | {
|
---|
| 2042 | yySymbol yytoken;
|
---|
| 2043 | yystackp->yytops.yylookaheadNeeds[yyk] = yytrue;
|
---|
| 2044 | if (yychar == YYEMPTY)
|
---|
| 2045 | {
|
---|
| 2046 | YYDPRINTF ((stderr, "Reading a token: "));
|
---|
| 2047 | yychar = YYLEX;
|
---|
| 2048 | }
|
---|
| 2049 |
|
---|
| 2050 | if (yychar <= YYEOF)
|
---|
| 2051 | {
|
---|
| 2052 | yychar = yytoken = YYEOF;
|
---|
| 2053 | YYDPRINTF ((stderr, "Now at end of input.\n"));
|
---|
| 2054 | }
|
---|
| 2055 | else
|
---|
| 2056 | {
|
---|
| 2057 | yytoken = YYTRANSLATE (yychar);
|
---|
| 2058 | YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
|
---|
| 2059 | }
|
---|
| 2060 |
|
---|
| 2061 | yygetLRActions (yystate, yytoken, &yyaction, &yyconflicts);
|
---|
| 2062 |
|
---|
| 2063 | while (*yyconflicts != 0)
|
---|
| 2064 | {
|
---|
| 2065 | size_t yynewStack = yysplitStack (yystackp, yyk);
|
---|
| 2066 | YYDPRINTF ((stderr, "Splitting off stack %lu from %lu.\n",
|
---|
| 2067 | (unsigned long int) yynewStack,
|
---|
| 2068 | (unsigned long int) yyk));
|
---|
| 2069 | YYCHK (yyglrReduce (yystackp, yynewStack,
|
---|
| 2070 | *yyconflicts, yyfalse]b4_user_args[));
|
---|
| 2071 | YYCHK (yyprocessOneStack (yystackp, yynewStack,
|
---|
| 2072 | yyposn]b4_pure_args[));
|
---|
| 2073 | yyconflicts += 1;
|
---|
| 2074 | }
|
---|
| 2075 |
|
---|
| 2076 | if (yyisShiftAction (yyaction))
|
---|
| 2077 | break;
|
---|
| 2078 | else if (yyisErrorAction (yyaction))
|
---|
| 2079 | {
|
---|
| 2080 | YYDPRINTF ((stderr, "Stack %lu dies.\n",
|
---|
| 2081 | (unsigned long int) yyk));
|
---|
| 2082 | yymarkStackDeleted (yystackp, yyk);
|
---|
| 2083 | break;
|
---|
| 2084 | }
|
---|
| 2085 | else
|
---|
| 2086 | YYCHK (yyglrReduce (yystackp, yyk, -yyaction,
|
---|
| 2087 | yyfalse]b4_user_args[));
|
---|
| 2088 | }
|
---|
| 2089 | }
|
---|
| 2090 | return yyok;
|
---|
| 2091 | }
|
---|
| 2092 |
|
---|
| 2093 | /*ARGSUSED*/ static void
|
---|
| 2094 | yyreportSyntaxError (yyGLRStack* yystackp]b4_user_formals[)
|
---|
| 2095 | {
|
---|
| 2096 | if (yystackp->yyerrState == 0)
|
---|
| 2097 | {
|
---|
| 2098 | #if YYERROR_VERBOSE
|
---|
| 2099 | int yyn;
|
---|
| 2100 | yyn = yypact[yystackp->yytops.yystates[0]->yylrState];
|
---|
| 2101 | if (YYPACT_NINF < yyn && yyn <= YYLAST)
|
---|
| 2102 | {
|
---|
| 2103 | yySymbol yytoken = YYTRANSLATE (yychar);
|
---|
| 2104 | size_t yysize0 = yytnamerr (NULL, yytokenName (yytoken));
|
---|
| 2105 | size_t yysize = yysize0;
|
---|
| 2106 | size_t yysize1;
|
---|
| 2107 | yybool yysize_overflow = yyfalse;
|
---|
| 2108 | char* yymsg = NULL;
|
---|
| 2109 | enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
|
---|
| 2110 | char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
|
---|
| 2111 | int yyx;
|
---|
| 2112 | char *yyfmt;
|
---|
| 2113 | char const *yyf;
|
---|
| 2114 | static char const yyunexpected[] = "syntax error, unexpected %s";
|
---|
| 2115 | static char const yyexpecting[] = ", expecting %s";
|
---|
| 2116 | static char const yyor[] = " or %s";
|
---|
| 2117 | char yyformat[sizeof yyunexpected
|
---|
| 2118 | + sizeof yyexpecting - 1
|
---|
| 2119 | + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
|
---|
| 2120 | * (sizeof yyor - 1))];
|
---|
| 2121 | char const *yyprefix = yyexpecting;
|
---|
| 2122 |
|
---|
| 2123 | /* Start YYX at -YYN if negative to avoid negative indexes in
|
---|
| 2124 | YYCHECK. */
|
---|
| 2125 | int yyxbegin = yyn < 0 ? -yyn : 0;
|
---|
| 2126 |
|
---|
| 2127 | /* Stay within bounds of both yycheck and yytname. */
|
---|
| 2128 | int yychecklim = YYLAST - yyn + 1;
|
---|
| 2129 | int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
|
---|
| 2130 | int yycount = 1;
|
---|
| 2131 |
|
---|
| 2132 | yyarg[0] = yytokenName (yytoken);
|
---|
| 2133 | yyfmt = yystpcpy (yyformat, yyunexpected);
|
---|
| 2134 |
|
---|
| 2135 | for (yyx = yyxbegin; yyx < yyxend; ++yyx)
|
---|
| 2136 | if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
|
---|
| 2137 | {
|
---|
| 2138 | if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
|
---|
| 2139 | {
|
---|
| 2140 | yycount = 1;
|
---|
| 2141 | yysize = yysize0;
|
---|
| 2142 | yyformat[sizeof yyunexpected - 1] = '\0';
|
---|
| 2143 | break;
|
---|
| 2144 | }
|
---|
| 2145 | yyarg[yycount++] = yytokenName (yyx);
|
---|
| 2146 | yysize1 = yysize + yytnamerr (NULL, yytokenName (yyx));
|
---|
| 2147 | yysize_overflow |= yysize1 < yysize;
|
---|
| 2148 | yysize = yysize1;
|
---|
| 2149 | yyfmt = yystpcpy (yyfmt, yyprefix);
|
---|
| 2150 | yyprefix = yyor;
|
---|
| 2151 | }
|
---|
| 2152 |
|
---|
| 2153 | yyf = YY_(yyformat);
|
---|
| 2154 | yysize1 = yysize + strlen (yyf);
|
---|
| 2155 | yysize_overflow |= yysize1 < yysize;
|
---|
| 2156 | yysize = yysize1;
|
---|
| 2157 |
|
---|
| 2158 | if (!yysize_overflow)
|
---|
| 2159 | yymsg = (char *) YYMALLOC (yysize);
|
---|
| 2160 |
|
---|
| 2161 | if (yymsg)
|
---|
| 2162 | {
|
---|
| 2163 | char *yyp = yymsg;
|
---|
| 2164 | int yyi = 0;
|
---|
| 2165 | while ((*yyp = *yyf))
|
---|
| 2166 | {
|
---|
| 2167 | if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
|
---|
| 2168 | {
|
---|
| 2169 | yyp += yytnamerr (yyp, yyarg[yyi++]);
|
---|
| 2170 | yyf += 2;
|
---|
| 2171 | }
|
---|
| 2172 | else
|
---|
| 2173 | {
|
---|
| 2174 | yyp++;
|
---|
| 2175 | yyf++;
|
---|
| 2176 | }
|
---|
| 2177 | }
|
---|
| 2178 | yyerror (]b4_lyyerror_args[yymsg);
|
---|
| 2179 | YYFREE (yymsg);
|
---|
| 2180 | }
|
---|
| 2181 | else
|
---|
| 2182 | {
|
---|
| 2183 | yyerror (]b4_lyyerror_args[YY_("syntax error"));
|
---|
| 2184 | yyMemoryExhausted (yystackp);
|
---|
| 2185 | }
|
---|
| 2186 | }
|
---|
| 2187 | else
|
---|
| 2188 | #endif /* YYERROR_VERBOSE */
|
---|
| 2189 | yyerror (]b4_lyyerror_args[YY_("syntax error"));
|
---|
| 2190 | yynerrs += 1;
|
---|
| 2191 | }
|
---|
| 2192 | }
|
---|
| 2193 |
|
---|
| 2194 | /* Recover from a syntax error on *YYSTACKP, assuming that *YYSTACKP->YYTOKENP,
|
---|
| 2195 | yylval, and yylloc are the syntactic category, semantic value, and location
|
---|
| 2196 | of the lookahead. */
|
---|
| 2197 | /*ARGSUSED*/ static void
|
---|
| 2198 | yyrecoverSyntaxError (yyGLRStack* yystackp]b4_user_formals[)
|
---|
| 2199 | {
|
---|
| 2200 | size_t yyk;
|
---|
| 2201 | int yyj;
|
---|
| 2202 |
|
---|
| 2203 | if (yystackp->yyerrState == 3)
|
---|
| 2204 | /* We just shifted the error token and (perhaps) took some
|
---|
| 2205 | reductions. Skip tokens until we can proceed. */
|
---|
| 2206 | while (YYID (yytrue))
|
---|
| 2207 | {
|
---|
| 2208 | yySymbol yytoken;
|
---|
| 2209 | if (yychar == YYEOF)
|
---|
| 2210 | yyFail (yystackp][]b4_lpure_args[, NULL);
|
---|
| 2211 | if (yychar != YYEMPTY)
|
---|
| 2212 | {]b4_locations_if([[
|
---|
| 2213 | /* We throw away the lookahead, but the error range
|
---|
| 2214 | of the shifted error token must take it into account. */
|
---|
| 2215 | yyGLRState *yys = yystackp->yytops.yystates[0];
|
---|
| 2216 | yyGLRStackItem yyerror_range[3];
|
---|
| 2217 | yyerror_range[1].yystate.yyloc = yys->yyloc;
|
---|
| 2218 | yyerror_range[2].yystate.yyloc = yylloc;
|
---|
| 2219 | YYLLOC_DEFAULT ((yys->yyloc), yyerror_range, 2);]])[
|
---|
| 2220 | yytoken = YYTRANSLATE (yychar);
|
---|
| 2221 | yydestruct ("Error: discarding",
|
---|
| 2222 | yytoken, &yylval]b4_locations_if([, &yylloc])[]b4_user_args[);
|
---|
| 2223 | }
|
---|
| 2224 | YYDPRINTF ((stderr, "Reading a token: "));
|
---|
| 2225 | yychar = YYLEX;
|
---|
| 2226 | if (yychar <= YYEOF)
|
---|
| 2227 | {
|
---|
| 2228 | yychar = yytoken = YYEOF;
|
---|
| 2229 | YYDPRINTF ((stderr, "Now at end of input.\n"));
|
---|
| 2230 | }
|
---|
| 2231 | else
|
---|
| 2232 | {
|
---|
| 2233 | yytoken = YYTRANSLATE (yychar);
|
---|
| 2234 | YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
|
---|
| 2235 | }
|
---|
| 2236 | yyj = yypact[yystackp->yytops.yystates[0]->yylrState];
|
---|
| 2237 | if (yyis_pact_ninf (yyj))
|
---|
| 2238 | return;
|
---|
| 2239 | yyj += yytoken;
|
---|
| 2240 | if (yyj < 0 || YYLAST < yyj || yycheck[yyj] != yytoken)
|
---|
| 2241 | {
|
---|
| 2242 | if (yydefact[yystackp->yytops.yystates[0]->yylrState] != 0)
|
---|
| 2243 | return;
|
---|
| 2244 | }
|
---|
| 2245 | else if (yytable[yyj] != 0 && ! yyis_table_ninf (yytable[yyj]))
|
---|
| 2246 | return;
|
---|
| 2247 | }
|
---|
| 2248 |
|
---|
| 2249 | /* Reduce to one stack. */
|
---|
| 2250 | for (yyk = 0; yyk < yystackp->yytops.yysize; yyk += 1)
|
---|
| 2251 | if (yystackp->yytops.yystates[yyk] != NULL)
|
---|
| 2252 | break;
|
---|
| 2253 | if (yyk >= yystackp->yytops.yysize)
|
---|
| 2254 | yyFail (yystackp][]b4_lpure_args[, NULL);
|
---|
| 2255 | for (yyk += 1; yyk < yystackp->yytops.yysize; yyk += 1)
|
---|
| 2256 | yymarkStackDeleted (yystackp, yyk);
|
---|
| 2257 | yyremoveDeletes (yystackp);
|
---|
| 2258 | yycompressStack (yystackp);
|
---|
| 2259 |
|
---|
| 2260 | /* Now pop stack until we find a state that shifts the error token. */
|
---|
| 2261 | yystackp->yyerrState = 3;
|
---|
| 2262 | while (yystackp->yytops.yystates[0] != NULL)
|
---|
| 2263 | {
|
---|
| 2264 | yyGLRState *yys = yystackp->yytops.yystates[0];
|
---|
| 2265 | yyj = yypact[yys->yylrState];
|
---|
| 2266 | if (! yyis_pact_ninf (yyj))
|
---|
| 2267 | {
|
---|
| 2268 | yyj += YYTERROR;
|
---|
| 2269 | if (0 <= yyj && yyj <= YYLAST && yycheck[yyj] == YYTERROR
|
---|
| 2270 | && yyisShiftAction (yytable[yyj]))
|
---|
| 2271 | {
|
---|
| 2272 | /* Shift the error token having adjusted its location. */
|
---|
| 2273 | YYLTYPE yyerrloc;]b4_locations_if([[
|
---|
| 2274 | yystackp->yyerror_range[2].yystate.yyloc = yylloc;
|
---|
| 2275 | YYLLOC_DEFAULT (yyerrloc, (yystackp->yyerror_range), 2);]])[
|
---|
| 2276 | YY_SYMBOL_PRINT ("Shifting", yystos[yytable[yyj]],
|
---|
| 2277 | &yylval, &yyerrloc);
|
---|
| 2278 | yyglrShift (yystackp, 0, yytable[yyj],
|
---|
| 2279 | yys->yyposn, &yylval, &yyerrloc);
|
---|
| 2280 | yys = yystackp->yytops.yystates[0];
|
---|
| 2281 | break;
|
---|
| 2282 | }
|
---|
| 2283 | }
|
---|
| 2284 | ]b4_locations_if([[ yystackp->yyerror_range[1].yystate.yyloc = yys->yyloc;]])[
|
---|
| 2285 | if (yys->yypred != NULL)
|
---|
| 2286 | yydestroyGLRState ("Error: popping", yys]b4_user_args[);
|
---|
| 2287 | yystackp->yytops.yystates[0] = yys->yypred;
|
---|
| 2288 | yystackp->yynextFree -= 1;
|
---|
| 2289 | yystackp->yyspaceLeft += 1;
|
---|
| 2290 | }
|
---|
| 2291 | if (yystackp->yytops.yystates[0] == NULL)
|
---|
| 2292 | yyFail (yystackp][]b4_lpure_args[, NULL);
|
---|
| 2293 | }
|
---|
| 2294 |
|
---|
| 2295 | #define YYCHK1(YYE) \
|
---|
| 2296 | do { \
|
---|
| 2297 | switch (YYE) { \
|
---|
| 2298 | case yyok: \
|
---|
| 2299 | break; \
|
---|
| 2300 | case yyabort: \
|
---|
| 2301 | goto yyabortlab; \
|
---|
| 2302 | case yyaccept: \
|
---|
| 2303 | goto yyacceptlab; \
|
---|
| 2304 | case yyerr: \
|
---|
| 2305 | goto yyuser_error; \
|
---|
| 2306 | default: \
|
---|
| 2307 | goto yybuglab; \
|
---|
| 2308 | } \
|
---|
| 2309 | } while (YYID (0))
|
---|
| 2310 |
|
---|
| 2311 |
|
---|
| 2312 | /*----------.
|
---|
| 2313 | | yyparse. |
|
---|
| 2314 | `----------*/
|
---|
| 2315 |
|
---|
| 2316 | ]b4_c_ansi_function_def([yyparse], [int], b4_parse_param)[
|
---|
| 2317 | {
|
---|
| 2318 | int yyresult;
|
---|
| 2319 | yyGLRStack yystack;
|
---|
| 2320 | yyGLRStack* const yystackp = &yystack;
|
---|
| 2321 | size_t yyposn;
|
---|
| 2322 |
|
---|
| 2323 | YYDPRINTF ((stderr, "Starting parse\n"));
|
---|
| 2324 |
|
---|
| 2325 | yychar = YYEMPTY;
|
---|
| 2326 | yylval = yyval_default;
|
---|
| 2327 | ]b4_locations_if([
|
---|
| 2328 | #if YYLTYPE_IS_TRIVIAL
|
---|
| 2329 | yylloc.first_line = yylloc.last_line = ]b4_location_initial_line[;
|
---|
| 2330 | yylloc.first_column = yylloc.last_column = ]b4_location_initial_column[;
|
---|
| 2331 | #endif
|
---|
| 2332 | ])
|
---|
| 2333 | m4_ifdef([b4_initial_action], [
|
---|
| 2334 | m4_pushdef([b4_at_dollar], [yylloc])dnl
|
---|
| 2335 | m4_pushdef([b4_dollar_dollar], [yylval])dnl
|
---|
| 2336 | /* User initialization code. */
|
---|
| 2337 | b4_user_initial_action
|
---|
| 2338 | m4_popdef([b4_dollar_dollar])dnl
|
---|
| 2339 | m4_popdef([b4_at_dollar])])dnl
|
---|
| 2340 | [
|
---|
| 2341 | if (! yyinitGLRStack (yystackp, YYINITDEPTH))
|
---|
| 2342 | goto yyexhaustedlab;
|
---|
| 2343 | switch (YYSETJMP (yystack.yyexception_buffer))
|
---|
| 2344 | {
|
---|
| 2345 | case 0: break;
|
---|
| 2346 | case 1: goto yyabortlab;
|
---|
| 2347 | case 2: goto yyexhaustedlab;
|
---|
| 2348 | default: goto yybuglab;
|
---|
| 2349 | }
|
---|
| 2350 | yyglrShift (&yystack, 0, 0, 0, &yylval, &yylloc);
|
---|
| 2351 | yyposn = 0;
|
---|
| 2352 |
|
---|
| 2353 | while (YYID (yytrue))
|
---|
| 2354 | {
|
---|
| 2355 | /* For efficiency, we have two loops, the first of which is
|
---|
| 2356 | specialized to deterministic operation (single stack, no
|
---|
| 2357 | potential ambiguity). */
|
---|
| 2358 | /* Standard mode */
|
---|
| 2359 | while (YYID (yytrue))
|
---|
| 2360 | {
|
---|
| 2361 | yyRuleNum yyrule;
|
---|
| 2362 | int yyaction;
|
---|
| 2363 | const short int* yyconflicts;
|
---|
| 2364 |
|
---|
| 2365 | yyStateNum yystate = yystack.yytops.yystates[0]->yylrState;
|
---|
| 2366 | YYDPRINTF ((stderr, "Entering state %d\n", yystate));
|
---|
| 2367 | if (yystate == YYFINAL)
|
---|
| 2368 | goto yyacceptlab;
|
---|
| 2369 | if (yyisDefaultedState (yystate))
|
---|
| 2370 | {
|
---|
| 2371 | yyrule = yydefaultAction (yystate);
|
---|
| 2372 | if (yyrule == 0)
|
---|
| 2373 | {
|
---|
| 2374 | ]b4_locations_if([[ yystack.yyerror_range[1].yystate.yyloc = yylloc;]])[
|
---|
| 2375 | yyreportSyntaxError (&yystack]b4_user_args[);
|
---|
| 2376 | goto yyuser_error;
|
---|
| 2377 | }
|
---|
| 2378 | YYCHK1 (yyglrReduce (&yystack, 0, yyrule, yytrue]b4_user_args[));
|
---|
| 2379 | }
|
---|
| 2380 | else
|
---|
| 2381 | {
|
---|
| 2382 | yySymbol yytoken;
|
---|
| 2383 | if (yychar == YYEMPTY)
|
---|
| 2384 | {
|
---|
| 2385 | YYDPRINTF ((stderr, "Reading a token: "));
|
---|
| 2386 | yychar = YYLEX;
|
---|
| 2387 | }
|
---|
| 2388 |
|
---|
| 2389 | if (yychar <= YYEOF)
|
---|
| 2390 | {
|
---|
| 2391 | yychar = yytoken = YYEOF;
|
---|
| 2392 | YYDPRINTF ((stderr, "Now at end of input.\n"));
|
---|
| 2393 | }
|
---|
| 2394 | else
|
---|
| 2395 | {
|
---|
| 2396 | yytoken = YYTRANSLATE (yychar);
|
---|
| 2397 | YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
|
---|
| 2398 | }
|
---|
| 2399 |
|
---|
| 2400 | yygetLRActions (yystate, yytoken, &yyaction, &yyconflicts);
|
---|
| 2401 | if (*yyconflicts != 0)
|
---|
| 2402 | break;
|
---|
| 2403 | if (yyisShiftAction (yyaction))
|
---|
| 2404 | {
|
---|
| 2405 | YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
|
---|
| 2406 | yychar = YYEMPTY;
|
---|
| 2407 | yyposn += 1;
|
---|
| 2408 | yyglrShift (&yystack, 0, yyaction, yyposn, &yylval, &yylloc);
|
---|
| 2409 | if (0 < yystack.yyerrState)
|
---|
| 2410 | yystack.yyerrState -= 1;
|
---|
| 2411 | }
|
---|
| 2412 | else if (yyisErrorAction (yyaction))
|
---|
| 2413 | {
|
---|
| 2414 | ]b4_locations_if([[ yystack.yyerror_range[1].yystate.yyloc = yylloc;]])[
|
---|
| 2415 | yyreportSyntaxError (&yystack]b4_user_args[);
|
---|
| 2416 | goto yyuser_error;
|
---|
| 2417 | }
|
---|
| 2418 | else
|
---|
| 2419 | YYCHK1 (yyglrReduce (&yystack, 0, -yyaction, yytrue]b4_user_args[));
|
---|
| 2420 | }
|
---|
| 2421 | }
|
---|
| 2422 |
|
---|
| 2423 | while (YYID (yytrue))
|
---|
| 2424 | {
|
---|
| 2425 | yySymbol yytoken_to_shift;
|
---|
| 2426 | size_t yys;
|
---|
| 2427 |
|
---|
| 2428 | for (yys = 0; yys < yystack.yytops.yysize; yys += 1)
|
---|
| 2429 | yystackp->yytops.yylookaheadNeeds[yys] = yychar != YYEMPTY;
|
---|
| 2430 |
|
---|
| 2431 | /* yyprocessOneStack returns one of three things:
|
---|
| 2432 |
|
---|
| 2433 | - An error flag. If the caller is yyprocessOneStack, it
|
---|
| 2434 | immediately returns as well. When the caller is finally
|
---|
| 2435 | yyparse, it jumps to an error label via YYCHK1.
|
---|
| 2436 |
|
---|
| 2437 | - yyok, but yyprocessOneStack has invoked yymarkStackDeleted
|
---|
| 2438 | (&yystack, yys), which sets the top state of yys to NULL. Thus,
|
---|
| 2439 | yyparse's following invocation of yyremoveDeletes will remove
|
---|
| 2440 | the stack.
|
---|
| 2441 |
|
---|
| 2442 | - yyok, when ready to shift a token.
|
---|
| 2443 |
|
---|
| 2444 | Except in the first case, yyparse will invoke yyremoveDeletes and
|
---|
| 2445 | then shift the next token onto all remaining stacks. This
|
---|
| 2446 | synchronization of the shift (that is, after all preceding
|
---|
| 2447 | reductions on all stacks) helps prevent double destructor calls
|
---|
| 2448 | on yylval in the event of memory exhaustion. */
|
---|
| 2449 |
|
---|
| 2450 | for (yys = 0; yys < yystack.yytops.yysize; yys += 1)
|
---|
| 2451 | YYCHK1 (yyprocessOneStack (&yystack, yys, yyposn]b4_lpure_args[));
|
---|
| 2452 | yyremoveDeletes (&yystack);
|
---|
| 2453 | if (yystack.yytops.yysize == 0)
|
---|
| 2454 | {
|
---|
| 2455 | yyundeleteLastStack (&yystack);
|
---|
| 2456 | if (yystack.yytops.yysize == 0)
|
---|
| 2457 | yyFail (&yystack][]b4_lpure_args[, YY_("syntax error"));
|
---|
| 2458 | YYCHK1 (yyresolveStack (&yystack]b4_user_args[));
|
---|
| 2459 | YYDPRINTF ((stderr, "Returning to deterministic operation.\n"));
|
---|
| 2460 | ]b4_locations_if([[ yystack.yyerror_range[1].yystate.yyloc = yylloc;]])[
|
---|
| 2461 | yyreportSyntaxError (&yystack]b4_user_args[);
|
---|
| 2462 | goto yyuser_error;
|
---|
| 2463 | }
|
---|
| 2464 |
|
---|
| 2465 | /* If any yyglrShift call fails, it will fail after shifting. Thus,
|
---|
| 2466 | a copy of yylval will already be on stack 0 in the event of a
|
---|
| 2467 | failure in the following loop. Thus, yychar is set to YYEMPTY
|
---|
| 2468 | before the loop to make sure the user destructor for yylval isn't
|
---|
| 2469 | called twice. */
|
---|
| 2470 | yytoken_to_shift = YYTRANSLATE (yychar);
|
---|
| 2471 | yychar = YYEMPTY;
|
---|
| 2472 | yyposn += 1;
|
---|
| 2473 | for (yys = 0; yys < yystack.yytops.yysize; yys += 1)
|
---|
| 2474 | {
|
---|
| 2475 | int yyaction;
|
---|
| 2476 | const short int* yyconflicts;
|
---|
| 2477 | yyStateNum yystate = yystack.yytops.yystates[yys]->yylrState;
|
---|
| 2478 | yygetLRActions (yystate, yytoken_to_shift, &yyaction,
|
---|
| 2479 | &yyconflicts);
|
---|
| 2480 | /* Note that yyconflicts were handled by yyprocessOneStack. */
|
---|
| 2481 | YYDPRINTF ((stderr, "On stack %lu, ", (unsigned long int) yys));
|
---|
| 2482 | YY_SYMBOL_PRINT ("shifting", yytoken_to_shift, &yylval, &yylloc);
|
---|
| 2483 | yyglrShift (&yystack, yys, yyaction, yyposn,
|
---|
| 2484 | &yylval, &yylloc);
|
---|
| 2485 | YYDPRINTF ((stderr, "Stack %lu now in state #%d\n",
|
---|
| 2486 | (unsigned long int) yys,
|
---|
| 2487 | yystack.yytops.yystates[yys]->yylrState));
|
---|
| 2488 | }
|
---|
| 2489 |
|
---|
| 2490 | if (yystack.yytops.yysize == 1)
|
---|
| 2491 | {
|
---|
| 2492 | YYCHK1 (yyresolveStack (&yystack]b4_user_args[));
|
---|
| 2493 | YYDPRINTF ((stderr, "Returning to deterministic operation.\n"));
|
---|
| 2494 | yycompressStack (&yystack);
|
---|
| 2495 | break;
|
---|
| 2496 | }
|
---|
| 2497 | }
|
---|
| 2498 | continue;
|
---|
| 2499 | yyuser_error:
|
---|
| 2500 | yyrecoverSyntaxError (&yystack]b4_user_args[);
|
---|
| 2501 | yyposn = yystack.yytops.yystates[0]->yyposn;
|
---|
| 2502 | }
|
---|
| 2503 |
|
---|
| 2504 | yyacceptlab:
|
---|
| 2505 | yyresult = 0;
|
---|
| 2506 | goto yyreturn;
|
---|
| 2507 |
|
---|
| 2508 | yybuglab:
|
---|
| 2509 | YYASSERT (yyfalse);
|
---|
| 2510 | goto yyabortlab;
|
---|
| 2511 |
|
---|
| 2512 | yyabortlab:
|
---|
| 2513 | yyresult = 1;
|
---|
| 2514 | goto yyreturn;
|
---|
| 2515 |
|
---|
| 2516 | yyexhaustedlab:
|
---|
| 2517 | yyerror (]b4_lyyerror_args[YY_("memory exhausted"));
|
---|
| 2518 | yyresult = 2;
|
---|
| 2519 | goto yyreturn;
|
---|
| 2520 |
|
---|
| 2521 | yyreturn:
|
---|
| 2522 | if (yychar != YYEMPTY)
|
---|
| 2523 | yydestruct ("Cleanup: discarding lookahead",
|
---|
| 2524 | YYTRANSLATE (yychar),
|
---|
| 2525 | &yylval]b4_locations_if([, &yylloc])[]b4_user_args[);
|
---|
| 2526 |
|
---|
| 2527 | /* If the stack is well-formed, pop the stack until it is empty,
|
---|
| 2528 | destroying its entries as we go. But free the stack regardless
|
---|
| 2529 | of whether it is well-formed. */
|
---|
| 2530 | if (yystack.yyitems)
|
---|
| 2531 | {
|
---|
| 2532 | yyGLRState** yystates = yystack.yytops.yystates;
|
---|
| 2533 | if (yystates)
|
---|
| 2534 | {
|
---|
| 2535 | size_t yysize = yystack.yytops.yysize;
|
---|
| 2536 | size_t yyk;
|
---|
| 2537 | for (yyk = 0; yyk < yysize; yyk += 1)
|
---|
| 2538 | if (yystates[yyk])
|
---|
| 2539 | {
|
---|
| 2540 | while (yystates[yyk])
|
---|
| 2541 | {
|
---|
| 2542 | yyGLRState *yys = yystates[yyk];
|
---|
| 2543 | ]b4_locations_if([[ yystack.yyerror_range[1].yystate.yyloc = yys->yyloc;]]
|
---|
| 2544 | )[ if (yys->yypred != NULL)
|
---|
| 2545 | yydestroyGLRState ("Cleanup: popping", yys]b4_user_args[);
|
---|
| 2546 | yystates[yyk] = yys->yypred;
|
---|
| 2547 | yystack.yynextFree -= 1;
|
---|
| 2548 | yystack.yyspaceLeft += 1;
|
---|
| 2549 | }
|
---|
| 2550 | break;
|
---|
| 2551 | }
|
---|
| 2552 | }
|
---|
| 2553 | yyfreeGLRStack (&yystack);
|
---|
| 2554 | }
|
---|
| 2555 |
|
---|
| 2556 | /* Make sure YYID is used. */
|
---|
| 2557 | return YYID (yyresult);
|
---|
| 2558 | }
|
---|
| 2559 |
|
---|
| 2560 | /* DEBUGGING ONLY */
|
---|
| 2561 | #if YYDEBUG
|
---|
| 2562 | static void yypstack (yyGLRStack* yystackp, size_t yyk)
|
---|
| 2563 | __attribute__ ((__unused__));
|
---|
| 2564 | static void yypdumpstack (yyGLRStack* yystackp) __attribute__ ((__unused__));
|
---|
| 2565 |
|
---|
| 2566 | static void
|
---|
| 2567 | yy_yypstack (yyGLRState* yys)
|
---|
| 2568 | {
|
---|
| 2569 | if (yys->yypred)
|
---|
| 2570 | {
|
---|
| 2571 | yy_yypstack (yys->yypred);
|
---|
| 2572 | YYFPRINTF (stderr, " -> ");
|
---|
| 2573 | }
|
---|
| 2574 | YYFPRINTF (stderr, "%d@@%lu", yys->yylrState,
|
---|
| 2575 | (unsigned long int) yys->yyposn);
|
---|
| 2576 | }
|
---|
| 2577 |
|
---|
| 2578 | static void
|
---|
| 2579 | yypstates (yyGLRState* yyst)
|
---|
| 2580 | {
|
---|
| 2581 | if (yyst == NULL)
|
---|
| 2582 | YYFPRINTF (stderr, "<null>");
|
---|
| 2583 | else
|
---|
| 2584 | yy_yypstack (yyst);
|
---|
| 2585 | YYFPRINTF (stderr, "\n");
|
---|
| 2586 | }
|
---|
| 2587 |
|
---|
| 2588 | static void
|
---|
| 2589 | yypstack (yyGLRStack* yystackp, size_t yyk)
|
---|
| 2590 | {
|
---|
| 2591 | yypstates (yystackp->yytops.yystates[yyk]);
|
---|
| 2592 | }
|
---|
| 2593 |
|
---|
| 2594 | #define YYINDEX(YYX) \
|
---|
| 2595 | ((YYX) == NULL ? -1 : (yyGLRStackItem*) (YYX) - yystackp->yyitems)
|
---|
| 2596 |
|
---|
| 2597 |
|
---|
| 2598 | static void
|
---|
| 2599 | yypdumpstack (yyGLRStack* yystackp)
|
---|
| 2600 | {
|
---|
| 2601 | yyGLRStackItem* yyp;
|
---|
| 2602 | size_t yyi;
|
---|
| 2603 | for (yyp = yystackp->yyitems; yyp < yystackp->yynextFree; yyp += 1)
|
---|
| 2604 | {
|
---|
| 2605 | YYFPRINTF (stderr, "%3lu. ",
|
---|
| 2606 | (unsigned long int) (yyp - yystackp->yyitems));
|
---|
| 2607 | if (*(yybool *) yyp)
|
---|
| 2608 | {
|
---|
| 2609 | YYFPRINTF (stderr, "Res: %d, LR State: %d, posn: %lu, pred: %ld",
|
---|
| 2610 | yyp->yystate.yyresolved, yyp->yystate.yylrState,
|
---|
| 2611 | (unsigned long int) yyp->yystate.yyposn,
|
---|
| 2612 | (long int) YYINDEX (yyp->yystate.yypred));
|
---|
| 2613 | if (! yyp->yystate.yyresolved)
|
---|
| 2614 | YYFPRINTF (stderr, ", firstVal: %ld",
|
---|
| 2615 | (long int) YYINDEX (yyp->yystate
|
---|
| 2616 | .yysemantics.yyfirstVal));
|
---|
| 2617 | }
|
---|
| 2618 | else
|
---|
| 2619 | {
|
---|
| 2620 | YYFPRINTF (stderr, "Option. rule: %d, state: %ld, next: %ld",
|
---|
| 2621 | yyp->yyoption.yyrule - 1,
|
---|
| 2622 | (long int) YYINDEX (yyp->yyoption.yystate),
|
---|
| 2623 | (long int) YYINDEX (yyp->yyoption.yynext));
|
---|
| 2624 | }
|
---|
| 2625 | YYFPRINTF (stderr, "\n");
|
---|
| 2626 | }
|
---|
| 2627 | YYFPRINTF (stderr, "Tops:");
|
---|
| 2628 | for (yyi = 0; yyi < yystackp->yytops.yysize; yyi += 1)
|
---|
| 2629 | YYFPRINTF (stderr, "%lu: %ld; ", (unsigned long int) yyi,
|
---|
| 2630 | (long int) YYINDEX (yystackp->yytops.yystates[yyi]));
|
---|
| 2631 | YYFPRINTF (stderr, "\n");
|
---|
| 2632 | }
|
---|
| 2633 | #endif
|
---|
| 2634 | ]
|
---|
| 2635 |
|
---|
| 2636 | b4_epilogue
|
---|
| 2637 | dnl
|
---|
| 2638 | dnl glr.cc produces its own header.
|
---|
| 2639 | dnl
|
---|
| 2640 | m4_if(b4_skeleton, ["glr.c"],
|
---|
| 2641 | [b4_defines_if(
|
---|
| 2642 | [@output(b4_spec_defines_file@)
|
---|
| 2643 | b4_copyright([Skeleton interface for Bison GLR parsers in C],
|
---|
| 2644 | [2002, 2003, 2004, 2005, 2006])
|
---|
| 2645 |
|
---|
| 2646 | b4_shared_declarations
|
---|
| 2647 |
|
---|
| 2648 | b4_pure_if([],
|
---|
| 2649 | [[extern YYSTYPE ]b4_prefix[lval;]])
|
---|
| 2650 |
|
---|
| 2651 | b4_locations_if([b4_pure_if([],
|
---|
| 2652 | [extern YYLTYPE ]b4_prefix[lloc;])
|
---|
| 2653 | ])
|
---|
| 2654 | ])])
|
---|
| 2655 | m4_divert_pop(0)
|
---|