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 2 7 #define YYMINOR 0 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 int 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 #if YYDEBUG 372 int yydebug; 373 #endif 374 375 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 376 #ifndef YYLLOC_DEFAULT 377 #define YYLLOC_DEFAULT(loc, rhs, n) \ 378 do \ 379 { \ 380 if (n == 0) \ 381 { \ 382 (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ 383 (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ 384 (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ 385 (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ 386 } \ 387 else \ 388 { \ 389 (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ 390 (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ 391 (loc).last_line = YYRHSLOC(rhs, n).last_line; \ 392 (loc).last_column = YYRHSLOC(rhs, n).last_column; \ 393 } \ 394 } while (0) 395 #endif /* YYLLOC_DEFAULT */ 396 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ 397 #if YYBTYACC 398 399 #ifndef YYLVQUEUEGROWTH 400 #define YYLVQUEUEGROWTH 32 401 #endif 402 #endif /* YYBTYACC */ 403 404 /* define the initial stack-sizes */ 405 #ifdef YYSTACKSIZE 406 #undef YYMAXDEPTH 407 #define YYMAXDEPTH YYSTACKSIZE 408 #else 409 #ifdef YYMAXDEPTH 410 #define YYSTACKSIZE YYMAXDEPTH 411 #else 412 #define YYSTACKSIZE 10000 413 #define YYMAXDEPTH 10000 414 #endif 415 #endif 416 417 #ifndef YYINITSTACKSIZE 418 #define YYINITSTACKSIZE 200 419 #endif 420 421 typedef struct { 422 unsigned stacksize; 423 YYINT *s_base; 424 YYINT *s_mark; 425 YYINT *s_last; 426 YYSTYPE *l_base; 427 YYSTYPE *l_mark; 428 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 429 YYLTYPE *p_base; 430 YYLTYPE *p_mark; 431 #endif 432 } YYSTACKDATA; 433 #if YYBTYACC 434 435 struct YYParseState_s 436 { 437 struct YYParseState_s *save; /* Previously saved parser state */ 438 YYSTACKDATA yystack; /* saved parser stack */ 439 int state; /* saved parser state */ 440 int errflag; /* saved error recovery status */ 441 int lexeme; /* saved index of the conflict lexeme in the lexical queue */ 442 YYINT ctry; /* saved index in yyctable[] for this conflict */ 443 }; 444 typedef struct YYParseState_s YYParseState; 445 #endif /* YYBTYACC */ 446 #line 104 "ok_syntax1.y" 447 /* start of programs */ 448 449 #ifdef YYBYACC 450 extern int YYLEX_DECL(); 451 #endif 452 453 int 454 main (void) 455 { 456 int regs[26]; 457 int base = 10; 458 459 while(!feof(stdin)) { 460 yyparse(regs, &base); 461 } 462 return 0; 463 } 464 465 #define UNUSED(x) ((void)(x)) 466 467 static void 468 YYERROR_DECL() 469 { 470 UNUSED(regs); /* %parse-param regs is not actually used here */ 471 UNUSED(base); /* %parse-param base is not actually used here */ 472 fprintf(stderr, "%s\n", s); 473 } 474 475 int 476 YYLEX_DECL() 477 { 478 /* lexical analysis routine */ 479 /* returns LETTER for a lower case letter, yylval = 0 through 25 */ 480 /* return DIGIT for a digit, yylval = 0 through 9 */ 481 /* all other characters are returned immediately */ 482 483 int c; 484 485 while( (c=getchar()) == ' ' ) { /* skip blanks */ } 486 487 /* c is now nonblank */ 488 489 if( islower( c )) { 490 yylval->ival = (c - 'a'); 491 return ( LETTER ); 492 } 493 if( isdigit( c )) { 494 yylval->ival = (c - '0') % (*base); 495 return ( DIGIT ); 496 } 497 return( c ); 498 } 499 #line 500 "ok_syntax1.tab.c" 500 501 /* For use in generated program */ 502 #define yydepth (int)(yystack.s_mark - yystack.s_base) 503 #if YYBTYACC 504 #define yytrial (yyps->save) 505 #endif /* YYBTYACC */ 506 507 #if YYDEBUG 508 #include <stdio.h> /* needed for printf */ 509 #endif 510 511 #include <stdlib.h> /* needed for malloc, etc */ 512 #include <string.h> /* needed for memset */ 513 514 /* allocate initial stack or double stack size, up to YYMAXDEPTH */ 515 static int yygrowstack(YYSTACKDATA *data) 516 { 517 int i; 518 unsigned newsize; 519 YYINT *newss; 520 YYSTYPE *newvs; 521 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 522 YYLTYPE *newps; 523 #endif 524 525 if ((newsize = data->stacksize) == 0) 526 newsize = YYINITSTACKSIZE; 527 else if (newsize >= YYMAXDEPTH) 528 return YYENOMEM; 529 else if ((newsize *= 2) > YYMAXDEPTH) 530 newsize = YYMAXDEPTH; 531 532 i = (int) (data->s_mark - data->s_base); 533 newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); 534 if (newss == NULL) 535 return YYENOMEM; 536 537 data->s_base = newss; 538 data->s_mark = newss + i; 539 540 newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); 541 if (newvs == NULL) 542 return YYENOMEM; 543 544 data->l_base = newvs; 545 data->l_mark = newvs + i; 546 547 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 548 newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); 549 if (newps == NULL) 550 return YYENOMEM; 551 552 data->p_base = newps; 553 data->p_mark = newps + i; 554 #endif 555 556 data->stacksize = newsize; 557 data->s_last = data->s_base + newsize - 1; 558 559 #if YYDEBUG 560 if (yydebug) 561 fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); 562 #endif 563 return 0; 564 } 565 566 #if YYPURE || defined(YY_NO_LEAKS) 567 static void yyfreestack(YYSTACKDATA *data) 568 { 569 free(data->s_base); 570 free(data->l_base); 571 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 572 free(data->p_base); 573 #endif 574 memset(data, 0, sizeof(*data)); 575 } 576 #else 577 #define yyfreestack(data) /* nothing */ 578 #endif /* YYPURE || defined(YY_NO_LEAKS) */ 579 #if YYBTYACC 580 581 static YYParseState * 582 yyNewState(unsigned size) 583 { 584 YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); 585 if (p == NULL) return NULL; 586 587 p->yystack.stacksize = size; 588 if (size == 0) 589 { 590 p->yystack.s_base = NULL; 591 p->yystack.l_base = NULL; 592 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 593 p->yystack.p_base = NULL; 594 #endif 595 return p; 596 } 597 p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); 598 if (p->yystack.s_base == NULL) return NULL; 599 p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); 600 if (p->yystack.l_base == NULL) return NULL; 601 memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); 602 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 603 p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); 604 if (p->yystack.p_base == NULL) return NULL; 605 memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); 606 #endif 607 608 return p; 609 } 610 611 static void 612 yyFreeState(YYParseState *p) 613 { 614 yyfreestack(&p->yystack); 615 free(p); 616 } 617 #endif /* YYBTYACC */ 618 619 #define YYABORT goto yyabort 620 #define YYREJECT goto yyabort 621 #define YYACCEPT goto yyaccept 622 #define YYERROR goto yyerrlab 623 #if YYBTYACC 624 #define YYVALID do { if (yyps->save) goto yyvalid; } while(0) 625 #define YYVALID_NESTED do { if (yyps->save && \ 626 yyps->save->save == 0) goto yyvalid; } while(0) 627 #endif /* YYBTYACC */ 628 629 int 630 YYPARSE_DECL() 631 { 632 int yyerrflag; 633 int yychar; 634 YYSTYPE yyval; 635 YYSTYPE yylval; 636 int yynerrs; 637 638 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 639 YYLTYPE yyloc; /* position returned by actions */ 640 YYLTYPE yylloc; /* position from the lexer */ 641 #endif 642 643 /* variables for the parser stack */ 644 YYSTACKDATA yystack; 645 #if YYBTYACC 646 647 /* Current parser state */ 648 static YYParseState *yyps = 0; 649 650 /* yypath != NULL: do the full parse, starting at *yypath parser state. */ 651 static YYParseState *yypath = 0; 652 653 /* Base of the lexical value queue */ 654 static YYSTYPE *yylvals = 0; 655 656 /* Current position at lexical value queue */ 657 static YYSTYPE *yylvp = 0; 658 659 /* End position of lexical value queue */ 660 static YYSTYPE *yylve = 0; 661 662 /* The last allocated position at the lexical value queue */ 663 static YYSTYPE *yylvlim = 0; 664 665 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 666 /* Base of the lexical position queue */ 667 static YYLTYPE *yylpsns = 0; 668 669 /* Current position at lexical position queue */ 670 static YYLTYPE *yylpp = 0; 671 672 /* End position of lexical position queue */ 673 static YYLTYPE *yylpe = 0; 674 675 /* The last allocated position at the lexical position queue */ 676 static YYLTYPE *yylplim = 0; 677 #endif 678 679 /* Current position at lexical token queue */ 680 static YYINT *yylexp = 0; 681 682 static YYINT *yylexemes = 0; 683 #endif /* YYBTYACC */ 684 int yym, yyn, yystate, yyresult; 685 #if YYBTYACC 686 int yynewerrflag; 687 YYParseState *yyerrctx = NULL; 688 #endif /* YYBTYACC */ 689 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 690 YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ 691 #endif 692 #if YYDEBUG 693 const char *yys; 694 695 if ((yys = getenv("YYDEBUG")) != NULL) 696 { 697 yyn = *yys; 698 if (yyn >= '0' && yyn <= '9') 699 yydebug = yyn - '0'; 700 } 701 if (yydebug) 702 fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); 703 #endif 704 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 705 memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); 706 #endif 707 708 yyerrflag = 0; 709 yychar = 0; 710 memset(&yyval, 0, sizeof(yyval)); 711 memset(&yylval, 0, sizeof(yylval)); 712 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 713 memset(&yyloc, 0, sizeof(yyloc)); 714 memset(&yylloc, 0, sizeof(yylloc)); 715 #endif 716 717 #if YYBTYACC 718 yyps = yyNewState(0); if (yyps == 0) goto yyenomem; 719 yyps->save = 0; 720 #endif /* YYBTYACC */ 721 yym = 0; 722 /* yyn is set below */ 723 yynerrs = 0; 724 yyerrflag = 0; 725 yychar = YYEMPTY; 726 yystate = 0; 727 728 #if YYPURE 729 memset(&yystack, 0, sizeof(yystack)); 730 #endif 731 732 if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; 733 yystack.s_mark = yystack.s_base; 734 yystack.l_mark = yystack.l_base; 735 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 736 yystack.p_mark = yystack.p_base; 737 #endif 738 yystate = 0; 739 *yystack.s_mark = 0; 740 741 yyloop: 742 if ((yyn = yydefred[yystate]) != 0) goto yyreduce; 743 if (yychar < 0) 744 { 745 #if YYBTYACC 746 do { 747 if (yylvp < yylve) 748 { 749 /* we're currently re-reading tokens */ 750 yylval = *yylvp++; 751 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 752 yylloc = *yylpp++; 753 #endif 754 yychar = *yylexp++; 755 break; 756 } 757 if (yyps->save) 758 { 759 /* in trial mode; save scanner results for future parse attempts */ 760 if (yylvp == yylvlim) 761 { /* Enlarge lexical value queue */ 762 size_t p = (size_t) (yylvp - yylvals); 763 size_t s = (size_t) (yylvlim - yylvals); 764 765 s += YYLVQUEUEGROWTH; 766 if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; 767 if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; 768 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 769 if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; 770 #endif 771 yylvp = yylve = yylvals + p; 772 yylvlim = yylvals + s; 773 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 774 yylpp = yylpe = yylpsns + p; 775 yylplim = yylpsns + s; 776 #endif 777 yylexp = yylexemes + p; 778 } 779 *yylexp = (YYINT) YYLEX; 780 *yylvp++ = yylval; 781 yylve++; 782 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 783 *yylpp++ = yylloc; 784 yylpe++; 785 #endif 786 yychar = *yylexp++; 787 break; 788 } 789 /* normal operation, no conflict encountered */ 790 #endif /* YYBTYACC */ 791 yychar = YYLEX; 792 #if YYBTYACC 793 } while (0); 794 #endif /* YYBTYACC */ 795 if (yychar < 0) yychar = YYEOF; 796 #if YYDEBUG 797 if (yydebug) 798 { 799 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; 800 fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", 801 YYDEBUGSTR, yydepth, yystate, yychar, yys); 802 #ifdef YYSTYPE_TOSTRING 803 #if YYBTYACC 804 if (!yytrial) 805 #endif /* YYBTYACC */ 806 fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); 807 #endif 808 fputc('\n', stderr); 809 } 810 #endif 811 } 812 #if YYBTYACC 813 814 /* Do we have a conflict? */ 815 if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && 816 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) 817 { 818 YYINT ctry; 819 820 if (yypath) 821 { 822 YYParseState *save; 823 #if YYDEBUG 824 if (yydebug) 825 fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", 826 YYDEBUGSTR, yydepth, yystate); 827 #endif 828 /* Switch to the next conflict context */ 829 save = yypath; 830 yypath = save->save; 831 save->save = NULL; 832 ctry = save->ctry; 833 if (save->state != yystate) YYABORT; 834 yyFreeState(save); 835 836 } 837 else 838 { 839 840 /* Unresolved conflict - start/continue trial parse */ 841 YYParseState *save; 842 #if YYDEBUG 843 if (yydebug) 844 { 845 fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); 846 if (yyps->save) 847 fputs("ALREADY in conflict, continuing trial parse.\n", stderr); 848 else 849 fputs("Starting trial parse.\n", stderr); 850 } 851 #endif 852 save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); 853 if (save == NULL) goto yyenomem; 854 save->save = yyps->save; 855 save->state = yystate; 856 save->errflag = yyerrflag; 857 save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); 858 memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); 859 save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); 860 memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); 861 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 862 save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); 863 memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); 864 #endif 865 ctry = yytable[yyn]; 866 if (yyctable[ctry] == -1) 867 { 868 #if YYDEBUG 869 if (yydebug && yychar >= YYEOF) 870 fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); 871 #endif 872 ctry++; 873 } 874 save->ctry = ctry; 875 if (yyps->save == NULL) 876 { 877 /* If this is a first conflict in the stack, start saving lexemes */ 878 if (!yylexemes) 879 { 880 yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); 881 if (yylexemes == NULL) goto yyenomem; 882 yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); 883 if (yylvals == NULL) goto yyenomem; 884 yylvlim = yylvals + YYLVQUEUEGROWTH; 885 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 886 yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); 887 if (yylpsns == NULL) goto yyenomem; 888 yylplim = yylpsns + YYLVQUEUEGROWTH; 889 #endif 890 } 891 if (yylvp == yylve) 892 { 893 yylvp = yylve = yylvals; 894 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 895 yylpp = yylpe = yylpsns; 896 #endif 897 yylexp = yylexemes; 898 if (yychar >= YYEOF) 899 { 900 *yylve++ = yylval; 901 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 902 *yylpe++ = yylloc; 903 #endif 904 *yylexp = (YYINT) yychar; 905 yychar = YYEMPTY; 906 } 907 } 908 } 909 if (yychar >= YYEOF) 910 { 911 yylvp--; 912 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 913 yylpp--; 914 #endif 915 yylexp--; 916 yychar = YYEMPTY; 917 } 918 save->lexeme = (int) (yylvp - yylvals); 919 yyps->save = save; 920 } 921 if (yytable[yyn] == ctry) 922 { 923 #if YYDEBUG 924 if (yydebug) 925 fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", 926 YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); 927 #endif 928 if (yychar < 0) 929 { 930 yylvp++; 931 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 932 yylpp++; 933 #endif 934 yylexp++; 935 } 936 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) 937 goto yyoverflow; 938 yystate = yyctable[ctry]; 939 *++yystack.s_mark = (YYINT) yystate; 940 *++yystack.l_mark = yylval; 941 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 942 *++yystack.p_mark = yylloc; 943 #endif 944 yychar = YYEMPTY; 945 if (yyerrflag > 0) --yyerrflag; 946 goto yyloop; 947 } 948 else 949 { 950 yyn = yyctable[ctry]; 951 goto yyreduce; 952 } 953 } /* End of code dealing with conflicts */ 954 #endif /* YYBTYACC */ 955 if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && 956 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) 957 { 958 #if YYDEBUG 959 if (yydebug) 960 fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", 961 YYDEBUGSTR, yydepth, yystate, yytable[yyn]); 962 #endif 963 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; 964 yystate = yytable[yyn]; 965 *++yystack.s_mark = yytable[yyn]; 966 *++yystack.l_mark = yylval; 967 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 968 *++yystack.p_mark = yylloc; 969 #endif 970 yychar = YYEMPTY; 971 if (yyerrflag > 0) --yyerrflag; 972 goto yyloop; 973 } 974 if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && 975 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) 976 { 977 yyn = yytable[yyn]; 978 goto yyreduce; 979 } 980 if (yyerrflag != 0) goto yyinrecovery; 981 #if YYBTYACC 982 983 yynewerrflag = 1; 984 goto yyerrhandler; 985 goto yyerrlab; /* redundant goto avoids 'unused label' warning */ 986 987 yyerrlab: 988 /* explicit YYERROR from an action -- pop the rhs of the rule reduced 989 * before looking for error recovery */ 990 yystack.s_mark -= yym; 991 yystate = *yystack.s_mark; 992 yystack.l_mark -= yym; 993 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 994 yystack.p_mark -= yym; 995 #endif 996 997 yynewerrflag = 0; 998 yyerrhandler: 999 while (yyps->save) 1000 { 1001 int ctry; 1002 YYParseState *save = yyps->save; 1003 #if YYDEBUG 1004 if (yydebug) 1005 fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", 1006 YYDEBUGSTR, yydepth, yystate, yyps->save->state, 1007 (int)(yylvp - yylvals - yyps->save->lexeme)); 1008 #endif 1009 /* Memorize most forward-looking error state in case it's really an error. */ 1010 if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) 1011 { 1012 /* Free old saved error context state */ 1013 if (yyerrctx) yyFreeState(yyerrctx); 1014 /* Create and fill out new saved error context state */ 1015 yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); 1016 if (yyerrctx == NULL) goto yyenomem; 1017 yyerrctx->save = yyps->save; 1018 yyerrctx->state = yystate; 1019 yyerrctx->errflag = yyerrflag; 1020 yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); 1021 memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); 1022 yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); 1023 memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); 1024 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1025 yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); 1026 memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); 1027 #endif 1028 yyerrctx->lexeme = (int) (yylvp - yylvals); 1029 } 1030 yylvp = yylvals + save->lexeme; 1031 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1032 yylpp = yylpsns + save->lexeme; 1033 #endif 1034 yylexp = yylexemes + save->lexeme; 1035 yychar = YYEMPTY; 1036 yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); 1037 memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); 1038 yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); 1039 memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); 1040 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1041 yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); 1042 memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); 1043 #endif 1044 ctry = ++save->ctry; 1045 yystate = save->state; 1046 /* We tried shift, try reduce now */ 1047 if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; 1048 yyps->save = save->save; 1049 save->save = NULL; 1050 yyFreeState(save); 1051 1052 /* Nothing left on the stack -- error */ 1053 if (!yyps->save) 1054 { 1055 #if YYDEBUG 1056 if (yydebug) 1057 fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", 1058 YYPREFIX, yydepth); 1059 #endif 1060 /* Restore state as it was in the most forward-advanced error */ 1061 yylvp = yylvals + yyerrctx->lexeme; 1062 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1063 yylpp = yylpsns + yyerrctx->lexeme; 1064 #endif 1065 yylexp = yylexemes + yyerrctx->lexeme; 1066 yychar = yylexp[-1]; 1067 yylval = yylvp[-1]; 1068 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1069 yylloc = yylpp[-1]; 1070 #endif 1071 yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); 1072 memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); 1073 yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); 1074 memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); 1075 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1076 yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); 1077 memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); 1078 #endif 1079 yystate = yyerrctx->state; 1080 yyFreeState(yyerrctx); 1081 yyerrctx = NULL; 1082 } 1083 yynewerrflag = 1; 1084 } 1085 if (yynewerrflag == 0) goto yyinrecovery; 1086 #endif /* YYBTYACC */ 1087 1088 YYERROR_CALL("syntax error"); 1089 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1090 yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ 1091 #endif 1092 1093 #if !YYBTYACC 1094 goto yyerrlab; /* redundant goto avoids 'unused label' warning */ 1095 yyerrlab: 1096 #endif 1097 ++yynerrs; 1098 1099 yyinrecovery: 1100 if (yyerrflag < 3) 1101 { 1102 yyerrflag = 3; 1103 for (;;) 1104 { 1105 if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && 1106 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) 1107 { 1108 #if YYDEBUG 1109 if (yydebug) 1110 fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", 1111 YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); 1112 #endif 1113 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; 1114 yystate = yytable[yyn]; 1115 *++yystack.s_mark = yytable[yyn]; 1116 *++yystack.l_mark = yylval; 1117 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1118 /* lookahead position is error end position */ 1119 yyerror_loc_range[2] = yylloc; 1120 YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ 1121 *++yystack.p_mark = yyloc; 1122 #endif 1123 goto yyloop; 1124 } 1125 else 1126 { 1127 #if YYDEBUG 1128 if (yydebug) 1129 fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", 1130 YYDEBUGSTR, yydepth, *yystack.s_mark); 1131 #endif 1132 if (yystack.s_mark <= yystack.s_base) goto yyabort; 1133 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1134 /* the current TOS position is the error start position */ 1135 yyerror_loc_range[1] = *yystack.p_mark; 1136 #endif 1137 #if defined(YYDESTRUCT_CALL) 1138 #if YYBTYACC 1139 if (!yytrial) 1140 #endif /* YYBTYACC */ 1141 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1142 YYDESTRUCT_CALL("error: discarding state", 1143 yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); 1144 #else 1145 YYDESTRUCT_CALL("error: discarding state", 1146 yystos[*yystack.s_mark], yystack.l_mark); 1147 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ 1148 #endif /* defined(YYDESTRUCT_CALL) */ 1149 --yystack.s_mark; 1150 --yystack.l_mark; 1151 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1152 --yystack.p_mark; 1153 #endif 1154 } 1155 } 1156 } 1157 else 1158 { 1159 if (yychar == YYEOF) goto yyabort; 1160 #if YYDEBUG 1161 if (yydebug) 1162 { 1163 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; 1164 fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", 1165 YYDEBUGSTR, yydepth, yystate, yychar, yys); 1166 } 1167 #endif 1168 #if defined(YYDESTRUCT_CALL) 1169 #if YYBTYACC 1170 if (!yytrial) 1171 #endif /* YYBTYACC */ 1172 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1173 YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); 1174 #else 1175 YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); 1176 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ 1177 #endif /* defined(YYDESTRUCT_CALL) */ 1178 yychar = YYEMPTY; 1179 goto yyloop; 1180 } 1181 1182 yyreduce: 1183 yym = yylen[yyn]; 1184 #if YYDEBUG 1185 if (yydebug) 1186 { 1187 fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", 1188 YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); 1189 #ifdef YYSTYPE_TOSTRING 1190 #if YYBTYACC 1191 if (!yytrial) 1192 #endif /* YYBTYACC */ 1193 if (yym > 0) 1194 { 1195 int i; 1196 fputc('<', stderr); 1197 for (i = yym; i > 0; i--) 1198 { 1199 if (i != yym) fputs(", ", stderr); 1200 fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], 1201 yystack.l_mark[1-i]), stderr); 1202 } 1203 fputc('>', stderr); 1204 } 1205 #endif 1206 fputc('\n', stderr); 1207 } 1208 #endif 1209 if (yym > 0) 1210 yyval = yystack.l_mark[1-yym]; 1211 else 1212 memset(&yyval, 0, sizeof yyval); 1213 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1214 1215 /* Perform position reduction */ 1216 memset(&yyloc, 0, sizeof(yyloc)); 1217 #if YYBTYACC 1218 if (!yytrial) 1219 #endif /* YYBTYACC */ 1220 { 1221 YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); 1222 /* just in case YYERROR is invoked within the action, save 1223 the start of the rhs as the error start position */ 1224 yyerror_loc_range[1] = yystack.p_mark[1-yym]; 1225 } 1226 #endif 1227 1228 switch (yyn) 1229 { 1230 case 3: 1231 #line 66 "ok_syntax1.y" 1232 { yyerrok ; } 1233 #line 1234 "ok_syntax1.tab.c" 1234 break; 1235 case 4: 1236 #line 70 "ok_syntax1.y" 1237 { printf("%d\n",yystack.l_mark[0].ival);} 1238 #line 1239 "ok_syntax1.tab.c" 1239 break; 1240 case 5: 1241 #line 72 "ok_syntax1.y" 1242 { regs[yystack.l_mark[-2].ival] = yystack.l_mark[0].ival; } 1243 #line 1244 "ok_syntax1.tab.c" 1244 break; 1245 case 6: 1246 #line 76 "ok_syntax1.y" 1247 { yyval.ival = yystack.l_mark[-1].ival; } 1248 #line 1249 "ok_syntax1.tab.c" 1249 break; 1250 case 7: 1251 #line 78 "ok_syntax1.y" 1252 { yyval.ival = yystack.l_mark[-2].ival + yystack.l_mark[0].ival; } 1253 #line 1254 "ok_syntax1.tab.c" 1254 break; 1255 case 8: 1256 #line 80 "ok_syntax1.y" 1257 { yyval.ival = yystack.l_mark[-2].ival - yystack.l_mark[0].ival; } 1258 #line 1259 "ok_syntax1.tab.c" 1259 break; 1260 case 9: 1261 #line 82 "ok_syntax1.y" 1262 { yyval.ival = yystack.l_mark[-2].ival * yystack.l_mark[0].ival; } 1263 #line 1264 "ok_syntax1.tab.c" 1264 break; 1265 case 10: 1266 #line 84 "ok_syntax1.y" 1267 { yyval.ival = yystack.l_mark[-2].ival / yystack.l_mark[0].ival; } 1268 #line 1269 "ok_syntax1.tab.c" 1269 break; 1270 case 11: 1271 #line 86 "ok_syntax1.y" 1272 { yyval.ival = yystack.l_mark[-2].ival % yystack.l_mark[0].ival; } 1273 #line 1274 "ok_syntax1.tab.c" 1274 break; 1275 case 12: 1276 #line 88 "ok_syntax1.y" 1277 { yyval.ival = yystack.l_mark[-2].ival & yystack.l_mark[0].ival; } 1278 #line 1279 "ok_syntax1.tab.c" 1279 break; 1280 case 13: 1281 #line 90 "ok_syntax1.y" 1282 { yyval.ival = yystack.l_mark[-2].ival | yystack.l_mark[0].ival; } 1283 #line 1284 "ok_syntax1.tab.c" 1284 break; 1285 case 14: 1286 #line 92 "ok_syntax1.y" 1287 { yyval.ival = - yystack.l_mark[0].ival; } 1288 #line 1289 "ok_syntax1.tab.c" 1289 break; 1290 case 15: 1291 #line 94 "ok_syntax1.y" 1292 { yyval.ival = regs[yystack.l_mark[0].ival]; } 1293 #line 1294 "ok_syntax1.tab.c" 1294 break; 1295 case 17: 1296 #line 99 "ok_syntax1.y" 1297 { yyval.ival = yystack.l_mark[0].ival; (*base) = (yystack.l_mark[0].ival==0) ? 8 : 10; } 1298 #line 1299 "ok_syntax1.tab.c" 1299 break; 1300 case 18: 1301 #line 101 "ok_syntax1.y" 1302 { yyval.ival = (*base) * yystack.l_mark[-1].ival + yystack.l_mark[0].ival; } 1303 #line 1304 "ok_syntax1.tab.c" 1304 break; 1305 #line 1306 "ok_syntax1.tab.c" 1306 default: 1307 break; 1308 } 1309 yystack.s_mark -= yym; 1310 yystate = *yystack.s_mark; 1311 yystack.l_mark -= yym; 1312 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1313 yystack.p_mark -= yym; 1314 #endif 1315 yym = yylhs[yyn]; 1316 if (yystate == 0 && yym == 0) 1317 { 1318 #if YYDEBUG 1319 if (yydebug) 1320 { 1321 fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); 1322 #ifdef YYSTYPE_TOSTRING 1323 #if YYBTYACC 1324 if (!yytrial) 1325 #endif /* YYBTYACC */ 1326 fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval)); 1327 #endif 1328 fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL); 1329 } 1330 #endif 1331 yystate = YYFINAL; 1332 *++yystack.s_mark = YYFINAL; 1333 *++yystack.l_mark = yyval; 1334 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1335 *++yystack.p_mark = yyloc; 1336 #endif 1337 if (yychar < 0) 1338 { 1339 #if YYBTYACC 1340 do { 1341 if (yylvp < yylve) 1342 { 1343 /* we're currently re-reading tokens */ 1344 yylval = *yylvp++; 1345 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1346 yylloc = *yylpp++; 1347 #endif 1348 yychar = *yylexp++; 1349 break; 1350 } 1351 if (yyps->save) 1352 { 1353 /* in trial mode; save scanner results for future parse attempts */ 1354 if (yylvp == yylvlim) 1355 { /* Enlarge lexical value queue */ 1356 size_t p = (size_t) (yylvp - yylvals); 1357 size_t s = (size_t) (yylvlim - yylvals); 1358 1359 s += YYLVQUEUEGROWTH; 1360 if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) 1361 goto yyenomem; 1362 if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) 1363 goto yyenomem; 1364 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1365 if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) 1366 goto yyenomem; 1367 #endif 1368 yylvp = yylve = yylvals + p; 1369 yylvlim = yylvals + s; 1370 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1371 yylpp = yylpe = yylpsns + p; 1372 yylplim = yylpsns + s; 1373 #endif 1374 yylexp = yylexemes + p; 1375 } 1376 *yylexp = (YYINT) YYLEX; 1377 *yylvp++ = yylval; 1378 yylve++; 1379 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1380 *yylpp++ = yylloc; 1381 yylpe++; 1382 #endif 1383 yychar = *yylexp++; 1384 break; 1385 } 1386 /* normal operation, no conflict encountered */ 1387 #endif /* YYBTYACC */ 1388 yychar = YYLEX; 1389 #if YYBTYACC 1390 } while (0); 1391 #endif /* YYBTYACC */ 1392 if (yychar < 0) yychar = YYEOF; 1393 #if YYDEBUG 1394 if (yydebug) 1395 { 1396 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; 1397 fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", 1398 YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); 1399 } 1400 #endif 1401 } 1402 if (yychar == YYEOF) goto yyaccept; 1403 goto yyloop; 1404 } 1405 if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && 1406 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) 1407 yystate = yytable[yyn]; 1408 else 1409 yystate = yydgoto[yym]; 1410 #if YYDEBUG 1411 if (yydebug) 1412 { 1413 fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); 1414 #ifdef YYSTYPE_TOSTRING 1415 #if YYBTYACC 1416 if (!yytrial) 1417 #endif /* YYBTYACC */ 1418 fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); 1419 #endif 1420 fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); 1421 } 1422 #endif 1423 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; 1424 *++yystack.s_mark = (YYINT) yystate; 1425 *++yystack.l_mark = yyval; 1426 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1427 *++yystack.p_mark = yyloc; 1428 #endif 1429 goto yyloop; 1430 #if YYBTYACC 1431 1432 /* Reduction declares that this path is valid. Set yypath and do a full parse */ 1433 yyvalid: 1434 if (yypath) YYABORT; 1435 while (yyps->save) 1436 { 1437 YYParseState *save = yyps->save; 1438 yyps->save = save->save; 1439 save->save = yypath; 1440 yypath = save; 1441 } 1442 #if YYDEBUG 1443 if (yydebug) 1444 fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", 1445 YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); 1446 #endif 1447 if (yyerrctx) 1448 { 1449 yyFreeState(yyerrctx); 1450 yyerrctx = NULL; 1451 } 1452 yylvp = yylvals + yypath->lexeme; 1453 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1454 yylpp = yylpsns + yypath->lexeme; 1455 #endif 1456 yylexp = yylexemes + yypath->lexeme; 1457 yychar = YYEMPTY; 1458 yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); 1459 memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); 1460 yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); 1461 memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); 1462 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1463 yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); 1464 memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); 1465 #endif 1466 yystate = yypath->state; 1467 goto yyloop; 1468 #endif /* YYBTYACC */ 1469 1470 yyoverflow: 1471 YYERROR_CALL("yacc stack overflow"); 1472 #if YYBTYACC 1473 goto yyabort_nomem; 1474 yyenomem: 1475 YYERROR_CALL("memory exhausted"); 1476 yyabort_nomem: 1477 #endif /* YYBTYACC */ 1478 yyresult = 2; 1479 goto yyreturn; 1480 1481 yyabort: 1482 yyresult = 1; 1483 goto yyreturn; 1484 1485 yyaccept: 1486 #if YYBTYACC 1487 if (yyps->save) goto yyvalid; 1488 #endif /* YYBTYACC */ 1489 yyresult = 0; 1490 1491 yyreturn: 1492 #if defined(YYDESTRUCT_CALL) 1493 if (yychar != YYEOF && yychar != YYEMPTY) 1494 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1495 YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); 1496 #else 1497 YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); 1498 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ 1499 1500 { 1501 YYSTYPE *pv; 1502 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1503 YYLTYPE *pp; 1504 1505 for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) 1506 YYDESTRUCT_CALL("cleanup: discarding state", 1507 yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); 1508 #else 1509 for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) 1510 YYDESTRUCT_CALL("cleanup: discarding state", 1511 yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); 1512 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ 1513 } 1514 #endif /* defined(YYDESTRUCT_CALL) */ 1515 1516 #if YYBTYACC 1517 if (yyerrctx) 1518 { 1519 yyFreeState(yyerrctx); 1520 yyerrctx = NULL; 1521 } 1522 while (yyps) 1523 { 1524 YYParseState *save = yyps; 1525 yyps = save->save; 1526 save->save = NULL; 1527 yyFreeState(save); 1528 } 1529 while (yypath) 1530 { 1531 YYParseState *save = yypath; 1532 yypath = save->save; 1533 save->save = NULL; 1534 yyFreeState(save); 1535 } 1536 #endif /* YYBTYACC */ 1537 yyfreestack(&yystack); 1538 return (yyresult); 1539 } 1540