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