1234949Sbapt#ifndef lint 2234949Sbaptstatic const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93"; 3234949Sbapt#endif 4234949Sbapt 5234949Sbapt#define YYBYACC 1 6234949Sbapt#define YYMAJOR 1 7234949Sbapt#define YYMINOR 9 8234949Sbapt 9234949Sbapt#define YYEMPTY (-1) 10234949Sbapt#define yyclearin (yychar = YYEMPTY) 11234949Sbapt#define yyerrok (yyerrflag = 0) 12234949Sbapt#define YYRECOVERING() (yyerrflag != 0) 13234949Sbapt 14234949Sbapt 15234949Sbapt#ifndef yyparse 16234949Sbapt#define yyparse error_parse 17234949Sbapt#endif /* yyparse */ 18234949Sbapt 19234949Sbapt#ifndef yylex 20234949Sbapt#define yylex error_lex 21234949Sbapt#endif /* yylex */ 22234949Sbapt 23234949Sbapt#ifndef yyerror 24234949Sbapt#define yyerror error_error 25234949Sbapt#endif /* yyerror */ 26234949Sbapt 27234949Sbapt#ifndef yychar 28234949Sbapt#define yychar error_char 29234949Sbapt#endif /* yychar */ 30234949Sbapt 31234949Sbapt#ifndef yyval 32234949Sbapt#define yyval error_val 33234949Sbapt#endif /* yyval */ 34234949Sbapt 35234949Sbapt#ifndef yylval 36234949Sbapt#define yylval error_lval 37234949Sbapt#endif /* yylval */ 38234949Sbapt 39234949Sbapt#ifndef yydebug 40234949Sbapt#define yydebug error_debug 41234949Sbapt#endif /* yydebug */ 42234949Sbapt 43234949Sbapt#ifndef yynerrs 44234949Sbapt#define yynerrs error_nerrs 45234949Sbapt#endif /* yynerrs */ 46234949Sbapt 47234949Sbapt#ifndef yyerrflag 48234949Sbapt#define yyerrflag error_errflag 49234949Sbapt#endif /* yyerrflag */ 50234949Sbapt 51234949Sbapt#ifndef yylhs 52234949Sbapt#define yylhs error_lhs 53234949Sbapt#endif /* yylhs */ 54234949Sbapt 55234949Sbapt#ifndef yylen 56234949Sbapt#define yylen error_len 57234949Sbapt#endif /* yylen */ 58234949Sbapt 59234949Sbapt#ifndef yydefred 60234949Sbapt#define yydefred error_defred 61234949Sbapt#endif /* yydefred */ 62234949Sbapt 63234949Sbapt#ifndef yydgoto 64234949Sbapt#define yydgoto error_dgoto 65234949Sbapt#endif /* yydgoto */ 66234949Sbapt 67234949Sbapt#ifndef yysindex 68234949Sbapt#define yysindex error_sindex 69234949Sbapt#endif /* yysindex */ 70234949Sbapt 71234949Sbapt#ifndef yyrindex 72234949Sbapt#define yyrindex error_rindex 73234949Sbapt#endif /* yyrindex */ 74234949Sbapt 75234949Sbapt#ifndef yygindex 76234949Sbapt#define yygindex error_gindex 77234949Sbapt#endif /* yygindex */ 78234949Sbapt 79234949Sbapt#ifndef yytable 80234949Sbapt#define yytable error_table 81234949Sbapt#endif /* yytable */ 82234949Sbapt 83234949Sbapt#ifndef yycheck 84234949Sbapt#define yycheck error_check 85234949Sbapt#endif /* yycheck */ 86234949Sbapt 87234949Sbapt#ifndef yyname 88234949Sbapt#define yyname error_name 89234949Sbapt#endif /* yyname */ 90234949Sbapt 91234949Sbapt#ifndef yyrule 92234949Sbapt#define yyrule error_rule 93234949Sbapt#endif /* yyrule */ 94234949Sbapt#define YYPREFIX "error_" 95234949Sbapt 96234949Sbapt#define YYPURE 0 97234949Sbapt 98234949Sbapt#line 2 "error.y" 99234949Sbaptint yylex(void); 100234949Sbaptstatic void yyerror(const char *); 101234949Sbapt#line 102 "error.tab.c" 102234949Sbapt 103234949Sbapt#ifndef YYSTYPE 104234949Sbapttypedef int YYSTYPE; 105234949Sbapt#endif 106234949Sbapt 107234949Sbapt/* compatibility with bison */ 108234949Sbapt#ifdef YYPARSE_PARAM 109234949Sbapt/* compatibility with FreeBSD */ 110234949Sbapt# ifdef YYPARSE_PARAM_TYPE 111234949Sbapt# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM) 112234949Sbapt# else 113234949Sbapt# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM) 114234949Sbapt# endif 115234949Sbapt#else 116234949Sbapt# define YYPARSE_DECL() yyparse(void) 117234949Sbapt#endif 118234949Sbapt 119234949Sbapt/* Parameters sent to lex. */ 120234949Sbapt#ifdef YYLEX_PARAM 121234949Sbapt# define YYLEX_DECL() yylex(void *YYLEX_PARAM) 122234949Sbapt# define YYLEX yylex(YYLEX_PARAM) 123234949Sbapt#else 124234949Sbapt# define YYLEX_DECL() yylex(void) 125234949Sbapt# define YYLEX yylex() 126234949Sbapt#endif 127234949Sbapt 128234949Sbapt/* Parameters sent to yyerror. */ 129234949Sbapt#ifndef YYERROR_DECL 130234949Sbapt#define YYERROR_DECL() yyerror(const char *s) 131234949Sbapt#endif 132234949Sbapt#ifndef YYERROR_CALL 133234949Sbapt#define YYERROR_CALL(msg) yyerror(msg) 134234949Sbapt#endif 135234949Sbapt 136234949Sbaptextern int YYPARSE_DECL(); 137234949Sbapt 138234949Sbapt#define YYERRCODE 256 139234949Sbaptstatic const short error_lhs[] = { -1, 140234949Sbapt 0, 141234949Sbapt}; 142234949Sbaptstatic const short error_len[] = { 2, 143234949Sbapt 1, 144234949Sbapt}; 145234949Sbaptstatic const short error_defred[] = { 0, 146234949Sbapt 1, 0, 147234949Sbapt}; 148234949Sbaptstatic const short error_dgoto[] = { 2, 149234949Sbapt}; 150234949Sbaptstatic const short error_sindex[] = { -256, 151234949Sbapt 0, 0, 152234949Sbapt}; 153234949Sbaptstatic const short error_rindex[] = { 0, 154234949Sbapt 0, 0, 155234949Sbapt}; 156234949Sbaptstatic const short error_gindex[] = { 0, 157234949Sbapt}; 158234949Sbapt#define YYTABLESIZE 0 159234949Sbaptstatic const short error_table[] = { 1, 160234949Sbapt}; 161234949Sbaptstatic const short error_check[] = { 256, 162234949Sbapt}; 163234949Sbapt#define YYFINAL 2 164234949Sbapt#ifndef YYDEBUG 165234949Sbapt#define YYDEBUG 0 166234949Sbapt#endif 167234949Sbapt#define YYMAXTOKEN 0 168234949Sbapt#if YYDEBUG 169234949Sbaptstatic const char *yyname[] = { 170234949Sbapt 171234949Sbapt"end-of-file", 172234949Sbapt}; 173234949Sbaptstatic const char *yyrule[] = { 174234949Sbapt"$accept : S", 175234949Sbapt"S : error", 176234949Sbapt 177234949Sbapt}; 178234949Sbapt#endif 179234949Sbapt 180234949Sbaptint yydebug; 181234949Sbaptint yynerrs; 182234949Sbapt 183234949Sbaptint yyerrflag; 184234949Sbaptint yychar; 185234949SbaptYYSTYPE yyval; 186234949SbaptYYSTYPE yylval; 187234949Sbapt 188234949Sbapt/* define the initial stack-sizes */ 189234949Sbapt#ifdef YYSTACKSIZE 190234949Sbapt#undef YYMAXDEPTH 191234949Sbapt#define YYMAXDEPTH YYSTACKSIZE 192234949Sbapt#else 193234949Sbapt#ifdef YYMAXDEPTH 194234949Sbapt#define YYSTACKSIZE YYMAXDEPTH 195234949Sbapt#else 196234949Sbapt#define YYSTACKSIZE 500 197234949Sbapt#define YYMAXDEPTH 500 198234949Sbapt#endif 199234949Sbapt#endif 200234949Sbapt 201234949Sbapt#define YYINITSTACKSIZE 500 202234949Sbapt 203234949Sbapttypedef struct { 204234949Sbapt unsigned stacksize; 205234949Sbapt short *s_base; 206234949Sbapt short *s_mark; 207234949Sbapt short *s_last; 208234949Sbapt YYSTYPE *l_base; 209234949Sbapt YYSTYPE *l_mark; 210234949Sbapt} YYSTACKDATA; 211234949Sbapt/* variables for the parser stack */ 212234949Sbaptstatic YYSTACKDATA yystack; 213234949Sbapt#line 8 "error.y" 214234949Sbapt 215234949Sbapt#include <stdio.h> 216234949Sbapt 217234949Sbaptint 218234949Sbaptmain(void) 219234949Sbapt{ 220234949Sbapt printf("yyparse() = %d\n", yyparse()); 221234949Sbapt return 0; 222234949Sbapt} 223234949Sbapt 224234949Sbaptint 225234949Sbaptyylex(void) 226234949Sbapt{ 227234949Sbapt return -1; 228234949Sbapt} 229234949Sbapt 230234949Sbaptstatic void 231234949Sbaptyyerror(const char* s) 232234949Sbapt{ 233234949Sbapt printf("%s\n", s); 234234949Sbapt} 235234949Sbapt#line 236 "error.tab.c" 236234949Sbapt 237234949Sbapt#if YYDEBUG 238234949Sbapt#include <stdio.h> /* needed for printf */ 239234949Sbapt#endif 240234949Sbapt 241234949Sbapt#include <stdlib.h> /* needed for malloc, etc */ 242234949Sbapt#include <string.h> /* needed for memset */ 243234949Sbapt 244234949Sbapt/* allocate initial stack or double stack size, up to YYMAXDEPTH */ 245234949Sbaptstatic int yygrowstack(YYSTACKDATA *data) 246234949Sbapt{ 247234949Sbapt int i; 248234949Sbapt unsigned newsize; 249234949Sbapt short *newss; 250234949Sbapt YYSTYPE *newvs; 251234949Sbapt 252234949Sbapt if ((newsize = data->stacksize) == 0) 253234949Sbapt newsize = YYINITSTACKSIZE; 254234949Sbapt else if (newsize >= YYMAXDEPTH) 255234949Sbapt return -1; 256234949Sbapt else if ((newsize *= 2) > YYMAXDEPTH) 257234949Sbapt newsize = YYMAXDEPTH; 258234949Sbapt 259251143Sbapt i = (int) (data->s_mark - data->s_base); 260234949Sbapt newss = (short *)realloc(data->s_base, newsize * sizeof(*newss)); 261234949Sbapt if (newss == 0) 262234949Sbapt return -1; 263234949Sbapt 264234949Sbapt data->s_base = newss; 265234949Sbapt data->s_mark = newss + i; 266234949Sbapt 267234949Sbapt newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); 268234949Sbapt if (newvs == 0) 269234949Sbapt return -1; 270234949Sbapt 271234949Sbapt data->l_base = newvs; 272234949Sbapt data->l_mark = newvs + i; 273234949Sbapt 274234949Sbapt data->stacksize = newsize; 275234949Sbapt data->s_last = data->s_base + newsize - 1; 276234949Sbapt return 0; 277234949Sbapt} 278234949Sbapt 279234949Sbapt#if YYPURE || defined(YY_NO_LEAKS) 280234949Sbaptstatic void yyfreestack(YYSTACKDATA *data) 281234949Sbapt{ 282234949Sbapt free(data->s_base); 283234949Sbapt free(data->l_base); 284234949Sbapt memset(data, 0, sizeof(*data)); 285234949Sbapt} 286234949Sbapt#else 287234949Sbapt#define yyfreestack(data) /* nothing */ 288234949Sbapt#endif 289234949Sbapt 290234949Sbapt#define YYABORT goto yyabort 291234949Sbapt#define YYREJECT goto yyabort 292234949Sbapt#define YYACCEPT goto yyaccept 293234949Sbapt#define YYERROR goto yyerrlab 294234949Sbapt 295234949Sbaptint 296234949SbaptYYPARSE_DECL() 297234949Sbapt{ 298234949Sbapt int yym, yyn, yystate; 299234949Sbapt#if YYDEBUG 300234949Sbapt const char *yys; 301234949Sbapt 302234949Sbapt if ((yys = getenv("YYDEBUG")) != 0) 303234949Sbapt { 304234949Sbapt yyn = *yys; 305234949Sbapt if (yyn >= '0' && yyn <= '9') 306234949Sbapt yydebug = yyn - '0'; 307234949Sbapt } 308234949Sbapt#endif 309234949Sbapt 310234949Sbapt yynerrs = 0; 311234949Sbapt yyerrflag = 0; 312234949Sbapt yychar = YYEMPTY; 313234949Sbapt yystate = 0; 314234949Sbapt 315234949Sbapt#if YYPURE 316234949Sbapt memset(&yystack, 0, sizeof(yystack)); 317234949Sbapt#endif 318234949Sbapt 319234949Sbapt if (yystack.s_base == NULL && yygrowstack(&yystack)) goto yyoverflow; 320234949Sbapt yystack.s_mark = yystack.s_base; 321234949Sbapt yystack.l_mark = yystack.l_base; 322234949Sbapt yystate = 0; 323234949Sbapt *yystack.s_mark = 0; 324234949Sbapt 325234949Sbaptyyloop: 326234949Sbapt if ((yyn = yydefred[yystate]) != 0) goto yyreduce; 327234949Sbapt if (yychar < 0) 328234949Sbapt { 329234949Sbapt if ((yychar = YYLEX) < 0) yychar = 0; 330234949Sbapt#if YYDEBUG 331234949Sbapt if (yydebug) 332234949Sbapt { 333234949Sbapt yys = 0; 334234949Sbapt if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; 335234949Sbapt if (!yys) yys = "illegal-symbol"; 336234949Sbapt printf("%sdebug: state %d, reading %d (%s)\n", 337234949Sbapt YYPREFIX, yystate, yychar, yys); 338234949Sbapt } 339234949Sbapt#endif 340234949Sbapt } 341234949Sbapt if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 && 342234949Sbapt yyn <= YYTABLESIZE && yycheck[yyn] == yychar) 343234949Sbapt { 344234949Sbapt#if YYDEBUG 345234949Sbapt if (yydebug) 346234949Sbapt printf("%sdebug: state %d, shifting to state %d\n", 347234949Sbapt YYPREFIX, yystate, yytable[yyn]); 348234949Sbapt#endif 349234949Sbapt if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack)) 350234949Sbapt { 351234949Sbapt goto yyoverflow; 352234949Sbapt } 353234949Sbapt yystate = yytable[yyn]; 354234949Sbapt *++yystack.s_mark = yytable[yyn]; 355234949Sbapt *++yystack.l_mark = yylval; 356234949Sbapt yychar = YYEMPTY; 357234949Sbapt if (yyerrflag > 0) --yyerrflag; 358234949Sbapt goto yyloop; 359234949Sbapt } 360234949Sbapt if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 && 361234949Sbapt yyn <= YYTABLESIZE && yycheck[yyn] == yychar) 362234949Sbapt { 363234949Sbapt yyn = yytable[yyn]; 364234949Sbapt goto yyreduce; 365234949Sbapt } 366234949Sbapt if (yyerrflag) goto yyinrecovery; 367234949Sbapt 368234949Sbapt yyerror("syntax error"); 369234949Sbapt 370234949Sbapt goto yyerrlab; 371234949Sbapt 372234949Sbaptyyerrlab: 373234949Sbapt ++yynerrs; 374234949Sbapt 375234949Sbaptyyinrecovery: 376234949Sbapt if (yyerrflag < 3) 377234949Sbapt { 378234949Sbapt yyerrflag = 3; 379234949Sbapt for (;;) 380234949Sbapt { 381234949Sbapt if ((yyn = yysindex[*yystack.s_mark]) && (yyn += YYERRCODE) >= 0 && 382234949Sbapt yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE) 383234949Sbapt { 384234949Sbapt#if YYDEBUG 385234949Sbapt if (yydebug) 386234949Sbapt printf("%sdebug: state %d, error recovery shifting\ 387234949Sbapt to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]); 388234949Sbapt#endif 389234949Sbapt if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack)) 390234949Sbapt { 391234949Sbapt goto yyoverflow; 392234949Sbapt } 393234949Sbapt yystate = yytable[yyn]; 394234949Sbapt *++yystack.s_mark = yytable[yyn]; 395234949Sbapt *++yystack.l_mark = yylval; 396234949Sbapt goto yyloop; 397234949Sbapt } 398234949Sbapt else 399234949Sbapt { 400234949Sbapt#if YYDEBUG 401234949Sbapt if (yydebug) 402234949Sbapt printf("%sdebug: error recovery discarding state %d\n", 403234949Sbapt YYPREFIX, *yystack.s_mark); 404234949Sbapt#endif 405234949Sbapt if (yystack.s_mark <= yystack.s_base) goto yyabort; 406234949Sbapt --yystack.s_mark; 407234949Sbapt --yystack.l_mark; 408234949Sbapt } 409234949Sbapt } 410234949Sbapt } 411234949Sbapt else 412234949Sbapt { 413234949Sbapt if (yychar == 0) goto yyabort; 414234949Sbapt#if YYDEBUG 415234949Sbapt if (yydebug) 416234949Sbapt { 417234949Sbapt yys = 0; 418234949Sbapt if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; 419234949Sbapt if (!yys) yys = "illegal-symbol"; 420234949Sbapt printf("%sdebug: state %d, error recovery discards token %d (%s)\n", 421234949Sbapt YYPREFIX, yystate, yychar, yys); 422234949Sbapt } 423234949Sbapt#endif 424234949Sbapt yychar = YYEMPTY; 425234949Sbapt goto yyloop; 426234949Sbapt } 427234949Sbapt 428234949Sbaptyyreduce: 429234949Sbapt#if YYDEBUG 430234949Sbapt if (yydebug) 431234949Sbapt printf("%sdebug: state %d, reducing by rule %d (%s)\n", 432234949Sbapt YYPREFIX, yystate, yyn, yyrule[yyn]); 433234949Sbapt#endif 434234949Sbapt yym = yylen[yyn]; 435234949Sbapt if (yym) 436234949Sbapt yyval = yystack.l_mark[1-yym]; 437234949Sbapt else 438234949Sbapt memset(&yyval, 0, sizeof yyval); 439234949Sbapt switch (yyn) 440234949Sbapt { 441234949Sbapt } 442234949Sbapt yystack.s_mark -= yym; 443234949Sbapt yystate = *yystack.s_mark; 444234949Sbapt yystack.l_mark -= yym; 445234949Sbapt yym = yylhs[yyn]; 446234949Sbapt if (yystate == 0 && yym == 0) 447234949Sbapt { 448234949Sbapt#if YYDEBUG 449234949Sbapt if (yydebug) 450234949Sbapt printf("%sdebug: after reduction, shifting from state 0 to\ 451234949Sbapt state %d\n", YYPREFIX, YYFINAL); 452234949Sbapt#endif 453234949Sbapt yystate = YYFINAL; 454234949Sbapt *++yystack.s_mark = YYFINAL; 455234949Sbapt *++yystack.l_mark = yyval; 456234949Sbapt if (yychar < 0) 457234949Sbapt { 458234949Sbapt if ((yychar = YYLEX) < 0) yychar = 0; 459234949Sbapt#if YYDEBUG 460234949Sbapt if (yydebug) 461234949Sbapt { 462234949Sbapt yys = 0; 463234949Sbapt if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; 464234949Sbapt if (!yys) yys = "illegal-symbol"; 465234949Sbapt printf("%sdebug: state %d, reading %d (%s)\n", 466234949Sbapt YYPREFIX, YYFINAL, yychar, yys); 467234949Sbapt } 468234949Sbapt#endif 469234949Sbapt } 470234949Sbapt if (yychar == 0) goto yyaccept; 471234949Sbapt goto yyloop; 472234949Sbapt } 473234949Sbapt if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 && 474234949Sbapt yyn <= YYTABLESIZE && yycheck[yyn] == yystate) 475234949Sbapt yystate = yytable[yyn]; 476234949Sbapt else 477234949Sbapt yystate = yydgoto[yym]; 478234949Sbapt#if YYDEBUG 479234949Sbapt if (yydebug) 480234949Sbapt printf("%sdebug: after reduction, shifting from state %d \ 481234949Sbaptto state %d\n", YYPREFIX, *yystack.s_mark, yystate); 482234949Sbapt#endif 483234949Sbapt if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack)) 484234949Sbapt { 485234949Sbapt goto yyoverflow; 486234949Sbapt } 487234949Sbapt *++yystack.s_mark = (short) yystate; 488234949Sbapt *++yystack.l_mark = yyval; 489234949Sbapt goto yyloop; 490234949Sbapt 491234949Sbaptyyoverflow: 492234949Sbapt yyerror("yacc stack overflow"); 493234949Sbapt 494234949Sbaptyyabort: 495234949Sbapt yyfreestack(&yystack); 496234949Sbapt return (1); 497234949Sbapt 498234949Sbaptyyaccept: 499234949Sbapt yyfreestack(&yystack); 500234949Sbapt return (0); 501234949Sbapt} 502