1 /* $NetBSD: btyacc_destroy3.tab.c,v 1.1.1.3 2016/01/09 21:59:46 christos Exp $ */ 2 3 /* original parser id follows */ 4 /* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ 5 /* (use YYMAJOR/YYMINOR for ifdefs dependent of parser version) */ 6 7 #define YYBYACC 1 8 #define YYMAJOR 1 9 #define YYMINOR 9 10 #define YYCHECK "yyyymmdd" 11 12 #define YYEMPTY (-1) 13 #define yyclearin (yychar = YYEMPTY) 14 #define yyerrok (yyerrflag = 0) 15 #define YYRECOVERING() (yyerrflag != 0) 16 #define YYENOMEM (-2) 17 #define YYEOF 0 18 #undef YYBTYACC 19 #define YYBTYACC 1 20 #define YYDEBUGSTR (yytrial ? YYPREFIX "debug(trial)" : YYPREFIX "debug") 21 22 #ifndef yyparse 23 #define yyparse destroy3_parse 24 #endif /* yyparse */ 25 26 #ifndef yylex 27 #define yylex destroy3_lex 28 #endif /* yylex */ 29 30 #ifndef yyerror 31 #define yyerror destroy3_error 32 #endif /* yyerror */ 33 34 #ifndef yychar 35 #define yychar destroy3_char 36 #endif /* yychar */ 37 38 #ifndef yyval 39 #define yyval destroy3_val 40 #endif /* yyval */ 41 42 #ifndef yylval 43 #define yylval destroy3_lval 44 #endif /* yylval */ 45 46 #ifndef yydebug 47 #define yydebug destroy3_debug 48 #endif /* yydebug */ 49 50 #ifndef yynerrs 51 #define yynerrs destroy3_nerrs 52 #endif /* yynerrs */ 53 54 #ifndef yyerrflag 55 #define yyerrflag destroy3_errflag 56 #endif /* yyerrflag */ 57 58 #ifndef yylhs 59 #define yylhs destroy3_lhs 60 #endif /* yylhs */ 61 62 #ifndef yylen 63 #define yylen destroy3_len 64 #endif /* yylen */ 65 66 #ifndef yydefred 67 #define yydefred destroy3_defred 68 #endif /* yydefred */ 69 70 #ifndef yystos 71 #define yystos destroy3_stos 72 #endif /* yystos */ 73 74 #ifndef yydgoto 75 #define yydgoto destroy3_dgoto 76 #endif /* yydgoto */ 77 78 #ifndef yysindex 79 #define yysindex destroy3_sindex 80 #endif /* yysindex */ 81 82 #ifndef yyrindex 83 #define yyrindex destroy3_rindex 84 #endif /* yyrindex */ 85 86 #ifndef yygindex 87 #define yygindex destroy3_gindex 88 #endif /* yygindex */ 89 90 #ifndef yytable 91 #define yytable destroy3_table 92 #endif /* yytable */ 93 94 #ifndef yycheck 95 #define yycheck destroy3_check 96 #endif /* yycheck */ 97 98 #ifndef yyname 99 #define yyname destroy3_name 100 #endif /* yyname */ 101 102 #ifndef yyrule 103 #define yyrule destroy3_rule 104 #endif /* yyrule */ 105 106 #if YYBTYACC 107 108 #ifndef yycindex 109 #define yycindex destroy3_cindex 110 #endif /* yycindex */ 111 112 #ifndef yyctable 113 #define yyctable destroy3_ctable 114 #endif /* yyctable */ 115 116 #endif /* YYBTYACC */ 117 118 #define YYPREFIX "destroy3_" 119 120 #define YYPURE 0 121 122 #line 7 "btyacc_destroy3.y" 123 #include <stdlib.h> 124 125 typedef enum {cGLOBAL, cLOCAL} class; 126 typedef enum {tREAL, tINTEGER} type; 127 typedef char * name; 128 129 struct symbol { class c; type t; name id; }; 130 typedef struct symbol symbol; 131 132 struct namelist { symbol *s; struct namelist *next; }; 133 typedef struct namelist namelist; 134 135 struct parser_param { 136 int *rtrn; 137 symbol ss; 138 }; 139 140 extern symbol *mksymbol(type t, class c, name id); 141 142 #ifdef YYBISON 143 #define YYLEX_DECL() yylex(void) 144 #define YYERROR_DECL() yyerror(const char *s) 145 #endif 146 #line 53 "btyacc_destroy3.y" 147 #ifdef YYSTYPE 148 #undef YYSTYPE_IS_DECLARED 149 #define YYSTYPE_IS_DECLARED 1 150 #endif 151 #ifndef YYSTYPE_IS_DECLARED 152 #define YYSTYPE_IS_DECLARED 1 153 typedef union 154 { 155 class cval; 156 type tval; 157 namelist * nlist; 158 name id; 159 } YYSTYPE; 160 #endif /* !YYSTYPE_IS_DECLARED */ 161 #line 160 "btyacc_destroy3.tab.c" 162 163 /* compatibility with bison */ 164 #ifdef YYPARSE_PARAM 165 /* compatibility with FreeBSD */ 166 # ifdef YYPARSE_PARAM_TYPE 167 # define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM) 168 # else 169 # define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM) 170 # endif 171 #else 172 # define YYPARSE_DECL() yyparse(struct parser_param *param, int flag) 173 #endif 174 175 /* Parameters sent to lex. */ 176 #ifdef YYLEX_PARAM 177 # define YYLEX_DECL() yylex(void *YYLEX_PARAM) 178 # define YYLEX yylex(YYLEX_PARAM) 179 #else 180 # define YYLEX_DECL() yylex(void) 181 # define YYLEX yylex() 182 #endif 183 184 /* Parameters sent to yyerror. */ 185 #ifndef YYERROR_DECL 186 #define YYERROR_DECL() yyerror(struct parser_param *param, int flag, const char *s) 187 #endif 188 #ifndef YYERROR_CALL 189 #define YYERROR_CALL(msg) yyerror(param, flag, msg) 190 #endif 191 192 #ifndef YYDESTRUCT_DECL 193 #define YYDESTRUCT_DECL() yydestruct(const char *msg, int psymb, YYSTYPE *val, struct parser_param *param, int flag) 194 #endif 195 #ifndef YYDESTRUCT_CALL 196 #define YYDESTRUCT_CALL(msg, psymb, val) yydestruct(msg, psymb, val, param, flag) 197 #endif 198 199 extern int YYPARSE_DECL(); 200 201 #define GLOBAL 257 202 #define LOCAL 258 203 #define REAL 259 204 #define INTEGER 260 205 #define NAME 261 206 #define YYERRCODE 256 207 typedef short YYINT; 208 static const YYINT destroy3_lhs[] = { -1, 209 0, 0, 2, 2, 3, 3, 4, 4, 1, 210 }; 211 static const YYINT destroy3_len[] = { 2, 212 8, 5, 1, 1, 1, 1, 2, 1, 6, 213 }; 214 static const YYINT destroy3_defred[] = { 0, 215 3, 4, 5, 6, 0, 0, 0, 0, 8, 0, 216 0, 0, 0, 7, 0, 0, 0, 0, 0, 2, 217 0, 0, 0, 0, 9, 1, 218 }; 219 static const YYINT destroy3_stos[] = { 0, 220 257, 258, 259, 260, 263, 265, 266, 266, 261, 264, 221 267, 267, 40, 261, 40, 40, 265, 258, 265, 41, 222 44, 44, 266, 266, 41, 41, 223 }; 224 static const YYINT destroy3_dgoto[] = { 5, 225 10, 6, 7, 11, 226 }; 227 static const YYINT destroy3_sindex[] = { -254, 228 0, 0, 0, 0, 0, -251, -248, -248, 0, -26, 229 -40, -39, -246, 0, -243, -246, -25, -24, -23, 0, 230 -251, -251, -22, -19, 0, 0, 231 }; 232 static const YYINT destroy3_rindex[] = { 0, 233 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 234 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 235 0, 0, 0, 0, 0, 0, 236 }; 237 #if YYBTYACC 238 static const YYINT destroy3_cindex[] = { 0, 239 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 240 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 241 0, 0, 0, 0, 0, 0, 242 }; 243 #endif 244 static const YYINT destroy3_gindex[] = { 0, 245 0, -6, -4, 15, 246 }; 247 #define YYTABLESIZE 222 248 static const YYINT destroy3_table[] = { 15, 249 16, 8, 1, 2, 3, 4, 17, 3, 4, 19, 250 1, 2, 9, 13, 18, 20, 23, 24, 25, 21, 251 22, 26, 12, 0, 0, 0, 0, 0, 0, 0, 252 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 253 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 254 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 256 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 257 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 258 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 259 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 260 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 261 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 262 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 263 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 264 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 265 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 266 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 267 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 268 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 269 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 270 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 271 14, 14, 272 }; 273 static const YYINT destroy3_check[] = { 40, 274 40, 6, 257, 258, 259, 260, 13, 259, 260, 16, 275 257, 258, 261, 40, 258, 41, 21, 22, 41, 44, 276 44, 41, 8, -1, -1, -1, -1, -1, -1, -1, 277 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 278 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 279 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 280 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 281 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 282 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 283 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 284 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 285 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 286 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 287 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 288 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 289 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 290 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 291 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 292 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 293 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 294 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 295 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 296 261, 261, 297 }; 298 #if YYBTYACC 299 static const YYINT destroy3_ctable[] = { -1, 300 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 301 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 302 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 303 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 304 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 305 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 306 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 307 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 308 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 309 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 310 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 311 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 312 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 313 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 314 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 315 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 316 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 317 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 318 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 319 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 320 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 321 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 322 -1, 323 }; 324 #endif 325 #define YYFINAL 5 326 #ifndef YYDEBUG 327 #define YYDEBUG 0 328 #endif 329 #define YYMAXTOKEN 261 330 #define YYUNDFTOKEN 268 331 #define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) 332 #if YYDEBUG 333 static const char *const destroy3_name[] = { 334 335 "$end",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 336 0,0,0,"'('","')'",0,0,"','",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 337 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 338 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 339 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 340 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 341 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"error","GLOBAL","LOCAL", 342 "REAL","INTEGER","NAME","$accept","declaration","locnamelist","class","type", 343 "namelist","illegal-symbol", 344 }; 345 static const char *const destroy3_rule[] = { 346 "$accept : declaration", 347 "declaration : class type namelist '(' class ',' type ')'", 348 "declaration : type locnamelist '(' class ')'", 349 "class : GLOBAL", 350 "class : LOCAL", 351 "type : REAL", 352 "type : INTEGER", 353 "namelist : namelist NAME", 354 "namelist : NAME", 355 "locnamelist : namelist '(' LOCAL ',' type ')'", 356 357 }; 358 #endif 359 360 int yydebug; 361 int yynerrs; 362 363 int yyerrflag; 364 int yychar; 365 YYSTYPE yyval; 366 YYSTYPE yylval; 367 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 368 YYLTYPE yyloc; /* position returned by actions */ 369 YYLTYPE yylloc; /* position from the lexer */ 370 #endif 371 372 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 373 #ifndef YYLLOC_DEFAULT 374 #define YYLLOC_DEFAULT(loc, rhs, n) \ 375 do \ 376 { \ 377 if (n == 0) \ 378 { \ 379 (loc).first_line = ((rhs)[-1]).last_line; \ 380 (loc).first_column = ((rhs)[-1]).last_column; \ 381 (loc).last_line = ((rhs)[-1]).last_line; \ 382 (loc).last_column = ((rhs)[-1]).last_column; \ 383 } \ 384 else \ 385 { \ 386 (loc).first_line = ((rhs)[ 0 ]).first_line; \ 387 (loc).first_column = ((rhs)[ 0 ]).first_column; \ 388 (loc).last_line = ((rhs)[n-1]).last_line; \ 389 (loc).last_column = ((rhs)[n-1]).last_column; \ 390 } \ 391 } while (0) 392 #endif /* YYLLOC_DEFAULT */ 393 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ 394 #if YYBTYACC 395 396 #ifndef YYLVQUEUEGROWTH 397 #define YYLVQUEUEGROWTH 32 398 #endif 399 #endif /* YYBTYACC */ 400 401 /* define the initial stack-sizes */ 402 #ifdef YYSTACKSIZE 403 #undef YYMAXDEPTH 404 #define YYMAXDEPTH YYSTACKSIZE 405 #else 406 #ifdef YYMAXDEPTH 407 #define YYSTACKSIZE YYMAXDEPTH 408 #else 409 #define YYSTACKSIZE 10000 410 #define YYMAXDEPTH 10000 411 #endif 412 #endif 413 414 #ifndef YYINITSTACKSIZE 415 #define YYINITSTACKSIZE 200 416 #endif 417 418 typedef struct { 419 unsigned stacksize; 420 short *s_base; 421 short *s_mark; 422 short *s_last; 423 YYSTYPE *l_base; 424 YYSTYPE *l_mark; 425 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 426 YYLTYPE *p_base; 427 YYLTYPE *p_mark; 428 #endif 429 } YYSTACKDATA; 430 #if YYBTYACC 431 432 struct YYParseState_s 433 { 434 struct YYParseState_s *save; /* Previously saved parser state */ 435 YYSTACKDATA yystack; /* saved parser stack */ 436 int state; /* saved parser state */ 437 int errflag; /* saved error recovery status */ 438 int lexeme; /* saved index of the conflict lexeme in the lexical queue */ 439 YYINT ctry; /* saved index in yyctable[] for this conflict */ 440 }; 441 typedef struct YYParseState_s YYParseState; 442 #endif /* YYBTYACC */ 443 /* variables for the parser stack */ 444 static YYSTACKDATA yystack; 445 #if YYBTYACC 446 447 /* Current parser state */ 448 static YYParseState *yyps = 0; 449 450 /* yypath != NULL: do the full parse, starting at *yypath parser state. */ 451 static YYParseState *yypath = 0; 452 453 /* Base of the lexical value queue */ 454 static YYSTYPE *yylvals = 0; 455 456 /* Current position at lexical value queue */ 457 static YYSTYPE *yylvp = 0; 458 459 /* End position of lexical value queue */ 460 static YYSTYPE *yylve = 0; 461 462 /* The last allocated position at the lexical value queue */ 463 static YYSTYPE *yylvlim = 0; 464 465 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 466 /* Base of the lexical position queue */ 467 static YYLTYPE *yylpsns = 0; 468 469 /* Current position at lexical position queue */ 470 static YYLTYPE *yylpp = 0; 471 472 /* End position of lexical position queue */ 473 static YYLTYPE *yylpe = 0; 474 475 /* The last allocated position at the lexical position queue */ 476 static YYLTYPE *yylplim = 0; 477 #endif 478 479 /* Current position at lexical token queue */ 480 static short *yylexp = 0; 481 482 static short *yylexemes = 0; 483 #endif /* YYBTYACC */ 484 #line 92 "btyacc_destroy3.y" 485 486 extern int YYLEX_DECL(); 487 extern void YYERROR_DECL(); 488 #line 487 "btyacc_destroy3.tab.c" 489 490 /* Release memory associated with symbol. */ 491 #if ! defined YYDESTRUCT_IS_DECLARED 492 static void 493 YYDESTRUCT_DECL() 494 { 495 switch (psymb) 496 { 497 case 263: 498 #line 44 "btyacc_destroy3.y" 499 { 500 namelist *p = (*val).nlist; 501 while (p != NULL) 502 { namelist *pp = p; 503 p = p->next; 504 free(pp->s); free(pp); 505 } 506 } 507 break; 508 #line 507 "btyacc_destroy3.tab.c" 509 } 510 } 511 #define YYDESTRUCT_IS_DECLARED 1 512 #endif 513 514 /* For use in generated program */ 515 #define yydepth (int)(yystack.s_mark - yystack.s_base) 516 #if YYBTYACC 517 #define yytrial (yyps->save) 518 #endif /* YYBTYACC */ 519 520 #if YYDEBUG 521 #include <stdio.h> /* needed for printf */ 522 #endif 523 524 #include <stdlib.h> /* needed for malloc, etc */ 525 #include <string.h> /* needed for memset */ 526 527 /* allocate initial stack or double stack size, up to YYMAXDEPTH */ 528 static int yygrowstack(YYSTACKDATA *data) 529 { 530 int i; 531 unsigned newsize; 532 short *newss; 533 YYSTYPE *newvs; 534 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 535 YYLTYPE *newps; 536 #endif 537 538 if ((newsize = data->stacksize) == 0) 539 newsize = YYINITSTACKSIZE; 540 else if (newsize >= YYMAXDEPTH) 541 return YYENOMEM; 542 else if ((newsize *= 2) > YYMAXDEPTH) 543 newsize = YYMAXDEPTH; 544 545 i = (int) (data->s_mark - data->s_base); 546 newss = (short *)realloc(data->s_base, newsize * sizeof(*newss)); 547 if (newss == 0) 548 return YYENOMEM; 549 550 data->s_base = newss; 551 data->s_mark = newss + i; 552 553 newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); 554 if (newvs == 0) 555 return YYENOMEM; 556 557 data->l_base = newvs; 558 data->l_mark = newvs + i; 559 560 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 561 newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); 562 if (newps == 0) 563 return YYENOMEM; 564 565 data->p_base = newps; 566 data->p_mark = newps + i; 567 #endif 568 569 data->stacksize = newsize; 570 data->s_last = data->s_base + newsize - 1; 571 572 #if YYDEBUG 573 if (yydebug) 574 fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); 575 #endif 576 return 0; 577 } 578 579 #if YYPURE || defined(YY_NO_LEAKS) 580 static void yyfreestack(YYSTACKDATA *data) 581 { 582 free(data->s_base); 583 free(data->l_base); 584 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 585 free(data->p_base); 586 #endif 587 memset(data, 0, sizeof(*data)); 588 } 589 #else 590 #define yyfreestack(data) /* nothing */ 591 #endif /* YYPURE || defined(YY_NO_LEAKS) */ 592 #if YYBTYACC 593 594 static YYParseState * 595 yyNewState(unsigned size) 596 { 597 YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); 598 if (p == NULL) return NULL; 599 600 p->yystack.stacksize = size; 601 if (size == 0) 602 { 603 p->yystack.s_base = NULL; 604 p->yystack.l_base = NULL; 605 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 606 p->yystack.p_base = NULL; 607 #endif 608 return p; 609 } 610 p->yystack.s_base = (short *) malloc(size * sizeof(short)); 611 if (p->yystack.s_base == NULL) return NULL; 612 p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); 613 if (p->yystack.l_base == NULL) return NULL; 614 memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); 615 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 616 p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); 617 if (p->yystack.p_base == NULL) return NULL; 618 memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); 619 #endif 620 621 return p; 622 } 623 624 static void 625 yyFreeState(YYParseState *p) 626 { 627 yyfreestack(&p->yystack); 628 free(p); 629 } 630 #endif /* YYBTYACC */ 631 632 #define YYABORT goto yyabort 633 #define YYREJECT goto yyabort 634 #define YYACCEPT goto yyaccept 635 #define YYERROR goto yyerrlab 636 #if YYBTYACC 637 #define YYVALID do { if (yyps->save) goto yyvalid; } while(0) 638 #define YYVALID_NESTED do { if (yyps->save && \ 639 yyps->save->save == 0) goto yyvalid; } while(0) 640 #endif /* YYBTYACC */ 641 642 int 643 YYPARSE_DECL() 644 { 645 int yym, yyn, yystate, yyresult; 646 #if YYBTYACC 647 int yynewerrflag; 648 YYParseState *yyerrctx = NULL; 649 #endif /* YYBTYACC */ 650 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 651 YYLTYPE yyerror_loc_range[2]; /* position of error start & end */ 652 #endif 653 #if YYDEBUG 654 const char *yys; 655 656 if ((yys = getenv("YYDEBUG")) != 0) 657 { 658 yyn = *yys; 659 if (yyn >= '0' && yyn <= '9') 660 yydebug = yyn - '0'; 661 } 662 if (yydebug) 663 fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); 664 #endif 665 666 #if YYBTYACC 667 yyps = yyNewState(0); if (yyps == 0) goto yyenomem; 668 yyps->save = 0; 669 #endif /* YYBTYACC */ 670 yynerrs = 0; 671 yyerrflag = 0; 672 yychar = YYEMPTY; 673 yystate = 0; 674 675 #if YYPURE 676 memset(&yystack, 0, sizeof(yystack)); 677 #endif 678 679 if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; 680 yystack.s_mark = yystack.s_base; 681 yystack.l_mark = yystack.l_base; 682 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 683 yystack.p_mark = yystack.p_base; 684 #endif 685 yystate = 0; 686 *yystack.s_mark = 0; 687 688 yyloop: 689 if ((yyn = yydefred[yystate]) != 0) goto yyreduce; 690 if (yychar < 0) 691 { 692 #if YYBTYACC 693 do { 694 if (yylvp < yylve) 695 { 696 /* we're currently re-reading tokens */ 697 yylval = *yylvp++; 698 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 699 yylloc = *yylpp++; 700 #endif 701 yychar = *yylexp++; 702 break; 703 } 704 if (yyps->save) 705 { 706 /* in trial mode; save scanner results for future parse attempts */ 707 if (yylvp == yylvlim) 708 { /* Enlarge lexical value queue */ 709 size_t p = (size_t) (yylvp - yylvals); 710 size_t s = (size_t) (yylvlim - yylvals); 711 712 s += YYLVQUEUEGROWTH; 713 if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) goto yyenomem; 714 if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; 715 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 716 if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; 717 #endif 718 yylvp = yylve = yylvals + p; 719 yylvlim = yylvals + s; 720 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 721 yylpp = yylpe = yylpsns + p; 722 yylplim = yylpsns + s; 723 #endif 724 yylexp = yylexemes + p; 725 } 726 *yylexp = (short) YYLEX; 727 *yylvp++ = yylval; 728 yylve++; 729 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 730 *yylpp++ = yylloc; 731 yylpe++; 732 #endif 733 yychar = *yylexp++; 734 break; 735 } 736 /* normal operation, no conflict encountered */ 737 #endif /* YYBTYACC */ 738 yychar = YYLEX; 739 #if YYBTYACC 740 } while (0); 741 #endif /* YYBTYACC */ 742 if (yychar < 0) yychar = YYEOF; 743 /* if ((yychar = YYLEX) < 0) yychar = YYEOF; */ 744 #if YYDEBUG 745 if (yydebug) 746 { 747 yys = yyname[YYTRANSLATE(yychar)]; 748 fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", 749 YYDEBUGSTR, yydepth, yystate, yychar, yys); 750 #ifdef YYSTYPE_TOSTRING 751 #if YYBTYACC 752 if (!yytrial) 753 #endif /* YYBTYACC */ 754 fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); 755 #endif 756 fputc('\n', stderr); 757 } 758 #endif 759 } 760 #if YYBTYACC 761 762 /* Do we have a conflict? */ 763 if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && 764 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) 765 { 766 YYINT ctry; 767 768 if (yypath) 769 { 770 YYParseState *save; 771 #if YYDEBUG 772 if (yydebug) 773 fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", 774 YYDEBUGSTR, yydepth, yystate); 775 #endif 776 /* Switch to the next conflict context */ 777 save = yypath; 778 yypath = save->save; 779 save->save = NULL; 780 ctry = save->ctry; 781 if (save->state != yystate) YYABORT; 782 yyFreeState(save); 783 784 } 785 else 786 { 787 788 /* Unresolved conflict - start/continue trial parse */ 789 YYParseState *save; 790 #if YYDEBUG 791 if (yydebug) 792 { 793 fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); 794 if (yyps->save) 795 fputs("ALREADY in conflict, continuing trial parse.\n", stderr); 796 else 797 fputs("Starting trial parse.\n", stderr); 798 } 799 #endif 800 save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); 801 if (save == NULL) goto yyenomem; 802 save->save = yyps->save; 803 save->state = yystate; 804 save->errflag = yyerrflag; 805 save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); 806 memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); 807 save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); 808 memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); 809 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 810 save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); 811 memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); 812 #endif 813 ctry = yytable[yyn]; 814 if (yyctable[ctry] == -1) 815 { 816 #if YYDEBUG 817 if (yydebug && yychar >= YYEOF) 818 fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); 819 #endif 820 ctry++; 821 } 822 save->ctry = ctry; 823 if (yyps->save == NULL) 824 { 825 /* If this is a first conflict in the stack, start saving lexemes */ 826 if (!yylexemes) 827 { 828 yylexemes = (short *) malloc((YYLVQUEUEGROWTH) * sizeof(short)); 829 if (yylexemes == NULL) goto yyenomem; 830 yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); 831 if (yylvals == NULL) goto yyenomem; 832 yylvlim = yylvals + YYLVQUEUEGROWTH; 833 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 834 yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); 835 if (yylpsns == NULL) goto yyenomem; 836 yylplim = yylpsns + YYLVQUEUEGROWTH; 837 #endif 838 } 839 if (yylvp == yylve) 840 { 841 yylvp = yylve = yylvals; 842 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 843 yylpp = yylpe = yylpsns; 844 #endif 845 yylexp = yylexemes; 846 if (yychar >= YYEOF) 847 { 848 *yylve++ = yylval; 849 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 850 *yylpe++ = yylloc; 851 #endif 852 *yylexp = (short) yychar; 853 yychar = YYEMPTY; 854 } 855 } 856 } 857 if (yychar >= YYEOF) 858 { 859 yylvp--; 860 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 861 yylpp--; 862 #endif 863 yylexp--; 864 yychar = YYEMPTY; 865 } 866 save->lexeme = (int) (yylvp - yylvals); 867 yyps->save = save; 868 } 869 if (yytable[yyn] == ctry) 870 { 871 #if YYDEBUG 872 if (yydebug) 873 fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", 874 YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); 875 #endif 876 if (yychar < 0) 877 { 878 yylvp++; 879 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 880 yylpp++; 881 #endif 882 yylexp++; 883 } 884 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) 885 goto yyoverflow; 886 yystate = yyctable[ctry]; 887 *++yystack.s_mark = (short) yystate; 888 *++yystack.l_mark = yylval; 889 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 890 *++yystack.p_mark = yylloc; 891 #endif 892 yychar = YYEMPTY; 893 if (yyerrflag > 0) --yyerrflag; 894 goto yyloop; 895 } 896 else 897 { 898 yyn = yyctable[ctry]; 899 goto yyreduce; 900 } 901 } /* End of code dealing with conflicts */ 902 #endif /* YYBTYACC */ 903 if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && 904 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) 905 { 906 #if YYDEBUG 907 if (yydebug) 908 fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", 909 YYDEBUGSTR, yydepth, yystate, yytable[yyn]); 910 #endif 911 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; 912 yystate = yytable[yyn]; 913 *++yystack.s_mark = yytable[yyn]; 914 *++yystack.l_mark = yylval; 915 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 916 *++yystack.p_mark = yylloc; 917 #endif 918 yychar = YYEMPTY; 919 if (yyerrflag > 0) --yyerrflag; 920 goto yyloop; 921 } 922 if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && 923 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) 924 { 925 yyn = yytable[yyn]; 926 goto yyreduce; 927 } 928 if (yyerrflag != 0) goto yyinrecovery; 929 #if YYBTYACC 930 931 yynewerrflag = 1; 932 goto yyerrhandler; 933 goto yyerrlab; 934 935 yyerrlab: 936 yynewerrflag = 0; 937 yyerrhandler: 938 while (yyps->save) 939 { 940 int ctry; 941 YYParseState *save = yyps->save; 942 #if YYDEBUG 943 if (yydebug) 944 fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", 945 YYDEBUGSTR, yydepth, yystate, yyps->save->state, 946 (int)(yylvp - yylvals - yyps->save->lexeme)); 947 #endif 948 /* Memorize most forward-looking error state in case it's really an error. */ 949 if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) 950 { 951 /* Free old saved error context state */ 952 if (yyerrctx) yyFreeState(yyerrctx); 953 /* Create and fill out new saved error context state */ 954 yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); 955 if (yyerrctx == NULL) goto yyenomem; 956 yyerrctx->save = yyps->save; 957 yyerrctx->state = yystate; 958 yyerrctx->errflag = yyerrflag; 959 yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); 960 memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); 961 yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); 962 memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); 963 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 964 yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); 965 memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); 966 #endif 967 yyerrctx->lexeme = (int) (yylvp - yylvals); 968 } 969 yylvp = yylvals + save->lexeme; 970 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 971 yylpp = yylpsns + save->lexeme; 972 #endif 973 yylexp = yylexemes + save->lexeme; 974 yychar = YYEMPTY; 975 yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); 976 memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); 977 yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); 978 memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); 979 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 980 yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); 981 memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); 982 #endif 983 ctry = ++save->ctry; 984 yystate = save->state; 985 /* We tried shift, try reduce now */ 986 if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; 987 yyps->save = save->save; 988 save->save = NULL; 989 yyFreeState(save); 990 991 /* Nothing left on the stack -- error */ 992 if (!yyps->save) 993 { 994 #if YYDEBUG 995 if (yydebug) 996 fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", 997 YYPREFIX, yydepth); 998 #endif 999 /* Restore state as it was in the most forward-advanced error */ 1000 yylvp = yylvals + yyerrctx->lexeme; 1001 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1002 yylpp = yylpsns + yyerrctx->lexeme; 1003 #endif 1004 yylexp = yylexemes + yyerrctx->lexeme; 1005 yychar = yylexp[-1]; 1006 yylval = yylvp[-1]; 1007 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1008 yylloc = yylpp[-1]; 1009 #endif 1010 yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); 1011 memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); 1012 yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); 1013 memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); 1014 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1015 yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); 1016 memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); 1017 #endif 1018 yystate = yyerrctx->state; 1019 yyFreeState(yyerrctx); 1020 yyerrctx = NULL; 1021 } 1022 yynewerrflag = 1; 1023 } 1024 if (yynewerrflag == 0) goto yyinrecovery; 1025 #endif /* YYBTYACC */ 1026 1027 YYERROR_CALL("syntax error"); 1028 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1029 yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */ 1030 #endif 1031 1032 #if !YYBTYACC 1033 goto yyerrlab; 1034 yyerrlab: 1035 #endif 1036 ++yynerrs; 1037 1038 yyinrecovery: 1039 if (yyerrflag < 3) 1040 { 1041 yyerrflag = 3; 1042 for (;;) 1043 { 1044 if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && 1045 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) 1046 { 1047 #if YYDEBUG 1048 if (yydebug) 1049 fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", 1050 YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); 1051 #endif 1052 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; 1053 yystate = yytable[yyn]; 1054 *++yystack.s_mark = yytable[yyn]; 1055 *++yystack.l_mark = yylval; 1056 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1057 /* lookahead position is error end position */ 1058 yyerror_loc_range[1] = yylloc; 1059 YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ 1060 *++yystack.p_mark = yyloc; 1061 #endif 1062 goto yyloop; 1063 } 1064 else 1065 { 1066 #if YYDEBUG 1067 if (yydebug) 1068 fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", 1069 YYDEBUGSTR, yydepth, *yystack.s_mark); 1070 #endif 1071 if (yystack.s_mark <= yystack.s_base) goto yyabort; 1072 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1073 /* the current TOS position is the error start position */ 1074 yyerror_loc_range[0] = *yystack.p_mark; 1075 #endif 1076 #if defined(YYDESTRUCT_CALL) 1077 #if YYBTYACC 1078 if (!yytrial) 1079 #endif /* YYBTYACC */ 1080 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1081 YYDESTRUCT_CALL("error: discarding state", 1082 yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); 1083 #else 1084 YYDESTRUCT_CALL("error: discarding state", 1085 yystos[*yystack.s_mark], yystack.l_mark); 1086 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ 1087 #endif /* defined(YYDESTRUCT_CALL) */ 1088 --yystack.s_mark; 1089 --yystack.l_mark; 1090 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1091 --yystack.p_mark; 1092 #endif 1093 } 1094 } 1095 } 1096 else 1097 { 1098 if (yychar == YYEOF) goto yyabort; 1099 #if YYDEBUG 1100 if (yydebug) 1101 { 1102 yys = yyname[YYTRANSLATE(yychar)]; 1103 fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", 1104 YYDEBUGSTR, yydepth, yystate, yychar, yys); 1105 } 1106 #endif 1107 #if defined(YYDESTRUCT_CALL) 1108 #if YYBTYACC 1109 if (!yytrial) 1110 #endif /* YYBTYACC */ 1111 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1112 YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); 1113 #else 1114 YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); 1115 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ 1116 #endif /* defined(YYDESTRUCT_CALL) */ 1117 yychar = YYEMPTY; 1118 goto yyloop; 1119 } 1120 1121 yyreduce: 1122 yym = yylen[yyn]; 1123 #if YYDEBUG 1124 if (yydebug) 1125 { 1126 fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", 1127 YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); 1128 #ifdef YYSTYPE_TOSTRING 1129 #if YYBTYACC 1130 if (!yytrial) 1131 #endif /* YYBTYACC */ 1132 if (yym > 0) 1133 { 1134 int i; 1135 fputc('<', stderr); 1136 for (i = yym; i > 0; i--) 1137 { 1138 if (i != yym) fputs(", ", stderr); 1139 fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], 1140 yystack.l_mark[1-i]), stderr); 1141 } 1142 fputc('>', stderr); 1143 } 1144 #endif 1145 fputc('\n', stderr); 1146 } 1147 #endif 1148 if (yym > 0) 1149 yyval = yystack.l_mark[1-yym]; 1150 else 1151 memset(&yyval, 0, sizeof yyval); 1152 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1153 1154 /* Perform position reduction */ 1155 memset(&yyloc, 0, sizeof(yyloc)); 1156 #if YYBTYACC 1157 if (!yytrial) 1158 #endif /* YYBTYACC */ 1159 { 1160 YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym); 1161 /* just in case YYERROR is invoked within the action, save 1162 the start of the rhs as the error start position */ 1163 yyerror_loc_range[0] = yystack.p_mark[1-yym]; 1164 } 1165 #endif 1166 1167 switch (yyn) 1168 { 1169 case 1: 1170 if (!yytrial) 1171 #line 65 "btyacc_destroy3.y" 1172 { yyval.nlist = yystack.l_mark[-5].nlist; } 1173 break; 1174 case 2: 1175 if (!yytrial) 1176 #line 67 "btyacc_destroy3.y" 1177 { yyval.nlist = yystack.l_mark[-3].nlist; } 1178 break; 1179 case 3: 1180 if (!yytrial) 1181 #line 70 "btyacc_destroy3.y" 1182 { yyval.cval = cGLOBAL; } 1183 break; 1184 case 4: 1185 if (!yytrial) 1186 #line 71 "btyacc_destroy3.y" 1187 { yyval.cval = cLOCAL; } 1188 break; 1189 case 5: 1190 if (!yytrial) 1191 #line 74 "btyacc_destroy3.y" 1192 { yyval.tval = tREAL; } 1193 break; 1194 case 6: 1195 if (!yytrial) 1196 #line 75 "btyacc_destroy3.y" 1197 { yyval.tval = tINTEGER; } 1198 break; 1199 case 7: 1200 if (!yytrial) 1201 #line 79 "btyacc_destroy3.y" 1202 { yyval.nlist->s = mksymbol(yystack.l_mark[-2].tval, yystack.l_mark[-2].cval, yystack.l_mark[0].id); 1203 yyval.nlist->next = yystack.l_mark[-1].nlist; 1204 } 1205 break; 1206 case 8: 1207 if (!yytrial) 1208 #line 83 "btyacc_destroy3.y" 1209 { yyval.nlist->s = mksymbol(0, 0, yystack.l_mark[0].id); 1210 yyval.nlist->next = NULL; 1211 } 1212 break; 1213 case 9: 1214 if (!yytrial) 1215 #line 89 "btyacc_destroy3.y" 1216 { yyval.nlist = yystack.l_mark[-5].nlist; } 1217 break; 1218 #line 1217 "btyacc_destroy3.tab.c" 1219 default: 1220 break; 1221 } 1222 yystack.s_mark -= yym; 1223 yystate = *yystack.s_mark; 1224 yystack.l_mark -= yym; 1225 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1226 yystack.p_mark -= yym; 1227 #endif 1228 yym = yylhs[yyn]; 1229 if (yystate == 0 && yym == 0) 1230 { 1231 #if YYDEBUG 1232 if (yydebug) 1233 { 1234 fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); 1235 #ifdef YYSTYPE_TOSTRING 1236 #if YYBTYACC 1237 if (!yytrial) 1238 #endif /* YYBTYACC */ 1239 fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval)); 1240 #endif 1241 fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL); 1242 } 1243 #endif 1244 yystate = YYFINAL; 1245 *++yystack.s_mark = YYFINAL; 1246 *++yystack.l_mark = yyval; 1247 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1248 *++yystack.p_mark = yyloc; 1249 #endif 1250 if (yychar < 0) 1251 { 1252 #if YYBTYACC 1253 do { 1254 if (yylvp < yylve) 1255 { 1256 /* we're currently re-reading tokens */ 1257 yylval = *yylvp++; 1258 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1259 yylloc = *yylpp++; 1260 #endif 1261 yychar = *yylexp++; 1262 break; 1263 } 1264 if (yyps->save) 1265 { 1266 /* in trial mode; save scanner results for future parse attempts */ 1267 if (yylvp == yylvlim) 1268 { /* Enlarge lexical value queue */ 1269 size_t p = (size_t) (yylvp - yylvals); 1270 size_t s = (size_t) (yylvlim - yylvals); 1271 1272 s += YYLVQUEUEGROWTH; 1273 if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) 1274 goto yyenomem; 1275 if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) 1276 goto yyenomem; 1277 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1278 if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) 1279 goto yyenomem; 1280 #endif 1281 yylvp = yylve = yylvals + p; 1282 yylvlim = yylvals + s; 1283 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1284 yylpp = yylpe = yylpsns + p; 1285 yylplim = yylpsns + s; 1286 #endif 1287 yylexp = yylexemes + p; 1288 } 1289 *yylexp = (short) YYLEX; 1290 *yylvp++ = yylval; 1291 yylve++; 1292 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1293 *yylpp++ = yylloc; 1294 yylpe++; 1295 #endif 1296 yychar = *yylexp++; 1297 break; 1298 } 1299 /* normal operation, no conflict encountered */ 1300 #endif /* YYBTYACC */ 1301 yychar = YYLEX; 1302 #if YYBTYACC 1303 } while (0); 1304 #endif /* YYBTYACC */ 1305 if (yychar < 0) yychar = YYEOF; 1306 /* if ((yychar = YYLEX) < 0) yychar = YYEOF; */ 1307 #if YYDEBUG 1308 if (yydebug) 1309 { 1310 yys = yyname[YYTRANSLATE(yychar)]; 1311 fprintf(stderr, "%s[%d]: state %d, reading %d (%s)\n", 1312 YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); 1313 } 1314 #endif 1315 } 1316 if (yychar == YYEOF) goto yyaccept; 1317 goto yyloop; 1318 } 1319 if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && 1320 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) 1321 yystate = yytable[yyn]; 1322 else 1323 yystate = yydgoto[yym]; 1324 #if YYDEBUG 1325 if (yydebug) 1326 { 1327 fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); 1328 #ifdef YYSTYPE_TOSTRING 1329 #if YYBTYACC 1330 if (!yytrial) 1331 #endif /* YYBTYACC */ 1332 fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); 1333 #endif 1334 fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); 1335 } 1336 #endif 1337 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; 1338 *++yystack.s_mark = (short) yystate; 1339 *++yystack.l_mark = yyval; 1340 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1341 *++yystack.p_mark = yyloc; 1342 #endif 1343 goto yyloop; 1344 #if YYBTYACC 1345 1346 /* Reduction declares that this path is valid. Set yypath and do a full parse */ 1347 yyvalid: 1348 if (yypath) YYABORT; 1349 while (yyps->save) 1350 { 1351 YYParseState *save = yyps->save; 1352 yyps->save = save->save; 1353 save->save = yypath; 1354 yypath = save; 1355 } 1356 #if YYDEBUG 1357 if (yydebug) 1358 fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", 1359 YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); 1360 #endif 1361 if (yyerrctx) 1362 { 1363 yyFreeState(yyerrctx); 1364 yyerrctx = NULL; 1365 } 1366 yylvp = yylvals + yypath->lexeme; 1367 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1368 yylpp = yylpsns + yypath->lexeme; 1369 #endif 1370 yylexp = yylexemes + yypath->lexeme; 1371 yychar = YYEMPTY; 1372 yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); 1373 memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(short)); 1374 yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); 1375 memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); 1376 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1377 yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); 1378 memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); 1379 #endif 1380 yystate = yypath->state; 1381 goto yyloop; 1382 #endif /* YYBTYACC */ 1383 1384 yyoverflow: 1385 YYERROR_CALL("yacc stack overflow"); 1386 #if YYBTYACC 1387 goto yyabort_nomem; 1388 yyenomem: 1389 YYERROR_CALL("memory exhausted"); 1390 yyabort_nomem: 1391 #endif /* YYBTYACC */ 1392 yyresult = 2; 1393 goto yyreturn; 1394 1395 yyabort: 1396 yyresult = 1; 1397 goto yyreturn; 1398 1399 yyaccept: 1400 #if YYBTYACC 1401 if (yyps->save) goto yyvalid; 1402 #endif /* YYBTYACC */ 1403 yyresult = 0; 1404 1405 yyreturn: 1406 #if defined(YYDESTRUCT_CALL) 1407 if (yychar != YYEOF && yychar != YYEMPTY) 1408 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1409 YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); 1410 #else 1411 YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); 1412 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ 1413 1414 { 1415 YYSTYPE *pv; 1416 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1417 YYLTYPE *pp; 1418 1419 for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) 1420 YYDESTRUCT_CALL("cleanup: discarding state", 1421 yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); 1422 #else 1423 for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) 1424 YYDESTRUCT_CALL("cleanup: discarding state", 1425 yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); 1426 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ 1427 } 1428 #endif /* defined(YYDESTRUCT_CALL) */ 1429 1430 #if YYBTYACC 1431 if (yyerrctx) 1432 { 1433 yyFreeState(yyerrctx); 1434 yyerrctx = NULL; 1435 } 1436 while (yyps) 1437 { 1438 YYParseState *save = yyps; 1439 yyps = save->save; 1440 save->save = NULL; 1441 yyFreeState(save); 1442 } 1443 while (yypath) 1444 { 1445 YYParseState *save = yypath; 1446 yypath = save->save; 1447 save->save = NULL; 1448 yyFreeState(save); 1449 } 1450 #endif /* YYBTYACC */ 1451 yyfreestack(&yystack); 1452 return (yyresult); 1453 } 1454