1 /* original parser id follows */ 2 /* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ 3 /* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ 4 5 #define YYBYACC 1 6 #define YYMAJOR 2 7 #define YYMINOR 0 8 #define YYCHECK "yyyymmdd" 9 10 #define YYEMPTY (-1) 11 #define yyclearin (yychar = YYEMPTY) 12 #define yyerrok (yyerrflag = 0) 13 #define YYRECOVERING() (yyerrflag != 0) 14 #define YYENOMEM (-2) 15 #define YYEOF 0 16 #undef YYBTYACC 17 #define YYBTYACC 1 18 #define YYDEBUGSTR (yytrial ? YYPREFIX "debug(trial)" : YYPREFIX "debug") 19 20 #ifndef yyparse 21 #define yyparse calc1_parse 22 #endif /* yyparse */ 23 24 #ifndef yylex 25 #define yylex calc1_lex 26 #endif /* yylex */ 27 28 #ifndef yyerror 29 #define yyerror calc1_error 30 #endif /* yyerror */ 31 32 #ifndef yychar 33 #define yychar calc1_char 34 #endif /* yychar */ 35 36 #ifndef yyval 37 #define yyval calc1_val 38 #endif /* yyval */ 39 40 #ifndef yylval 41 #define yylval calc1_lval 42 #endif /* yylval */ 43 44 #ifndef yydebug 45 #define yydebug calc1_debug 46 #endif /* yydebug */ 47 48 #ifndef yynerrs 49 #define yynerrs calc1_nerrs 50 #endif /* yynerrs */ 51 52 #ifndef yyerrflag 53 #define yyerrflag calc1_errflag 54 #endif /* yyerrflag */ 55 56 #ifndef yylhs 57 #define yylhs calc1_lhs 58 #endif /* yylhs */ 59 60 #ifndef yylen 61 #define yylen calc1_len 62 #endif /* yylen */ 63 64 #ifndef yydefred 65 #define yydefred calc1_defred 66 #endif /* yydefred */ 67 68 #ifndef yystos 69 #define yystos calc1_stos 70 #endif /* yystos */ 71 72 #ifndef yydgoto 73 #define yydgoto calc1_dgoto 74 #endif /* yydgoto */ 75 76 #ifndef yysindex 77 #define yysindex calc1_sindex 78 #endif /* yysindex */ 79 80 #ifndef yyrindex 81 #define yyrindex calc1_rindex 82 #endif /* yyrindex */ 83 84 #ifndef yygindex 85 #define yygindex calc1_gindex 86 #endif /* yygindex */ 87 88 #ifndef yytable 89 #define yytable calc1_table 90 #endif /* yytable */ 91 92 #ifndef yycheck 93 #define yycheck calc1_check 94 #endif /* yycheck */ 95 96 #ifndef yyname 97 #define yyname calc1_name 98 #endif /* yyname */ 99 100 #ifndef yyrule 101 #define yyrule calc1_rule 102 #endif /* yyrule */ 103 104 #if YYBTYACC 105 106 #ifndef yycindex 107 #define yycindex calc1_cindex 108 #endif /* yycindex */ 109 110 #ifndef yyctable 111 #define yyctable calc1_ctable 112 #endif /* yyctable */ 113 114 #endif /* YYBTYACC */ 115 116 #define YYPREFIX "calc1_" 117 118 #define YYPURE 1 119 120 #line 3 "btyacc_calc1.y" 121 122 /* http://dinosaur.compilertools.net/yacc/index.html */ 123 124 #include <stdlib.h> 125 #include <stdio.h> 126 #include <ctype.h> 127 #include <math.h> 128 129 typedef struct interval 130 { 131 double lo, hi; 132 } 133 INTERVAL; 134 135 INTERVAL vmul(double, double, INTERVAL); 136 INTERVAL vdiv(double, double, INTERVAL); 137 138 int dcheck(INTERVAL); 139 140 double dreg[26]; 141 INTERVAL vreg[26]; 142 143 #ifdef YYSTYPE 144 #undef YYSTYPE_IS_DECLARED 145 #define YYSTYPE_IS_DECLARED 1 146 #endif 147 #ifndef YYSTYPE_IS_DECLARED 148 #define YYSTYPE_IS_DECLARED 1 149 #line 29 "btyacc_calc1.y" 150 typedef union YYSTYPE 151 { 152 int ival; 153 double dval; 154 INTERVAL vval; 155 } YYSTYPE; 156 #endif /* !YYSTYPE_IS_DECLARED */ 157 #line 158 "btyacc_calc1.tab.c" 158 159 /* compatibility with bison */ 160 #ifdef YYPARSE_PARAM 161 /* compatibility with FreeBSD */ 162 # ifdef YYPARSE_PARAM_TYPE 163 # define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM) 164 # else 165 # define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM) 166 # endif 167 #else 168 # define YYPARSE_DECL() yyparse(void) 169 #endif 170 171 /* Parameters sent to lex. */ 172 #ifdef YYLEX_PARAM 173 # ifdef YYLEX_PARAM_TYPE 174 # define YYLEX_DECL() yylex(YYSTYPE *yylval, YYLEX_PARAM_TYPE YYLEX_PARAM) 175 # else 176 # define YYLEX_DECL() yylex(YYSTYPE *yylval, void * YYLEX_PARAM) 177 # endif 178 # define YYLEX yylex(&yylval, YYLEX_PARAM) 179 #else 180 # define YYLEX_DECL() yylex(YYSTYPE *yylval) 181 # define YYLEX yylex(&yylval) 182 #endif 183 184 /* Parameters sent to yyerror. */ 185 #ifndef YYERROR_DECL 186 #define YYERROR_DECL() yyerror(const char *s) 187 #endif 188 #ifndef YYERROR_CALL 189 #define YYERROR_CALL(msg) yyerror(msg) 190 #endif 191 192 extern int YYPARSE_DECL(); 193 194 #define DREG 257 195 #define VREG 258 196 #define CONST 259 197 #define UMINUS 260 198 #define YYERRCODE 256 199 typedef int YYINT; 200 static const YYINT calc1_lhs[] = { -1, 201 0, 0, 0, 3, 3, 3, 3, 1, 1, 1, 202 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 203 2, 2, 2, 2, 2, 2, 2, 2, 204 }; 205 static const YYINT calc1_len[] = { 2, 206 0, 3, 3, 1, 1, 3, 3, 1, 1, 3, 207 3, 3, 3, 2, 3, 1, 5, 1, 3, 3, 208 3, 3, 3, 3, 3, 3, 2, 3, 209 }; 210 static const YYINT calc1_defred[] = { 1, 211 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 212 3, 0, 0, 9, 18, 0, 27, 0, 0, 0, 213 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 214 0, 0, 0, 15, 0, 28, 0, 0, 0, 0, 215 0, 24, 0, 26, 0, 0, 23, 25, 14, 0, 216 0, 0, 0, 0, 0, 0, 0, 12, 13, 17, 217 }; 218 #if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) 219 static const YYINT calc1_stos[] = { 0, 220 262, 256, 257, 258, 259, 45, 40, 263, 264, 265, 221 10, 61, 61, 257, 258, 263, 264, 263, 264, 43, 222 45, 42, 47, 43, 45, 42, 47, 10, 45, 40, 223 263, 263, 264, 41, 44, 41, 263, 264, 263, 264, 224 263, 264, 263, 264, 264, 264, 264, 264, 263, 263, 225 43, 45, 42, 47, 263, 263, 263, 263, 263, 41, 226 }; 227 #endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ 228 static const YYINT calc1_dgoto[] = { 1, 229 32, 9, 10, 230 }; 231 static const YYINT calc1_sindex[] = { 0, 232 -40, -9, -59, -54, 0, -37, -37, 0, 82, 4, 233 0, -34, -37, 0, 0, 0, 0, -31, -25, -37, 234 -37, -37, -37, -37, -37, -37, -37, 0, -34, -34, 235 132, 0, 82, 0, -34, 0, 0, -12, 0, -12, 236 0, 0, 0, 0, -12, -12, 0, 0, 0, 112, 237 -34, -34, -34, -34, 119, -11, -11, 0, 0, 0, 238 }; 239 static const YYINT calc1_rindex[] = { 0, 240 0, 0, 51, 58, 0, 0, 0, 0, 11, 0, 241 0, 0, 0, 0, 0, -16, 0, 0, 0, 0, 242 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 243 19, 9, 27, 0, 0, 0, -5, 41, -4, 77, 244 -2, 0, 8, 0, 78, 85, 0, 0, 0, 0, 245 0, 0, 0, 0, 0, 92, 99, 0, 0, 0, 246 }; 247 #if YYBTYACC 248 static const YYINT calc1_cindex[] = { 0, 249 0, 0, 0, 0, 0, 0, 0, 65, 0, 0, 250 0, 0, 0, 0, 0, 2, 0, 126, 0, 0, 251 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 252 0, 138, 0, 0, 0, 0, 17, 0, 24, 0, 253 31, 0, 38, 0, 0, 0, 0, 0, 0, 0, 254 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255 }; 256 #endif 257 static const YYINT calc1_gindex[] = { 0, 258 3, 125, 0, 259 }; 260 #define YYTABLESIZE 225 261 static const YYINT calc1_table[] = { 7, 262 11, 12, 7, 8, 6, 30, 13, 6, 16, 18, 263 29, 14, 35, 28, 31, 36, 26, 24, 16, 25, 264 5, 27, 37, 39, 41, 43, 20, 14, 6, 26, 265 53, 49, 50, 23, 27, 54, 7, 55, 10, 11, 266 26, 12, 14, 14, 14, 0, 14, 29, 14, 16, 267 20, 13, 0, 56, 57, 58, 59, 20, 6, 20, 268 9, 20, 0, 9, 23, 6, 23, 18, 23, 0, 269 9, 26, 26, 26, 11, 26, 0, 26, 29, 29, 270 29, 20, 29, 20, 29, 20, 22, 19, 0, 0, 271 0, 0, 9, 9, 21, 9, 0, 9, 0, 18, 272 18, 10, 18, 0, 18, 0, 6, 0, 11, 3, 273 0, 9, 0, 0, 0, 0, 0, 22, 19, 22, 274 19, 22, 19, 26, 24, 21, 25, 21, 27, 21, 275 17, 19, 10, 0, 10, 0, 10, 33, 0, 11, 276 0, 11, 0, 11, 38, 40, 42, 44, 45, 46, 277 47, 48, 34, 53, 51, 0, 52, 0, 54, 60, 278 53, 51, 0, 52, 0, 54, 18, 6, 0, 0, 279 3, 0, 9, 53, 51, 0, 52, 0, 54, 6, 280 0, 0, 3, 0, 9, 0, 0, 0, 0, 0, 281 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 282 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 283 0, 0, 0, 0, 0, 2, 3, 4, 5, 14, 284 15, 5, 14, 0, 5, 285 }; 286 static const YYINT calc1_check[] = { 40, 287 10, 61, 40, 1, 45, 40, 61, 45, 6, 7, 288 45, 10, 44, 10, 12, 41, 42, 43, 10, 45, 289 10, 47, 20, 21, 22, 23, 10, 44, 10, 42, 290 42, 29, 30, 10, 47, 47, 10, 35, 44, 44, 291 10, 44, 41, 42, 43, -1, 45, 10, 47, 41, 292 10, 44, -1, 51, 52, 53, 54, 41, 42, 43, 293 10, 45, -1, 47, 41, 42, 43, 10, 45, -1, 294 47, 41, 42, 43, 10, 45, -1, 47, 41, 42, 295 43, 41, 45, 43, 47, 45, 10, 10, -1, -1, 296 -1, -1, 42, 43, 10, 45, -1, 47, -1, 42, 297 43, 10, 45, -1, 47, -1, 42, 43, 10, 45, 298 -1, 47, -1, -1, -1, -1, -1, 41, 41, 43, 299 43, 45, 45, 42, 43, 41, 45, 43, 47, 45, 300 6, 7, 41, -1, 43, -1, 45, 13, -1, 41, 301 -1, 43, -1, 45, 20, 21, 22, 23, 24, 25, 302 26, 27, 41, 42, 43, -1, 45, -1, 47, 41, 303 42, 43, -1, 45, -1, 47, 41, 42, 43, -1, 304 45, -1, 47, 42, 43, -1, 45, -1, 47, 42, 305 43, -1, 45, -1, 47, -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, 256, 257, 258, 259, 257, 309 258, 259, 257, -1, 259, 310 }; 311 #if YYBTYACC 312 static const YYINT calc1_ctable[] = { 20, 313 16, -1, 21, 16, -1, 22, 16, -1, 23, 16, 314 -1, 4, 16, -1, 14, 16, -1, 34, 16, -1, 315 10, 16, -1, 11, 16, -1, 12, 16, -1, 13, 316 16, -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, -1, -1, -1, -1, -1, -1, -1, -1, -1, 323 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 324 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 325 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 326 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 327 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 328 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 329 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 330 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 331 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 332 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 333 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 334 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 335 -1, -1, -1, -1, 336 }; 337 #endif 338 #define YYFINAL 1 339 #ifndef YYDEBUG 340 #define YYDEBUG 0 341 #endif 342 #define YYMAXTOKEN 260 343 #define YYUNDFTOKEN 266 344 #define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) 345 #if YYDEBUG 346 static const char *const calc1_name[] = { 347 348 "$end",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 349 0,0,0,0,0,0,"'('","')'","'*'","'+'","','","'-'",0,"'/'",0,0,0,0,0,0,0,0,0,0,0,0, 350 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, 351 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, 352 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, 353 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, 354 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, 355 "error","DREG","VREG","CONST","UMINUS","$accept","lines","dexp","vexp","line", 356 "illegal-symbol", 357 }; 358 static const char *const calc1_rule[] = { 359 "$accept : lines", 360 "lines :", 361 "lines : lines line '\\n'", 362 "lines : lines error '\\n'", 363 "line : dexp", 364 "line : vexp", 365 "line : DREG '=' dexp", 366 "line : VREG '=' vexp", 367 "dexp : CONST", 368 "dexp : DREG", 369 "dexp : dexp '+' dexp", 370 "dexp : dexp '-' dexp", 371 "dexp : dexp '*' dexp", 372 "dexp : dexp '/' dexp", 373 "dexp : '-' dexp", 374 "dexp : '(' dexp ')'", 375 "vexp : dexp", 376 "vexp : '(' dexp ',' dexp ')'", 377 "vexp : VREG", 378 "vexp : vexp '+' vexp", 379 "vexp : dexp '+' vexp", 380 "vexp : vexp '-' vexp", 381 "vexp : dexp '-' vexp", 382 "vexp : vexp '*' vexp", 383 "vexp : dexp '*' vexp", 384 "vexp : vexp '/' vexp", 385 "vexp : dexp '/' vexp", 386 "vexp : '-' vexp", 387 "vexp : '(' vexp ')'", 388 389 }; 390 #endif 391 392 #if YYDEBUG 393 int yydebug; 394 #endif 395 396 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 397 #ifndef YYLLOC_DEFAULT 398 #define YYLLOC_DEFAULT(loc, rhs, n) \ 399 do \ 400 { \ 401 if (n == 0) \ 402 { \ 403 (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ 404 (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ 405 (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ 406 (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ 407 } \ 408 else \ 409 { \ 410 (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ 411 (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ 412 (loc).last_line = YYRHSLOC(rhs, n).last_line; \ 413 (loc).last_column = YYRHSLOC(rhs, n).last_column; \ 414 } \ 415 } while (0) 416 #endif /* YYLLOC_DEFAULT */ 417 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ 418 #if YYBTYACC 419 420 #ifndef YYLVQUEUEGROWTH 421 #define YYLVQUEUEGROWTH 32 422 #endif 423 #endif /* YYBTYACC */ 424 425 /* define the initial stack-sizes */ 426 #ifdef YYSTACKSIZE 427 #undef YYMAXDEPTH 428 #define YYMAXDEPTH YYSTACKSIZE 429 #else 430 #ifdef YYMAXDEPTH 431 #define YYSTACKSIZE YYMAXDEPTH 432 #else 433 #define YYSTACKSIZE 10000 434 #define YYMAXDEPTH 10000 435 #endif 436 #endif 437 438 #ifndef YYINITSTACKSIZE 439 #define YYINITSTACKSIZE 200 440 #endif 441 442 typedef struct { 443 unsigned stacksize; 444 YYINT *s_base; 445 YYINT *s_mark; 446 YYINT *s_last; 447 YYSTYPE *l_base; 448 YYSTYPE *l_mark; 449 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 450 YYLTYPE *p_base; 451 YYLTYPE *p_mark; 452 #endif 453 } YYSTACKDATA; 454 #if YYBTYACC 455 456 struct YYParseState_s 457 { 458 struct YYParseState_s *save; /* Previously saved parser state */ 459 YYSTACKDATA yystack; /* saved parser stack */ 460 int state; /* saved parser state */ 461 int errflag; /* saved error recovery status */ 462 int lexeme; /* saved index of the conflict lexeme in the lexical queue */ 463 YYINT ctry; /* saved index in yyctable[] for this conflict */ 464 }; 465 typedef struct YYParseState_s YYParseState; 466 #endif /* YYBTYACC */ 467 #line 174 "btyacc_calc1.y" 468 /* beginning of subroutines section */ 469 470 int 471 main (void) 472 { 473 while(!feof(stdin)) { 474 yyparse(); 475 } 476 return 0; 477 } 478 479 #define BSZ 50 /* buffer size for floating point numbers */ 480 481 static void 482 YYERROR_DECL() 483 { 484 fprintf(stderr, "%s\n", s); 485 } 486 487 /* lexical analysis */ 488 489 static int 490 YYLEX_DECL() 491 { 492 int c; 493 494 while ((c = getchar()) == ' ') 495 { /* skip over blanks */ 496 } 497 498 if (isupper(c)) 499 { 500 #if YYPURE 501 (*yylval).ival = c - 'A'; 502 #else 503 yylval.ival = c - 'A'; 504 #endif 505 return (VREG); 506 } 507 if (islower(c)) 508 { 509 #if YYPURE 510 (*yylval).ival = c - 'a'; 511 #else 512 yylval.ival = c - 'a'; 513 #endif 514 return (DREG); 515 } 516 517 if (isdigit(c) || c == '.') 518 { 519 /* gobble up digits, points, exponents */ 520 char buf[BSZ + 1], *cp = buf; 521 int dot = 0, expr = 0; 522 523 for (; (cp - buf) < BSZ; ++cp, c = getchar()) 524 { 525 526 *cp = (char) c; 527 if (isdigit(c)) 528 continue; 529 if (c == '.') 530 { 531 if (dot++ || expr) 532 return ('.'); /* will cause syntax error */ 533 continue; 534 } 535 536 if (c == 'e') 537 { 538 if (expr++) 539 return ('e'); /* will cause syntax error */ 540 continue; 541 } 542 543 /* end of number */ 544 break; 545 } 546 *cp = '\0'; 547 548 if ((cp - buf) >= BSZ) 549 printf("constant too long: truncated\n"); 550 else 551 ungetc(c, stdin); /* push back last char read */ 552 #if YYPURE 553 (*yylval).dval = atof(buf); 554 #else 555 yylval.dval = atof(buf); 556 #endif 557 return (CONST); 558 } 559 return (c); 560 } 561 562 static INTERVAL 563 hilo(double a, double b, double c, double d) 564 { 565 /* returns the smallest interval containing a, b, c, and d */ 566 /* used by *, / routines */ 567 INTERVAL v; 568 569 if (a > b) 570 { 571 v.hi = a; 572 v.lo = b; 573 } 574 else 575 { 576 v.hi = b; 577 v.lo = a; 578 } 579 580 if (c > d) 581 { 582 if (c > v.hi) 583 v.hi = c; 584 if (d < v.lo) 585 v.lo = d; 586 } 587 else 588 { 589 if (d > v.hi) 590 v.hi = d; 591 if (c < v.lo) 592 v.lo = c; 593 } 594 return (v); 595 } 596 597 INTERVAL 598 vmul(double a, double b, INTERVAL v) 599 { 600 return (hilo(a * v.hi, a * v.lo, b * v.hi, b * v.lo)); 601 } 602 603 int 604 dcheck(INTERVAL v) 605 { 606 if (v.hi >= 0. && v.lo <= 0.) 607 { 608 printf("divisor interval contains 0.\n"); 609 return (1); 610 } 611 return (0); 612 } 613 614 INTERVAL 615 vdiv(double a, double b, INTERVAL v) 616 { 617 return (hilo(a / v.hi, a / v.lo, b / v.hi, b / v.lo)); 618 } 619 #line 620 "btyacc_calc1.tab.c" 620 621 /* For use in generated program */ 622 #define yydepth (int)(yystack.s_mark - yystack.s_base) 623 #if YYBTYACC 624 #define yytrial (yyps->save) 625 #endif /* YYBTYACC */ 626 627 #if YYDEBUG 628 #include <stdio.h> /* needed for printf */ 629 #endif 630 631 #include <stdlib.h> /* needed for malloc, etc */ 632 #include <string.h> /* needed for memset */ 633 634 /* allocate initial stack or double stack size, up to YYMAXDEPTH */ 635 static int yygrowstack(YYSTACKDATA *data) 636 { 637 int i; 638 unsigned newsize; 639 YYINT *newss; 640 YYSTYPE *newvs; 641 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 642 YYLTYPE *newps; 643 #endif 644 645 if ((newsize = data->stacksize) == 0) 646 newsize = YYINITSTACKSIZE; 647 else if (newsize >= YYMAXDEPTH) 648 return YYENOMEM; 649 else if ((newsize *= 2) > YYMAXDEPTH) 650 newsize = YYMAXDEPTH; 651 652 i = (int) (data->s_mark - data->s_base); 653 newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); 654 if (newss == NULL) 655 return YYENOMEM; 656 657 data->s_base = newss; 658 data->s_mark = newss + i; 659 660 newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); 661 if (newvs == NULL) 662 return YYENOMEM; 663 664 data->l_base = newvs; 665 data->l_mark = newvs + i; 666 667 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 668 newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); 669 if (newps == NULL) 670 return YYENOMEM; 671 672 data->p_base = newps; 673 data->p_mark = newps + i; 674 #endif 675 676 data->stacksize = newsize; 677 data->s_last = data->s_base + newsize - 1; 678 679 #if YYDEBUG 680 if (yydebug) 681 fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); 682 #endif 683 return 0; 684 } 685 686 #if YYPURE || defined(YY_NO_LEAKS) 687 static void yyfreestack(YYSTACKDATA *data) 688 { 689 free(data->s_base); 690 free(data->l_base); 691 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 692 free(data->p_base); 693 #endif 694 memset(data, 0, sizeof(*data)); 695 } 696 #else 697 #define yyfreestack(data) /* nothing */ 698 #endif /* YYPURE || defined(YY_NO_LEAKS) */ 699 #if YYBTYACC 700 701 static YYParseState * 702 yyNewState(unsigned size) 703 { 704 YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); 705 if (p == NULL) return NULL; 706 707 p->yystack.stacksize = size; 708 if (size == 0) 709 { 710 p->yystack.s_base = NULL; 711 p->yystack.l_base = NULL; 712 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 713 p->yystack.p_base = NULL; 714 #endif 715 return p; 716 } 717 p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); 718 if (p->yystack.s_base == NULL) return NULL; 719 p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); 720 if (p->yystack.l_base == NULL) return NULL; 721 memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); 722 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 723 p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); 724 if (p->yystack.p_base == NULL) return NULL; 725 memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); 726 #endif 727 728 return p; 729 } 730 731 static void 732 yyFreeState(YYParseState *p) 733 { 734 yyfreestack(&p->yystack); 735 free(p); 736 } 737 #endif /* YYBTYACC */ 738 739 #define YYABORT goto yyabort 740 #define YYREJECT goto yyabort 741 #define YYACCEPT goto yyaccept 742 #define YYERROR goto yyerrlab 743 #if YYBTYACC 744 #define YYVALID do { if (yyps->save) goto yyvalid; } while(0) 745 #define YYVALID_NESTED do { if (yyps->save && \ 746 yyps->save->save == 0) goto yyvalid; } while(0) 747 #endif /* YYBTYACC */ 748 749 int 750 YYPARSE_DECL() 751 { 752 int yyerrflag; 753 int yychar; 754 YYSTYPE yyval; 755 YYSTYPE yylval; 756 int yynerrs; 757 758 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 759 YYLTYPE yyloc; /* position returned by actions */ 760 YYLTYPE yylloc; /* position from the lexer */ 761 #endif 762 763 /* variables for the parser stack */ 764 YYSTACKDATA yystack; 765 #if YYBTYACC 766 767 /* Current parser state */ 768 static YYParseState *yyps = 0; 769 770 /* yypath != NULL: do the full parse, starting at *yypath parser state. */ 771 static YYParseState *yypath = 0; 772 773 /* Base of the lexical value queue */ 774 static YYSTYPE *yylvals = 0; 775 776 /* Current position at lexical value queue */ 777 static YYSTYPE *yylvp = 0; 778 779 /* End position of lexical value queue */ 780 static YYSTYPE *yylve = 0; 781 782 /* The last allocated position at the lexical value queue */ 783 static YYSTYPE *yylvlim = 0; 784 785 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 786 /* Base of the lexical position queue */ 787 static YYLTYPE *yylpsns = 0; 788 789 /* Current position at lexical position queue */ 790 static YYLTYPE *yylpp = 0; 791 792 /* End position of lexical position queue */ 793 static YYLTYPE *yylpe = 0; 794 795 /* The last allocated position at the lexical position queue */ 796 static YYLTYPE *yylplim = 0; 797 #endif 798 799 /* Current position at lexical token queue */ 800 static YYINT *yylexp = 0; 801 802 static YYINT *yylexemes = 0; 803 #endif /* YYBTYACC */ 804 int yym, yyn, yystate, yyresult; 805 #if YYBTYACC 806 int yynewerrflag; 807 YYParseState *yyerrctx = NULL; 808 #endif /* YYBTYACC */ 809 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 810 YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ 811 #endif 812 #if YYDEBUG 813 const char *yys; 814 815 if ((yys = getenv("YYDEBUG")) != NULL) 816 { 817 yyn = *yys; 818 if (yyn >= '0' && yyn <= '9') 819 yydebug = yyn - '0'; 820 } 821 if (yydebug) 822 fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); 823 #endif 824 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 825 memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); 826 #endif 827 828 yyerrflag = 0; 829 yychar = 0; 830 memset(&yyval, 0, sizeof(yyval)); 831 memset(&yylval, 0, sizeof(yylval)); 832 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 833 memset(&yyloc, 0, sizeof(yyloc)); 834 memset(&yylloc, 0, sizeof(yylloc)); 835 #endif 836 837 #if YYBTYACC 838 yyps = yyNewState(0); if (yyps == 0) goto yyenomem; 839 yyps->save = 0; 840 #endif /* YYBTYACC */ 841 yym = 0; 842 /* yyn is set below */ 843 yynerrs = 0; 844 yyerrflag = 0; 845 yychar = YYEMPTY; 846 yystate = 0; 847 848 #if YYPURE 849 memset(&yystack, 0, sizeof(yystack)); 850 #endif 851 852 if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; 853 yystack.s_mark = yystack.s_base; 854 yystack.l_mark = yystack.l_base; 855 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 856 yystack.p_mark = yystack.p_base; 857 #endif 858 yystate = 0; 859 *yystack.s_mark = 0; 860 861 yyloop: 862 if ((yyn = yydefred[yystate]) != 0) goto yyreduce; 863 if (yychar < 0) 864 { 865 #if YYBTYACC 866 do { 867 if (yylvp < yylve) 868 { 869 /* we're currently re-reading tokens */ 870 yylval = *yylvp++; 871 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 872 yylloc = *yylpp++; 873 #endif 874 yychar = *yylexp++; 875 break; 876 } 877 if (yyps->save) 878 { 879 /* in trial mode; save scanner results for future parse attempts */ 880 if (yylvp == yylvlim) 881 { /* Enlarge lexical value queue */ 882 size_t p = (size_t) (yylvp - yylvals); 883 size_t s = (size_t) (yylvlim - yylvals); 884 885 s += YYLVQUEUEGROWTH; 886 if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; 887 if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; 888 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 889 if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; 890 #endif 891 yylvp = yylve = yylvals + p; 892 yylvlim = yylvals + s; 893 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 894 yylpp = yylpe = yylpsns + p; 895 yylplim = yylpsns + s; 896 #endif 897 yylexp = yylexemes + p; 898 } 899 *yylexp = (YYINT) YYLEX; 900 *yylvp++ = yylval; 901 yylve++; 902 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 903 *yylpp++ = yylloc; 904 yylpe++; 905 #endif 906 yychar = *yylexp++; 907 break; 908 } 909 /* normal operation, no conflict encountered */ 910 #endif /* YYBTYACC */ 911 yychar = YYLEX; 912 #if YYBTYACC 913 } while (0); 914 #endif /* YYBTYACC */ 915 if (yychar < 0) yychar = YYEOF; 916 #if YYDEBUG 917 if (yydebug) 918 { 919 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; 920 fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", 921 YYDEBUGSTR, yydepth, yystate, yychar, yys); 922 #ifdef YYSTYPE_TOSTRING 923 #if YYBTYACC 924 if (!yytrial) 925 #endif /* YYBTYACC */ 926 fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); 927 #endif 928 fputc('\n', stderr); 929 } 930 #endif 931 } 932 #if YYBTYACC 933 934 /* Do we have a conflict? */ 935 if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && 936 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) 937 { 938 YYINT ctry; 939 940 if (yypath) 941 { 942 YYParseState *save; 943 #if YYDEBUG 944 if (yydebug) 945 fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", 946 YYDEBUGSTR, yydepth, yystate); 947 #endif 948 /* Switch to the next conflict context */ 949 save = yypath; 950 yypath = save->save; 951 save->save = NULL; 952 ctry = save->ctry; 953 if (save->state != yystate) YYABORT; 954 yyFreeState(save); 955 956 } 957 else 958 { 959 960 /* Unresolved conflict - start/continue trial parse */ 961 YYParseState *save; 962 #if YYDEBUG 963 if (yydebug) 964 { 965 fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); 966 if (yyps->save) 967 fputs("ALREADY in conflict, continuing trial parse.\n", stderr); 968 else 969 fputs("Starting trial parse.\n", stderr); 970 } 971 #endif 972 save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); 973 if (save == NULL) goto yyenomem; 974 save->save = yyps->save; 975 save->state = yystate; 976 save->errflag = yyerrflag; 977 save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); 978 memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); 979 save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); 980 memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); 981 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 982 save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); 983 memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); 984 #endif 985 ctry = yytable[yyn]; 986 if (yyctable[ctry] == -1) 987 { 988 #if YYDEBUG 989 if (yydebug && yychar >= YYEOF) 990 fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); 991 #endif 992 ctry++; 993 } 994 save->ctry = ctry; 995 if (yyps->save == NULL) 996 { 997 /* If this is a first conflict in the stack, start saving lexemes */ 998 if (!yylexemes) 999 { 1000 yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); 1001 if (yylexemes == NULL) goto yyenomem; 1002 yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); 1003 if (yylvals == NULL) goto yyenomem; 1004 yylvlim = yylvals + YYLVQUEUEGROWTH; 1005 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1006 yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); 1007 if (yylpsns == NULL) goto yyenomem; 1008 yylplim = yylpsns + YYLVQUEUEGROWTH; 1009 #endif 1010 } 1011 if (yylvp == yylve) 1012 { 1013 yylvp = yylve = yylvals; 1014 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1015 yylpp = yylpe = yylpsns; 1016 #endif 1017 yylexp = yylexemes; 1018 if (yychar >= YYEOF) 1019 { 1020 *yylve++ = yylval; 1021 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1022 *yylpe++ = yylloc; 1023 #endif 1024 *yylexp = (YYINT) yychar; 1025 yychar = YYEMPTY; 1026 } 1027 } 1028 } 1029 if (yychar >= YYEOF) 1030 { 1031 yylvp--; 1032 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1033 yylpp--; 1034 #endif 1035 yylexp--; 1036 yychar = YYEMPTY; 1037 } 1038 save->lexeme = (int) (yylvp - yylvals); 1039 yyps->save = save; 1040 } 1041 if (yytable[yyn] == ctry) 1042 { 1043 #if YYDEBUG 1044 if (yydebug) 1045 fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", 1046 YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); 1047 #endif 1048 if (yychar < 0) 1049 { 1050 yylvp++; 1051 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1052 yylpp++; 1053 #endif 1054 yylexp++; 1055 } 1056 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) 1057 goto yyoverflow; 1058 yystate = yyctable[ctry]; 1059 *++yystack.s_mark = (YYINT) yystate; 1060 *++yystack.l_mark = yylval; 1061 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1062 *++yystack.p_mark = yylloc; 1063 #endif 1064 yychar = YYEMPTY; 1065 if (yyerrflag > 0) --yyerrflag; 1066 goto yyloop; 1067 } 1068 else 1069 { 1070 yyn = yyctable[ctry]; 1071 goto yyreduce; 1072 } 1073 } /* End of code dealing with conflicts */ 1074 #endif /* YYBTYACC */ 1075 if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && 1076 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) 1077 { 1078 #if YYDEBUG 1079 if (yydebug) 1080 fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", 1081 YYDEBUGSTR, yydepth, yystate, yytable[yyn]); 1082 #endif 1083 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; 1084 yystate = yytable[yyn]; 1085 *++yystack.s_mark = yytable[yyn]; 1086 *++yystack.l_mark = yylval; 1087 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1088 *++yystack.p_mark = yylloc; 1089 #endif 1090 yychar = YYEMPTY; 1091 if (yyerrflag > 0) --yyerrflag; 1092 goto yyloop; 1093 } 1094 if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && 1095 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) 1096 { 1097 yyn = yytable[yyn]; 1098 goto yyreduce; 1099 } 1100 if (yyerrflag != 0) goto yyinrecovery; 1101 #if YYBTYACC 1102 1103 yynewerrflag = 1; 1104 goto yyerrhandler; 1105 goto yyerrlab; /* redundant goto avoids 'unused label' warning */ 1106 1107 yyerrlab: 1108 /* explicit YYERROR from an action -- pop the rhs of the rule reduced 1109 * before looking for error recovery */ 1110 yystack.s_mark -= yym; 1111 yystate = *yystack.s_mark; 1112 yystack.l_mark -= yym; 1113 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1114 yystack.p_mark -= yym; 1115 #endif 1116 1117 yynewerrflag = 0; 1118 yyerrhandler: 1119 while (yyps->save) 1120 { 1121 int ctry; 1122 YYParseState *save = yyps->save; 1123 #if YYDEBUG 1124 if (yydebug) 1125 fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", 1126 YYDEBUGSTR, yydepth, yystate, yyps->save->state, 1127 (int)(yylvp - yylvals - yyps->save->lexeme)); 1128 #endif 1129 /* Memorize most forward-looking error state in case it's really an error. */ 1130 if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) 1131 { 1132 /* Free old saved error context state */ 1133 if (yyerrctx) yyFreeState(yyerrctx); 1134 /* Create and fill out new saved error context state */ 1135 yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); 1136 if (yyerrctx == NULL) goto yyenomem; 1137 yyerrctx->save = yyps->save; 1138 yyerrctx->state = yystate; 1139 yyerrctx->errflag = yyerrflag; 1140 yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); 1141 memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); 1142 yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); 1143 memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); 1144 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1145 yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); 1146 memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); 1147 #endif 1148 yyerrctx->lexeme = (int) (yylvp - yylvals); 1149 } 1150 yylvp = yylvals + save->lexeme; 1151 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1152 yylpp = yylpsns + save->lexeme; 1153 #endif 1154 yylexp = yylexemes + save->lexeme; 1155 yychar = YYEMPTY; 1156 yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); 1157 memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); 1158 yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); 1159 memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); 1160 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1161 yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); 1162 memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); 1163 #endif 1164 ctry = ++save->ctry; 1165 yystate = save->state; 1166 /* We tried shift, try reduce now */ 1167 if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; 1168 yyps->save = save->save; 1169 save->save = NULL; 1170 yyFreeState(save); 1171 1172 /* Nothing left on the stack -- error */ 1173 if (!yyps->save) 1174 { 1175 #if YYDEBUG 1176 if (yydebug) 1177 fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", 1178 YYPREFIX, yydepth); 1179 #endif 1180 /* Restore state as it was in the most forward-advanced error */ 1181 yylvp = yylvals + yyerrctx->lexeme; 1182 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1183 yylpp = yylpsns + yyerrctx->lexeme; 1184 #endif 1185 yylexp = yylexemes + yyerrctx->lexeme; 1186 yychar = yylexp[-1]; 1187 yylval = yylvp[-1]; 1188 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1189 yylloc = yylpp[-1]; 1190 #endif 1191 yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); 1192 memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); 1193 yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); 1194 memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); 1195 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1196 yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); 1197 memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); 1198 #endif 1199 yystate = yyerrctx->state; 1200 yyFreeState(yyerrctx); 1201 yyerrctx = NULL; 1202 } 1203 yynewerrflag = 1; 1204 } 1205 if (yynewerrflag == 0) goto yyinrecovery; 1206 #endif /* YYBTYACC */ 1207 1208 YYERROR_CALL("syntax error"); 1209 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1210 yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ 1211 #endif 1212 1213 #if !YYBTYACC 1214 goto yyerrlab; /* redundant goto avoids 'unused label' warning */ 1215 yyerrlab: 1216 #endif 1217 ++yynerrs; 1218 1219 yyinrecovery: 1220 if (yyerrflag < 3) 1221 { 1222 yyerrflag = 3; 1223 for (;;) 1224 { 1225 if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && 1226 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) 1227 { 1228 #if YYDEBUG 1229 if (yydebug) 1230 fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", 1231 YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); 1232 #endif 1233 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; 1234 yystate = yytable[yyn]; 1235 *++yystack.s_mark = yytable[yyn]; 1236 *++yystack.l_mark = yylval; 1237 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1238 /* lookahead position is error end position */ 1239 yyerror_loc_range[2] = yylloc; 1240 YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ 1241 *++yystack.p_mark = yyloc; 1242 #endif 1243 goto yyloop; 1244 } 1245 else 1246 { 1247 #if YYDEBUG 1248 if (yydebug) 1249 fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", 1250 YYDEBUGSTR, yydepth, *yystack.s_mark); 1251 #endif 1252 if (yystack.s_mark <= yystack.s_base) goto yyabort; 1253 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1254 /* the current TOS position is the error start position */ 1255 yyerror_loc_range[1] = *yystack.p_mark; 1256 #endif 1257 #if defined(YYDESTRUCT_CALL) 1258 #if YYBTYACC 1259 if (!yytrial) 1260 #endif /* YYBTYACC */ 1261 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1262 YYDESTRUCT_CALL("error: discarding state", 1263 yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); 1264 #else 1265 YYDESTRUCT_CALL("error: discarding state", 1266 yystos[*yystack.s_mark], yystack.l_mark); 1267 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ 1268 #endif /* defined(YYDESTRUCT_CALL) */ 1269 --yystack.s_mark; 1270 --yystack.l_mark; 1271 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1272 --yystack.p_mark; 1273 #endif 1274 } 1275 } 1276 } 1277 else 1278 { 1279 if (yychar == YYEOF) goto yyabort; 1280 #if YYDEBUG 1281 if (yydebug) 1282 { 1283 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; 1284 fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", 1285 YYDEBUGSTR, yydepth, yystate, yychar, yys); 1286 } 1287 #endif 1288 #if defined(YYDESTRUCT_CALL) 1289 #if YYBTYACC 1290 if (!yytrial) 1291 #endif /* YYBTYACC */ 1292 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1293 YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); 1294 #else 1295 YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); 1296 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ 1297 #endif /* defined(YYDESTRUCT_CALL) */ 1298 yychar = YYEMPTY; 1299 goto yyloop; 1300 } 1301 1302 yyreduce: 1303 yym = yylen[yyn]; 1304 #if YYDEBUG 1305 if (yydebug) 1306 { 1307 fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", 1308 YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); 1309 #ifdef YYSTYPE_TOSTRING 1310 #if YYBTYACC 1311 if (!yytrial) 1312 #endif /* YYBTYACC */ 1313 if (yym > 0) 1314 { 1315 int i; 1316 fputc('<', stderr); 1317 for (i = yym; i > 0; i--) 1318 { 1319 if (i != yym) fputs(", ", stderr); 1320 fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], 1321 yystack.l_mark[1-i]), stderr); 1322 } 1323 fputc('>', stderr); 1324 } 1325 #endif 1326 fputc('\n', stderr); 1327 } 1328 #endif 1329 if (yym > 0) 1330 yyval = yystack.l_mark[1-yym]; 1331 else 1332 memset(&yyval, 0, sizeof yyval); 1333 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1334 1335 /* Perform position reduction */ 1336 memset(&yyloc, 0, sizeof(yyloc)); 1337 #if YYBTYACC 1338 if (!yytrial) 1339 #endif /* YYBTYACC */ 1340 { 1341 YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); 1342 /* just in case YYERROR is invoked within the action, save 1343 the start of the rhs as the error start position */ 1344 yyerror_loc_range[1] = yystack.p_mark[1-yym]; 1345 } 1346 #endif 1347 1348 switch (yyn) 1349 { 1350 case 2: 1351 #line 51 "btyacc_calc1.y" 1352 {YYVALID;} 1353 #line 1354 "btyacc_calc1.tab.c" 1354 break; 1355 case 3: 1356 #line 52 "btyacc_calc1.y" 1357 {YYVALID;} if (!yytrial) 1358 #line 53 "btyacc_calc1.y" 1359 { 1360 yyerrok; 1361 } 1362 #line 1363 "btyacc_calc1.tab.c" 1363 break; 1364 case 4: 1365 if (!yytrial) 1366 #line 59 "btyacc_calc1.y" 1367 { 1368 (void) printf("%15.8f\n", yystack.l_mark[0].dval); 1369 } 1370 #line 1371 "btyacc_calc1.tab.c" 1371 break; 1372 case 5: 1373 if (!yytrial) 1374 #line 63 "btyacc_calc1.y" 1375 { 1376 (void) printf("(%15.8f, %15.8f)\n", yystack.l_mark[0].vval.lo, yystack.l_mark[0].vval.hi); 1377 } 1378 #line 1379 "btyacc_calc1.tab.c" 1379 break; 1380 case 6: 1381 if (!yytrial) 1382 #line 67 "btyacc_calc1.y" 1383 { 1384 dreg[yystack.l_mark[-2].ival] = yystack.l_mark[0].dval; 1385 } 1386 #line 1387 "btyacc_calc1.tab.c" 1387 break; 1388 case 7: 1389 if (!yytrial) 1390 #line 71 "btyacc_calc1.y" 1391 { 1392 vreg[yystack.l_mark[-2].ival] = yystack.l_mark[0].vval; 1393 } 1394 #line 1395 "btyacc_calc1.tab.c" 1395 break; 1396 case 9: 1397 if (!yytrial) 1398 #line 78 "btyacc_calc1.y" 1399 { 1400 yyval.dval = dreg[yystack.l_mark[0].ival]; 1401 } 1402 #line 1403 "btyacc_calc1.tab.c" 1403 break; 1404 case 10: 1405 if (!yytrial) 1406 #line 82 "btyacc_calc1.y" 1407 { 1408 yyval.dval = yystack.l_mark[-2].dval + yystack.l_mark[0].dval; 1409 } 1410 #line 1411 "btyacc_calc1.tab.c" 1411 break; 1412 case 11: 1413 if (!yytrial) 1414 #line 86 "btyacc_calc1.y" 1415 { 1416 yyval.dval = yystack.l_mark[-2].dval - yystack.l_mark[0].dval; 1417 } 1418 #line 1419 "btyacc_calc1.tab.c" 1419 break; 1420 case 12: 1421 if (!yytrial) 1422 #line 90 "btyacc_calc1.y" 1423 { 1424 yyval.dval = yystack.l_mark[-2].dval * yystack.l_mark[0].dval; 1425 } 1426 #line 1427 "btyacc_calc1.tab.c" 1427 break; 1428 case 13: 1429 if (!yytrial) 1430 #line 94 "btyacc_calc1.y" 1431 { 1432 yyval.dval = yystack.l_mark[-2].dval / yystack.l_mark[0].dval; 1433 } 1434 #line 1435 "btyacc_calc1.tab.c" 1435 break; 1436 case 14: 1437 if (!yytrial) 1438 #line 98 "btyacc_calc1.y" 1439 { 1440 yyval.dval = -yystack.l_mark[0].dval; 1441 } 1442 #line 1443 "btyacc_calc1.tab.c" 1443 break; 1444 case 15: 1445 if (!yytrial) 1446 #line 102 "btyacc_calc1.y" 1447 { 1448 yyval.dval = yystack.l_mark[-1].dval; 1449 } 1450 #line 1451 "btyacc_calc1.tab.c" 1451 break; 1452 case 16: 1453 if (!yytrial) 1454 #line 108 "btyacc_calc1.y" 1455 { 1456 yyval.vval.hi = yyval.vval.lo = yystack.l_mark[0].dval; 1457 } 1458 #line 1459 "btyacc_calc1.tab.c" 1459 break; 1460 case 17: 1461 if (!yytrial) 1462 #line 112 "btyacc_calc1.y" 1463 { 1464 yyval.vval.lo = yystack.l_mark[-3].dval; 1465 yyval.vval.hi = yystack.l_mark[-1].dval; 1466 if ( yyval.vval.lo > yyval.vval.hi ) 1467 { 1468 (void) printf("interval out of order\n"); 1469 YYERROR; 1470 } 1471 } 1472 #line 1473 "btyacc_calc1.tab.c" 1473 break; 1474 case 18: 1475 if (!yytrial) 1476 #line 122 "btyacc_calc1.y" 1477 { 1478 yyval.vval = vreg[yystack.l_mark[0].ival]; 1479 } 1480 #line 1481 "btyacc_calc1.tab.c" 1481 break; 1482 case 19: 1483 if (!yytrial) 1484 #line 126 "btyacc_calc1.y" 1485 { 1486 yyval.vval.hi = yystack.l_mark[-2].vval.hi + yystack.l_mark[0].vval.hi; 1487 yyval.vval.lo = yystack.l_mark[-2].vval.lo + yystack.l_mark[0].vval.lo; 1488 } 1489 #line 1490 "btyacc_calc1.tab.c" 1490 break; 1491 case 20: 1492 if (!yytrial) 1493 #line 131 "btyacc_calc1.y" 1494 { 1495 yyval.vval.hi = yystack.l_mark[-2].dval + yystack.l_mark[0].vval.hi; 1496 yyval.vval.lo = yystack.l_mark[-2].dval + yystack.l_mark[0].vval.lo; 1497 } 1498 #line 1499 "btyacc_calc1.tab.c" 1499 break; 1500 case 21: 1501 if (!yytrial) 1502 #line 136 "btyacc_calc1.y" 1503 { 1504 yyval.vval.hi = yystack.l_mark[-2].vval.hi - yystack.l_mark[0].vval.lo; 1505 yyval.vval.lo = yystack.l_mark[-2].vval.lo - yystack.l_mark[0].vval.hi; 1506 } 1507 #line 1508 "btyacc_calc1.tab.c" 1508 break; 1509 case 22: 1510 if (!yytrial) 1511 #line 141 "btyacc_calc1.y" 1512 { 1513 yyval.vval.hi = yystack.l_mark[-2].dval - yystack.l_mark[0].vval.lo; 1514 yyval.vval.lo = yystack.l_mark[-2].dval - yystack.l_mark[0].vval.hi; 1515 } 1516 #line 1517 "btyacc_calc1.tab.c" 1517 break; 1518 case 23: 1519 if (!yytrial) 1520 #line 146 "btyacc_calc1.y" 1521 { 1522 yyval.vval = vmul( yystack.l_mark[-2].vval.lo, yystack.l_mark[-2].vval.hi, yystack.l_mark[0].vval ); 1523 } 1524 #line 1525 "btyacc_calc1.tab.c" 1525 break; 1526 case 24: 1527 if (!yytrial) 1528 #line 150 "btyacc_calc1.y" 1529 { 1530 yyval.vval = vmul (yystack.l_mark[-2].dval, yystack.l_mark[-2].dval, yystack.l_mark[0].vval ); 1531 } 1532 #line 1533 "btyacc_calc1.tab.c" 1533 break; 1534 case 25: 1535 if (!yytrial) 1536 #line 154 "btyacc_calc1.y" 1537 { 1538 if (dcheck(yystack.l_mark[0].vval)) YYERROR; 1539 yyval.vval = vdiv ( yystack.l_mark[-2].vval.lo, yystack.l_mark[-2].vval.hi, yystack.l_mark[0].vval ); 1540 } 1541 #line 1542 "btyacc_calc1.tab.c" 1542 break; 1543 case 26: 1544 if (!yytrial) 1545 #line 159 "btyacc_calc1.y" 1546 { 1547 if (dcheck ( yystack.l_mark[0].vval )) YYERROR; 1548 yyval.vval = vdiv (yystack.l_mark[-2].dval, yystack.l_mark[-2].dval, yystack.l_mark[0].vval ); 1549 } 1550 #line 1551 "btyacc_calc1.tab.c" 1551 break; 1552 case 27: 1553 if (!yytrial) 1554 #line 164 "btyacc_calc1.y" 1555 { 1556 yyval.vval.hi = -yystack.l_mark[0].vval.lo; 1557 yyval.vval.lo = -yystack.l_mark[0].vval.hi; 1558 } 1559 #line 1560 "btyacc_calc1.tab.c" 1560 break; 1561 case 28: 1562 if (!yytrial) 1563 #line 169 "btyacc_calc1.y" 1564 { 1565 yyval.vval = yystack.l_mark[-1].vval; 1566 } 1567 #line 1568 "btyacc_calc1.tab.c" 1568 break; 1569 #line 1570 "btyacc_calc1.tab.c" 1570 default: 1571 break; 1572 } 1573 yystack.s_mark -= yym; 1574 yystate = *yystack.s_mark; 1575 yystack.l_mark -= yym; 1576 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1577 yystack.p_mark -= yym; 1578 #endif 1579 yym = yylhs[yyn]; 1580 if (yystate == 0 && yym == 0) 1581 { 1582 #if YYDEBUG 1583 if (yydebug) 1584 { 1585 fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); 1586 #ifdef YYSTYPE_TOSTRING 1587 #if YYBTYACC 1588 if (!yytrial) 1589 #endif /* YYBTYACC */ 1590 fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval)); 1591 #endif 1592 fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL); 1593 } 1594 #endif 1595 yystate = YYFINAL; 1596 *++yystack.s_mark = YYFINAL; 1597 *++yystack.l_mark = yyval; 1598 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1599 *++yystack.p_mark = yyloc; 1600 #endif 1601 if (yychar < 0) 1602 { 1603 #if YYBTYACC 1604 do { 1605 if (yylvp < yylve) 1606 { 1607 /* we're currently re-reading tokens */ 1608 yylval = *yylvp++; 1609 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1610 yylloc = *yylpp++; 1611 #endif 1612 yychar = *yylexp++; 1613 break; 1614 } 1615 if (yyps->save) 1616 { 1617 /* in trial mode; save scanner results for future parse attempts */ 1618 if (yylvp == yylvlim) 1619 { /* Enlarge lexical value queue */ 1620 size_t p = (size_t) (yylvp - yylvals); 1621 size_t s = (size_t) (yylvlim - yylvals); 1622 1623 s += YYLVQUEUEGROWTH; 1624 if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) 1625 goto yyenomem; 1626 if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) 1627 goto yyenomem; 1628 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1629 if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) 1630 goto yyenomem; 1631 #endif 1632 yylvp = yylve = yylvals + p; 1633 yylvlim = yylvals + s; 1634 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1635 yylpp = yylpe = yylpsns + p; 1636 yylplim = yylpsns + s; 1637 #endif 1638 yylexp = yylexemes + p; 1639 } 1640 *yylexp = (YYINT) YYLEX; 1641 *yylvp++ = yylval; 1642 yylve++; 1643 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1644 *yylpp++ = yylloc; 1645 yylpe++; 1646 #endif 1647 yychar = *yylexp++; 1648 break; 1649 } 1650 /* normal operation, no conflict encountered */ 1651 #endif /* YYBTYACC */ 1652 yychar = YYLEX; 1653 #if YYBTYACC 1654 } while (0); 1655 #endif /* YYBTYACC */ 1656 if (yychar < 0) yychar = YYEOF; 1657 #if YYDEBUG 1658 if (yydebug) 1659 { 1660 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; 1661 fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", 1662 YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); 1663 } 1664 #endif 1665 } 1666 if (yychar == YYEOF) goto yyaccept; 1667 goto yyloop; 1668 } 1669 if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && 1670 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) 1671 yystate = yytable[yyn]; 1672 else 1673 yystate = yydgoto[yym]; 1674 #if YYDEBUG 1675 if (yydebug) 1676 { 1677 fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); 1678 #ifdef YYSTYPE_TOSTRING 1679 #if YYBTYACC 1680 if (!yytrial) 1681 #endif /* YYBTYACC */ 1682 fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); 1683 #endif 1684 fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); 1685 } 1686 #endif 1687 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; 1688 *++yystack.s_mark = (YYINT) yystate; 1689 *++yystack.l_mark = yyval; 1690 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1691 *++yystack.p_mark = yyloc; 1692 #endif 1693 goto yyloop; 1694 #if YYBTYACC 1695 1696 /* Reduction declares that this path is valid. Set yypath and do a full parse */ 1697 yyvalid: 1698 if (yypath) YYABORT; 1699 while (yyps->save) 1700 { 1701 YYParseState *save = yyps->save; 1702 yyps->save = save->save; 1703 save->save = yypath; 1704 yypath = save; 1705 } 1706 #if YYDEBUG 1707 if (yydebug) 1708 fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", 1709 YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); 1710 #endif 1711 if (yyerrctx) 1712 { 1713 yyFreeState(yyerrctx); 1714 yyerrctx = NULL; 1715 } 1716 yylvp = yylvals + yypath->lexeme; 1717 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1718 yylpp = yylpsns + yypath->lexeme; 1719 #endif 1720 yylexp = yylexemes + yypath->lexeme; 1721 yychar = YYEMPTY; 1722 yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); 1723 memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); 1724 yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); 1725 memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); 1726 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1727 yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); 1728 memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); 1729 #endif 1730 yystate = yypath->state; 1731 goto yyloop; 1732 #endif /* YYBTYACC */ 1733 1734 yyoverflow: 1735 YYERROR_CALL("yacc stack overflow"); 1736 #if YYBTYACC 1737 goto yyabort_nomem; 1738 yyenomem: 1739 YYERROR_CALL("memory exhausted"); 1740 yyabort_nomem: 1741 #endif /* YYBTYACC */ 1742 yyresult = 2; 1743 goto yyreturn; 1744 1745 yyabort: 1746 yyresult = 1; 1747 goto yyreturn; 1748 1749 yyaccept: 1750 #if YYBTYACC 1751 if (yyps->save) goto yyvalid; 1752 #endif /* YYBTYACC */ 1753 yyresult = 0; 1754 1755 yyreturn: 1756 #if defined(YYDESTRUCT_CALL) 1757 if (yychar != YYEOF && yychar != YYEMPTY) 1758 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1759 YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); 1760 #else 1761 YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); 1762 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ 1763 1764 { 1765 YYSTYPE *pv; 1766 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1767 YYLTYPE *pp; 1768 1769 for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) 1770 YYDESTRUCT_CALL("cleanup: discarding state", 1771 yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); 1772 #else 1773 for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) 1774 YYDESTRUCT_CALL("cleanup: discarding state", 1775 yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); 1776 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ 1777 } 1778 #endif /* defined(YYDESTRUCT_CALL) */ 1779 1780 #if YYBTYACC 1781 if (yyerrctx) 1782 { 1783 yyFreeState(yyerrctx); 1784 yyerrctx = NULL; 1785 } 1786 while (yyps) 1787 { 1788 YYParseState *save = yyps; 1789 yyps = save->save; 1790 save->save = NULL; 1791 yyFreeState(save); 1792 } 1793 while (yypath) 1794 { 1795 YYParseState *save = yypath; 1796 yypath = save->save; 1797 save->save = NULL; 1798 yyFreeState(save); 1799 } 1800 #endif /* YYBTYACC */ 1801 yyfreestack(&yystack); 1802 return (yyresult); 1803 } 1804