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 17 /* %code "top" block start */ 18 #line 1 "calc_code_top.y" 19 /* CODE-TOP */ 20 #line 2 "calc_code_top.y" 21 /* CODE-TOP2 */ 22 /* %code "top" block end */ 23 #line 24 "calc_code_top.tab.c" 24 25 #ifndef yyparse 26 #define yyparse calc_code_top_parse 27 #endif /* yyparse */ 28 29 #ifndef yylex 30 #define yylex calc_code_top_lex 31 #endif /* yylex */ 32 33 #ifndef yyerror 34 #define yyerror calc_code_top_error 35 #endif /* yyerror */ 36 37 #ifndef yychar 38 #define yychar calc_code_top_char 39 #endif /* yychar */ 40 41 #ifndef yyval 42 #define yyval calc_code_top_val 43 #endif /* yyval */ 44 45 #ifndef yylval 46 #define yylval calc_code_top_lval 47 #endif /* yylval */ 48 49 #ifndef yydebug 50 #define yydebug calc_code_top_debug 51 #endif /* yydebug */ 52 53 #ifndef yynerrs 54 #define yynerrs calc_code_top_nerrs 55 #endif /* yynerrs */ 56 57 #ifndef yyerrflag 58 #define yyerrflag calc_code_top_errflag 59 #endif /* yyerrflag */ 60 61 #ifndef yylhs 62 #define yylhs calc_code_top_lhs 63 #endif /* yylhs */ 64 65 #ifndef yylen 66 #define yylen calc_code_top_len 67 #endif /* yylen */ 68 69 #ifndef yydefred 70 #define yydefred calc_code_top_defred 71 #endif /* yydefred */ 72 73 #ifndef yydgoto 74 #define yydgoto calc_code_top_dgoto 75 #endif /* yydgoto */ 76 77 #ifndef yysindex 78 #define yysindex calc_code_top_sindex 79 #endif /* yysindex */ 80 81 #ifndef yyrindex 82 #define yyrindex calc_code_top_rindex 83 #endif /* yyrindex */ 84 85 #ifndef yygindex 86 #define yygindex calc_code_top_gindex 87 #endif /* yygindex */ 88 89 #ifndef yytable 90 #define yytable calc_code_top_table 91 #endif /* yytable */ 92 93 #ifndef yycheck 94 #define yycheck calc_code_top_check 95 #endif /* yycheck */ 96 97 #ifndef yyname 98 #define yyname calc_code_top_name 99 #endif /* yyname */ 100 101 #ifndef yyrule 102 #define yyrule calc_code_top_rule 103 #endif /* yyrule */ 104 #define YYPREFIX "calc_code_top_" 105 106 #define YYPURE 0 107 108 #line 5 "calc_code_top.y" 109 # include <stdio.h> 110 # include <ctype.h> 111 112 int regs[26]; 113 int base; 114 115 extern int yylex(void); 116 static void yyerror(const char *s); 117 118 #line 119 "calc_code_top.tab.c" 119 120 #if ! defined(YYSTYPE) && ! defined(YYSTYPE_IS_DECLARED) 121 /* Default: YYSTYPE is the semantic value type. */ 122 typedef int YYSTYPE; 123 # define YYSTYPE_IS_DECLARED 1 124 #endif 125 126 /* compatibility with bison */ 127 #ifdef YYPARSE_PARAM 128 /* compatibility with FreeBSD */ 129 # ifdef YYPARSE_PARAM_TYPE 130 # define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM) 131 # else 132 # define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM) 133 # endif 134 #else 135 # define YYPARSE_DECL() yyparse(void) 136 #endif 137 138 /* Parameters sent to lex. */ 139 #ifdef YYLEX_PARAM 140 # define YYLEX_DECL() yylex(void *YYLEX_PARAM) 141 # define YYLEX yylex(YYLEX_PARAM) 142 #else 143 # define YYLEX_DECL() yylex(void) 144 # define YYLEX yylex() 145 #endif 146 147 /* Parameters sent to yyerror. */ 148 #ifndef YYERROR_DECL 149 #define YYERROR_DECL() yyerror(const char *s) 150 #endif 151 #ifndef YYERROR_CALL 152 #define YYERROR_CALL(msg) yyerror(msg) 153 #endif 154 155 extern int YYPARSE_DECL(); 156 157 #define DIGIT 257 158 #define LETTER 258 159 #define UMINUS 259 160 #define YYERRCODE 256 161 typedef int YYINT; 162 static const YYINT calc_code_top_lhs[] = { -1, 163 0, 0, 0, 1, 1, 2, 2, 2, 2, 2, 164 2, 2, 2, 2, 2, 2, 3, 3, 165 }; 166 static const YYINT calc_code_top_len[] = { 2, 167 0, 3, 3, 1, 3, 3, 3, 3, 3, 3, 168 3, 3, 3, 2, 1, 1, 1, 2, 169 }; 170 static const YYINT calc_code_top_defred[] = { 1, 171 0, 0, 17, 0, 0, 0, 0, 0, 0, 3, 172 0, 15, 14, 0, 2, 0, 0, 0, 0, 0, 173 0, 0, 18, 0, 6, 0, 0, 0, 0, 9, 174 10, 11, 175 }; 176 static const YYINT calc_code_top_dgoto[] = { 1, 177 7, 8, 9, 178 }; 179 static const YYINT calc_code_top_sindex[] = { 0, 180 -40, -7, 0, -55, -38, -38, 1, -29, -247, 0, 181 -38, 0, 0, 22, 0, -38, -38, -38, -38, -38, 182 -38, -38, 0, -29, 0, 51, 60, -20, -20, 0, 183 0, 0, 184 }; 185 static const YYINT calc_code_top_rindex[] = { 0, 186 0, 0, 0, 2, 0, 0, 0, 9, -9, 0, 187 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 188 0, 0, 0, 10, 0, -6, 14, 5, 13, 0, 189 0, 0, 190 }; 191 static const YYINT calc_code_top_gindex[] = { 0, 192 0, 65, 0, 193 }; 194 #define YYTABLESIZE 220 195 static const YYINT calc_code_top_table[] = { 6, 196 16, 6, 10, 13, 5, 11, 5, 22, 17, 23, 197 15, 15, 20, 18, 7, 19, 22, 21, 4, 5, 198 0, 20, 8, 12, 0, 0, 21, 16, 16, 0, 199 0, 16, 16, 16, 13, 16, 0, 16, 15, 15, 200 0, 0, 7, 15, 15, 7, 15, 7, 15, 7, 201 8, 12, 0, 8, 12, 8, 0, 8, 22, 17, 202 0, 0, 25, 20, 18, 0, 19, 0, 21, 13, 203 14, 0, 0, 0, 0, 24, 0, 0, 0, 0, 204 26, 27, 28, 29, 30, 31, 32, 22, 17, 0, 205 0, 0, 20, 18, 16, 19, 22, 21, 0, 0, 206 0, 20, 18, 0, 19, 0, 21, 0, 0, 0, 207 0, 0, 0, 0, 16, 0, 0, 13, 0, 0, 208 0, 0, 0, 0, 0, 15, 0, 0, 7, 0, 209 0, 0, 0, 0, 0, 0, 8, 12, 0, 0, 210 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, 211 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 212 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 213 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 214 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 215 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 216 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 217 0, 0, 0, 0, 0, 2, 3, 4, 3, 12, 218 }; 219 static const YYINT calc_code_top_check[] = { 40, 220 10, 40, 10, 10, 45, 61, 45, 37, 38, 257, 221 10, 10, 42, 43, 10, 45, 37, 47, 10, 10, 222 -1, 42, 10, 10, -1, -1, 47, 37, 38, -1, 223 -1, 41, 42, 43, 41, 45, -1, 47, 37, 38, 224 -1, -1, 38, 42, 43, 41, 45, 43, 47, 45, 225 38, 38, -1, 41, 41, 43, -1, 45, 37, 38, 226 -1, -1, 41, 42, 43, -1, 45, -1, 47, 5, 227 6, -1, -1, -1, -1, 11, -1, -1, -1, -1, 228 16, 17, 18, 19, 20, 21, 22, 37, 38, -1, 229 -1, -1, 42, 43, 124, 45, 37, 47, -1, -1, 230 -1, 42, 43, -1, 45, -1, 47, -1, -1, -1, 231 -1, -1, -1, -1, 124, -1, -1, 124, -1, -1, 232 -1, -1, -1, -1, -1, 124, -1, -1, 124, -1, 233 -1, -1, -1, -1, -1, -1, 124, 124, -1, -1, 234 -1, -1, -1, -1, -1, 124, -1, -1, -1, -1, 235 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 236 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 237 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 238 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 239 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 240 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 241 -1, -1, -1, -1, -1, 256, 257, 258, 257, 258, 242 }; 243 #define YYFINAL 1 244 #ifndef YYDEBUG 245 #define YYDEBUG 0 246 #endif 247 #define YYMAXTOKEN 259 248 #define YYUNDFTOKEN 265 249 #define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) 250 #if YYDEBUG 251 static const char *const calc_code_top_name[] = { 252 253 "end-of-file",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, 254 0,0,0,0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0, 255 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, 256 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, 257 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, 258 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, 259 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, 260 0,0,0,0,0,0,"DIGIT","LETTER","UMINUS",0,0,0,0,0,"illegal-symbol", 261 }; 262 static const char *const calc_code_top_rule[] = { 263 "$accept : list", 264 "list :", 265 "list : list stat '\\n'", 266 "list : list error '\\n'", 267 "stat : expr", 268 "stat : LETTER '=' expr", 269 "expr : '(' expr ')'", 270 "expr : expr '+' expr", 271 "expr : expr '-' expr", 272 "expr : expr '*' expr", 273 "expr : expr '/' expr", 274 "expr : expr '%' expr", 275 "expr : expr '&' expr", 276 "expr : expr '|' expr", 277 "expr : '-' expr", 278 "expr : LETTER", 279 "expr : number", 280 "number : DIGIT", 281 "number : number DIGIT", 282 283 }; 284 #endif 285 286 #if YYDEBUG 287 int yydebug; 288 #endif 289 290 int yyerrflag; 291 int yychar; 292 YYSTYPE yyval; 293 YYSTYPE yylval; 294 int yynerrs; 295 296 /* define the initial stack-sizes */ 297 #ifdef YYSTACKSIZE 298 #undef YYMAXDEPTH 299 #define YYMAXDEPTH YYSTACKSIZE 300 #else 301 #ifdef YYMAXDEPTH 302 #define YYSTACKSIZE YYMAXDEPTH 303 #else 304 #define YYSTACKSIZE 10000 305 #define YYMAXDEPTH 10000 306 #endif 307 #endif 308 309 #define YYINITSTACKSIZE 200 310 311 typedef struct { 312 unsigned stacksize; 313 YYINT *s_base; 314 YYINT *s_mark; 315 YYINT *s_last; 316 YYSTYPE *l_base; 317 YYSTYPE *l_mark; 318 } YYSTACKDATA; 319 /* variables for the parser stack */ 320 static YYSTACKDATA yystack; 321 #line 69 "calc_code_top.y" 322 /* start of programs */ 323 324 int 325 main (void) 326 { 327 while(!feof(stdin)) { 328 yyparse(); 329 } 330 return 0; 331 } 332 333 static void 334 yyerror(const char *s) 335 { 336 fprintf(stderr, "%s\n", s); 337 } 338 339 int 340 yylex(void) 341 { 342 /* lexical analysis routine */ 343 /* returns LETTER for a lower case letter, yylval = 0 through 25 */ 344 /* return DIGIT for a digit, yylval = 0 through 9 */ 345 /* all other characters are returned immediately */ 346 347 int c; 348 349 while( (c=getchar()) == ' ' ) { /* skip blanks */ } 350 351 /* c is now nonblank */ 352 353 if( islower( c )) { 354 yylval = c - 'a'; 355 return ( LETTER ); 356 } 357 if( isdigit( c )) { 358 yylval = c - '0'; 359 return ( DIGIT ); 360 } 361 return( c ); 362 } 363 #line 364 "calc_code_top.tab.c" 364 365 #if YYDEBUG 366 #include <stdio.h> /* needed for printf */ 367 #endif 368 369 #include <stdlib.h> /* needed for malloc, etc */ 370 #include <string.h> /* needed for memset */ 371 372 /* allocate initial stack or double stack size, up to YYMAXDEPTH */ 373 static int yygrowstack(YYSTACKDATA *data) 374 { 375 int i; 376 unsigned newsize; 377 YYINT *newss; 378 YYSTYPE *newvs; 379 380 if ((newsize = data->stacksize) == 0) 381 newsize = YYINITSTACKSIZE; 382 else if (newsize >= YYMAXDEPTH) 383 return YYENOMEM; 384 else if ((newsize *= 2) > YYMAXDEPTH) 385 newsize = YYMAXDEPTH; 386 387 i = (int) (data->s_mark - data->s_base); 388 newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); 389 if (newss == NULL) 390 return YYENOMEM; 391 392 data->s_base = newss; 393 data->s_mark = newss + i; 394 395 newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); 396 if (newvs == NULL) 397 return YYENOMEM; 398 399 data->l_base = newvs; 400 data->l_mark = newvs + i; 401 402 data->stacksize = newsize; 403 data->s_last = data->s_base + newsize - 1; 404 return 0; 405 } 406 407 #if YYPURE || defined(YY_NO_LEAKS) 408 static void yyfreestack(YYSTACKDATA *data) 409 { 410 free(data->s_base); 411 free(data->l_base); 412 memset(data, 0, sizeof(*data)); 413 } 414 #else 415 #define yyfreestack(data) /* nothing */ 416 #endif 417 418 #define YYABORT goto yyabort 419 #define YYREJECT goto yyabort 420 #define YYACCEPT goto yyaccept 421 #define YYERROR goto yyerrlab 422 423 int 424 YYPARSE_DECL() 425 { 426 int yym, yyn, yystate; 427 #if YYDEBUG 428 const char *yys; 429 430 if ((yys = getenv("YYDEBUG")) != NULL) 431 { 432 yyn = *yys; 433 if (yyn >= '0' && yyn <= '9') 434 yydebug = yyn - '0'; 435 } 436 #endif 437 438 /* yym is set below */ 439 /* yyn is set below */ 440 yynerrs = 0; 441 yyerrflag = 0; 442 yychar = YYEMPTY; 443 yystate = 0; 444 445 #if YYPURE 446 memset(&yystack, 0, sizeof(yystack)); 447 #endif 448 449 if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; 450 yystack.s_mark = yystack.s_base; 451 yystack.l_mark = yystack.l_base; 452 yystate = 0; 453 *yystack.s_mark = 0; 454 455 yyloop: 456 if ((yyn = yydefred[yystate]) != 0) goto yyreduce; 457 if (yychar < 0) 458 { 459 yychar = YYLEX; 460 if (yychar < 0) yychar = YYEOF; 461 #if YYDEBUG 462 if (yydebug) 463 { 464 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; 465 printf("%sdebug: state %d, reading %d (%s)\n", 466 YYPREFIX, yystate, yychar, yys); 467 } 468 #endif 469 } 470 if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && 471 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) 472 { 473 #if YYDEBUG 474 if (yydebug) 475 printf("%sdebug: state %d, shifting to state %d\n", 476 YYPREFIX, yystate, yytable[yyn]); 477 #endif 478 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; 479 yystate = yytable[yyn]; 480 *++yystack.s_mark = yytable[yyn]; 481 *++yystack.l_mark = yylval; 482 yychar = YYEMPTY; 483 if (yyerrflag > 0) --yyerrflag; 484 goto yyloop; 485 } 486 if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && 487 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) 488 { 489 yyn = yytable[yyn]; 490 goto yyreduce; 491 } 492 if (yyerrflag != 0) goto yyinrecovery; 493 494 YYERROR_CALL("syntax error"); 495 496 goto yyerrlab; /* redundant goto avoids 'unused label' warning */ 497 yyerrlab: 498 ++yynerrs; 499 500 yyinrecovery: 501 if (yyerrflag < 3) 502 { 503 yyerrflag = 3; 504 for (;;) 505 { 506 if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && 507 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) 508 { 509 #if YYDEBUG 510 if (yydebug) 511 printf("%sdebug: state %d, error recovery shifting\ 512 to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); 513 #endif 514 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; 515 yystate = yytable[yyn]; 516 *++yystack.s_mark = yytable[yyn]; 517 *++yystack.l_mark = yylval; 518 goto yyloop; 519 } 520 else 521 { 522 #if YYDEBUG 523 if (yydebug) 524 printf("%sdebug: error recovery discarding state %d\n", 525 YYPREFIX, *yystack.s_mark); 526 #endif 527 if (yystack.s_mark <= yystack.s_base) goto yyabort; 528 --yystack.s_mark; 529 --yystack.l_mark; 530 } 531 } 532 } 533 else 534 { 535 if (yychar == YYEOF) goto yyabort; 536 #if YYDEBUG 537 if (yydebug) 538 { 539 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; 540 printf("%sdebug: state %d, error recovery discards token %d (%s)\n", 541 YYPREFIX, yystate, yychar, yys); 542 } 543 #endif 544 yychar = YYEMPTY; 545 goto yyloop; 546 } 547 548 yyreduce: 549 #if YYDEBUG 550 if (yydebug) 551 printf("%sdebug: state %d, reducing by rule %d (%s)\n", 552 YYPREFIX, yystate, yyn, yyrule[yyn]); 553 #endif 554 yym = yylen[yyn]; 555 if (yym > 0) 556 yyval = yystack.l_mark[1-yym]; 557 else 558 memset(&yyval, 0, sizeof yyval); 559 560 switch (yyn) 561 { 562 case 3: 563 #line 31 "calc_code_top.y" 564 { yyerrok ; } 565 #line 566 "calc_code_top.tab.c" 566 break; 567 case 4: 568 #line 35 "calc_code_top.y" 569 { printf("%d\n",yystack.l_mark[0]);} 570 #line 571 "calc_code_top.tab.c" 571 break; 572 case 5: 573 #line 37 "calc_code_top.y" 574 { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; } 575 #line 576 "calc_code_top.tab.c" 576 break; 577 case 6: 578 #line 41 "calc_code_top.y" 579 { yyval = yystack.l_mark[-1]; } 580 #line 581 "calc_code_top.tab.c" 581 break; 582 case 7: 583 #line 43 "calc_code_top.y" 584 { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; } 585 #line 586 "calc_code_top.tab.c" 586 break; 587 case 8: 588 #line 45 "calc_code_top.y" 589 { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; } 590 #line 591 "calc_code_top.tab.c" 591 break; 592 case 9: 593 #line 47 "calc_code_top.y" 594 { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; } 595 #line 596 "calc_code_top.tab.c" 596 break; 597 case 10: 598 #line 49 "calc_code_top.y" 599 { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; } 600 #line 601 "calc_code_top.tab.c" 601 break; 602 case 11: 603 #line 51 "calc_code_top.y" 604 { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; } 605 #line 606 "calc_code_top.tab.c" 606 break; 607 case 12: 608 #line 53 "calc_code_top.y" 609 { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; } 610 #line 611 "calc_code_top.tab.c" 611 break; 612 case 13: 613 #line 55 "calc_code_top.y" 614 { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; } 615 #line 616 "calc_code_top.tab.c" 616 break; 617 case 14: 618 #line 57 "calc_code_top.y" 619 { yyval = - yystack.l_mark[0]; } 620 #line 621 "calc_code_top.tab.c" 621 break; 622 case 15: 623 #line 59 "calc_code_top.y" 624 { yyval = regs[yystack.l_mark[0]]; } 625 #line 626 "calc_code_top.tab.c" 626 break; 627 case 17: 628 #line 64 "calc_code_top.y" 629 { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; } 630 #line 631 "calc_code_top.tab.c" 631 break; 632 case 18: 633 #line 66 "calc_code_top.y" 634 { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; } 635 #line 636 "calc_code_top.tab.c" 636 break; 637 #line 638 "calc_code_top.tab.c" 638 } 639 yystack.s_mark -= yym; 640 yystate = *yystack.s_mark; 641 yystack.l_mark -= yym; 642 yym = yylhs[yyn]; 643 if (yystate == 0 && yym == 0) 644 { 645 #if YYDEBUG 646 if (yydebug) 647 printf("%sdebug: after reduction, shifting from state 0 to\ 648 state %d\n", YYPREFIX, YYFINAL); 649 #endif 650 yystate = YYFINAL; 651 *++yystack.s_mark = YYFINAL; 652 *++yystack.l_mark = yyval; 653 if (yychar < 0) 654 { 655 yychar = YYLEX; 656 if (yychar < 0) yychar = YYEOF; 657 #if YYDEBUG 658 if (yydebug) 659 { 660 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; 661 printf("%sdebug: state %d, reading %d (%s)\n", 662 YYPREFIX, YYFINAL, yychar, yys); 663 } 664 #endif 665 } 666 if (yychar == YYEOF) goto yyaccept; 667 goto yyloop; 668 } 669 if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && 670 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) 671 yystate = yytable[yyn]; 672 else 673 yystate = yydgoto[yym]; 674 #if YYDEBUG 675 if (yydebug) 676 printf("%sdebug: after reduction, shifting from state %d \ 677 to state %d\n", YYPREFIX, *yystack.s_mark, yystate); 678 #endif 679 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; 680 *++yystack.s_mark = (YYINT) yystate; 681 *++yystack.l_mark = yyval; 682 goto yyloop; 683 684 yyoverflow: 685 YYERROR_CALL("yacc stack overflow"); 686 687 yyabort: 688 yyfreestack(&yystack); 689 return (1); 690 691 yyaccept: 692 yyfreestack(&yystack); 693 return (0); 694 } 695