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 17 #ifndef yyparse 18 #define yyparse error_parse 19 #endif /* yyparse */ 20 21 #ifndef yylex 22 #define yylex error_lex 23 #endif /* yylex */ 24 25 #ifndef yyerror 26 #define yyerror error_error 27 #endif /* yyerror */ 28 29 #ifndef yychar 30 #define yychar error_char 31 #endif /* yychar */ 32 33 #ifndef yyval 34 #define yyval error_val 35 #endif /* yyval */ 36 37 #ifndef yylval 38 #define yylval error_lval 39 #endif /* yylval */ 40 41 #ifndef yydebug 42 #define yydebug error_debug 43 #endif /* yydebug */ 44 45 #ifndef yynerrs 46 #define yynerrs error_nerrs 47 #endif /* yynerrs */ 48 49 #ifndef yyerrflag 50 #define yyerrflag error_errflag 51 #endif /* yyerrflag */ 52 53 #ifndef yylhs 54 #define yylhs error_lhs 55 #endif /* yylhs */ 56 57 #ifndef yylen 58 #define yylen error_len 59 #endif /* yylen */ 60 61 #ifndef yydefred 62 #define yydefred error_defred 63 #endif /* yydefred */ 64 65 #ifndef yydgoto 66 #define yydgoto error_dgoto 67 #endif /* yydgoto */ 68 69 #ifndef yysindex 70 #define yysindex error_sindex 71 #endif /* yysindex */ 72 73 #ifndef yyrindex 74 #define yyrindex error_rindex 75 #endif /* yyrindex */ 76 77 #ifndef yygindex 78 #define yygindex error_gindex 79 #endif /* yygindex */ 80 81 #ifndef yytable 82 #define yytable error_table 83 #endif /* yytable */ 84 85 #ifndef yycheck 86 #define yycheck error_check 87 #endif /* yycheck */ 88 89 #ifndef yyname 90 #define yyname error_name 91 #endif /* yyname */ 92 93 #ifndef yyrule 94 #define yyrule error_rule 95 #endif /* yyrule */ 96 #define YYPREFIX "error_" 97 98 #define YYPURE 1 99 100 #line 2 "pure_error.y" 101 102 #ifdef YYBISON 103 #define YYSTYPE int 104 #define YYLEX_PARAM &yylval 105 #define YYLEX_DECL() yylex(YYSTYPE *yylval) 106 #define YYERROR_DECL() yyerror(const char *s) 107 int YYLEX_DECL(); 108 static void YYERROR_DECL(); 109 #endif 110 111 #line 112 "pure_error.tab.c" 112 113 #if ! defined(YYSTYPE) && ! defined(YYSTYPE_IS_DECLARED) 114 /* Default: YYSTYPE is the semantic value type. */ 115 typedef int YYSTYPE; 116 # define YYSTYPE_IS_DECLARED 1 117 #endif 118 119 /* compatibility with bison */ 120 #ifdef YYPARSE_PARAM 121 /* compatibility with FreeBSD */ 122 # ifdef YYPARSE_PARAM_TYPE 123 # define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM) 124 # else 125 # define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM) 126 # endif 127 #else 128 # define YYPARSE_DECL() yyparse(void) 129 #endif 130 131 /* Parameters sent to lex. */ 132 #ifdef YYLEX_PARAM 133 # ifdef YYLEX_PARAM_TYPE 134 # define YYLEX_DECL() yylex(YYSTYPE *yylval, YYLEX_PARAM_TYPE YYLEX_PARAM) 135 # else 136 # define YYLEX_DECL() yylex(YYSTYPE *yylval, void * YYLEX_PARAM) 137 # endif 138 # define YYLEX yylex(&yylval, YYLEX_PARAM) 139 #else 140 # define YYLEX_DECL() yylex(YYSTYPE *yylval) 141 # define YYLEX yylex(&yylval) 142 #endif 143 144 /* Parameters sent to yyerror. */ 145 #ifndef YYERROR_DECL 146 #define YYERROR_DECL() yyerror(const char *s) 147 #endif 148 #ifndef YYERROR_CALL 149 #define YYERROR_CALL(msg) yyerror(msg) 150 #endif 151 152 extern int YYPARSE_DECL(); 153 154 #define YYERRCODE 256 155 typedef int YYINT; 156 static const YYINT error_lhs[] = { -1, 157 0, 158 }; 159 static const YYINT error_len[] = { 2, 160 1, 161 }; 162 static const YYINT error_defred[] = { 0, 163 1, 0, 164 }; 165 static const YYINT error_dgoto[] = { 2, 166 }; 167 static const YYINT error_sindex[] = { -256, 168 0, 0, 169 }; 170 static const YYINT error_rindex[] = { 0, 171 0, 0, 172 }; 173 static const YYINT error_gindex[] = { 0, 174 }; 175 #define YYTABLESIZE 0 176 static const YYINT error_table[] = { 1, 177 }; 178 static const YYINT error_check[] = { 256, 179 }; 180 #define YYFINAL 2 181 #ifndef YYDEBUG 182 #define YYDEBUG 0 183 #endif 184 #define YYMAXTOKEN 256 185 #define YYUNDFTOKEN 259 186 #define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) 187 #if YYDEBUG 188 static const char *const error_name[] = { 189 190 "end-of-file",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 191 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 192 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 193 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 194 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 195 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 196 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"illegal-symbol", 197 }; 198 static const char *const error_rule[] = { 199 "$accept : S", 200 "S : error", 201 202 }; 203 #endif 204 205 int yydebug; 206 int yynerrs; 207 208 /* define the initial stack-sizes */ 209 #ifdef YYSTACKSIZE 210 #undef YYMAXDEPTH 211 #define YYMAXDEPTH YYSTACKSIZE 212 #else 213 #ifdef YYMAXDEPTH 214 #define YYSTACKSIZE YYMAXDEPTH 215 #else 216 #define YYSTACKSIZE 10000 217 #define YYMAXDEPTH 10000 218 #endif 219 #endif 220 221 #define YYINITSTACKSIZE 200 222 223 typedef struct { 224 unsigned stacksize; 225 YYINT *s_base; 226 YYINT *s_mark; 227 YYINT *s_last; 228 YYSTYPE *l_base; 229 YYSTYPE *l_mark; 230 } YYSTACKDATA; 231 #line 17 "pure_error.y" 232 233 #include <stdio.h> 234 235 #ifdef YYBYACC 236 extern int YYLEX_DECL(); 237 #endif 238 239 int 240 main(void) 241 { 242 printf("yyparse() = %d\n", yyparse()); 243 return 0; 244 } 245 246 int 247 yylex(YYSTYPE *value) 248 { 249 return value ? 0 : -1; 250 } 251 252 static void 253 yyerror(const char* s) 254 { 255 printf("%s\n", s); 256 } 257 #line 258 "pure_error.tab.c" 258 259 #if YYDEBUG 260 #include <stdio.h> /* needed for printf */ 261 #endif 262 263 #include <stdlib.h> /* needed for malloc, etc */ 264 #include <string.h> /* needed for memset */ 265 266 /* allocate initial stack or double stack size, up to YYMAXDEPTH */ 267 static int yygrowstack(YYSTACKDATA *data) 268 { 269 int i; 270 unsigned newsize; 271 YYINT *newss; 272 YYSTYPE *newvs; 273 274 if ((newsize = data->stacksize) == 0) 275 newsize = YYINITSTACKSIZE; 276 else if (newsize >= YYMAXDEPTH) 277 return YYENOMEM; 278 else if ((newsize *= 2) > YYMAXDEPTH) 279 newsize = YYMAXDEPTH; 280 281 i = (int) (data->s_mark - data->s_base); 282 newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); 283 if (newss == 0) 284 return YYENOMEM; 285 286 data->s_base = newss; 287 data->s_mark = newss + i; 288 289 newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); 290 if (newvs == 0) 291 return YYENOMEM; 292 293 data->l_base = newvs; 294 data->l_mark = newvs + i; 295 296 data->stacksize = newsize; 297 data->s_last = data->s_base + newsize - 1; 298 return 0; 299 } 300 301 #if YYPURE || defined(YY_NO_LEAKS) 302 static void yyfreestack(YYSTACKDATA *data) 303 { 304 free(data->s_base); 305 free(data->l_base); 306 memset(data, 0, sizeof(*data)); 307 } 308 #else 309 #define yyfreestack(data) /* nothing */ 310 #endif 311 312 #define YYABORT goto yyabort 313 #define YYREJECT goto yyabort 314 #define YYACCEPT goto yyaccept 315 #define YYERROR goto yyerrlab 316 317 int 318 YYPARSE_DECL() 319 { 320 int yyerrflag; 321 int yychar; 322 YYSTYPE yyval; 323 YYSTYPE yylval; 324 325 /* variables for the parser stack */ 326 YYSTACKDATA yystack; 327 int yym, yyn, yystate; 328 #if YYDEBUG 329 const char *yys; 330 331 if ((yys = getenv("YYDEBUG")) != 0) 332 { 333 yyn = *yys; 334 if (yyn >= '0' && yyn <= '9') 335 yydebug = yyn - '0'; 336 } 337 #endif 338 339 memset(&yyval, 0, sizeof(yyval)); 340 memset(&yylval, 0, sizeof(yylval)); 341 342 yym = 0; 343 yyn = 0; 344 yynerrs = 0; 345 yyerrflag = 0; 346 yychar = YYEMPTY; 347 yystate = 0; 348 349 #if YYPURE 350 memset(&yystack, 0, sizeof(yystack)); 351 #endif 352 353 if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; 354 yystack.s_mark = yystack.s_base; 355 yystack.l_mark = yystack.l_base; 356 yystate = 0; 357 *yystack.s_mark = 0; 358 359 yyloop: 360 if ((yyn = yydefred[yystate]) != 0) goto yyreduce; 361 if (yychar < 0) 362 { 363 yychar = YYLEX; 364 if (yychar < 0) yychar = YYEOF; 365 #if YYDEBUG 366 if (yydebug) 367 { 368 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; 369 printf("%sdebug: state %d, reading %d (%s)\n", 370 YYPREFIX, yystate, yychar, yys); 371 } 372 #endif 373 } 374 if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && 375 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) 376 { 377 #if YYDEBUG 378 if (yydebug) 379 printf("%sdebug: state %d, shifting to state %d\n", 380 YYPREFIX, yystate, yytable[yyn]); 381 #endif 382 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; 383 yystate = yytable[yyn]; 384 *++yystack.s_mark = yytable[yyn]; 385 *++yystack.l_mark = yylval; 386 yychar = YYEMPTY; 387 if (yyerrflag > 0) --yyerrflag; 388 goto yyloop; 389 } 390 if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && 391 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) 392 { 393 yyn = yytable[yyn]; 394 goto yyreduce; 395 } 396 if (yyerrflag != 0) goto yyinrecovery; 397 398 YYERROR_CALL("syntax error"); 399 400 goto yyerrlab; /* redundant goto avoids 'unused label' warning */ 401 yyerrlab: 402 ++yynerrs; 403 404 yyinrecovery: 405 if (yyerrflag < 3) 406 { 407 yyerrflag = 3; 408 for (;;) 409 { 410 if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && 411 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) 412 { 413 #if YYDEBUG 414 if (yydebug) 415 printf("%sdebug: state %d, error recovery shifting\ 416 to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); 417 #endif 418 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; 419 yystate = yytable[yyn]; 420 *++yystack.s_mark = yytable[yyn]; 421 *++yystack.l_mark = yylval; 422 goto yyloop; 423 } 424 else 425 { 426 #if YYDEBUG 427 if (yydebug) 428 printf("%sdebug: error recovery discarding state %d\n", 429 YYPREFIX, *yystack.s_mark); 430 #endif 431 if (yystack.s_mark <= yystack.s_base) goto yyabort; 432 --yystack.s_mark; 433 --yystack.l_mark; 434 } 435 } 436 } 437 else 438 { 439 if (yychar == YYEOF) goto yyabort; 440 #if YYDEBUG 441 if (yydebug) 442 { 443 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; 444 printf("%sdebug: state %d, error recovery discards token %d (%s)\n", 445 YYPREFIX, yystate, yychar, yys); 446 } 447 #endif 448 yychar = YYEMPTY; 449 goto yyloop; 450 } 451 452 yyreduce: 453 #if YYDEBUG 454 if (yydebug) 455 printf("%sdebug: state %d, reducing by rule %d (%s)\n", 456 YYPREFIX, yystate, yyn, yyrule[yyn]); 457 #endif 458 yym = yylen[yyn]; 459 if (yym > 0) 460 yyval = yystack.l_mark[1-yym]; 461 else 462 memset(&yyval, 0, sizeof yyval); 463 464 switch (yyn) 465 { 466 } 467 yystack.s_mark -= yym; 468 yystate = *yystack.s_mark; 469 yystack.l_mark -= yym; 470 yym = yylhs[yyn]; 471 if (yystate == 0 && yym == 0) 472 { 473 #if YYDEBUG 474 if (yydebug) 475 printf("%sdebug: after reduction, shifting from state 0 to\ 476 state %d\n", YYPREFIX, YYFINAL); 477 #endif 478 yystate = YYFINAL; 479 *++yystack.s_mark = YYFINAL; 480 *++yystack.l_mark = yyval; 481 if (yychar < 0) 482 { 483 yychar = YYLEX; 484 if (yychar < 0) yychar = YYEOF; 485 #if YYDEBUG 486 if (yydebug) 487 { 488 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; 489 printf("%sdebug: state %d, reading %d (%s)\n", 490 YYPREFIX, YYFINAL, yychar, yys); 491 } 492 #endif 493 } 494 if (yychar == YYEOF) goto yyaccept; 495 goto yyloop; 496 } 497 if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && 498 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) 499 yystate = yytable[yyn]; 500 else 501 yystate = yydgoto[yym]; 502 #if YYDEBUG 503 if (yydebug) 504 printf("%sdebug: after reduction, shifting from state %d \ 505 to state %d\n", YYPREFIX, *yystack.s_mark, yystate); 506 #endif 507 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; 508 *++yystack.s_mark = (YYINT) yystate; 509 *++yystack.l_mark = yyval; 510 goto yyloop; 511 512 yyoverflow: 513 YYERROR_CALL("yacc stack overflow"); 514 515 yyabort: 516 yyfreestack(&yystack); 517 return (1); 518 519 yyaccept: 520 yyfreestack(&yystack); 521 return (0); 522 } 523