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 yynerrs = 0; 340 yyerrflag = 0; 341 yychar = YYEMPTY; 342 yystate = 0; 343 344 #if YYPURE 345 memset(&yystack, 0, sizeof(yystack)); 346 #endif 347 348 if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; 349 yystack.s_mark = yystack.s_base; 350 yystack.l_mark = yystack.l_base; 351 yystate = 0; 352 *yystack.s_mark = 0; 353 354 yyloop: 355 if ((yyn = yydefred[yystate]) != 0) goto yyreduce; 356 if (yychar < 0) 357 { 358 if ((yychar = YYLEX) < 0) yychar = YYEOF; 359 #if YYDEBUG 360 if (yydebug) 361 { 362 yys = yyname[YYTRANSLATE(yychar)]; 363 printf("%sdebug: state %d, reading %d (%s)\n", 364 YYPREFIX, yystate, yychar, yys); 365 } 366 #endif 367 } 368 if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 && 369 yyn <= YYTABLESIZE && yycheck[yyn] == yychar) 370 { 371 #if YYDEBUG 372 if (yydebug) 373 printf("%sdebug: state %d, shifting to state %d\n", 374 YYPREFIX, yystate, yytable[yyn]); 375 #endif 376 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) 377 { 378 goto yyoverflow; 379 } 380 yystate = yytable[yyn]; 381 *++yystack.s_mark = yytable[yyn]; 382 *++yystack.l_mark = yylval; 383 yychar = YYEMPTY; 384 if (yyerrflag > 0) --yyerrflag; 385 goto yyloop; 386 } 387 if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 && 388 yyn <= YYTABLESIZE && yycheck[yyn] == yychar) 389 { 390 yyn = yytable[yyn]; 391 goto yyreduce; 392 } 393 if (yyerrflag) goto yyinrecovery; 394 395 YYERROR_CALL("syntax error"); 396 397 goto yyerrlab; 398 399 yyerrlab: 400 ++yynerrs; 401 402 yyinrecovery: 403 if (yyerrflag < 3) 404 { 405 yyerrflag = 3; 406 for (;;) 407 { 408 if ((yyn = yysindex[*yystack.s_mark]) && (yyn += YYERRCODE) >= 0 && 409 yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE) 410 { 411 #if YYDEBUG 412 if (yydebug) 413 printf("%sdebug: state %d, error recovery shifting\ 414 to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); 415 #endif 416 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) 417 { 418 goto yyoverflow; 419 } 420 yystate = yytable[yyn]; 421 *++yystack.s_mark = yytable[yyn]; 422 *++yystack.l_mark = yylval; 423 goto yyloop; 424 } 425 else 426 { 427 #if YYDEBUG 428 if (yydebug) 429 printf("%sdebug: error recovery discarding state %d\n", 430 YYPREFIX, *yystack.s_mark); 431 #endif 432 if (yystack.s_mark <= yystack.s_base) goto yyabort; 433 --yystack.s_mark; 434 --yystack.l_mark; 435 } 436 } 437 } 438 else 439 { 440 if (yychar == YYEOF) goto yyabort; 441 #if YYDEBUG 442 if (yydebug) 443 { 444 yys = yyname[YYTRANSLATE(yychar)]; 445 printf("%sdebug: state %d, error recovery discards token %d (%s)\n", 446 YYPREFIX, yystate, yychar, yys); 447 } 448 #endif 449 yychar = YYEMPTY; 450 goto yyloop; 451 } 452 453 yyreduce: 454 #if YYDEBUG 455 if (yydebug) 456 printf("%sdebug: state %d, reducing by rule %d (%s)\n", 457 YYPREFIX, yystate, yyn, yyrule[yyn]); 458 #endif 459 yym = yylen[yyn]; 460 if (yym) 461 yyval = yystack.l_mark[1-yym]; 462 else 463 memset(&yyval, 0, sizeof yyval); 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 if ((yychar = YYLEX) < 0) yychar = YYEOF; 484 #if YYDEBUG 485 if (yydebug) 486 { 487 yys = yyname[YYTRANSLATE(yychar)]; 488 printf("%sdebug: state %d, reading %d (%s)\n", 489 YYPREFIX, YYFINAL, yychar, yys); 490 } 491 #endif 492 } 493 if (yychar == YYEOF) goto yyaccept; 494 goto yyloop; 495 } 496 if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 && 497 yyn <= YYTABLESIZE && yycheck[yyn] == yystate) 498 yystate = yytable[yyn]; 499 else 500 yystate = yydgoto[yym]; 501 #if YYDEBUG 502 if (yydebug) 503 printf("%sdebug: after reduction, shifting from state %d \ 504 to state %d\n", YYPREFIX, *yystack.s_mark, yystate); 505 #endif 506 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) 507 { 508 goto yyoverflow; 509 } 510 *++yystack.s_mark = (YYINT) yystate; 511 *++yystack.l_mark = yyval; 512 goto yyloop; 513 514 yyoverflow: 515 YYERROR_CALL("yacc stack overflow"); 516 517 yyabort: 518 yyfreestack(&yystack); 519 return (1); 520 521 yyaccept: 522 yyfreestack(&yystack); 523 return (0); 524 } 525