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