2 static char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93";
7 #define yyclearin (yychar=(-1))
8 #define yyerrok (yyerrflag=0)
9 #define YYRECOVERING (yyerrflag!=0)
11 /* SCCS Id: @(#)dgn_comp.c 3.4 1996/06/22 */
12 /* Copyright (c) 1989 by Jean-Christophe Collet */
13 /* Copyright (c) 1990 by M. Stephenson */
14 /* NetHack may be freely redistributed. See license for details. */
17 * This file contains the Dungeon Compiler code
20 /* In case we're using bison in AIX. This definition must be
21 * placed before any other C-language construct in the file
22 * excluding comments and preprocessor directives (thanks IBM
23 * for this wonderful feature...).
25 * Note: some cpps barf on this 'undefined control' (#pragma).
26 * Addition of the leading space seems to prevent barfage for now,
27 * and AIX will still see the directive in its non-standard locale.
31 #pragma alloca /* keep leading space! */
38 void FDECL(yyerror, (const char *));
39 void FDECL(yywarning, (const char *));
42 int FDECL(getchain, (char *));
43 int NDECL(check_dungeon);
44 int NDECL(check_branch);
45 int NDECL(check_level);
46 void NDECL(init_dungeon);
47 void NDECL(init_branch);
48 void NDECL(init_level);
49 void NDECL(output_dgn);
51 #define Free(ptr) free((genericptr_t)ptr)
56 # define memset(addr,val,len) setmem(addr,len,val)
62 static struct couple couple;
63 static struct tmpdungeon tmpdungeon[MAXDUNGEON];
64 static struct tmplevel tmplevel[LEV_LIMIT];
65 static struct tmpbranch tmpbranch[BRANCH_LIMIT];
67 static int in_dungeon = 0, n_dgns = -1, n_levs = -1, n_brs = -1;
69 extern int fatal_error;
70 extern const char *fname;
71 extern FILE *yyin, *yyout; /* from dgn_lex.c */
85 #define RNDCHLEVEL 264
86 #define UP_OR_DOWN 265
88 #define DESCRIPTION 267
89 #define DESCRIPTOR 268
100 short yylhs[] = { -1,
101 0, 0, 5, 5, 6, 6, 6, 6, 7, 1,
102 1, 8, 8, 8, 12, 13, 15, 15, 14, 10,
103 10, 10, 10, 10, 16, 16, 17, 17, 18, 18,
104 19, 19, 20, 20, 9, 9, 22, 23, 3, 3,
105 3, 3, 3, 2, 2, 4, 21, 11,
108 0, 1, 1, 2, 1, 1, 1, 1, 6, 0,
109 1, 1, 1, 1, 3, 1, 3, 3, 3, 1,
110 1, 1, 1, 1, 6, 7, 7, 8, 3, 3,
111 7, 8, 8, 9, 1, 1, 7, 8, 0, 1,
112 1, 1, 1, 0, 1, 1, 5, 5,
114 short yydefred[] = { 0,
115 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
116 0, 0, 0, 0, 0, 3, 5, 6, 7, 8,
117 12, 13, 14, 16, 20, 21, 22, 23, 24, 35,
118 36, 0, 0, 0, 0, 0, 0, 0, 0, 0,
119 0, 0, 0, 0, 4, 0, 0, 0, 0, 0,
120 0, 0, 19, 17, 29, 18, 30, 15, 46, 0,
121 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
122 0, 0, 0, 0, 0, 0, 11, 9, 0, 40,
123 41, 42, 43, 0, 0, 0, 0, 0, 0, 0,
124 0, 45, 37, 0, 27, 0, 0, 0, 0, 0,
125 38, 28, 33, 0, 48, 47, 34,
127 short yydgoto[] = { 14,
128 78, 93, 84, 60, 15, 16, 17, 18, 19, 20,
129 68, 21, 22, 23, 24, 25, 26, 27, 28, 29,
132 short yysindex[] = { -237,
133 -46, -45, -44, -39, -38, -30, -22, -21, -20, -19,
134 -18, -17, -16, 0, -237, 0, 0, 0, 0, 0,
135 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
136 0, -262, -234, -233, -232, -230, -229, -228, -227, -217,
137 -216, -215, -214, -202, 0, -221, -7, -219, -221, -221,
138 -221, -221, 0, 0, 0, 0, 0, 0, 0, 19,
139 20, 21, -2, -1, -212, -211, -190, -189, -188, -271,
140 19, 20, 20, 27, 28, 29, 0, 0, 30, 0,
141 0, 0, 0, -193, -271, -182, -180, 19, 19, -179,
142 -178, 0, 0, -193, 0, -177, -176, -175, 42, 43,
143 0, 0, 0, -172, 0, 0, 0,
145 short yyrindex[] = { 86,
146 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
147 0, 0, 0, 0, 87, 0, 0, 0, 0, 0,
148 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
149 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
150 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
151 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
152 0, 0, 0, 0, 0, 0, 0, 16, 0, 1,
153 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
154 0, 0, 0, 31, 1, 46, 0, 0, 0, 0,
155 0, 0, 0, 31, 0, 61, 76, 0, 0, 0,
156 0, 0, 0, 91, 0, 0, 0,
158 short yygindex[] = { 0,
159 0, -6, 4, -43, 0, 75, 0, 0, 0, 0,
160 -71, 0, 0, 0, 0, 0, 0, 0, 0, 0,
163 #define YYTABLESIZE 363
164 short yytable[] = { 85,
165 39, 80, 81, 82, 83, 63, 64, 65, 66, 86,
166 87, 32, 33, 34, 46, 10, 97, 98, 35, 36,
167 1, 2, 3, 4, 5, 6, 7, 37, 8, 9,
168 44, 10, 11, 12, 13, 38, 39, 40, 41, 42,
169 43, 44, 47, 48, 49, 25, 50, 51, 52, 53,
170 54, 55, 56, 57, 58, 59, 61, 62, 67, 69,
171 26, 72, 73, 71, 74, 75, 76, 77, 79, 88,
172 89, 92, 90, 91, 95, 31, 96, 99, 100, 102,
173 103, 104, 105, 106, 107, 1, 2, 101, 94, 45,
174 32, 0, 0, 0, 0, 0, 0, 0, 0, 0,
175 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
176 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
177 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
178 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
179 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
180 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
181 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
182 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
183 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
184 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
185 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
186 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
187 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
188 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
189 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
190 0, 0, 0, 0, 0, 0, 0, 0, 39, 39,
191 39, 39, 39, 39, 39, 39, 39, 39, 0, 39,
192 39, 39, 39, 10, 10, 10, 10, 10, 10, 10,
193 0, 10, 10, 0, 10, 10, 10, 10, 44, 44,
194 44, 44, 44, 44, 44, 0, 44, 44, 0, 44,
195 44, 44, 44, 25, 25, 25, 25, 25, 25, 25,
196 0, 25, 25, 0, 25, 25, 25, 25, 26, 26,
197 26, 26, 26, 26, 26, 0, 26, 26, 0, 26,
198 26, 26, 26, 31, 31, 31, 31, 31, 31, 31,
199 0, 31, 31, 0, 31, 31, 31, 31, 32, 32,
200 32, 32, 32, 32, 32, 0, 32, 32, 0, 32,
203 short yycheck[] = { 71,
204 0, 273, 274, 275, 276, 49, 50, 51, 52, 72,
205 73, 58, 58, 58, 277, 0, 88, 89, 58, 58,
206 258, 259, 260, 261, 262, 263, 264, 58, 266, 267,
207 0, 269, 270, 271, 272, 58, 58, 58, 58, 58,
208 58, 58, 277, 277, 277, 0, 277, 277, 277, 277,
209 268, 268, 268, 268, 257, 277, 64, 277, 40, 40,
210 0, 64, 64, 43, 277, 277, 257, 257, 257, 43,
211 43, 265, 44, 44, 257, 0, 257, 257, 257, 257,
212 257, 257, 41, 41, 257, 0, 0, 94, 85, 15,
213 0, -1, -1, -1, -1, -1, -1, -1, -1, -1,
214 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
215 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
216 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
217 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
218 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
219 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
220 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
221 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
222 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
223 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
224 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
225 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
226 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
227 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
228 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
229 -1, -1, -1, -1, -1, -1, -1, -1, 258, 259,
230 260, 261, 262, 263, 264, 265, 266, 267, -1, 269,
231 270, 271, 272, 258, 259, 260, 261, 262, 263, 264,
232 -1, 266, 267, -1, 269, 270, 271, 272, 258, 259,
233 260, 261, 262, 263, 264, -1, 266, 267, -1, 269,
234 270, 271, 272, 258, 259, 260, 261, 262, 263, 264,
235 -1, 266, 267, -1, 269, 270, 271, 272, 258, 259,
236 260, 261, 262, 263, 264, -1, 266, 267, -1, 269,
237 270, 271, 272, 258, 259, 260, 261, 262, 263, 264,
238 -1, 266, 267, -1, 269, 270, 271, 272, 258, 259,
239 260, 261, 262, 263, 264, -1, 266, 267, -1, 269,
246 #define YYMAXTOKEN 277
249 "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,
250 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,
251 "'@'",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,
252 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,
253 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,
254 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,
255 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,"INTEGER",
256 "A_DUNGEON","BRANCH","CHBRANCH","LEVEL","RNDLEVEL","CHLEVEL","RNDCHLEVEL",
257 "UP_OR_DOWN","PROTOFILE","DESCRIPTION","DESCRIPTOR","LEVELDESC","ALIGNMENT",
258 "LEVALIGN","ENTRY","STAIR","NO_UP","NO_DOWN","PORTAL","STRING",
264 "dungeons : dungeon",
265 "dungeons : dungeons dungeon",
266 "dungeon : dungeonline",
267 "dungeon : dungeondesc",
268 "dungeon : branches",
270 "dungeonline : A_DUNGEON ':' STRING bones_tag rcouple optional_int",
272 "optional_int : INTEGER",
273 "dungeondesc : entry",
274 "dungeondesc : descriptions",
275 "dungeondesc : prototype",
276 "entry : ENTRY ':' INTEGER",
277 "descriptions : desc",
278 "desc : DESCRIPTION ':' DESCRIPTOR",
279 "desc : ALIGNMENT ':' DESCRIPTOR",
280 "prototype : PROTOFILE ':' STRING",
286 "level1 : LEVEL ':' STRING bones_tag '@' acouple",
287 "level1 : RNDLEVEL ':' STRING bones_tag '@' acouple INTEGER",
288 "level2 : LEVEL ':' STRING bones_tag '@' acouple INTEGER",
289 "level2 : RNDLEVEL ':' STRING bones_tag '@' acouple INTEGER INTEGER",
290 "levdesc : LEVELDESC ':' DESCRIPTOR",
291 "levdesc : LEVALIGN ':' DESCRIPTOR",
292 "chlevel1 : CHLEVEL ':' STRING bones_tag STRING '+' rcouple",
293 "chlevel1 : RNDCHLEVEL ':' STRING bones_tag STRING '+' rcouple INTEGER",
294 "chlevel2 : CHLEVEL ':' STRING bones_tag STRING '+' rcouple INTEGER",
295 "chlevel2 : RNDCHLEVEL ':' STRING bones_tag STRING '+' rcouple INTEGER INTEGER",
297 "branches : chbranch",
298 "branch : BRANCH ':' STRING '@' acouple branch_type direction",
299 "chbranch : CHBRANCH ':' STRING STRING '+' rcouple branch_type direction",
301 "branch_type : STAIR",
302 "branch_type : NO_UP",
303 "branch_type : NO_DOWN",
304 "branch_type : PORTAL",
306 "direction : UP_OR_DOWN",
307 "bones_tag : STRING",
308 "acouple : '(' INTEGER ',' INTEGER ')'",
309 "rcouple : '(' INTEGER ',' INTEGER ')'",
314 #define YYMAXDEPTH YYSTACKSIZE
317 #define YYSTACKSIZE YYMAXDEPTH
319 #define YYSTACKSIZE 500
320 #define YYMAXDEPTH 500
331 short yyss[YYSTACKSIZE];
332 YYSTYPE yyvs[YYSTACKSIZE];
333 #define yystacksize YYSTACKSIZE
338 if(++n_dgns > MAXDUNGEON) {
339 (void) fprintf(stderr, "FATAL - Too many dungeons (limit: %d).\n",
341 (void) fprintf(stderr, "To increase the limit edit MAXDUNGEON in global.h\n");
346 tmpdungeon[n_dgns].lev.base = 0;
347 tmpdungeon[n_dgns].lev.rand = 0;
348 tmpdungeon[n_dgns].chance = 100;
349 Strcpy(tmpdungeon[n_dgns].name, "");
350 Strcpy(tmpdungeon[n_dgns].protoname, "");
351 tmpdungeon[n_dgns].flags = 0;
352 tmpdungeon[n_dgns].levels = 0;
353 tmpdungeon[n_dgns].branches = 0;
354 tmpdungeon[n_dgns].entry_lev = 0;
360 if(++n_levs > LEV_LIMIT) {
362 yyerror("FATAL - Too many special levels defined.");
365 tmplevel[n_levs].lev.base = 0;
366 tmplevel[n_levs].lev.rand = 0;
367 tmplevel[n_levs].chance = 100;
368 tmplevel[n_levs].rndlevs = 0;
369 tmplevel[n_levs].flags = 0;
370 Strcpy(tmplevel[n_levs].name, "");
371 tmplevel[n_levs].chain = -1;
377 if(++n_brs > BRANCH_LIMIT) {
379 yyerror("FATAL - Too many special levels defined.");
382 tmpbranch[n_brs].lev.base = 0;
383 tmpbranch[n_brs].lev.rand = 0;
384 Strcpy(tmpbranch[n_brs].name, "");
385 tmpbranch[n_brs].chain = -1;
396 for(i = n_levs - tmpdungeon[n_dgns].levels + 1; i <= n_levs; i++)
397 if(!strcmp(tmplevel[i].name, s)) return i;
399 yyerror("Can't locate the specified chain level.");
406 * Consistancy checking routines:
408 * - A dungeon must have a unique name.
409 * - A dungeon must have a originating "branch" command
410 * (except, of course, for the first dungeon).
411 * - A dungeon must have a proper depth (at least (1, 0)).
419 for(i = 0; i < n_dgns; i++)
420 if(!strcmp(tmpdungeon[i].name, tmpdungeon[n_dgns].name)) {
421 yyerror("Duplicate dungeon name.");
426 for(i = 0; i < n_brs - tmpdungeon[n_dgns].branches; i++) {
427 if(!strcmp(tmpbranch[i].name, tmpdungeon[n_dgns].name)) break;
429 if(i >= n_brs - tmpdungeon[n_dgns].branches) {
430 yyerror("Dungeon cannot be reached.");
435 if(tmpdungeon[n_dgns].lev.base <= 0 ||
436 tmpdungeon[n_dgns].lev.rand < 0) {
437 yyerror("Invalid dungeon depth specified.");
444 * - A level must have a unique level name.
445 * - If chained, the level used as reference for the chain
446 * must be in this dungeon, must be previously defined, and
447 * the level chained from must be "non-probabilistic" (ie.
448 * have a 100% chance of existing).
457 yyerror("Level defined outside of dungeon.");
461 for(i = 0; i < n_levs; i++)
462 if(!strcmp(tmplevel[i].name, tmplevel[n_levs].name)) {
463 yyerror("Duplicate level name.");
467 if(tmplevel[i].chain == -2) {
468 yyerror("Invaild level chain reference.");
470 } else if(tmplevel[i].chain != -1) { /* there is a chain */
471 /* KMH -- tmplevel[tmpbranch[i].chain].chance was in error */
472 if(tmplevel[tmplevel[i].chain].chance != 100) {
473 yyerror("Level cannot chain from a probabilistic level.");
475 } else if(tmplevel[i].chain == n_levs) {
476 yyerror("A level cannot chain to itself!");
484 * - A branch may not branch backwards - to avoid branch loops.
485 * - A branch name must be unique.
486 * (ie. You can only have one entry point to each dungeon).
487 * - If chained, the level used as reference for the chain
488 * must be in this dungeon, must be previously defined, and
489 * the level chained from must be "non-probabilistic" (ie.
490 * have a 100% chance of existing).
499 yyerror("Branch defined outside of dungeon.");
503 for(i = 0; i < n_dgns; i++)
504 if(!strcmp(tmpdungeon[i].name, tmpbranch[n_brs].name)) {
506 yyerror("Reverse branching not allowed.");
510 if(tmpbranch[i].chain == -2) {
512 yyerror("Invaild branch chain reference.");
514 } else if(tmpbranch[i].chain != -1) { /* it is chained */
516 if(tmplevel[tmpbranch[i].chain].chance != 100) {
517 yyerror("Branch cannot chain from a probabilistic level.");
525 * Output the dungon definition into a file.
527 * The file will have the following format:
529 * [ nethack version ID ]
530 * [ number of dungeons ]
531 * [ first dungeon struct ]
532 * [ levels for the first dungeon ]
534 * [ branches for the first dungeon ]
536 * [ second dungeon struct ]
543 int nd, cl = 0, nl = 0,
545 static struct version_info version_data = {
546 VERSION_NUMBER, VERSION_FEATURES,
547 VERSION_SANITY1, VERSION_SANITY2
551 yyerror("FATAL - no dungeons were defined.");
555 if (fwrite((char *)&version_data, sizeof version_data, 1, yyout) != 1) {
556 yyerror("FATAL - output failure.");
560 (void) fwrite((char *)&n_dgns, sizeof(int), 1, yyout);
561 for (nd = 0; nd < n_dgns; nd++) {
562 (void) fwrite((char *)&tmpdungeon[nd], sizeof(struct tmpdungeon),
565 nl += tmpdungeon[nd].levels;
567 (void) fwrite((char *)&tmplevel[cl], sizeof(struct tmplevel),
570 nb += tmpdungeon[nd].branches;
572 (void) fwrite((char *)&tmpbranch[cb], sizeof(struct tmpbranch),
575 /* apparently necessary for Think C 5.x, otherwise harmless */
576 (void) fflush(yyout);
580 #define YYABORT goto yyabort
581 #define YYREJECT goto yyabort
582 #define YYACCEPT goto yyaccept
583 #define YYERROR goto yyerrlab
587 register int yym, yyn, yystate;
590 extern char *getenv();
592 if ((yys = getenv("YYDEBUG")) != 0)
595 if (yyn >= '0' && yyn <= '9')
606 *yyssp = yystate = 0;
609 if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
612 if ((yychar = yylex()) < 0) yychar = 0;
617 if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
618 if (!yys) yys = "illegal-symbol";
619 printf("%sdebug: state %d, reading %d (%s)\n",
620 YYPREFIX, yystate, yychar, yys);
624 if ((yyn = yysindex[yystate]) != 0 && (yyn += yychar) >= 0 &&
625 yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
629 printf("%sdebug: state %d, shifting to state %d\n",
630 YYPREFIX, yystate, yytable[yyn]);
632 if (yyssp >= yyss + yystacksize - 1)
636 *++yyssp = yystate = yytable[yyn];
639 if (yyerrflag > 0) --yyerrflag;
642 if ((yyn = yyrindex[yystate]) != 0 && (yyn += yychar) >= 0 &&
643 yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
648 if (yyerrflag) goto yyinrecovery;
653 yyerror("syntax error");
665 if ((yyn = yysindex[*yyssp]) != 0 && (yyn += YYERRCODE) >= 0 &&
666 yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
670 printf("%sdebug: state %d, error recovery shifting\
671 to state %d\n", YYPREFIX, *yyssp, yytable[yyn]);
673 if (yyssp >= yyss + yystacksize - 1)
677 *++yyssp = yystate = yytable[yyn];
685 printf("%sdebug: error recovery discarding state %d\n",
688 if (yyssp <= yyss) goto yyabort;
696 if (yychar == 0) goto yyabort;
701 if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
702 if (!yys) yys = "illegal-symbol";
703 printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
704 YYPREFIX, yystate, yychar, yys);
713 printf("%sdebug: state %d, reducing by rule %d (%s)\n",
714 YYPREFIX, yystate, yyn, yyrule[yyn]);
717 yyval = yyvsp[1-yym];
728 Strcpy(tmpdungeon[n_dgns].name, yyvsp[-3].str);
729 tmpdungeon[n_dgns].boneschar = (char)yyvsp[-2].i;
730 tmpdungeon[n_dgns].lev.base = couple.base;
731 tmpdungeon[n_dgns].lev.rand = couple.rand;
732 tmpdungeon[n_dgns].chance = yyvsp[0].i;
743 yyval.i = yyvsp[0].i;
748 tmpdungeon[n_dgns].entry_lev = yyvsp[0].i;
753 if(yyvsp[0].i <= TOWN || yyvsp[0].i >= D_ALIGN_CHAOTIC)
754 yyerror("Illegal description - ignoring!");
756 tmpdungeon[n_dgns].flags |= yyvsp[0].i ;
761 if(yyvsp[0].i && yyvsp[0].i < D_ALIGN_CHAOTIC)
762 yyerror("Illegal alignment - ignoring!");
764 tmpdungeon[n_dgns].flags |= yyvsp[0].i ;
769 Strcpy(tmpdungeon[n_dgns].protoname, yyvsp[0].str);
776 Strcpy(tmplevel[n_levs].name, yyvsp[-3].str);
777 tmplevel[n_levs].boneschar = (char)yyvsp[-2].i;
778 tmplevel[n_levs].lev.base = couple.base;
779 tmplevel[n_levs].lev.rand = couple.rand;
780 tmpdungeon[n_dgns].levels++;
787 Strcpy(tmplevel[n_levs].name, yyvsp[-4].str);
788 tmplevel[n_levs].boneschar = (char)yyvsp[-3].i;
789 tmplevel[n_levs].lev.base = couple.base;
790 tmplevel[n_levs].lev.rand = couple.rand;
791 tmplevel[n_levs].rndlevs = yyvsp[0].i;
792 tmpdungeon[n_dgns].levels++;
799 Strcpy(tmplevel[n_levs].name, yyvsp[-4].str);
800 tmplevel[n_levs].boneschar = (char)yyvsp[-3].i;
801 tmplevel[n_levs].lev.base = couple.base;
802 tmplevel[n_levs].lev.rand = couple.rand;
803 tmplevel[n_levs].chance = yyvsp[0].i;
804 tmpdungeon[n_dgns].levels++;
811 Strcpy(tmplevel[n_levs].name, yyvsp[-5].str);
812 tmplevel[n_levs].boneschar = (char)yyvsp[-4].i;
813 tmplevel[n_levs].lev.base = couple.base;
814 tmplevel[n_levs].lev.rand = couple.rand;
815 tmplevel[n_levs].chance = yyvsp[-1].i;
816 tmplevel[n_levs].rndlevs = yyvsp[0].i;
817 tmpdungeon[n_dgns].levels++;
823 if(yyvsp[0].i >= D_ALIGN_CHAOTIC)
824 yyerror("Illegal description - ignoring!");
826 tmplevel[n_levs].flags |= yyvsp[0].i ;
831 if(yyvsp[0].i && yyvsp[0].i < D_ALIGN_CHAOTIC)
832 yyerror("Illegal alignment - ignoring!");
834 tmplevel[n_levs].flags |= yyvsp[0].i ;
840 Strcpy(tmplevel[n_levs].name, yyvsp[-4].str);
841 tmplevel[n_levs].boneschar = (char)yyvsp[-3].i;
842 tmplevel[n_levs].chain = getchain(yyvsp[-2].str);
843 tmplevel[n_levs].lev.base = couple.base;
844 tmplevel[n_levs].lev.rand = couple.rand;
845 if(!check_level()) n_levs--;
846 else tmpdungeon[n_dgns].levels++;
854 Strcpy(tmplevel[n_levs].name, yyvsp[-5].str);
855 tmplevel[n_levs].boneschar = (char)yyvsp[-4].i;
856 tmplevel[n_levs].chain = getchain(yyvsp[-3].str);
857 tmplevel[n_levs].lev.base = couple.base;
858 tmplevel[n_levs].lev.rand = couple.rand;
859 tmplevel[n_levs].rndlevs = yyvsp[0].i;
860 if(!check_level()) n_levs--;
861 else tmpdungeon[n_dgns].levels++;
869 Strcpy(tmplevel[n_levs].name, yyvsp[-5].str);
870 tmplevel[n_levs].boneschar = (char)yyvsp[-4].i;
871 tmplevel[n_levs].chain = getchain(yyvsp[-3].str);
872 tmplevel[n_levs].lev.base = couple.base;
873 tmplevel[n_levs].lev.rand = couple.rand;
874 tmplevel[n_levs].chance = yyvsp[0].i;
875 if(!check_level()) n_levs--;
876 else tmpdungeon[n_dgns].levels++;
884 Strcpy(tmplevel[n_levs].name, yyvsp[-6].str);
885 tmplevel[n_levs].boneschar = (char)yyvsp[-5].i;
886 tmplevel[n_levs].chain = getchain(yyvsp[-4].str);
887 tmplevel[n_levs].lev.base = couple.base;
888 tmplevel[n_levs].lev.rand = couple.rand;
889 tmplevel[n_levs].chance = yyvsp[-1].i;
890 tmplevel[n_levs].rndlevs = yyvsp[0].i;
891 if(!check_level()) n_levs--;
892 else tmpdungeon[n_dgns].levels++;
900 Strcpy(tmpbranch[n_brs].name, yyvsp[-4].str);
901 tmpbranch[n_brs].lev.base = couple.base;
902 tmpbranch[n_brs].lev.rand = couple.rand;
903 tmpbranch[n_brs].type = yyvsp[-1].i;
904 tmpbranch[n_brs].up = yyvsp[0].i;
905 if(!check_branch()) n_brs--;
906 else tmpdungeon[n_dgns].branches++;
913 Strcpy(tmpbranch[n_brs].name, yyvsp[-5].str);
914 tmpbranch[n_brs].chain = getchain(yyvsp[-4].str);
915 tmpbranch[n_brs].lev.base = couple.base;
916 tmpbranch[n_brs].lev.rand = couple.rand;
917 tmpbranch[n_brs].type = yyvsp[-1].i;
918 tmpbranch[n_brs].up = yyvsp[0].i;
919 if(!check_branch()) n_brs--;
920 else tmpdungeon[n_dgns].branches++;
927 yyval.i = TBR_STAIR; /* two way stair */
932 yyval.i = TBR_STAIR; /* two way stair */
937 yyval.i = TBR_NO_UP; /* no up staircase */
942 yyval.i = TBR_NO_DOWN; /* no down staircase */
947 yyval.i = TBR_PORTAL; /* portal connection */
952 yyval.i = 0; /* defaults to down */
957 yyval.i = yyvsp[0].i;
962 char *p = yyvsp[0].str;
963 if (strlen(p) != 1) {
964 if (strcmp(p, "none") != 0)
965 yyerror("Bones marker must be a single char, or \"none\"!");
974 if (yyvsp[-3].i < -MAXLEVEL || yyvsp[-3].i > MAXLEVEL) {
975 yyerror("Abs base out of dlevel range - zeroing!");
976 couple.base = couple.rand = 0;
977 } else if (yyvsp[-1].i < -1 ||
978 ((yyvsp[-3].i < 0) ? (MAXLEVEL + yyvsp[-3].i + yyvsp[-1].i + 1) > MAXLEVEL :
979 (yyvsp[-3].i + yyvsp[-1].i) > MAXLEVEL)) {
980 yyerror("Abs range out of dlevel range - zeroing!");
981 couple.base = couple.rand = 0;
983 couple.base = yyvsp[-3].i;
984 couple.rand = yyvsp[-1].i;
990 if (yyvsp[-3].i < -MAXLEVEL || yyvsp[-3].i > MAXLEVEL) {
991 yyerror("Rel base out of dlevel range - zeroing!");
992 couple.base = couple.rand = 0;
994 couple.base = yyvsp[-3].i;
995 couple.rand = yyvsp[-1].i;
1004 if (yystate == 0 && yym == 0)
1008 printf("%sdebug: after reduction, shifting from state 0 to\
1009 state %d\n", YYPREFIX, YYFINAL);
1016 if ((yychar = yylex()) < 0) yychar = 0;
1021 if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
1022 if (!yys) yys = "illegal-symbol";
1023 printf("%sdebug: state %d, reading %d (%s)\n",
1024 YYPREFIX, YYFINAL, yychar, yys);
1028 if (yychar == 0) goto yyaccept;
1031 if ((yyn = yygindex[yym]) != 0 && (yyn += yystate) >= 0 &&
1032 yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
1033 yystate = yytable[yyn];
1035 yystate = yydgoto[yym];
1038 printf("%sdebug: after reduction, shifting from state %d \
1039 to state %d\n", YYPREFIX, *yyssp, yystate);
1041 if (yyssp >= yyss + yystacksize - 1)
1049 yyerror("yacc stack overflow");