1 /* This file generated automatically using 2 * @Id: skel2c,v 1.4 2016/06/07 00:26:09 tom Exp @ 3 */ 4 5 /* @Id: yaccpar.skel,v 1.10 2018/05/06 21:28:14 Guy.Harris Exp @ */ 6 7 #include "defs.h" 8 9 /* If the skeleton is changed, the banner should be changed so that */ 10 /* the altered version can be easily distinguished from the original. */ 11 /* */ 12 /* The #defines included with the banner are there because they are */ 13 /* useful in subsequent code. The macros #defined in the header or */ 14 /* the body either are not useful outside of semantic actions or */ 15 /* are conditional. */ 16 17 const char *const banner[] = 18 { 19 "/* original parser id follows */", 20 "/* yysccsid[] = \"@(#)yaccpar 1.9 (Berkeley) 02/21/93\" */", 21 "/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */", 22 "", 23 "#define YYBYACC 1", 24 CONCAT1("#define YYMAJOR ", YYMAJOR), 25 CONCAT1("#define YYMINOR ", YYMINOR), 26 #ifdef YYPATCH 27 CONCAT1("#define YYPATCH ", YYPATCH), 28 #endif 29 "", 30 "#define YYEMPTY (-1)", 31 "#define yyclearin (yychar = YYEMPTY)", 32 "#define yyerrok (yyerrflag = 0)", 33 "#define YYRECOVERING() (yyerrflag != 0)", 34 "#define YYENOMEM (-2)", 35 "#define YYEOF 0", 36 0 37 }; 38 39 const char *const xdecls[] = 40 { 41 "", 42 "extern int YYPARSE_DECL();", 43 0 44 }; 45 46 const char *const tables[] = 47 { 48 "extern YYINT yylhs[];", 49 "extern YYINT yylen[];", 50 "extern YYINT yydefred[];", 51 "extern YYINT yydgoto[];", 52 "extern YYINT yysindex[];", 53 "extern YYINT yyrindex[];", 54 "extern YYINT yygindex[];", 55 "extern YYINT yytable[];", 56 "extern YYINT yycheck[];", 57 "", 58 "#if YYDEBUG || defined(yytname)", 59 "extern char *yyname[];", 60 "#endif", 61 "#if YYDEBUG", 62 "extern char *yyrule[];", 63 "#endif", 64 0 65 }; 66 67 const char *const global_vars[] = 68 { 69 "", 70 "#if YYDEBUG", 71 "int yydebug;", 72 "#endif", 73 0 74 }; 75 76 const char *const impure_vars[] = 77 { 78 "", 79 "int yyerrflag;", 80 "int yychar;", 81 "YYSTYPE yyval;", 82 "YYSTYPE yylval;", 83 "int yynerrs;", 84 0 85 }; 86 87 const char *const hdr_defs[] = 88 { 89 "", 90 "/* define the initial stack-sizes */", 91 "#ifdef YYSTACKSIZE", 92 "#undef YYMAXDEPTH", 93 "#define YYMAXDEPTH YYSTACKSIZE", 94 "#else", 95 "#ifdef YYMAXDEPTH", 96 "#define YYSTACKSIZE YYMAXDEPTH", 97 "#else", 98 "#define YYSTACKSIZE 10000", 99 "#define YYMAXDEPTH 10000", 100 "#endif", 101 "#endif", 102 "", 103 "#define YYINITSTACKSIZE 200", 104 "", 105 "typedef struct {", 106 " unsigned stacksize;", 107 " YYINT *s_base;", 108 " YYINT *s_mark;", 109 " YYINT *s_last;", 110 " YYSTYPE *l_base;", 111 " YYSTYPE *l_mark;", 112 "} YYSTACKDATA;", 113 0 114 }; 115 116 const char *const hdr_vars[] = 117 { 118 "/* variables for the parser stack */", 119 "static YYSTACKDATA yystack;", 120 0 121 }; 122 123 const char *const body_vars[] = 124 { 125 " int yyerrflag;", 126 " int yychar;", 127 " YYSTYPE yyval;", 128 " YYSTYPE yylval;", 129 " int yynerrs;", 130 "", 131 " /* variables for the parser stack */", 132 " YYSTACKDATA yystack;", 133 0 134 }; 135 136 const char *const body_1[] = 137 { 138 "", 139 "#if YYDEBUG", 140 "#include <stdio.h> /* needed for printf */", 141 "#endif", 142 "", 143 "#include <stdlib.h> /* needed for malloc, etc */", 144 "#include <string.h> /* needed for memset */", 145 "", 146 "/* allocate initial stack or double stack size, up to YYMAXDEPTH */", 147 "static int yygrowstack(YYSTACKDATA *data)", 148 "{", 149 " int i;", 150 " unsigned newsize;", 151 " YYINT *newss;", 152 " YYSTYPE *newvs;", 153 "", 154 " if ((newsize = data->stacksize) == 0)", 155 " newsize = YYINITSTACKSIZE;", 156 " else if (newsize >= YYMAXDEPTH)", 157 " return YYENOMEM;", 158 " else if ((newsize *= 2) > YYMAXDEPTH)", 159 " newsize = YYMAXDEPTH;", 160 "", 161 " i = (int) (data->s_mark - data->s_base);", 162 " newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss));", 163 " if (newss == NULL)", 164 " return YYENOMEM;", 165 "", 166 " data->s_base = newss;", 167 " data->s_mark = newss + i;", 168 "", 169 " newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));", 170 " if (newvs == NULL)", 171 " return YYENOMEM;", 172 "", 173 " data->l_base = newvs;", 174 " data->l_mark = newvs + i;", 175 "", 176 " data->stacksize = newsize;", 177 " data->s_last = data->s_base + newsize - 1;", 178 " return 0;", 179 "}", 180 "", 181 "#if YYPURE || defined(YY_NO_LEAKS)", 182 "static void yyfreestack(YYSTACKDATA *data)", 183 "{", 184 " free(data->s_base);", 185 " free(data->l_base);", 186 " memset(data, 0, sizeof(*data));", 187 "}", 188 "#else", 189 "#define yyfreestack(data) /* nothing */", 190 "#endif", 191 "", 192 "#define YYABORT goto yyabort", 193 "#define YYREJECT goto yyabort", 194 "#define YYACCEPT goto yyaccept", 195 "#define YYERROR goto yyerrlab", 196 "", 197 "int", 198 "YYPARSE_DECL()", 199 "{", 200 0 201 }; 202 203 const char *const body_2[] = 204 { 205 " int yym, yyn, yystate;", 206 "#if YYDEBUG", 207 " const char *yys;", 208 "", 209 " if ((yys = getenv(\"YYDEBUG\")) != NULL)", 210 " {", 211 " yyn = *yys;", 212 " if (yyn >= '0' && yyn <= '9')", 213 " yydebug = yyn - '0';", 214 " }", 215 "#endif", 216 "", 217 0 218 }; 219 220 const char *const init_vars[] = 221 { 222 " memset(&yyval, 0, sizeof(yyval));", 223 " memset(&yylval, 0, sizeof(yylval));", 224 "", 225 0 226 }; 227 228 const char *const body_3[] = 229 { 230 " yym = 0;", 231 " yyn = 0;", 232 " yynerrs = 0;", 233 " yyerrflag = 0;", 234 " yychar = YYEMPTY;", 235 " yystate = 0;", 236 "", 237 "#if YYPURE", 238 " memset(&yystack, 0, sizeof(yystack));", 239 "#endif", 240 "", 241 " if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;", 242 " yystack.s_mark = yystack.s_base;", 243 " yystack.l_mark = yystack.l_base;", 244 " yystate = 0;", 245 " *yystack.s_mark = 0;", 246 "", 247 "yyloop:", 248 " if ((yyn = yydefred[yystate]) != 0) goto yyreduce;", 249 " if (yychar < 0)", 250 " {", 251 " yychar = YYLEX;", 252 " if (yychar < 0) yychar = YYEOF;", 253 "#if YYDEBUG", 254 " if (yydebug)", 255 " {", 256 " if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];", 257 " printf(\"%sdebug: state %d, reading %d (%s)\\n\",", 258 " YYPREFIX, yystate, yychar, yys);", 259 " }", 260 "#endif", 261 " }", 262 " if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 &&", 263 " yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)", 264 " {", 265 "#if YYDEBUG", 266 " if (yydebug)", 267 " printf(\"%sdebug: state %d, shifting to state %d\\n\",", 268 " YYPREFIX, yystate, yytable[yyn]);", 269 "#endif", 270 " if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;", 271 " yystate = yytable[yyn];", 272 " *++yystack.s_mark = yytable[yyn];", 273 " *++yystack.l_mark = yylval;", 274 " yychar = YYEMPTY;", 275 " if (yyerrflag > 0) --yyerrflag;", 276 " goto yyloop;", 277 " }", 278 " if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 &&", 279 " yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)", 280 " {", 281 " yyn = yytable[yyn];", 282 " goto yyreduce;", 283 " }", 284 " if (yyerrflag != 0) goto yyinrecovery;", 285 "", 286 " YYERROR_CALL(\"syntax error\");", 287 "", 288 " goto yyerrlab; /* redundant goto avoids 'unused label' warning */", 289 "yyerrlab:", 290 " ++yynerrs;", 291 "", 292 "yyinrecovery:", 293 " if (yyerrflag < 3)", 294 " {", 295 " yyerrflag = 3;", 296 " for (;;)", 297 " {", 298 " if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 &&", 299 " yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE)", 300 " {", 301 "#if YYDEBUG", 302 " if (yydebug)", 303 " printf(\"%sdebug: state %d, error recovery shifting\\", 304 " to state %d\\n\", YYPREFIX, *yystack.s_mark, yytable[yyn]);", 305 "#endif", 306 " if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;", 307 " yystate = yytable[yyn];", 308 " *++yystack.s_mark = yytable[yyn];", 309 " *++yystack.l_mark = yylval;", 310 " goto yyloop;", 311 " }", 312 " else", 313 " {", 314 "#if YYDEBUG", 315 " if (yydebug)", 316 " printf(\"%sdebug: error recovery discarding state %d\\n\",", 317 " YYPREFIX, *yystack.s_mark);", 318 "#endif", 319 " if (yystack.s_mark <= yystack.s_base) goto yyabort;", 320 " --yystack.s_mark;", 321 " --yystack.l_mark;", 322 " }", 323 " }", 324 " }", 325 " else", 326 " {", 327 " if (yychar == YYEOF) goto yyabort;", 328 "#if YYDEBUG", 329 " if (yydebug)", 330 " {", 331 " if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];", 332 " printf(\"%sdebug: state %d, error recovery discards token %d (%s)\\n\",", 333 " YYPREFIX, yystate, yychar, yys);", 334 " }", 335 "#endif", 336 " yychar = YYEMPTY;", 337 " goto yyloop;", 338 " }", 339 "", 340 "yyreduce:", 341 "#if YYDEBUG", 342 " if (yydebug)", 343 " printf(\"%sdebug: state %d, reducing by rule %d (%s)\\n\",", 344 " YYPREFIX, yystate, yyn, yyrule[yyn]);", 345 "#endif", 346 " yym = yylen[yyn];", 347 " if (yym > 0)", 348 " yyval = yystack.l_mark[1-yym];", 349 " else", 350 " memset(&yyval, 0, sizeof yyval);", 351 "", 352 " switch (yyn)", 353 " {", 354 0 355 }; 356 357 const char *const trailer[] = 358 { 359 " }", 360 " yystack.s_mark -= yym;", 361 " yystate = *yystack.s_mark;", 362 " yystack.l_mark -= yym;", 363 " yym = yylhs[yyn];", 364 " if (yystate == 0 && yym == 0)", 365 " {", 366 "#if YYDEBUG", 367 " if (yydebug)", 368 " printf(\"%sdebug: after reduction, shifting from state 0 to\\", 369 " state %d\\n\", YYPREFIX, YYFINAL);", 370 "#endif", 371 " yystate = YYFINAL;", 372 " *++yystack.s_mark = YYFINAL;", 373 " *++yystack.l_mark = yyval;", 374 " if (yychar < 0)", 375 " {", 376 " yychar = YYLEX;", 377 " if (yychar < 0) yychar = YYEOF;", 378 "#if YYDEBUG", 379 " if (yydebug)", 380 " {", 381 " if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];", 382 " printf(\"%sdebug: state %d, reading %d (%s)\\n\",", 383 " YYPREFIX, YYFINAL, yychar, yys);", 384 " }", 385 "#endif", 386 " }", 387 " if (yychar == YYEOF) goto yyaccept;", 388 " goto yyloop;", 389 " }", 390 " if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 &&", 391 " yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate)", 392 " yystate = yytable[yyn];", 393 " else", 394 " yystate = yydgoto[yym];", 395 "#if YYDEBUG", 396 " if (yydebug)", 397 " printf(\"%sdebug: after reduction, shifting from state %d \\", 398 "to state %d\\n\", YYPREFIX, *yystack.s_mark, yystate);", 399 "#endif", 400 " if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;", 401 " *++yystack.s_mark = (YYINT) yystate;", 402 " *++yystack.l_mark = yyval;", 403 " goto yyloop;", 404 "", 405 "yyoverflow:", 406 " YYERROR_CALL(\"yacc stack overflow\");", 407 "", 408 "yyabort:", 409 " yyfreestack(&yystack);", 410 " return (1);", 411 "", 412 "yyaccept:", 413 " yyfreestack(&yystack);", 414 " return (0);", 415 "}", 416 0 417 }; 418 419 void 420 write_section(FILE * fp, const char *const section[]) 421 { 422 int i; 423 const char *s; 424 425 for (i = 0; (s = section[i]) != 0; ++i) 426 { 427 if (fp == code_file) 428 ++outline; 429 fprintf(fp, "%s\n", s); 430 } 431 } 432