home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / gnu / nethack-3.1 / sys / share / dgn_yacc.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-01-18  |  31.8 KB  |  1,247 lines

  1. extern char *malloc(), *realloc();
  2.  
  3. # line 2 "dgn_comp.y"
  4. /*    SCCS Id: @(#)dgn_comp.c    3.1    93/01/17    */
  5. /*    Copyright (c) 1989 by Jean-Christophe Collet */
  6. /*    Copyright (c) 1990 by M. Stephenson                  */
  7. /* NetHack may be freely redistributed.  See license for details. */
  8.  
  9. /*
  10.  * This file contains the Dungeon Compiler code
  11.  */
  12.  
  13. /* In case we're using bison in AIX.  This definition must be
  14.  * placed before any other C-language construct in the file
  15.  * excluding comments and preprocessor directives (thanks IBM
  16.  * for this wonderful feature...).
  17.  *
  18.  * Note: some cpps barf on this 'undefined control' (#pragma).
  19.  * Addition of the leading space seems to prevent barfage for now,
  20.  * and AIX will still see the directive in its non-standard locale.
  21.  */
  22.  
  23. #ifdef _AIX
  24.  #pragma alloca        /* keep leading space! */
  25. #endif
  26.  
  27. #include "config.h"
  28. #include "dgn_file.h"
  29.  
  30. void FDECL(yyerror, (char *));
  31. void FDECL(yywarning, (char *));
  32. int NDECL(yylex);
  33. int NDECL(yyparse);
  34. int FDECL(getchain, (char *));
  35. int NDECL(check_dungeon);
  36. int NDECL(check_branch);
  37. int NDECL(check_level);
  38. void NDECL(init_dungeon);
  39. void NDECL(init_branch);
  40. void NDECL(init_level);
  41. void NDECL(output_dgn);
  42.  
  43. #ifdef AMIGA
  44. # undef    printf
  45. #ifndef    LATTICE
  46. # define    memset(addr,val,len)    setmem(addr,len,val)
  47. #endif
  48. #endif
  49.  
  50. #ifdef MICRO
  51. # undef exit
  52. extern void FDECL(exit, (int));
  53. #endif
  54.  
  55. #undef NULL
  56.  
  57. #define ERR        (-1)
  58.  
  59. static struct couple couple;
  60. static struct tmpdungeon tmpdungeon[MAXDUNGEON];
  61. static struct tmplevel tmplevel[LEV_LIMIT];
  62. static struct tmpbranch tmpbranch[BRANCH_LIMIT];
  63.  
  64. static int in_dungeon = 0, n_dgns = -1, n_levs = -1, n_brs = -1;
  65.  
  66. extern int fatal_error;
  67. extern char* fname;
  68.  
  69.  
  70. # line 69 "dgn_comp.y"
  71. typedef union 
  72. {
  73.     int    i;
  74.     char*    str;
  75. } YYSTYPE;
  76. # define INTEGER 257
  77. # define A_DUNGEON 258
  78. # define BRANCH 259
  79. # define CHBRANCH 260
  80. # define LEVEL 261
  81. # define RNDLEVEL 262
  82. # define CHLEVEL 263
  83. # define RNDCHLEVEL 264
  84. # define UP_OR_DOWN 265
  85. # define PROTOFILE 266
  86. # define DESCRIPTION 267
  87. # define DESCRIPTOR 268
  88. # define LEVELDESC 269
  89. # define ALIGNMENT 270
  90. # define LEVALIGN 271
  91. # define ENTRY 272
  92. # define STAIR 273
  93. # define NO_UP 274
  94. # define NO_DOWN 275
  95. # define PORTAL 276
  96. # define STRING 277
  97. #define yyclearin yychar = -1
  98. #define yyerrok yyerrflag = 0
  99. extern int yychar;
  100. extern int yyerrflag;
  101. #ifndef YYMAXDEPTH
  102. #define YYMAXDEPTH 150
  103. #endif
  104. YYSTYPE yylval, yyval;
  105. # define YYERRCODE 256
  106.  
  107. # line 450 "dgn_comp.y"
  108.  
  109.  
  110. void
  111. init_dungeon()
  112. {
  113.     if(++n_dgns > MAXDUNGEON) {
  114.         fprintf(stderr, "FATAL - Too many dungeons (limit: %d).\n",
  115.             MAXDUNGEON);
  116.         fprintf(stderr, "To increase the limit edit MAXDUNGEON in global.h\n");
  117.         exit(1);
  118.     }
  119.  
  120.     in_dungeon = 1;
  121.     tmpdungeon[n_dgns].lev.base = 0;
  122.     tmpdungeon[n_dgns].lev.rand = 0;
  123.     tmpdungeon[n_dgns].chance = 100;
  124.     strcpy(tmpdungeon[n_dgns].name, "");
  125.     strcpy(tmpdungeon[n_dgns].protoname, "");
  126.     tmpdungeon[n_dgns].flags = 0;
  127.     tmpdungeon[n_dgns].levels = 0;
  128.     tmpdungeon[n_dgns].branches = 0;
  129.     tmpdungeon[n_dgns].entry_lev = 0;
  130. }
  131.  
  132. void
  133. init_level()
  134. {
  135.     if(++n_levs > LEV_LIMIT) {
  136.  
  137.         yyerror("FATAL - Too many special levels defined.");
  138.         exit(1);
  139.     }
  140.     tmplevel[n_levs].lev.base = 0;
  141.     tmplevel[n_levs].lev.rand = 0;
  142.     tmplevel[n_levs].chance = 100;
  143.     tmplevel[n_levs].rndlevs = 0;
  144.     tmplevel[n_levs].flags = 0;
  145.     strcpy(tmplevel[n_levs].name, "");
  146.     tmplevel[n_levs].chain = -1;
  147. }
  148.  
  149. void
  150. init_branch()
  151. {
  152.     if(++n_brs > BRANCH_LIMIT) {
  153.  
  154.         yyerror("FATAL - Too many special levels defined.");
  155.         exit(1);
  156.     }
  157.     tmpbranch[n_brs].lev.base = 0;
  158.     tmpbranch[n_brs].lev.rand = 0;
  159.     strcpy(tmpbranch[n_brs].name, "");
  160.     tmpbranch[n_brs].chain = -1;
  161. }
  162.  
  163. int
  164. getchain(s)
  165.     char    *s;
  166. {
  167.     int i;
  168.  
  169.     if(strlen(s)) {
  170.  
  171.         for(i = n_levs - tmpdungeon[n_dgns].levels + 1; i <= n_levs; i++)
  172.         if(!strcmp(tmplevel[i].name, s)) return i;
  173.  
  174.         yyerror("Can't locate the specified chain level.");
  175.         return(-2);
  176.     }
  177.     return(-1);
  178. }
  179.  
  180. /*
  181.  *    Consistancy checking routines:
  182.  *
  183.  *    - A dungeon must have a unique name.
  184.  *    - A dungeon must have a originating "branch" command
  185.  *      (except, of course, for the first dungeon).
  186.  *    - A dungeon must have a proper depth (at least (1, 0)).
  187.  */
  188.  
  189. int
  190. check_dungeon()
  191. {
  192.     int i;
  193.  
  194.     for(i = 0; i < n_dgns; i++)
  195.         if(!strcmp(tmpdungeon[i].name, tmpdungeon[n_dgns].name)) {
  196.         yyerror("Duplicate dungeon name.");
  197.         return(0);
  198.         }
  199.  
  200.     if(n_dgns)
  201.       for(i = 0; i < n_brs - tmpdungeon[n_dgns].branches; i++) {
  202.         if(!strcmp(tmpbranch[i].name, tmpdungeon[n_dgns].name)) break;
  203.  
  204.         if(i >= n_brs - tmpdungeon[n_dgns].branches) {
  205.         yyerror("Dungeon cannot be reached.");
  206.         return(0);
  207.         }
  208.       }
  209.  
  210.     if(tmpdungeon[n_dgns].lev.base <= 0 ||
  211.        tmpdungeon[n_dgns].lev.rand < 0) {
  212.         yyerror("Invalid dungeon depth specified.");
  213.         return(0);
  214.     }
  215.     return(1);    /* OK */
  216. }
  217.  
  218. /*
  219.  *    - A level must have a unique level name.
  220.  *    - If chained, the level used as reference for the chain
  221.  *      must be in this dungeon, must be previously defined, and
  222.  *      the level chained from must be "non-probabalistic" (ie.
  223.  *      have a 100% chance of existing).
  224.  */
  225.  
  226. int
  227. check_level()
  228. {
  229.     int i;
  230.  
  231.     if(!in_dungeon) {
  232.         yyerror("Level defined outside of dungeon.");
  233.         return(0);
  234.     }
  235.  
  236.     for(i = 0; i < n_levs; i++)
  237.         if(!strcmp(tmplevel[i].name, tmplevel[n_levs].name)) {
  238.         yyerror("Duplicate level name.");
  239.         return(0);
  240.         }
  241.  
  242.     if(tmplevel[i].chain == -2) {
  243.         yyerror("Invaild level chain reference.");
  244.         return(0);
  245.     } else if(tmplevel[i].chain != -1) {    /* there is a chain */
  246.         if(tmplevel[tmpbranch[i].chain].chance != 100) {
  247.         yyerror("Level cannot chain from a probabalistic level.");
  248.         return(0);
  249.         } else if(tmplevel[i].chain == n_levs) {
  250.         yyerror("A level cannot chain to itself!");
  251.         return(0);
  252.         }
  253.     }
  254.     return(1);    /* OK */
  255. }
  256.  
  257. /*
  258.  *    - A branch may not branch backwards - to avoid branch loops.
  259.  *    - A branch name must be unique.
  260.  *      (ie. You can only have one entry point to each dungeon).
  261.  *    - If chained, the level used as reference for the chain
  262.  *      must be in this dungeon, must be previously defined, and
  263.  *      the level chained from must be "non-probabalistic" (ie.
  264.  *      have a 100% chance of existing).
  265.  */
  266.  
  267. int
  268. check_branch()
  269. {
  270.     int i;
  271.  
  272.     if(!in_dungeon) {
  273.         yyerror("Branch defined outside of dungeon.");
  274.         return(0);
  275.     }
  276.  
  277.     for(i = 0; i < n_dgns; i++)
  278.         if(!strcmp(tmpdungeon[i].name, tmpbranch[n_brs].name)) {
  279.  
  280.         yyerror("Reverse branching not allowed.");
  281.         return(0);
  282.         }
  283.  
  284.     if(tmpbranch[i].chain == -2) {
  285.  
  286.         yyerror("Invaild branch chain reference.");
  287.         return(0);
  288.     } else if(tmpbranch[i].chain != -1) {    /* it is chained */
  289.  
  290.         if(tmplevel[tmpbranch[i].chain].chance != 100) {
  291.         yyerror("Branch cannot chain from a probabalistic level.");
  292.         return(0);
  293.         }
  294.     }
  295.     return(1);    /* OK */
  296. }
  297.  
  298. /*
  299.  *    Output the dungon definition into a file.
  300.  *
  301.  *    The file will have the following format:
  302.  *
  303.  *    [ number of dungeons ]
  304.  *    [ first dungeon struct ]
  305.  *    [ levels for the first dungeon ]
  306.  *      ...
  307.  *    [ branches for the first dungeon ]
  308.  *      ...
  309.  *    [ second dungeon struct ]
  310.  *      ...
  311.  */
  312.  
  313. void
  314. output_dgn()
  315. {
  316.     int    nd, cl = 0, nl = 0,
  317.             cb = 0, nb = 0;
  318.  
  319.     if(++n_dgns <= 0) {
  320.  
  321.         yyerror("FATAL - no dungeons were defined.");
  322.         exit(1);
  323.     }
  324.  
  325.     fwrite((char *)(&n_dgns), sizeof(int), 1, stdout);
  326.     for(nd = 0; nd < n_dgns; nd++) {
  327.  
  328.         fwrite((char *)&tmpdungeon[nd], sizeof(struct tmpdungeon), 1,
  329.                                 stdout);
  330.  
  331.         nl += tmpdungeon[nd].levels;
  332.         for(; cl < nl; cl++)
  333.         fwrite((char *)&tmplevel[cl], sizeof(struct tmplevel), 1,
  334.                                 stdout);
  335.  
  336.         nb += tmpdungeon[nd].branches;
  337.         for(; cb < nb; cb++)
  338.         fwrite((char *)&tmpbranch[cb], sizeof(struct tmpbranch), 1,
  339.                                 stdout);
  340.     }
  341. }
  342. int yyexca[] ={
  343. -1, 1,
  344.     0, -1,
  345.     -2, 0,
  346.     };
  347. # define YYNPROD 48
  348. # define YYLAST 145
  349. int yyact[]={
  350.  
  351.      8,    22,    23,    24,    25,    28,    29,    74,    21,    30,
  352.     73,    26,    31,    27,    19,    65,    79,    80,    81,    82,
  353.    106,    64,    63,    62,    61,    59,    56,    55,    52,    51,
  354.     50,    49,    48,    46,    58,    57,    54,    53,    91,   103,
  355.    102,   101,    99,    98,    95,    94,    83,    77,    76,    47,
  356.     90,    66,    78,    68,    72,    71,    60,    45,    44,    43,
  357.     42,    41,    40,    39,    38,    37,    36,    35,    34,    33,
  358.     92,    89,    88,    87,    70,   105,   104,    67,    69,     3,
  359.     13,    12,    32,    18,    17,    16,    15,    14,    20,    11,
  360.     10,     9,     7,     6,     5,     4,     2,     1,    75,     0,
  361.      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
  362.      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
  363.      0,     0,    84,     0,     0,    85,    86,     0,     0,     0,
  364.      0,     0,     0,     0,     0,     0,     0,    93,     0,    96,
  365.     97,     0,     0,     0,   100 };
  366. int yypact[]={
  367.  
  368.   -258, -1000,  -258, -1000, -1000, -1000, -1000, -1000,    11, -1000,
  369.  -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000,    10,
  370.  -1000,     9,     8,     7,     6,     5,     4,     3,     2,     1,
  371.      0,    -1, -1000,  -244,  -208,  -245,  -246,  -247,  -248,  -249,
  372.   -231,  -232,  -250,  -251,  -233,  -234,  -252, -1000, -1000,    -8,
  373.   -253,  -254,  -255, -1000, -1000,  -256,  -262, -1000, -1000,    37,
  374.     38,    31,    -9,   -10,  -267,  -270,  -209,  -210,  -257,  -211,
  375.     37,    38,    38,    30,    29, -1000, -1000,    27,  -227, -1000,
  376.  -1000, -1000, -1000,    26,  -257,  -212,  -213,    37,    37,  -214,
  377.  -1000, -1000,  -215,  -227, -1000,  -216,  -217,  -218,    35,    34,
  378.  -1000, -1000, -1000,  -237, -1000, -1000, -1000 };
  379. int yypgo[]={
  380.  
  381.      0,    98,    50,    52,    97,    96,    79,    95,    94,    93,
  382.     92,    51,    91,    90,    89,    88,    87,    86,    85,    84,
  383.     83,    53,    81,    80 };
  384. int yyr1[]={
  385.  
  386.      0,     4,     4,     5,     5,     6,     6,     6,     6,     7,
  387.      1,     1,     8,     8,     8,    12,    13,    15,    15,    14,
  388.     10,    10,    10,    10,    10,    16,    16,    17,    17,    18,
  389.     18,    19,    19,    20,    20,     9,     9,    22,    23,     3,
  390.      3,     3,     3,     3,     2,     2,    21,    11 };
  391. int yyr2[]={
  392.  
  393.      0,     0,     3,     2,     4,     2,     2,     2,     2,    13,
  394.      1,     3,     2,     2,     2,     7,     2,     7,     7,     7,
  395.      2,     2,     2,     2,     2,    13,    15,    15,    17,     7,
  396.      7,    15,    17,    17,    19,     2,     2,    15,    17,     1,
  397.      3,     3,     3,     3,     1,     3,    11,    11 };
  398. int yychk[]={
  399.  
  400.  -1000,    -4,    -5,    -6,    -7,    -8,    -9,   -10,   258,   -12,
  401.    -13,   -14,   -22,   -23,   -16,   -17,   -18,   -19,   -20,   272,
  402.    -15,   266,   259,   260,   261,   262,   269,   271,   263,   264,
  403.    267,   270,    -6,    58,    58,    58,    58,    58,    58,    58,
  404.     58,    58,    58,    58,    58,    58,   277,   257,   277,   277,
  405.    277,   277,   277,   268,   268,   277,   277,   268,   268,   277,
  406.     64,   277,   277,   277,   277,   277,   -11,    40,   -21,    40,
  407.     43,    64,    64,   277,   277,    -1,   257,   257,    -3,   273,
  408.    274,   275,   276,   257,   -11,   -21,   -21,    43,    43,    44,
  409.     -2,   265,    44,    -3,   257,   257,   -11,   -11,   257,   257,
  410.     -2,   257,   257,   257,    41,    41,   257 };
  411. int yydef[]={
  412.  
  413.      1,    -2,     2,     3,     5,     6,     7,     8,     0,    12,
  414.     13,    14,    35,    36,    20,    21,    22,    23,    24,     0,
  415.     16,     0,     0,     0,     0,     0,     0,     0,     0,     0,
  416.      0,     0,     4,     0,     0,     0,     0,     0,     0,     0,
  417.      0,     0,     0,     0,     0,     0,     0,    15,    19,     0,
  418.      0,     0,     0,    29,    30,     0,     0,    17,    18,     0,
  419.      0,     0,     0,     0,     0,     0,    10,     0,    39,     0,
  420.      0,     0,     0,     0,     0,     9,    11,     0,    44,    40,
  421.     41,    42,    43,     0,    39,    25,     0,     0,     0,     0,
  422.     37,    45,     0,    44,    27,    26,    31,     0,     0,     0,
  423.     38,    28,    33,    32,    47,    46,    34 };
  424. typedef struct { char *t_name; int t_val; } yytoktype;
  425. #ifndef YYDEBUG
  426. #    define YYDEBUG    0    /* don't allow debugging */
  427. #endif
  428.  
  429. #if YYDEBUG
  430.  
  431. yytoktype yytoks[] =
  432. {
  433.     "INTEGER",    257,
  434.     "A_DUNGEON",    258,
  435.     "BRANCH",    259,
  436.     "CHBRANCH",    260,
  437.     "LEVEL",    261,
  438.     "RNDLEVEL",    262,
  439.     "CHLEVEL",    263,
  440.     "RNDCHLEVEL",    264,
  441.     "UP_OR_DOWN",    265,
  442.     "PROTOFILE",    266,
  443.     "DESCRIPTION",    267,
  444.     "DESCRIPTOR",    268,
  445.     "LEVELDESC",    269,
  446.     "ALIGNMENT",    270,
  447.     "LEVALIGN",    271,
  448.     "ENTRY",    272,
  449.     "STAIR",    273,
  450.     "NO_UP",    274,
  451.     "NO_DOWN",    275,
  452.     "PORTAL",    276,
  453.     "STRING",    277,
  454.     "-unknown-",    -1    /* ends search */
  455. };
  456.  
  457. char * yyreds[] =
  458. {
  459.     "-no such reduction-",
  460.     "file : /* empty */",
  461.     "file : dungeons",
  462.     "dungeons : dungeon",
  463.     "dungeons : dungeons dungeon",
  464.     "dungeon : dungeonline",
  465.     "dungeon : dungeondesc",
  466.     "dungeon : branches",
  467.     "dungeon : levels",
  468.     "dungeonline : A_DUNGEON ':' STRING STRING rcouple optional_int",
  469.     "optional_int : /* empty */",
  470.     "optional_int : INTEGER",
  471.     "dungeondesc : entry",
  472.     "dungeondesc : descriptions",
  473.     "dungeondesc : prototype",
  474.     "entry : ENTRY ':' INTEGER",
  475.     "descriptions : desc",
  476.     "desc : DESCRIPTION ':' DESCRIPTOR",
  477.     "desc : ALIGNMENT ':' DESCRIPTOR",
  478.     "prototype : PROTOFILE ':' STRING",
  479.     "levels : level1",
  480.     "levels : level2",
  481.     "levels : levdesc",
  482.     "levels : chlevel1",
  483.     "levels : chlevel2",
  484.     "level1 : LEVEL ':' STRING STRING '@' acouple",
  485.     "level1 : RNDLEVEL ':' STRING STRING '@' acouple INTEGER",
  486.     "level2 : LEVEL ':' STRING STRING '@' acouple INTEGER",
  487.     "level2 : RNDLEVEL ':' STRING STRING '@' acouple INTEGER INTEGER",
  488.     "levdesc : LEVELDESC ':' DESCRIPTOR",
  489.     "levdesc : LEVALIGN ':' DESCRIPTOR",
  490.     "chlevel1 : CHLEVEL ':' STRING STRING STRING '+' rcouple",
  491.     "chlevel1 : RNDCHLEVEL ':' STRING STRING STRING '+' rcouple INTEGER",
  492.     "chlevel2 : CHLEVEL ':' STRING STRING STRING '+' rcouple INTEGER",
  493.     "chlevel2 : RNDCHLEVEL ':' STRING STRING STRING '+' rcouple INTEGER INTEGER",
  494.     "branches : branch",
  495.     "branches : chbranch",
  496.     "branch : BRANCH ':' STRING '@' acouple branch_type direction",
  497.     "chbranch : CHBRANCH ':' STRING STRING '+' rcouple branch_type direction",
  498.     "branch_type : /* empty */",
  499.     "branch_type : STAIR",
  500.     "branch_type : NO_UP",
  501.     "branch_type : NO_DOWN",
  502.     "branch_type : PORTAL",
  503.     "direction : /* empty */",
  504.     "direction : UP_OR_DOWN",
  505.     "acouple : '(' INTEGER ',' INTEGER ')'",
  506.     "rcouple : '(' INTEGER ',' INTEGER ')'",
  507. };
  508. #endif /* YYDEBUG */
  509. #line 1 "/usr/lib/yaccpar"
  510. /*    @(#)yaccpar 1.10 89/04/04 SMI; from S5R3 1.10    */
  511.  
  512. /*
  513. ** Skeleton parser driver for yacc output
  514. */
  515.  
  516. /*
  517. ** yacc user known macros and defines
  518. */
  519. #define YYERROR        goto yyerrlab
  520. #define YYACCEPT    { free(yys); free(yyv); return(0); }
  521. #define YYABORT        { free(yys); free(yyv); return(1); }
  522. #define YYBACKUP( newtoken, newvalue )\
  523. {\
  524.     if ( yychar >= 0 || ( yyr2[ yytmp ] >> 1 ) != 1 )\
  525.     {\
  526.         yyerror( "syntax error - cannot backup" );\
  527.         goto yyerrlab;\
  528.     }\
  529.     yychar = newtoken;\
  530.     yystate = *yyps;\
  531.     yylval = newvalue;\
  532.     goto yynewstate;\
  533. }
  534. #define YYRECOVERING()    (!!yyerrflag)
  535. #ifndef YYDEBUG
  536. #    define YYDEBUG    1    /* make debugging available */
  537. #endif
  538.  
  539. /*
  540. ** user known globals
  541. */
  542. int yydebug;            /* set to 1 to get debugging */
  543.  
  544. /*
  545. ** driver internal defines
  546. */
  547. #define YYFLAG        (-1000)
  548.  
  549. /*
  550. ** static variables used by the parser
  551. */
  552. static YYSTYPE *yyv;            /* value stack */
  553. static int *yys;            /* state stack */
  554.  
  555. static YYSTYPE *yypv;            /* top of value stack */
  556. static int *yyps;            /* top of state stack */
  557.  
  558. static int yystate;            /* current state */
  559. static int yytmp;            /* extra var (lasts between blocks) */
  560.  
  561. int yynerrs;            /* number of errors */
  562.  
  563. int yyerrflag;            /* error recovery flag */
  564. int yychar;            /* current input token number */
  565.  
  566.  
  567. /*
  568. ** yyparse - return 0 if worked, 1 if syntax error not recovered from
  569. */
  570. int
  571. yyparse()
  572. {
  573.     register YYSTYPE *yypvt;    /* top of value stack for $vars */
  574.     unsigned yymaxdepth = YYMAXDEPTH;
  575.  
  576.     /*
  577.     ** Initialize externals - yyparse may be called more than once
  578.     */
  579.     yyv = (YYSTYPE*)malloc(yymaxdepth*sizeof(YYSTYPE));
  580.     yys = (int*)malloc(yymaxdepth*sizeof(int));
  581.     if (!yyv || !yys)
  582.     {
  583.         yyerror( "out of memory" );
  584.         return(1);
  585.     }
  586.     yypv = &yyv[-1];
  587.     yyps = &yys[-1];
  588.     yystate = 0;
  589.     yytmp = 0;
  590.     yynerrs = 0;
  591.     yyerrflag = 0;
  592.     yychar = -1;
  593.  
  594.     goto yystack;
  595.     {
  596.         register YYSTYPE *yy_pv;    /* top of value stack */
  597.         register int *yy_ps;        /* top of state stack */
  598.         register int yy_state;        /* current state */
  599.         register int  yy_n;        /* internal state number info */
  600.  
  601.         /*
  602.         ** get globals into registers.
  603.         ** branch to here only if YYBACKUP was called.
  604.         */
  605.     yynewstate:
  606.         yy_pv = yypv;
  607.         yy_ps = yyps;
  608.         yy_state = yystate;
  609.         goto yy_newstate;
  610.  
  611.         /*
  612.         ** get globals into registers.
  613.         ** either we just started, or we just finished a reduction
  614.         */
  615.     yystack:
  616.         yy_pv = yypv;
  617.         yy_ps = yyps;
  618.         yy_state = yystate;
  619.  
  620.         /*
  621.         ** top of for (;;) loop while no reductions done
  622.         */
  623.     yy_stack:
  624.         /*
  625.         ** put a state and value onto the stacks
  626.         */
  627. #if YYDEBUG
  628.         /*
  629.         ** if debugging, look up token value in list of value vs.
  630.         ** name pairs.  0 and negative (-1) are special values.
  631.         ** Note: linear search is used since time is not a real
  632.         ** consideration while debugging.
  633.         */
  634.         if ( yydebug )
  635.         {
  636.             register int yy_i;
  637.  
  638.             (void)printf( "State %d, token ", yy_state );
  639.             if ( yychar == 0 )
  640.                 (void)printf( "end-of-file\n" );
  641.             else if ( yychar < 0 )
  642.                 (void)printf( "-none-\n" );
  643.             else
  644.             {
  645.                 for ( yy_i = 0; yytoks[yy_i].t_val >= 0;
  646.                     yy_i++ )
  647.                 {
  648.                     if ( yytoks[yy_i].t_val == yychar )
  649.                         break;
  650.                 }
  651.                 (void)printf( "%s\n", yytoks[yy_i].t_name );
  652.             }
  653.         }
  654. #endif /* YYDEBUG */
  655.         if ( ++yy_ps >= &yys[ yymaxdepth ] )    /* room on stack? */
  656.         {
  657.             /*
  658.             ** reallocate and recover.  Note that pointers
  659.             ** have to be reset, or bad things will happen
  660.             */
  661.             int yyps_index = (yy_ps - yys);
  662.             int yypv_index = (yy_pv - yyv);
  663.             int yypvt_index = (yypvt - yyv);
  664.             yymaxdepth += YYMAXDEPTH;
  665.             yyv = (YYSTYPE*)realloc((char*)yyv,
  666.                 yymaxdepth * sizeof(YYSTYPE));
  667.             yys = (int*)realloc((char*)yys,
  668.                 yymaxdepth * sizeof(int));
  669.             if (!yyv || !yys)
  670.             {
  671.                 yyerror( "yacc stack overflow" );
  672.                 return(1);
  673.             }
  674.             yy_ps = yys + yyps_index;
  675.             yy_pv = yyv + yypv_index;
  676.             yypvt = yyv + yypvt_index;
  677.         }
  678.         *yy_ps = yy_state;
  679.         *++yy_pv = yyval;
  680.  
  681.         /*
  682.         ** we have a new state - find out what to do
  683.         */
  684.     yy_newstate:
  685.         if ( ( yy_n = yypact[ yy_state ] ) <= YYFLAG )
  686.             goto yydefault;        /* simple state */
  687. #if YYDEBUG
  688.         /*
  689.         ** if debugging, need to mark whether new token grabbed
  690.         */
  691.         yytmp = yychar < 0;
  692. #endif
  693.         if ( ( yychar < 0 ) && ( ( yychar = yylex() ) < 0 ) )
  694.             yychar = 0;        /* reached EOF */
  695. #if YYDEBUG
  696.         if ( yydebug && yytmp )
  697.         {
  698.             register int yy_i;
  699.  
  700.             (void)printf( "Received token " );
  701.             if ( yychar == 0 )
  702.                 (void)printf( "end-of-file\n" );
  703.             else if ( yychar < 0 )
  704.                 (void)printf( "-none-\n" );
  705.             else
  706.             {
  707.                 for ( yy_i = 0; yytoks[yy_i].t_val >= 0;
  708.                     yy_i++ )
  709.                 {
  710.                     if ( yytoks[yy_i].t_val == yychar )
  711.                         break;
  712.                 }
  713.                 (void)printf( "%s\n", yytoks[yy_i].t_name );
  714.             }
  715.         }
  716. #endif /* YYDEBUG */
  717.         if ( ( ( yy_n += yychar ) < 0 ) || ( yy_n >= YYLAST ) )
  718.             goto yydefault;
  719.         if ( yychk[ yy_n = yyact[ yy_n ] ] == yychar )    /*valid shift*/
  720.         {
  721.             yychar = -1;
  722.             yyval = yylval;
  723.             yy_state = yy_n;
  724.             if ( yyerrflag > 0 )
  725.                 yyerrflag--;
  726.             goto yy_stack;
  727.         }
  728.  
  729.     yydefault:
  730.         if ( ( yy_n = yydef[ yy_state ] ) == -2 )
  731.         {
  732. #if YYDEBUG
  733.             yytmp = yychar < 0;
  734. #endif
  735.             if ( ( yychar < 0 ) && ( ( yychar = yylex() ) < 0 ) )
  736.                 yychar = 0;        /* reached EOF */
  737. #if YYDEBUG
  738.             if ( yydebug && yytmp )
  739.             {
  740.                 register int yy_i;
  741.  
  742.                 (void)printf( "Received token " );
  743.                 if ( yychar == 0 )
  744.                     (void)printf( "end-of-file\n" );
  745.                 else if ( yychar < 0 )
  746.                     (void)printf( "-none-\n" );
  747.                 else
  748.                 {
  749.                     for ( yy_i = 0;
  750.                         yytoks[yy_i].t_val >= 0;
  751.                         yy_i++ )
  752.                     {
  753.                         if ( yytoks[yy_i].t_val
  754.                             == yychar )
  755.                         {
  756.                             break;
  757.                         }
  758.                     }
  759.                     (void)printf( "%s\n", yytoks[yy_i].t_name );
  760.                 }
  761.             }
  762. #endif /* YYDEBUG */
  763.             /*
  764.             ** look through exception table
  765.             */
  766.             {
  767.                 register int *yyxi = yyexca;
  768.  
  769.                 while ( ( *yyxi != -1 ) ||
  770.                     ( yyxi[1] != yy_state ) )
  771.                 {
  772.                     yyxi += 2;
  773.                 }
  774.                 while ( ( *(yyxi += 2) >= 0 ) &&
  775.                     ( *yyxi != yychar ) )
  776.                     ;
  777.                 if ( ( yy_n = yyxi[1] ) < 0 )
  778.                     YYACCEPT;
  779.             }
  780.         }
  781.  
  782.         /*
  783.         ** check for syntax error
  784.         */
  785.         if ( yy_n == 0 )    /* have an error */
  786.         {
  787.             /* no worry about speed here! */
  788.             switch ( yyerrflag )
  789.             {
  790.             case 0:        /* new error */
  791.                 yyerror( "syntax error" );
  792.                 goto skip_init;
  793.             yyerrlab:
  794.                 /*
  795.                 ** get globals into registers.
  796.                 ** we have a user generated syntax type error
  797.                 */
  798.                 yy_pv = yypv;
  799.                 yy_ps = yyps;
  800.                 yy_state = yystate;
  801.                 yynerrs++;
  802.             skip_init:
  803.             case 1:
  804.             case 2:        /* incompletely recovered error */
  805.                     /* try again... */
  806.                 yyerrflag = 3;
  807.                 /*
  808.                 ** find state where "error" is a legal
  809.                 ** shift action
  810.                 */
  811.                 while ( yy_ps >= yys )
  812.                 {
  813.                     yy_n = yypact[ *yy_ps ] + YYERRCODE;
  814.                     if ( yy_n >= 0 && yy_n < YYLAST &&
  815.                         yychk[yyact[yy_n]] == YYERRCODE)                    {
  816.                         /*
  817.                         ** simulate shift of "error"
  818.                         */
  819.                         yy_state = yyact[ yy_n ];
  820.                         goto yy_stack;
  821.                     }
  822.                     /*
  823.                     ** current state has no shift on
  824.                     ** "error", pop stack
  825.                     */
  826. #if YYDEBUG
  827. #    define _POP_ "Error recovery pops state %d, uncovers state %d\n"
  828.                     if ( yydebug )
  829.                         (void)printf( _POP_, *yy_ps,
  830.                             yy_ps[-1] );
  831. #    undef _POP_
  832. #endif
  833.                     yy_ps--;
  834.                     yy_pv--;
  835.                 }
  836.                 /*
  837.                 ** there is no state on stack with "error" as
  838.                 ** a valid shift.  give up.
  839.                 */
  840.                 YYABORT;
  841.             case 3:        /* no shift yet; eat a token */
  842. #if YYDEBUG
  843.                 /*
  844.                 ** if debugging, look up token in list of
  845.                 ** pairs.  0 and negative shouldn't occur,
  846.                 ** but since timing doesn't matter when
  847.                 ** debugging, it doesn't hurt to leave the
  848.                 ** tests here.
  849.                 */
  850.                 if ( yydebug )
  851.                 {
  852.                     register int yy_i;
  853.  
  854.                     (void)printf( "Error recovery discards " );
  855.                     if ( yychar == 0 )
  856.                         (void)printf( "token end-of-file\n" );
  857.                     else if ( yychar < 0 )
  858.                         (void)printf( "token -none-\n" );
  859.                     else
  860.                     {
  861.                         for ( yy_i = 0;
  862.                             yytoks[yy_i].t_val >= 0;
  863.                             yy_i++ )
  864.                         {
  865.                             if ( yytoks[yy_i].t_val
  866.                                 == yychar )
  867.                             {
  868.                                 break;
  869.                             }
  870.                         }
  871.                         (void)printf( "token %s\n",
  872.                             yytoks[yy_i].t_name );
  873.                     }
  874.                 }
  875. #endif /* YYDEBUG */
  876.                 if ( yychar == 0 )    /* reached EOF. quit */
  877.                     YYABORT;
  878.                 yychar = -1;
  879.                 goto yy_newstate;
  880.             }
  881.         }/* end if ( yy_n == 0 ) */
  882.         /*
  883.         ** reduction by production yy_n
  884.         ** put stack tops, etc. so things right after switch
  885.         */
  886. #if YYDEBUG
  887.         /*
  888.         ** if debugging, print the string that is the user's
  889.         ** specification of the reduction which is just about
  890.         ** to be done.
  891.         */
  892.         if ( yydebug )
  893.             (void)printf( "Reduce by (%d) \"%s\"\n",
  894.                 yy_n, yyreds[ yy_n ] );
  895. #endif
  896.         yytmp = yy_n;            /* value to switch over */
  897.         yypvt = yy_pv;            /* $vars top of value stack */
  898.         /*
  899.         ** Look in goto table for next state
  900.         ** Sorry about using yy_state here as temporary
  901.         ** register variable, but why not, if it works...
  902.         ** If yyr2[ yy_n ] doesn't have the low order bit
  903.         ** set, then there is no action to be done for
  904.         ** this reduction.  So, no saving & unsaving of
  905.         ** registers done.  The only difference between the
  906.         ** code just after the if and the body of the if is
  907.         ** the goto yy_stack in the body.  This way the test
  908.         ** can be made before the choice of what to do is needed.
  909.         */
  910.         {
  911.             /* length of production doubled with extra bit */
  912.             register int yy_len = yyr2[ yy_n ];
  913.  
  914.             if ( !( yy_len & 01 ) )
  915.             {
  916.                 yy_len >>= 1;
  917.                 yyval = ( yy_pv -= yy_len )[1];    /* $$ = $1 */
  918.                 yy_state = yypgo[ yy_n = yyr1[ yy_n ] ] +
  919.                     *( yy_ps -= yy_len ) + 1;
  920.                 if ( yy_state >= YYLAST ||
  921.                     yychk[ yy_state =
  922.                     yyact[ yy_state ] ] != -yy_n )
  923.                 {
  924.                     yy_state = yyact[ yypgo[ yy_n ] ];
  925.                 }
  926.                 goto yy_stack;
  927.             }
  928.             yy_len >>= 1;
  929.             yyval = ( yy_pv -= yy_len )[1];    /* $$ = $1 */
  930.             yy_state = yypgo[ yy_n = yyr1[ yy_n ] ] +
  931.                 *( yy_ps -= yy_len ) + 1;
  932.             if ( yy_state >= YYLAST ||
  933.                 yychk[ yy_state = yyact[ yy_state ] ] != -yy_n )
  934.             {
  935.                 yy_state = yyact[ yypgo[ yy_n ] ];
  936.             }
  937.         }
  938.                     /* save until reenter driver code */
  939.         yystate = yy_state;
  940.         yyps = yy_ps;
  941.         yypv = yy_pv;
  942.     }
  943.     /*
  944.     ** code supplied by user is placed in this switch
  945.     */
  946.     switch( yytmp )
  947.     {
  948.         
  949. case 2:
  950. # line 86 "dgn_comp.y"
  951. {
  952.             output_dgn();
  953.           } break;
  954. case 9:
  955. # line 102 "dgn_comp.y"
  956. {
  957.             init_dungeon();
  958.             strcpy(tmpdungeon[n_dgns].name, yypvt[-3].str);
  959.             if (!strcmp(yypvt[-2].str, "none"))
  960.                 tmpdungeon[n_levs].boneschar = '\0';
  961.             else if (yypvt[-2].str[1])
  962.                 yyerror("Bones marker must be a single char, or \"none\"!");
  963.             else
  964.                 tmpdungeon[n_dgns].boneschar = yypvt[-2].str[0];
  965.             tmpdungeon[n_dgns].lev.base = couple.base;
  966.             tmpdungeon[n_dgns].lev.rand = couple.rand;
  967.             tmpdungeon[n_dgns].chance = yypvt[-0].i;
  968.           } break;
  969. case 10:
  970. # line 118 "dgn_comp.y"
  971. {
  972.             yyval.i = 0;
  973.           } break;
  974. case 11:
  975. # line 122 "dgn_comp.y"
  976. {
  977.             yyval.i = yypvt[-0].i;
  978.           } break;
  979. case 15:
  980. # line 133 "dgn_comp.y"
  981. {
  982.             tmpdungeon[n_dgns].entry_lev = yypvt[-0].i;
  983.           } break;
  984. case 17:
  985. # line 142 "dgn_comp.y"
  986. {
  987.             if(yypvt[-0].i <= TOWN || yypvt[-0].i >= D_ALIGN_CHAOTIC)
  988.                 yyerror("Illegal description - ignoring!");
  989.             else
  990.                 tmpdungeon[n_dgns].flags |= yypvt[-0].i ;
  991.           } break;
  992. case 18:
  993. # line 149 "dgn_comp.y"
  994. {
  995.             if(yypvt[-0].i && yypvt[-0].i < D_ALIGN_CHAOTIC)
  996.                 yyerror("Illegal alignment - ignoring!");
  997.             else
  998.                 tmpdungeon[n_dgns].flags |= yypvt[-0].i ;
  999.           } break;
  1000. case 19:
  1001. # line 158 "dgn_comp.y"
  1002. {
  1003.             strcpy(tmpdungeon[n_dgns].protoname, yypvt[-0].str);
  1004.           } break;
  1005. case 25:
  1006. # line 171 "dgn_comp.y"
  1007. {
  1008.             init_level();
  1009.             strcpy(tmplevel[n_levs].name, yypvt[-3].str);
  1010.             if (!strcmp(yypvt[-2].str, "none"))
  1011.                 tmplevel[n_levs].boneschar = '\0';
  1012.             else if (yypvt[-2].str[1])
  1013.                 yyerror("Bones marker must be a single char, or \"none\"!");
  1014.             else
  1015.                 tmplevel[n_levs].boneschar = yypvt[-2].str[0];
  1016.             tmplevel[n_levs].lev.base = couple.base;
  1017.             tmplevel[n_levs].lev.rand = couple.rand;
  1018.             tmpdungeon[n_dgns].levels++;
  1019.           } break;
  1020. case 26:
  1021. # line 185 "dgn_comp.y"
  1022. {
  1023.             init_level();
  1024.             strcpy(tmplevel[n_levs].name, yypvt[-4].str);
  1025.             if (!strcmp(yypvt[-3].str, "none"))
  1026.                 tmplevel[n_levs].boneschar = '\0';
  1027.             else if (yypvt[-3].str[1])
  1028.                 yyerror("Bones marker must be a single char, or \"none\"!");
  1029.             else
  1030.                 tmplevel[n_levs].boneschar = yypvt[-3].str[0];
  1031.             tmplevel[n_levs].lev.base = couple.base;
  1032.             tmplevel[n_levs].lev.rand = couple.rand;
  1033.             tmplevel[n_levs].rndlevs = yypvt[-0].i;
  1034.             tmpdungeon[n_dgns].levels++;
  1035.           } break;
  1036. case 27:
  1037. # line 202 "dgn_comp.y"
  1038. {
  1039.             init_level();
  1040.             strcpy(tmplevel[n_levs].name, yypvt[-4].str);
  1041.             if (!strcmp(yypvt[-3].str, "none"))
  1042.                 tmplevel[n_levs].boneschar = '\0';
  1043.             else if (yypvt[-3].str[1])
  1044.                 yyerror("Bones marker must be a single char, or \"none\"!");
  1045.             else
  1046.                 tmplevel[n_levs].boneschar = yypvt[-3].str[0];
  1047.             tmplevel[n_levs].lev.base = couple.base;
  1048.             tmplevel[n_levs].lev.rand = couple.rand;
  1049.             tmplevel[n_levs].chance = yypvt[-0].i;
  1050.             tmpdungeon[n_dgns].levels++;
  1051.           } break;
  1052. case 28:
  1053. # line 217 "dgn_comp.y"
  1054. {
  1055.             init_level();
  1056.             strcpy(tmplevel[n_levs].name, yypvt[-5].str);
  1057.             if (!strcmp(yypvt[-4].str, "none"))
  1058.                 tmplevel[n_levs].boneschar = '\0';
  1059.             else if (yypvt[-4].str[1])
  1060.                 yyerror("Bones marker must be a single char, or \"none\"!");
  1061.             else
  1062.                 tmplevel[n_levs].boneschar = yypvt[-4].str[0];
  1063.             tmplevel[n_levs].lev.base = couple.base;
  1064.             tmplevel[n_levs].lev.rand = couple.rand;
  1065.             tmplevel[n_levs].chance = yypvt[-1].i;
  1066.             tmplevel[n_levs].rndlevs = yypvt[-0].i;
  1067.             tmpdungeon[n_dgns].levels++;
  1068.           } break;
  1069. case 29:
  1070. # line 235 "dgn_comp.y"
  1071. {
  1072.             if(yypvt[-0].i >= D_ALIGN_CHAOTIC)
  1073.                 yyerror("Illegal description - ignoring!");
  1074.             else
  1075.                 tmplevel[n_levs].flags |= yypvt[-0].i ;
  1076.           } break;
  1077. case 30:
  1078. # line 242 "dgn_comp.y"
  1079. {
  1080.             if(yypvt[-0].i && yypvt[-0].i < D_ALIGN_CHAOTIC)
  1081.                 yyerror("Illegal alignment - ignoring!");
  1082.             else
  1083.                 tmplevel[n_levs].flags |= yypvt[-0].i ;
  1084.           } break;
  1085. case 31:
  1086. # line 251 "dgn_comp.y"
  1087. {
  1088.             init_level();
  1089.             strcpy(tmplevel[n_levs].name, yypvt[-4].str);
  1090.             if (!strcmp(yypvt[-3].str, "none"))
  1091.                 tmplevel[n_levs].boneschar = '\0';
  1092.             else if (yypvt[-3].str[1])
  1093.                 yyerror("Bones marker must be a single char, or \"none\"!");
  1094.             else
  1095.                 tmplevel[n_levs].boneschar = yypvt[-3].str[0];
  1096.             tmplevel[n_levs].chain = getchain(yypvt[-2].str);
  1097.             tmplevel[n_levs].lev.base = couple.base;
  1098.             tmplevel[n_levs].lev.rand = couple.rand;
  1099.             if(!check_level()) n_levs--;
  1100.             else tmpdungeon[n_dgns].levels++;
  1101.           } break;
  1102. case 32:
  1103. # line 267 "dgn_comp.y"
  1104. {
  1105.             init_level();
  1106.             strcpy(tmplevel[n_levs].name, yypvt[-5].str);
  1107.             if (!strcmp(yypvt[-4].str, "none"))
  1108.                 tmplevel[n_levs].boneschar = '\0';
  1109.             else if (yypvt[-4].str[1])
  1110.                 yyerror("Bones marker must be a single char, or \"none\"!");
  1111.             else
  1112.                 tmplevel[n_levs].boneschar = yypvt[-4].str[0];
  1113.             tmplevel[n_levs].chain = getchain(yypvt[-3].str);
  1114.             tmplevel[n_levs].lev.base = couple.base;
  1115.             tmplevel[n_levs].lev.rand = couple.rand;
  1116.             tmplevel[n_levs].rndlevs = yypvt[-0].i;
  1117.             if(!check_level()) n_levs--;
  1118.             else tmpdungeon[n_dgns].levels++;
  1119.           } break;
  1120. case 33:
  1121. # line 286 "dgn_comp.y"
  1122. {
  1123.             init_level();
  1124.             strcpy(tmplevel[n_levs].name, yypvt[-5].str);
  1125.             if (!strcmp(yypvt[-4].str, "none"))
  1126.                 tmplevel[n_levs].boneschar = '\0';
  1127.             else if (yypvt[-4].str[1])
  1128.                 yyerror("Bones marker must be a single char, or \"none\"!");
  1129.             else
  1130.                 tmplevel[n_levs].boneschar = yypvt[-4].str[0];
  1131.             tmplevel[n_levs].chain = getchain(yypvt[-3].str);
  1132.             tmplevel[n_levs].lev.base = couple.base;
  1133.             tmplevel[n_levs].lev.rand = couple.rand;
  1134.             tmplevel[n_levs].chance = yypvt[-0].i;
  1135.             if(!check_level()) n_levs--;
  1136.             else tmpdungeon[n_dgns].levels++;
  1137.           } break;
  1138. case 34:
  1139. # line 303 "dgn_comp.y"
  1140. {
  1141.             init_level();
  1142.             strcpy(tmplevel[n_levs].name, yypvt[-6].str);
  1143.             if (!strcmp(yypvt[-5].str, "none"))
  1144.                 tmplevel[n_levs].boneschar = '\0';
  1145.             else if (yypvt[-5].str[1])
  1146.                 yyerror("Bones marker must be a single char, or \"none\"!");
  1147.             else
  1148.                 tmplevel[n_levs].boneschar = yypvt[-5].str[0];
  1149.             tmplevel[n_levs].chain = getchain(yypvt[-4].str);
  1150.             tmplevel[n_levs].lev.base = couple.base;
  1151.             tmplevel[n_levs].lev.rand = couple.rand;
  1152.             tmplevel[n_levs].chance = yypvt[-1].i;
  1153.             tmplevel[n_levs].rndlevs = yypvt[-0].i;
  1154.             if(!check_level()) n_levs--;
  1155.             else tmpdungeon[n_dgns].levels++;
  1156.           } break;
  1157. case 37:
  1158. # line 327 "dgn_comp.y"
  1159. {
  1160.             init_branch();
  1161.             strcpy(tmpbranch[n_brs].name, yypvt[-4].str);
  1162.             tmpbranch[n_brs].lev.base = couple.base;
  1163.             tmpbranch[n_brs].lev.rand = couple.rand;
  1164.             tmpbranch[n_brs].type = yypvt[-1].i;
  1165.             tmpbranch[n_brs].up = yypvt[-0].i;
  1166.             if(!check_branch()) n_brs--;
  1167.             else tmpdungeon[n_dgns].branches++;
  1168.           } break;
  1169. case 38:
  1170. # line 340 "dgn_comp.y"
  1171. {
  1172.             init_branch();
  1173.             strcpy(tmpbranch[n_brs].name, yypvt[-5].str);
  1174.             tmpbranch[n_brs].chain = getchain(yypvt[-4].str);
  1175.             tmpbranch[n_brs].lev.base = couple.base;
  1176.             tmpbranch[n_brs].lev.rand = couple.rand;
  1177.             tmpbranch[n_brs].type = yypvt[-1].i;
  1178.             tmpbranch[n_brs].up = yypvt[-0].i;
  1179.             if(!check_branch()) n_brs--;
  1180.             else tmpdungeon[n_dgns].branches++;
  1181.           } break;
  1182. case 39:
  1183. # line 354 "dgn_comp.y"
  1184. {
  1185.             yyval.i = TBR_STAIR;    /* two way stair */
  1186.           } break;
  1187. case 40:
  1188. # line 358 "dgn_comp.y"
  1189. {
  1190.             yyval.i = TBR_STAIR;    /* two way stair */
  1191.           } break;
  1192. case 41:
  1193. # line 362 "dgn_comp.y"
  1194. {
  1195.             yyval.i = TBR_NO_UP;    /* no up staircase */
  1196.           } break;
  1197. case 42:
  1198. # line 366 "dgn_comp.y"
  1199. {
  1200.             yyval.i = TBR_NO_DOWN;    /* no down staircase */
  1201.           } break;
  1202. case 43:
  1203. # line 370 "dgn_comp.y"
  1204. {
  1205.             yyval.i = TBR_PORTAL;    /* portal connection */
  1206.           } break;
  1207. case 44:
  1208. # line 376 "dgn_comp.y"
  1209. {
  1210.             yyval.i = 0;    /* defaults to down */
  1211.           } break;
  1212. case 45:
  1213. # line 380 "dgn_comp.y"
  1214. {
  1215.             yyval.i = yypvt[-0].i;
  1216.           } break;
  1217. case 46:
  1218. # line 403 "dgn_comp.y"
  1219. {
  1220.             if (yypvt[-3].i < -MAXLEVEL || yypvt[-3].i > MAXLEVEL) {
  1221.                 yyerror("Abs base out of dlevel range - zeroing!");
  1222.                 couple.base = couple.rand = 0;
  1223.             } else if (yypvt[-1].i < -1 ||
  1224.                 ((yypvt[-3].i < 0) ? (MAXLEVEL + yypvt[-3].i + yypvt[-1].i + 1) > MAXLEVEL :
  1225.                     (yypvt[-3].i + yypvt[-1].i) > MAXLEVEL)) {
  1226.                 yyerror("Abs range out of dlevel range - zeroing!");
  1227.                 couple.base = couple.rand = 0;
  1228.             } else {
  1229.                 couple.base = yypvt[-3].i;
  1230.                 couple.rand = yypvt[-1].i;
  1231.             }
  1232.           } break;
  1233. case 47:
  1234. # line 440 "dgn_comp.y"
  1235. {
  1236.             if (yypvt[-3].i < -MAXLEVEL || yypvt[-3].i > MAXLEVEL) {
  1237.                 yyerror("Rel base out of dlevel range - zeroing!");
  1238.                 couple.base = couple.rand = 0;
  1239.             } else {
  1240.                 couple.base = yypvt[-3].i;
  1241.                 couple.rand = yypvt[-1].i;
  1242.             }
  1243.           } break;
  1244.     }
  1245.     goto yystack;        /* reset registers in driver code */
  1246. }
  1247.