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