1 /* 2 * Copyright (c) 1989 The Regents of the University of California. 3 * All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Robert Paul Corbett. 7 * 8 * %sccs.include.redist.c% 9 */ 10 11 #ifndef lint 12 static char sccsid[] = "@(#)skeleton.c 5.7 (Berkeley) 05/24/93"; 13 #endif /* not lint */ 14 15 #include "defs.h" 16 17 /* The definition of yysccsid in the banner should be replaced with */ 18 /* a #pragma ident directive if the target C compiler supports */ 19 /* #pragma ident directives. */ 20 /* */ 21 /* If the skeleton is changed, the banner should be changed so that */ 22 /* the altered version can be easily distinguished from the original. */ 23 /* */ 24 /* The #defines included with the banner are there because they are */ 25 /* useful in subsequent code. The macros #defined in the header or */ 26 /* the body either are not useful outside of semantic actions or */ 27 /* are conditional. */ 28 29 char *banner[] = 30 { 31 "#ifndef lint", 32 "static char yysccsid[] = \"@(#)yaccpar 1.9 (Berkeley) 02/21/93\";", 33 "#endif", 34 "#define YYBYACC 1", 35 "#define YYMAJOR 1", 36 "#define YYMINOR 9", 37 "#define yyclearin (yychar=(-1))", 38 "#define yyerrok (yyerrflag=0)", 39 "#define YYRECOVERING (yyerrflag!=0)", 40 0 41 }; 42 43 44 char *tables[] = 45 { 46 "extern short yylhs[];", 47 "extern short yylen[];", 48 "extern short yydefred[];", 49 "extern short yydgoto[];", 50 "extern short yysindex[];", 51 "extern short yyrindex[];", 52 "extern short yygindex[];", 53 "extern short yytable[];", 54 "extern short yycheck[];", 55 "#if YYDEBUG", 56 "extern char *yyname[];", 57 "extern char *yyrule[];", 58 "#endif", 59 0 60 }; 61 62 63 char *header[] = 64 { 65 "#ifdef YYSTACKSIZE", 66 "#undef YYMAXDEPTH", 67 "#define YYMAXDEPTH YYSTACKSIZE", 68 "#else", 69 "#ifdef YYMAXDEPTH", 70 "#define YYSTACKSIZE YYMAXDEPTH", 71 "#else", 72 "#define YYSTACKSIZE 500", 73 "#define YYMAXDEPTH 500", 74 "#endif", 75 "#endif", 76 "int yydebug;", 77 "int yynerrs;", 78 "int yyerrflag;", 79 "int yychar;", 80 "short *yyssp;", 81 "YYSTYPE *yyvsp;", 82 "YYSTYPE yyval;", 83 "YYSTYPE yylval;", 84 "short yyss[YYSTACKSIZE];", 85 "YYSTYPE yyvs[YYSTACKSIZE];", 86 "#define yystacksize YYSTACKSIZE", 87 0 88 }; 89 90 91 char *body[] = 92 { 93 "#define YYABORT goto yyabort", 94 "#define YYREJECT goto yyabort", 95 "#define YYACCEPT goto yyaccept", 96 "#define YYERROR goto yyerrlab", 97 "int", 98 "yyparse()", 99 "{", 100 " register int yym, yyn, yystate;", 101 "#if YYDEBUG", 102 " register char *yys;", 103 " extern char *getenv();", 104 "", 105 " if (yys = getenv(\"YYDEBUG\"))", 106 " {", 107 " yyn = *yys;", 108 " if (yyn >= '0' && yyn <= '9')", 109 " yydebug = yyn - '0';", 110 " }", 111 "#endif", 112 "", 113 " yynerrs = 0;", 114 " yyerrflag = 0;", 115 " yychar = (-1);", 116 "", 117 " yyssp = yyss;", 118 " yyvsp = yyvs;", 119 " *yyssp = yystate = 0;", 120 "", 121 "yyloop:", 122 " if (yyn = yydefred[yystate]) goto yyreduce;", 123 " if (yychar < 0)", 124 " {", 125 " if ((yychar = yylex()) < 0) yychar = 0;", 126 "#if YYDEBUG", 127 " if (yydebug)", 128 " {", 129 " yys = 0;", 130 " if (yychar <= YYMAXTOKEN) yys = yyname[yychar];", 131 " if (!yys) yys = \"illegal-symbol\";", 132 " printf(\"%sdebug: state %d, reading %d (%s)\\n\",", 133 " YYPREFIX, yystate, yychar, yys);", 134 " }", 135 "#endif", 136 " }", 137 " if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&", 138 " yyn <= YYTABLESIZE && yycheck[yyn] == yychar)", 139 " {", 140 "#if YYDEBUG", 141 " if (yydebug)", 142 " printf(\"%sdebug: state %d, shifting to state %d\\n\",", 143 " YYPREFIX, yystate, yytable[yyn]);", 144 "#endif", 145 " if (yyssp >= yyss + yystacksize - 1)", 146 " {", 147 " goto yyoverflow;", 148 " }", 149 " *++yyssp = yystate = yytable[yyn];", 150 " *++yyvsp = yylval;", 151 " yychar = (-1);", 152 " if (yyerrflag > 0) --yyerrflag;", 153 " goto yyloop;", 154 " }", 155 " if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&", 156 " yyn <= YYTABLESIZE && yycheck[yyn] == yychar)", 157 " {", 158 " yyn = yytable[yyn];", 159 " goto yyreduce;", 160 " }", 161 " if (yyerrflag) goto yyinrecovery;", 162 "#ifdef lint", 163 " goto yynewerror;", 164 "#endif", 165 "yynewerror:", 166 " yyerror(\"syntax error\");", 167 "#ifdef lint", 168 " goto yyerrlab;", 169 "#endif", 170 "yyerrlab:", 171 " ++yynerrs;", 172 "yyinrecovery:", 173 " if (yyerrflag < 3)", 174 " {", 175 " yyerrflag = 3;", 176 " for (;;)", 177 " {", 178 " if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE) >= 0 &&", 179 " yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)", 180 " {", 181 "#if YYDEBUG", 182 " if (yydebug)", 183 " printf(\"%sdebug: state %d, error recovery shifting\\", 184 " to state %d\\n\", YYPREFIX, *yyssp, yytable[yyn]);", 185 "#endif", 186 " if (yyssp >= yyss + yystacksize - 1)", 187 " {", 188 " goto yyoverflow;", 189 " }", 190 " *++yyssp = yystate = yytable[yyn];", 191 " *++yyvsp = yylval;", 192 " goto yyloop;", 193 " }", 194 " else", 195 " {", 196 "#if YYDEBUG", 197 " if (yydebug)", 198 " printf(\"%sdebug: error recovery discarding state %d\ 199 \\n\",", 200 " YYPREFIX, *yyssp);", 201 "#endif", 202 " if (yyssp <= yyss) goto yyabort;", 203 " --yyssp;", 204 " --yyvsp;", 205 " }", 206 " }", 207 " }", 208 " else", 209 " {", 210 " if (yychar == 0) goto yyabort;", 211 "#if YYDEBUG", 212 " if (yydebug)", 213 " {", 214 " yys = 0;", 215 " if (yychar <= YYMAXTOKEN) yys = yyname[yychar];", 216 " if (!yys) yys = \"illegal-symbol\";", 217 " printf(\"%sdebug: state %d, error recovery discards token %d\ 218 (%s)\\n\",", 219 " YYPREFIX, yystate, yychar, yys);", 220 " }", 221 "#endif", 222 " yychar = (-1);", 223 " goto yyloop;", 224 " }", 225 "yyreduce:", 226 "#if YYDEBUG", 227 " if (yydebug)", 228 " printf(\"%sdebug: state %d, reducing by rule %d (%s)\\n\",", 229 " YYPREFIX, yystate, yyn, yyrule[yyn]);", 230 "#endif", 231 " yym = yylen[yyn];", 232 " yyval = yyvsp[1-yym];", 233 " switch (yyn)", 234 " {", 235 0 236 }; 237 238 239 char *trailer[] = 240 { 241 " }", 242 " yyssp -= yym;", 243 " yystate = *yyssp;", 244 " yyvsp -= yym;", 245 " yym = yylhs[yyn];", 246 " if (yystate == 0 && yym == 0)", 247 " {", 248 "#if YYDEBUG", 249 " if (yydebug)", 250 " printf(\"%sdebug: after reduction, shifting from state 0 to\\", 251 " state %d\\n\", YYPREFIX, YYFINAL);", 252 "#endif", 253 " yystate = YYFINAL;", 254 " *++yyssp = YYFINAL;", 255 " *++yyvsp = yyval;", 256 " if (yychar < 0)", 257 " {", 258 " if ((yychar = yylex()) < 0) yychar = 0;", 259 "#if YYDEBUG", 260 " if (yydebug)", 261 " {", 262 " yys = 0;", 263 " if (yychar <= YYMAXTOKEN) yys = yyname[yychar];", 264 " if (!yys) yys = \"illegal-symbol\";", 265 " printf(\"%sdebug: state %d, reading %d (%s)\\n\",", 266 " YYPREFIX, YYFINAL, yychar, yys);", 267 " }", 268 "#endif", 269 " }", 270 " if (yychar == 0) goto yyaccept;", 271 " goto yyloop;", 272 " }", 273 " if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&", 274 " yyn <= YYTABLESIZE && yycheck[yyn] == yystate)", 275 " yystate = yytable[yyn];", 276 " else", 277 " yystate = yydgoto[yym];", 278 "#if YYDEBUG", 279 " if (yydebug)", 280 " printf(\"%sdebug: after reduction, shifting from state %d \\", 281 "to state %d\\n\", YYPREFIX, *yyssp, yystate);", 282 "#endif", 283 " if (yyssp >= yyss + yystacksize - 1)", 284 " {", 285 " goto yyoverflow;", 286 " }", 287 " *++yyssp = yystate;", 288 " *++yyvsp = yyval;", 289 " goto yyloop;", 290 "yyoverflow:", 291 " yyerror(\"yacc stack overflow\");", 292 "yyabort:", 293 " return (1);", 294 "yyaccept:", 295 " return (0);", 296 "}", 297 0 298 }; 299 300 301 write_section(section) 302 char *section[]; 303 { 304 register int c; 305 register int i; 306 register char *s; 307 register FILE *f; 308 309 f = code_file; 310 for (i = 0; s = section[i]; ++i) 311 { 312 ++outline; 313 while (c = *s) 314 { 315 putc(c, f); 316 ++s; 317 } 318 putc('\n', f); 319 } 320 } 321