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