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