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