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