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