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