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