home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / gnu / nethack-3.1 / sys / share / lev_yacc.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-01-15  |  70.6 KB  |  2,388 lines

  1. extern char *malloc(), *realloc();
  2.  
  3. # line 2 "lev_comp.y"
  4. /*    SCCS Id: @(#)lev_comp.c    3.1    92/07/12    */
  5. /*    Copyright (c) 1989 by Jean-Christophe Collet */
  6. /* NetHack may be freely redistributed.  See license for details. */
  7.  
  8. /*
  9.  * This file contains the Level Compiler code
  10.  * It may handle special mazes & special room-levels
  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 "hack.h"
  28. #include "sp_lev.h"
  29. #ifndef O_WRONLY
  30. # include <fcntl.h>
  31. #endif
  32. #ifndef O_CREAT    /* some older BSD systems do not define O_CREAT in <fcntl.h> */
  33. # include <sys/file.h>
  34. #endif
  35. #ifndef O_BINARY    /* used for micros, no-op for others */
  36. # define O_BINARY 0
  37. #endif
  38.  
  39. #ifdef MICRO
  40. # define OMASK FCMASK
  41. #else
  42. # define OMASK 0644
  43. #endif
  44.  
  45. #define MAX_REGISTERS    10
  46. #define ERR        (-1)
  47.  
  48. #define New(type)        (type *) alloc(sizeof(type))
  49. #define NewTab(type, size)    (type **) alloc(sizeof(type *) * size)
  50.  
  51. #ifdef MICRO
  52. # undef exit
  53. extern void FDECL(exit, (int));
  54. #endif
  55.  
  56. extern void FDECL(yyerror, (char *));
  57. extern void FDECL(yywarning, (char *));
  58. extern int NDECL(yylex);
  59. int NDECL(yyparse);
  60.  
  61. extern char *FDECL(dup_string,(char *));
  62. extern int FDECL(get_floor_type, (CHAR_P));
  63. extern int FDECL(get_room_type, (char *));
  64. extern int FDECL(get_trap_type, (char *));
  65. extern int FDECL(get_monster_id, (char *, CHAR_P));
  66. extern int FDECL(get_object_id, (char *));
  67. extern boolean FDECL(check_monster_char, (CHAR_P));
  68. extern boolean FDECL(check_object_char, (CHAR_P));
  69. extern char FDECL(what_map_char, (CHAR_P));
  70. extern void FDECL(scan_map, (char *));
  71. extern void NDECL(wallify_map);
  72. extern boolean NDECL(check_subrooms);
  73. extern void FDECL(check_coord, (int, int, char *));
  74. extern void NDECL(store_part);
  75. extern void NDECL(store_room);
  76. extern void FDECL(write_maze, (int, specialmaze *));
  77. extern void FDECL(write_lev, (int, splev *));
  78. extern void FDECL(free_rooms, (room **, int));
  79.  
  80. static struct reg {
  81.     int x1, y1;
  82.     int x2, y2;
  83. }        current_region;
  84.  
  85. static struct coord {
  86.     int x;
  87.     int y;
  88. }        current_coord, current_align;
  89.  
  90. static struct size {
  91.     int height;
  92.     int width;
  93. }        current_size;
  94.  
  95. char tmpmessage[256];
  96. altar *tmpaltar[256];
  97. lad *tmplad[256];
  98. stair *tmpstair[256];
  99. digpos *tmpdig[256];
  100. char *tmpmap[ROWNO];
  101. region *tmpreg[256];
  102. lev_region *tmplreg[32];
  103. door *tmpdoor[256];
  104. room_door *tmprdoor[256];
  105. trap *tmptrap[256];
  106. monster *tmpmonst[256];
  107. object *tmpobj[256];
  108. drawbridge *tmpdb[256];
  109. walk *tmpwalk[256];
  110. gold *tmpgold[256];
  111. fountain *tmpfountain[256];
  112. sink *tmpsink[256];
  113. pool *tmppool[256];
  114. engraving *tmpengraving[256];
  115. mazepart *tmppart[10];
  116. room *tmproom[MAXNROFROOMS*2];
  117. corridor *tmpcor[256];
  118.  
  119. static specialmaze maze;
  120. static splev special_lev;
  121. static lev_init init_lev;
  122.  
  123. static char olist[MAX_REGISTERS], mlist[MAX_REGISTERS];
  124. static struct coord plist[MAX_REGISTERS];
  125.  
  126. int n_olist = 0, n_mlist = 0, n_plist = 0;
  127.  
  128. unsigned int nlreg = 0, nreg = 0, ndoor = 0, ntrap = 0, nmons = 0, nobj = 0;
  129. unsigned int ndb = 0, nwalk = 0, npart = 0, ndig = 0, nlad = 0, nstair = 0;
  130. unsigned int naltar = 0, ncorridor = 0, nrooms = 0, ngold = 0, nengraving = 0;
  131. unsigned int nfountain = 0, npool = 0, nsink = 0;
  132.  
  133. static unsigned long lev_flags = 0;
  134.  
  135. unsigned int max_x_map, max_y_map;
  136.  
  137. static xchar in_room;
  138.  
  139. extern int fatal_error;
  140. extern int want_warnings;
  141. extern char* fname;
  142.  
  143.  
  144. # line 143 "lev_comp.y"
  145. typedef union 
  146. {
  147.     int    i;
  148.     char*    map;
  149.     struct {
  150.         xchar room;
  151.         xchar wall;
  152.         xchar door;
  153.     } corpos;
  154. } YYSTYPE;
  155. # define CHAR 257
  156. # define INTEGER 258
  157. # define BOOLEAN 259
  158. # define MESSAGE_ID 260
  159. # define MAZE_ID 261
  160. # define LEVEL_ID 262
  161. # define LEV_INIT_ID 263
  162. # define GEOMETRY_ID 264
  163. # define NOMAP_ID 265
  164. # define OBJECT_ID 266
  165. # define MONSTER_ID 267
  166. # define TRAP_ID 268
  167. # define DOOR_ID 269
  168. # define DRAWBRIDGE_ID 270
  169. # define MAZEWALK_ID 271
  170. # define WALLIFY_ID 272
  171. # define REGION_ID 273
  172. # define FILLING 274
  173. # define RANDOM_OBJECTS_ID 275
  174. # define RANDOM_MONSTERS_ID 276
  175. # define RANDOM_PLACES_ID 277
  176. # define ALTAR_ID 278
  177. # define LADDER_ID 279
  178. # define STAIR_ID 280
  179. # define NON_DIGGABLE_ID 281
  180. # define ROOM_ID 282
  181. # define PORTAL_ID 283
  182. # define TELEPRT_ID 284
  183. # define BRANCH_ID 285
  184. # define LEV 286
  185. # define CHANCE_ID 287
  186. # define CORRIDOR_ID 288
  187. # define GOLD_ID 289
  188. # define ENGRAVING_ID 290
  189. # define FOUNTAIN_ID 291
  190. # define POOL_ID 292
  191. # define SINK_ID 293
  192. # define NONE 294
  193. # define RAND_CORRIDOR_ID 295
  194. # define DOOR_STATE 296
  195. # define LIGHT_STATE 297
  196. # define CURSE_TYPE 298
  197. # define ENGRAVING_TYPE 299
  198. # define DIRECTION 300
  199. # define RANDOM_TYPE 301
  200. # define O_REGISTER 302
  201. # define M_REGISTER 303
  202. # define P_REGISTER 304
  203. # define A_REGISTER 305
  204. # define ALIGNMENT 306
  205. # define LEFT_OR_RIGHT 307
  206. # define CENTER 308
  207. # define TOP_OR_BOT 309
  208. # define ALTAR_TYPE 310
  209. # define UP_OR_DOWN 311
  210. # define SUBROOM_ID 312
  211. # define NAME_ID 313
  212. # define FLAGS_ID 314
  213. # define FLAG_TYPE 315
  214. # define MON_ATTITUDE 316
  215. # define MON_ALERTNESS 317
  216. # define MON_APPEARANCE 318
  217. # define STRING 319
  218. # define MAP_ID 320
  219. #define yyclearin yychar = -1
  220. #define yyerrok yyerrflag = 0
  221. extern int yychar;
  222. extern int yyerrflag;
  223. #ifndef YYMAXDEPTH
  224. #define YYMAXDEPTH 150
  225. #endif
  226. YYSTYPE yylval, yyval;
  227. # define YYERRCODE 256
  228.  
  229. # line 1528 "lev_comp.y"
  230.  
  231. int yyexca[] ={
  232. -1, 1,
  233.     0, -1,
  234.     -2, 0,
  235. -1, 176,
  236.     44, 98,
  237.     -2, 97,
  238.     };
  239. # define YYNPROD 212
  240. # define YYLAST 483
  241. int yyact[]={
  242.  
  243.    154,   447,   304,   428,   180,   376,    67,   394,   218,   153,
  244.    205,    47,   455,   307,   249,    20,    22,   308,   305,    21,
  245.    103,   102,   105,   149,   155,    49,    28,    12,   434,   435,
  246.    437,    21,   112,   424,   152,   289,   423,   454,   285,   210,
  247.     60,   148,    21,   117,   118,   113,   151,   150,    55,    56,
  248.    410,   385,   364,    21,   421,    60,    21,    21,   310,   297,
  249.    219,   363,   222,   182,   181,   448,   178,   147,    68,    69,
  250.     61,   307,   377,   373,   132,   308,   305,   129,   370,   371,
  251.    395,   206,   392,   250,   245,    61,   207,   251,   326,   323,
  252.    231,   156,   103,   102,   105,   104,   106,   114,   115,   107,
  253.    313,    43,   314,   347,   112,   116,   108,   119,   449,   109,
  254.    110,   111,   309,   293,    74,   117,   118,   113,   197,   126,
  255.    199,   202,   204,   396,   393,   217,   246,    64,    66,    65,
  256.    238,   212,   175,   232,   407,    36,    34,    17,     8,     9,
  257.     25,   443,   440,   277,   183,    44,   442,   239,   432,   426,
  258.    409,   403,   402,   400,   384,   365,   359,   352,   350,   338,
  259.    335,   209,   316,   299,   294,   290,   286,   279,   266,   262,
  260.    211,   243,   236,   132,   129,    70,   226,   227,   228,   229,
  261.     39,   233,   130,   220,   131,   390,   127,   333,   242,   128,
  262.    331,   329,   343,   260,   256,   254,   146,   145,   144,   247,
  263.    248,   141,   140,    78,   192,   139,   138,   137,   191,   252,
  264.    190,   189,   188,   187,   184,   173,   172,   171,   170,   169,
  265.    168,   167,   166,   165,   164,   223,   224,   225,   163,   162,
  266.    161,   160,   159,   158,   157,   122,   121,   120,    81,    80,
  267.     76,    75,    48,    38,    26,    18,    15,    14,    54,   345,
  268.    452,   439,   357,   177,   284,   438,   288,   429,   427,    98,
  269.    100,    99,   425,    79,    94,    93,   291,   292,    86,    84,
  270.     83,   420,   417,   414,   408,   406,   295,   401,   398,   397,
  271.    389,   386,   311,   383,   379,   375,   368,   367,   360,   358,
  272.    357,   321,   351,   349,   348,   344,   342,   337,   334,   332,
  273.    330,   328,   320,   317,   303,   179,    77,   174,   221,   302,
  274.    301,   300,   298,   296,   282,   281,   280,   278,   276,   275,
  275.    274,   273,   272,   214,   271,   270,   215,   214,   263,   261,
  276.    215,   259,   346,   378,   374,   258,   257,   353,   255,   354,
  277.    253,   237,   196,   355,   356,   366,   216,   194,   201,   327,
  278.    324,   193,   186,   185,   124,   123,    50,   234,    40,   336,
  279.     30,   387,   339,   340,   341,   319,   451,   445,   444,   241,
  280.    441,   221,   240,   418,   415,   411,   345,    27,   178,   265,
  281.    399,   239,   217,    31,    16,    11,    23,     2,   213,   269,
  282.    388,    10,   361,    13,   268,   267,   264,   405,    19,   381,
  283.    419,   404,   416,   380,   413,   412,    29,   177,   315,   318,
  284.    101,    37,    97,    96,    95,    92,    45,    91,    51,   430,
  285.    431,   433,    90,   436,    89,    88,    87,    85,    82,   235,
  286.    176,    63,    35,    62,    46,    33,    32,   143,   446,   142,
  287.    136,   450,   135,   134,   133,   372,   322,   325,    59,    58,
  288.    125,    73,    72,    57,    53,    24,    71,    52,    41,     5,
  289.      4,     3,     1,   453,   287,   283,     7,     6,   203,   200,
  290.    198,   195,   382,   312,   230,   422,   244,   391,   369,    42,
  291.    306,   362,   208 };
  292. int yypact[]={
  293.  
  294.   -123, -1000, -1000,  -123, -1000, -1000,  -287,  -287,   189,   188,
  295.  -1000,  -126,   187,  -126,  -300,  -300,  -120,   186,  -289,  -120,
  296.    316, -1000, -1000,  -129,  -120,   185,   -77, -1000,   314, -1000,
  297.   -156, -1000,  -129, -1000, -1000,  -309,   184, -1000,  -294,   312,
  298.   -289,  -227, -1000, -1000, -1000, -1000,  -148, -1000,  -239, -1000,
  299.    -82, -1000,  -181, -1000, -1000,   183,   182,  -242, -1000, -1000,
  300.    181,   180,  -174, -1000,   179,   178,   177,   311, -1000, -1000,
  301.    310, -1000, -1000,  -169, -1000,   -83,   -84, -1000,  -246,  -246,
  302.   -277,  -277, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000,
  303.  -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000,
  304.  -1000, -1000,   176,   175,   174,   173,   172,   171,   170,   166,
  305.    165,   164,   163,   162,   161, -1000,   160,   159,   158,   157,
  306.    -83,   338,   -84,  -245,  -115, -1000,   156, -1000,   309, -1000,
  307.  -1000,   308, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000,
  308.  -1000, -1000, -1000, -1000, -1000, -1000, -1000,   155,   154,   153,
  309.    152,   150,   146,   307, -1000, -1000,   303,  -183,  -180,  -215,
  310.   -262,    26,   342,    22,    85,    85,    85,    26,    26,    26,
  311.     26,  -168,    26,   342, -1000, -1000, -1000, -1000,   -86, -1000,
  312.  -1000, -1000, -1000,   297,   341,   -83,   -84,  -300,   -87,  -175,
  313.     26,    26,    26,  -214,  -214,   296, -1000, -1000, -1000,   104,
  314.    294, -1000, -1000, -1000,   103,   292, -1000, -1000,   291, -1000,
  315.  -1000,   287, -1000, -1000, -1000,   102,   285,   -89,   284, -1000,
  316.  -1000,   339,   -90, -1000, -1000, -1000,   281, -1000,   280,   278,
  317.    277, -1000, -1000,   276, -1000,   275,   274,  -116,   273,   -91,
  318.  -1000, -1000, -1000, -1000,   272, -1000, -1000, -1000, -1000,   271,
  319.  -1000, -1000,   270,  -263,   -92,  -266,   -93,    26,    26,  -187,
  320.    -94,  -214,   269,  -252,   268,   -95,   267,   266,   265,   260,
  321.   -230,  -188,  -253,    26,  -199,   338,   -96,   259,   107,   258,
  322.   -215,    49,    48,   257, -1000, -1000,    98,   256, -1000, -1000,
  323.     97, -1000, -1000,   255,    94,   254,   -98, -1000,    85,   253,
  324.    -99,    85,    85,    85,   252, -1000, -1000, -1000,   101, -1000,
  325.  -1000, -1000,   251, -1000, -1000, -1000,   335,  -214, -1000, -1000,
  326.   -197,   250,   249,  -100, -1000,   248,  -101, -1000,    26, -1000,
  327.     26, -1000,  -215, -1000,  -277,   246,   245,  -102,   208,   244,
  328.  -1000, -1000,  -249,  -103,  -300, -1000,   243,   242,  -222,    33,
  329.    241,    32,   240, -1000, -1000, -1000,   239,  -104,  -260,   237,
  330.   -300,   236, -1000, -1000, -1000,    92, -1000,  -177,  -178,   235,
  331.  -1000, -1000,   234,  -239, -1000,  -105,   233,  -106, -1000,  -107,
  332.  -1000,   231, -1000,  -140,   230, -1000,  -108, -1000, -1000,  -261,
  333.  -1000, -1000, -1000, -1000,   334, -1000, -1000,  -178,    32,   229,
  334.    333,  -300,   228,   332,   227, -1000,  -265,   218,  -109,   214,
  335.  -1000, -1000, -1000,   213,  -245, -1000,   213,  -110, -1000, -1000,
  336.   -288,   211,   207, -1000, -1000,  -117,   329,  -112, -1000,  -118,
  337.    327, -1000,   326, -1000, -1000, -1000, -1000,  -300,  -193,  -193,
  338.  -1000, -1000,   325, -1000, -1000, -1000, -1000, -1000, -1000, -1000,
  339.    206, -1000,  -282, -1000, -1000, -1000 };
  340. int yypgo[]={
  341.  
  342.      0,     6,     4,   482,     9,    10,    14,     2,   481,   480,
  343.      3,   479,     7,   478,   477,   476,   475,     1,   474,   473,
  344.    385,   377,   472,    60,   384,   184,   471,   470,   189,   469,
  345.    468,     0,   467,   466,   465,   464,   463,   130,   462,   387,
  346.    461,   460,   459,   386,   383,   458,   457,   456,   455,   454,
  347.    186,   182,   248,   453,   452,   451,   450,   449,   203,   448,
  348.    447,     5,   446,   445,   444,   443,   442,   440,   207,   206,
  349.    205,   202,   201,   439,   437,   198,   197,   196,   436,   435,
  350.    434,   433,   432,   431,   132,   430,   429,   428,   427,   426,
  351.    425,   424,   422,   417,   415,   414,   413,   412,   410,     8,
  352.    403,   401,   400,   399,   397,   396,   395,   394,   392,   390,
  353.    389,   183,   131,   388 };
  354. int yyr1[]={
  355.  
  356.      0,    38,    38,    39,    39,    40,    40,    41,    42,    33,
  357.     24,    24,    14,    14,    20,    20,    21,    21,    43,    43,
  358.     48,    45,    45,    49,    49,    46,    46,    52,    52,    47,
  359.     47,    54,    55,    55,    56,    56,    37,    53,    53,    59,
  360.     57,    10,    10,    62,    62,    60,    60,    63,    63,    61,
  361.     61,    58,    58,    64,    64,    64,    64,    64,    64,    64,
  362.     64,    64,    64,    64,    64,    64,    65,    66,    67,    15,
  363.     15,    13,    13,    12,    12,    32,    11,    11,    44,    44,
  364.     78,    79,    79,    82,     1,     1,     2,     2,    80,    80,
  365.     83,    83,    83,    50,    50,    51,    51,    84,    86,    84,
  366.     81,    81,    87,    87,    87,    87,    87,    87,    87,    87,
  367.     87,    87,    87,    87,    87,    87,    87,    87,    87,    87,
  368.     87,   100,    68,   101,   101,   102,   102,   102,   102,   102,
  369.    103,    69,   104,   104,   104,    16,    16,    17,    17,    88,
  370.     70,    89,    95,    96,    97,    77,   105,    91,   106,    92,
  371.    107,   108,    93,   110,    94,   109,   109,    23,    23,    72,
  372.     73,    74,    98,    90,    71,    75,    76,    26,    26,    26,
  373.     29,    29,    29,    34,    34,    35,    35,     3,     3,     4,
  374.      4,    22,    22,    22,    99,    99,    99,     5,     5,     6,
  375.      6,     7,     7,     7,     8,     8,   113,    30,    27,     9,
  376.     85,    25,    28,    31,    36,    36,    18,    18,    19,    19,
  377.    112,   111 };
  378. int yyr2[]={
  379.  
  380.      0,     0,     2,     2,     4,     2,     2,    11,    15,     7,
  381.      1,    27,     2,     2,     1,     7,     3,     7,     0,     4,
  382.      7,     0,     4,     7,     7,     1,     2,     2,     4,     2,
  383.      2,     3,     0,     4,    11,    11,    15,     5,     5,    25,
  384.     25,     1,     5,    11,     3,    11,     3,    11,     3,    11,
  385.      3,     0,     4,     2,     2,     2,     2,     2,     2,     2,
  386.      2,     2,     2,     2,     2,     2,     7,     7,    19,     2,
  387.      2,     2,     2,     2,     2,    11,     3,     3,     2,     4,
  388.      7,     3,     5,    11,     2,     2,     2,     2,     0,     4,
  389.      7,     7,     7,     3,     7,     3,     7,     3,     1,     8,
  390.      0,     4,     2,     2,     2,     2,     2,     2,     2,     2,
  391.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  392.      2,     1,    19,     0,     4,     5,     5,     5,     5,     7,
  393.      1,    19,     1,     9,    13,     2,     2,     2,     3,    11,
  394.     11,    15,    11,     3,    11,    11,     1,    17,     1,    17,
  395.      1,     1,    17,     1,    13,     1,     5,     3,    21,     7,
  396.      7,     7,     7,    17,    15,    11,    15,     2,     3,     2,
  397.      2,     3,     2,     2,     3,     2,     3,     3,     2,     3,
  398.      2,     1,     5,     9,     2,     2,     3,     2,     2,     2,
  399.      2,     2,     2,     3,     2,     2,     9,     9,     9,     9,
  400.      2,     3,     3,     2,     2,     3,     2,     2,     2,     2,
  401.     11,    19 };
  402. int yychk[]={
  403.  
  404.  -1000,   -38,   -39,   -40,   -41,   -42,   -32,   -33,   261,   262,
  405.    -39,   -20,   314,   -20,    58,    58,   -24,   263,    58,   -24,
  406.    -31,   319,   -31,   -43,   -48,   260,    58,   -21,   315,   -43,
  407.     44,   -44,   -78,   -79,   265,   -82,   264,   -43,    58,   257,
  408.     44,   -45,   -11,   257,   301,   -44,   -80,   320,    58,   319,
  409.     44,   -21,   -46,   -49,   -52,   275,   276,   -53,   -57,   -59,
  410.    282,   312,   -81,   -83,   275,   277,   276,    -1,   307,   308,
  411.    257,   -47,   -54,   -55,   295,    58,    58,   -52,   -58,   -58,
  412.     58,    58,   -87,   -68,   -69,   -88,   -70,   -89,   -90,   -91,
  413.    -92,   -93,   -94,   -71,   -72,   -95,   -96,   -97,   -77,   -75,
  414.    -76,   -98,   267,   266,   269,   268,   270,   273,   280,   283,
  415.    284,   285,   278,   291,   271,   272,   279,   289,   290,   281,
  416.     58,    58,    58,    44,    44,   -56,   288,   -50,   -28,   257,
  417.    -51,   -25,   257,   -64,   -65,   -66,   -67,   -68,   -69,   -70,
  418.    -71,   -72,   -73,   -74,   -75,   -76,   -77,   313,   287,   269,
  419.    293,   292,   280,    -4,   -31,   301,    -4,    58,    58,    58,
  420.     58,    58,    58,    58,    58,    58,    58,    58,    58,    58,
  421.     58,    58,    58,    58,   -50,   -84,   -85,  -112,    40,   -51,
  422.     -2,   309,   308,   259,    58,    44,    44,    58,    58,    58,
  423.     58,    58,    58,    44,    44,   -26,   -25,   301,   -27,   303,
  424.    -29,   -28,   301,   -30,   302,    -5,   296,   301,    -3,   -31,
  425.    301,   -99,  -112,  -113,   301,   304,  -111,    40,   -99,   -23,
  426.   -111,   286,    40,   -23,   -23,   -23,   -99,   -99,   -99,   -99,
  427.    -18,   258,   301,   -99,  -111,   -86,   258,    44,   -37,    40,
  428.    -50,   -51,   -31,   258,   -15,   259,   301,   -99,   -99,    -6,
  429.    297,   301,    -6,    44,    91,    44,    91,    44,    44,    44,
  430.     91,    44,   258,    44,  -105,    40,   258,  -106,  -107,  -110,
  431.     44,    44,    44,    44,    44,    44,    44,   259,    44,   258,
  432.     44,    44,    44,   -34,   -31,   301,   258,   -35,   -31,   301,
  433.    258,   -99,   -99,   300,   258,    -6,    44,   311,    44,   258,
  434.     44,    44,    44,    44,    -7,   306,    -9,   301,   305,   300,
  435.    311,   -99,   -19,   299,   301,   -84,   258,    44,   -37,   258,
  436.     44,    -5,   -62,    40,   301,   -60,    40,   301,    44,    93,
  437.     44,    93,    44,    93,    44,   258,   -23,    44,   258,   -23,
  438.    -23,   -23,    44,    91,    44,    41,    -6,   300,    44,    44,
  439.    258,    44,   258,   -99,   -99,    -5,    -4,    44,    44,   258,
  440.     44,  -108,    -8,   310,   301,   258,   -31,    44,    44,   -13,
  441.    300,   301,   -63,    40,   301,    44,   -61,    40,   301,    44,
  442.   -100,  -103,   -22,    44,   258,   311,    44,   -31,  -109,    44,
  443.     93,   -14,   259,   301,   -12,   258,   301,    44,    44,    -1,
  444.    258,    44,   258,   258,  -101,  -104,    44,   274,    44,   258,
  445.    311,    41,   -12,   -61,    44,    41,   -31,    44,    41,  -102,
  446.     44,   319,   -16,   301,   298,    44,   258,    44,   -10,    44,
  447.     -2,   -10,   258,   -31,   316,   317,    -7,   318,    44,    44,
  448.    259,    41,   258,   259,    41,    41,   -31,   -17,   258,   301,
  449.    -17,    41,    44,   -36,   319,   294 };
  450. int yydef[]={
  451.  
  452.      1,    -2,     2,     3,     5,     6,    14,    14,     0,     0,
  453.      4,    10,     0,    10,     0,     0,    18,     0,     0,    18,
  454.      0,   203,     9,     0,    18,     0,     0,    15,    16,    21,
  455.      0,     7,    78,    88,    81,     0,     0,    19,     0,     0,
  456.      0,    25,    75,    76,    77,    79,   100,    82,     0,    20,
  457.      0,    17,    32,    22,    26,     0,     0,    27,    51,    51,
  458.      0,     0,    80,    89,     0,     0,     0,     0,    84,    85,
  459.      0,     8,    29,    30,    31,     0,     0,    28,    37,    38,
  460.      0,     0,   101,   102,   103,   104,   105,   106,   107,   108,
  461.    109,   110,   111,   112,   113,   114,   115,   116,   117,   118,
  462.    119,   120,     0,     0,     0,     0,     0,     0,     0,     0,
  463.      0,     0,     0,     0,     0,   143,     0,     0,     0,     0,
  464.      0,     0,     0,     0,     0,    33,     0,    23,    93,   202,
  465.     24,    95,   201,    52,    53,    54,    55,    56,    57,    58,
  466.     59,    60,    61,    62,    63,    64,    65,     0,     0,     0,
  467.      0,     0,     0,     0,   179,   180,     0,     0,     0,     0,
  468.      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
  469.      0,     0,     0,     0,    90,    91,    -2,   200,     0,    92,
  470.     83,    86,    87,     0,     0,     0,     0,     0,     0,     0,
  471.      0,     0,     0,     0,     0,     0,   167,   168,   169,     0,
  472.      0,   170,   171,   172,     0,     0,   187,   188,     0,   177,
  473.    178,     0,   184,   185,   186,     0,     0,     0,     0,   146,
  474.    157,     0,     0,   148,   150,   153,     0,   159,     0,     0,
  475.      0,   206,   207,     0,   162,     0,     0,     0,     0,     0,
  476.     94,    96,    66,    67,     0,    69,    70,   160,   161,     0,
  477.    189,   190,     0,     0,     0,     0,     0,     0,     0,     0,
  478.      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
  479.      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
  480.      0,     0,     0,     0,   173,   174,     0,     0,   175,   176,
  481.      0,   139,   140,     0,     0,     0,     0,   145,     0,     0,
  482.      0,     0,     0,     0,     0,   191,   192,   193,     0,   142,
  483.    144,   165,     0,   208,   209,    99,     0,     0,    34,    35,
  484.      0,     0,     0,     0,    44,     0,     0,    46,     0,   198,
  485.      0,   197,     0,   196,     0,     0,     0,     0,     0,     0,
  486.    151,   154,     0,     0,     0,   210,     0,     0,     0,     0,
  487.      0,     0,     0,   121,   130,   141,   181,     0,     0,     0,
  488.      0,   155,   164,   194,   195,     0,   166,     0,     0,     0,
  489.     71,    72,     0,     0,    48,     0,     0,     0,    50,     0,
  490.    123,   132,   163,     0,     0,   147,     0,   149,   152,     0,
  491.    199,    11,    12,    13,     0,    73,    74,     0,     0,     0,
  492.      0,     0,     0,     0,   122,   131,     0,   182,     0,     0,
  493.    156,    36,    68,    41,     0,    43,    41,     0,    45,   124,
  494.      0,     0,     0,   135,   136,     0,     0,     0,    40,     0,
  495.      0,    39,     0,   125,   126,   127,   128,     0,     0,     0,
  496.    183,   211,     0,    42,    47,    49,   129,   133,   137,   138,
  497.      0,   158,     0,   134,   204,   205 };
  498. typedef struct { char *t_name; int t_val; } yytoktype;
  499. #ifndef YYDEBUG
  500. #    define YYDEBUG    0    /* don't allow debugging */
  501. #endif
  502.  
  503. #if YYDEBUG
  504.  
  505. yytoktype yytoks[] =
  506. {
  507.     "CHAR",    257,
  508.     "INTEGER",    258,
  509.     "BOOLEAN",    259,
  510.     "MESSAGE_ID",    260,
  511.     "MAZE_ID",    261,
  512.     "LEVEL_ID",    262,
  513.     "LEV_INIT_ID",    263,
  514.     "GEOMETRY_ID",    264,
  515.     "NOMAP_ID",    265,
  516.     "OBJECT_ID",    266,
  517.     "MONSTER_ID",    267,
  518.     "TRAP_ID",    268,
  519.     "DOOR_ID",    269,
  520.     "DRAWBRIDGE_ID",    270,
  521.     "MAZEWALK_ID",    271,
  522.     "WALLIFY_ID",    272,
  523.     "REGION_ID",    273,
  524.     "FILLING",    274,
  525.     "RANDOM_OBJECTS_ID",    275,
  526.     "RANDOM_MONSTERS_ID",    276,
  527.     "RANDOM_PLACES_ID",    277,
  528.     "ALTAR_ID",    278,
  529.     "LADDER_ID",    279,
  530.     "STAIR_ID",    280,
  531.     "NON_DIGGABLE_ID",    281,
  532.     "ROOM_ID",    282,
  533.     "PORTAL_ID",    283,
  534.     "TELEPRT_ID",    284,
  535.     "BRANCH_ID",    285,
  536.     "LEV",    286,
  537.     "CHANCE_ID",    287,
  538.     "CORRIDOR_ID",    288,
  539.     "GOLD_ID",    289,
  540.     "ENGRAVING_ID",    290,
  541.     "FOUNTAIN_ID",    291,
  542.     "POOL_ID",    292,
  543.     "SINK_ID",    293,
  544.     "NONE",    294,
  545.     "RAND_CORRIDOR_ID",    295,
  546.     "DOOR_STATE",    296,
  547.     "LIGHT_STATE",    297,
  548.     "CURSE_TYPE",    298,
  549.     "ENGRAVING_TYPE",    299,
  550.     "DIRECTION",    300,
  551.     "RANDOM_TYPE",    301,
  552.     "O_REGISTER",    302,
  553.     "M_REGISTER",    303,
  554.     "P_REGISTER",    304,
  555.     "A_REGISTER",    305,
  556.     "ALIGNMENT",    306,
  557.     "LEFT_OR_RIGHT",    307,
  558.     "CENTER",    308,
  559.     "TOP_OR_BOT",    309,
  560.     "ALTAR_TYPE",    310,
  561.     "UP_OR_DOWN",    311,
  562.     "SUBROOM_ID",    312,
  563.     "NAME_ID",    313,
  564.     "FLAGS_ID",    314,
  565.     "FLAG_TYPE",    315,
  566.     "MON_ATTITUDE",    316,
  567.     "MON_ALERTNESS",    317,
  568.     "MON_APPEARANCE",    318,
  569.     ",",    44,
  570.     ":",    58,
  571.     "(",    40,
  572.     ")",    41,
  573.     "[",    91,
  574.     "]",    93,
  575.     "STRING",    319,
  576.     "MAP_ID",    320,
  577.     "-unknown-",    -1    /* ends search */
  578. };
  579.  
  580. char * yyreds[] =
  581. {
  582.     "-no such reduction-",
  583.     "file : /* empty */",
  584.     "file : levels",
  585.     "levels : level",
  586.     "levels : level levels",
  587.     "level : maze_level",
  588.     "level : room_level",
  589.     "maze_level : maze_def flags lev_init messages regions",
  590.     "room_level : level_def flags lev_init messages rreg_init rooms corridors_def",
  591.     "level_def : LEVEL_ID ':' string",
  592.     "lev_init : /* empty */",
  593.     "lev_init : LEV_INIT_ID ':' CHAR ',' CHAR ',' BOOLEAN ',' BOOLEAN ',' light_state ',' walled",
  594.     "walled : BOOLEAN",
  595.     "walled : RANDOM_TYPE",
  596.     "flags : /* empty */",
  597.     "flags : FLAGS_ID ':' flag_list",
  598.     "flag_list : FLAG_TYPE",
  599.     "flag_list : FLAG_TYPE ',' flag_list",
  600.     "messages : /* empty */",
  601.     "messages : message messages",
  602.     "message : MESSAGE_ID ':' STRING",
  603.     "rreg_init : /* empty */",
  604.     "rreg_init : rreg_init init_rreg",
  605.     "init_rreg : RANDOM_OBJECTS_ID ':' object_list",
  606.     "init_rreg : RANDOM_MONSTERS_ID ':' monster_list",
  607.     "rooms : /* empty */",
  608.     "rooms : roomlist",
  609.     "roomlist : aroom",
  610.     "roomlist : aroom roomlist",
  611.     "corridors_def : random_corridors",
  612.     "corridors_def : corridors",
  613.     "random_corridors : RAND_CORRIDOR_ID",
  614.     "corridors : /* empty */",
  615.     "corridors : corridors corridor",
  616.     "corridor : CORRIDOR_ID ':' corr_spec ',' corr_spec",
  617.     "corridor : CORRIDOR_ID ':' corr_spec ',' INTEGER",
  618.     "corr_spec : '(' INTEGER ',' DIRECTION ',' door_pos ')'",
  619.     "aroom : room_def room_details",
  620.     "aroom : subroom_def room_details",
  621.     "subroom_def : SUBROOM_ID ':' room_type ',' light_state ',' subroom_pos ',' room_size ',' string roomfill",
  622.     "room_def : ROOM_ID ':' room_type ',' light_state ',' room_pos ',' room_align ',' room_size roomfill",
  623.     "roomfill : /* empty */",
  624.     "roomfill : ',' BOOLEAN",
  625.     "room_pos : '(' INTEGER ',' INTEGER ')'",
  626.     "room_pos : RANDOM_TYPE",
  627.     "subroom_pos : '(' INTEGER ',' INTEGER ')'",
  628.     "subroom_pos : RANDOM_TYPE",
  629.     "room_align : '(' h_justif ',' v_justif ')'",
  630.     "room_align : RANDOM_TYPE",
  631.     "room_size : '(' INTEGER ',' INTEGER ')'",
  632.     "room_size : RANDOM_TYPE",
  633.     "room_details : /* empty */",
  634.     "room_details : room_details room_detail",
  635.     "room_detail : room_name",
  636.     "room_detail : room_chance",
  637.     "room_detail : room_door",
  638.     "room_detail : monster_detail",
  639.     "room_detail : object_detail",
  640.     "room_detail : trap_detail",
  641.     "room_detail : altar_detail",
  642.     "room_detail : fountain_detail",
  643.     "room_detail : sink_detail",
  644.     "room_detail : pool_detail",
  645.     "room_detail : gold_detail",
  646.     "room_detail : engraving_detail",
  647.     "room_detail : stair_detail",
  648.     "room_name : NAME_ID ':' string",
  649.     "room_chance : CHANCE_ID ':' INTEGER",
  650.     "room_door : DOOR_ID ':' secret ',' door_state ',' door_wall ',' door_pos",
  651.     "secret : BOOLEAN",
  652.     "secret : RANDOM_TYPE",
  653.     "door_wall : DIRECTION",
  654.     "door_wall : RANDOM_TYPE",
  655.     "door_pos : INTEGER",
  656.     "door_pos : RANDOM_TYPE",
  657.     "maze_def : MAZE_ID ':' string ',' filling",
  658.     "filling : CHAR",
  659.     "filling : RANDOM_TYPE",
  660.     "regions : aregion",
  661.     "regions : aregion regions",
  662.     "aregion : map_definition reg_init map_details",
  663.     "map_definition : NOMAP_ID",
  664.     "map_definition : map_geometry MAP_ID",
  665.     "map_geometry : GEOMETRY_ID ':' h_justif ',' v_justif",
  666.     "h_justif : LEFT_OR_RIGHT",
  667.     "h_justif : CENTER",
  668.     "v_justif : TOP_OR_BOT",
  669.     "v_justif : CENTER",
  670.     "reg_init : /* empty */",
  671.     "reg_init : reg_init init_reg",
  672.     "init_reg : RANDOM_OBJECTS_ID ':' object_list",
  673.     "init_reg : RANDOM_PLACES_ID ':' place_list",
  674.     "init_reg : RANDOM_MONSTERS_ID ':' monster_list",
  675.     "object_list : object",
  676.     "object_list : object ',' object_list",
  677.     "monster_list : monster",
  678.     "monster_list : monster ',' monster_list",
  679.     "place_list : place",
  680.     "place_list : place",
  681.     "place_list : place ',' place_list",
  682.     "map_details : /* empty */",
  683.     "map_details : map_details map_detail",
  684.     "map_detail : monster_detail",
  685.     "map_detail : object_detail",
  686.     "map_detail : door_detail",
  687.     "map_detail : trap_detail",
  688.     "map_detail : drawbridge_detail",
  689.     "map_detail : region_detail",
  690.     "map_detail : stair_region",
  691.     "map_detail : portal_region",
  692.     "map_detail : teleprt_region",
  693.     "map_detail : branch_region",
  694.     "map_detail : altar_detail",
  695.     "map_detail : fountain_detail",
  696.     "map_detail : mazewalk_detail",
  697.     "map_detail : wallify_detail",
  698.     "map_detail : ladder_detail",
  699.     "map_detail : stair_detail",
  700.     "map_detail : gold_detail",
  701.     "map_detail : engraving_detail",
  702.     "map_detail : diggable_detail",
  703.     "monster_detail : MONSTER_ID ':' monster_c ',' m_name ',' coordinate",
  704.     "monster_detail : MONSTER_ID ':' monster_c ',' m_name ',' coordinate monster_infos",
  705.     "monster_infos : /* empty */",
  706.     "monster_infos : monster_infos monster_info",
  707.     "monster_info : ',' string",
  708.     "monster_info : ',' MON_ATTITUDE",
  709.     "monster_info : ',' MON_ALERTNESS",
  710.     "monster_info : ',' alignment",
  711.     "monster_info : ',' MON_APPEARANCE string",
  712.     "object_detail : OBJECT_ID ':' object_c ',' o_name ',' coordinate",
  713.     "object_detail : OBJECT_ID ':' object_c ',' o_name ',' coordinate object_infos",
  714.     "object_infos : /* empty */",
  715.     "object_infos : ',' STRING ',' enchantment",
  716.     "object_infos : ',' curse_state ',' enchantment ',' art_name",
  717.     "curse_state : RANDOM_TYPE",
  718.     "curse_state : CURSE_TYPE",
  719.     "enchantment : INTEGER",
  720.     "enchantment : RANDOM_TYPE",
  721.     "door_detail : DOOR_ID ':' door_state ',' coordinate",
  722.     "trap_detail : TRAP_ID ':' trap_name ',' coordinate",
  723.     "drawbridge_detail : DRAWBRIDGE_ID ':' coordinate ',' DIRECTION ',' door_state",
  724.     "mazewalk_detail : MAZEWALK_ID ':' coordinate ',' DIRECTION",
  725.     "wallify_detail : WALLIFY_ID",
  726.     "ladder_detail : LADDER_ID ':' coordinate ',' UP_OR_DOWN",
  727.     "stair_detail : STAIR_ID ':' coordinate ',' UP_OR_DOWN",
  728.     "stair_region : STAIR_ID ':' lev_region",
  729.     "stair_region : STAIR_ID ':' lev_region ',' lev_region ',' UP_OR_DOWN",
  730.     "portal_region : PORTAL_ID ':' lev_region",
  731.     "portal_region : PORTAL_ID ':' lev_region ',' lev_region ',' string",
  732.     "teleprt_region : TELEPRT_ID ':' lev_region",
  733.     "teleprt_region : TELEPRT_ID ':' lev_region ',' lev_region",
  734.     "teleprt_region : TELEPRT_ID ':' lev_region ',' lev_region teleprt_detail",
  735.     "branch_region : BRANCH_ID ':' lev_region",
  736.     "branch_region : BRANCH_ID ':' lev_region ',' lev_region",
  737.     "teleprt_detail : /* empty */",
  738.     "teleprt_detail : ',' UP_OR_DOWN",
  739.     "lev_region : region",
  740.     "lev_region : LEV '(' INTEGER ',' INTEGER ',' INTEGER ',' INTEGER ')'",
  741.     "fountain_detail : FOUNTAIN_ID ':' coordinate",
  742.     "sink_detail : SINK_ID ':' coordinate",
  743.     "pool_detail : POOL_ID ':' coordinate",
  744.     "diggable_detail : NON_DIGGABLE_ID ':' region",
  745.     "region_detail : REGION_ID ':' region ',' light_state ',' room_type prefilled",
  746.     "altar_detail : ALTAR_ID ':' coordinate ',' alignment ',' altar_type",
  747.     "gold_detail : GOLD_ID ':' amount ',' coordinate",
  748.     "engraving_detail : ENGRAVING_ID ':' coordinate ',' engraving_type ',' string",
  749.     "monster_c : monster",
  750.     "monster_c : RANDOM_TYPE",
  751.     "monster_c : m_register",
  752.     "object_c : object",
  753.     "object_c : RANDOM_TYPE",
  754.     "object_c : o_register",
  755.     "m_name : string",
  756.     "m_name : RANDOM_TYPE",
  757.     "o_name : string",
  758.     "o_name : RANDOM_TYPE",
  759.     "trap_name : string",
  760.     "trap_name : RANDOM_TYPE",
  761.     "room_type : string",
  762.     "room_type : RANDOM_TYPE",
  763.     "prefilled : /* empty */",
  764.     "prefilled : ',' FILLING",
  765.     "prefilled : ',' FILLING ',' BOOLEAN",
  766.     "coordinate : coord",
  767.     "coordinate : p_register",
  768.     "coordinate : RANDOM_TYPE",
  769.     "door_state : DOOR_STATE",
  770.     "door_state : RANDOM_TYPE",
  771.     "light_state : LIGHT_STATE",
  772.     "light_state : RANDOM_TYPE",
  773.     "alignment : ALIGNMENT",
  774.     "alignment : a_register",
  775.     "alignment : RANDOM_TYPE",
  776.     "altar_type : ALTAR_TYPE",
  777.     "altar_type : RANDOM_TYPE",
  778.     "p_register : P_REGISTER '[' INTEGER ']'",
  779.     "o_register : O_REGISTER '[' INTEGER ']'",
  780.     "m_register : M_REGISTER '[' INTEGER ']'",
  781.     "a_register : A_REGISTER '[' INTEGER ']'",
  782.     "place : coord",
  783.     "monster : CHAR",
  784.     "object : CHAR",
  785.     "string : STRING",
  786.     "art_name : STRING",
  787.     "art_name : NONE",
  788.     "amount : INTEGER",
  789.     "amount : RANDOM_TYPE",
  790.     "engraving_type : ENGRAVING_TYPE",
  791.     "engraving_type : RANDOM_TYPE",
  792.     "coord : '(' INTEGER ',' INTEGER ')'",
  793.     "region : '(' INTEGER ',' INTEGER ',' INTEGER ',' INTEGER ')'",
  794. };
  795. #endif /* YYDEBUG */
  796. #line 1 "/usr/lib/yaccpar"
  797. /*    @(#)yaccpar 1.10 89/04/04 SMI; from S5R3 1.10    */
  798.  
  799. /*
  800. ** Skeleton parser driver for yacc output
  801. */
  802.  
  803. /*
  804. ** yacc user known macros and defines
  805. */
  806. #define YYERROR        goto yyerrlab
  807. #define YYACCEPT    { free(yys); free(yyv); return(0); }
  808. #define YYABORT        { free(yys); free(yyv); return(1); }
  809. #define YYBACKUP( newtoken, newvalue )\
  810. {\
  811.     if ( yychar >= 0 || ( yyr2[ yytmp ] >> 1 ) != 1 )\
  812.     {\
  813.         yyerror( "syntax error - cannot backup" );\
  814.         goto yyerrlab;\
  815.     }\
  816.     yychar = newtoken;\
  817.     yystate = *yyps;\
  818.     yylval = newvalue;\
  819.     goto yynewstate;\
  820. }
  821. #define YYRECOVERING()    (!!yyerrflag)
  822. #ifndef YYDEBUG
  823. #    define YYDEBUG    1    /* make debugging available */
  824. #endif
  825.  
  826. /*
  827. ** user known globals
  828. */
  829. int yydebug;            /* set to 1 to get debugging */
  830.  
  831. /*
  832. ** driver internal defines
  833. */
  834. #define YYFLAG        (-1000)
  835.  
  836. /*
  837. ** static variables used by the parser
  838. */
  839. static YYSTYPE *yyv;            /* value stack */
  840. static int *yys;            /* state stack */
  841.  
  842. static YYSTYPE *yypv;            /* top of value stack */
  843. static int *yyps;            /* top of state stack */
  844.  
  845. static int yystate;            /* current state */
  846. static int yytmp;            /* extra var (lasts between blocks) */
  847.  
  848. int yynerrs;            /* number of errors */
  849.  
  850. int yyerrflag;            /* error recovery flag */
  851. int yychar;            /* current input token number */
  852.  
  853.  
  854. /*
  855. ** yyparse - return 0 if worked, 1 if syntax error not recovered from
  856. */
  857. int
  858. yyparse()
  859. {
  860.     register YYSTYPE *yypvt;    /* top of value stack for $vars */
  861.     unsigned yymaxdepth = YYMAXDEPTH;
  862.  
  863.     /*
  864.     ** Initialize externals - yyparse may be called more than once
  865.     */
  866.     yyv = (YYSTYPE*)malloc(yymaxdepth*sizeof(YYSTYPE));
  867.     yys = (int*)malloc(yymaxdepth*sizeof(int));
  868.     if (!yyv || !yys)
  869.     {
  870.         yyerror( "out of memory" );
  871.         return(1);
  872.     }
  873.     yypv = &yyv[-1];
  874.     yyps = &yys[-1];
  875.     yystate = 0;
  876.     yytmp = 0;
  877.     yynerrs = 0;
  878.     yyerrflag = 0;
  879.     yychar = -1;
  880.  
  881.     goto yystack;
  882.     {
  883.         register YYSTYPE *yy_pv;    /* top of value stack */
  884.         register int *yy_ps;        /* top of state stack */
  885.         register int yy_state;        /* current state */
  886.         register int  yy_n;        /* internal state number info */
  887.  
  888.         /*
  889.         ** get globals into registers.
  890.         ** branch to here only if YYBACKUP was called.
  891.         */
  892.     yynewstate:
  893.         yy_pv = yypv;
  894.         yy_ps = yyps;
  895.         yy_state = yystate;
  896.         goto yy_newstate;
  897.  
  898.         /*
  899.         ** get globals into registers.
  900.         ** either we just started, or we just finished a reduction
  901.         */
  902.     yystack:
  903.         yy_pv = yypv;
  904.         yy_ps = yyps;
  905.         yy_state = yystate;
  906.  
  907.         /*
  908.         ** top of for (;;) loop while no reductions done
  909.         */
  910.     yy_stack:
  911.         /*
  912.         ** put a state and value onto the stacks
  913.         */
  914. #if YYDEBUG
  915.         /*
  916.         ** if debugging, look up token value in list of value vs.
  917.         ** name pairs.  0 and negative (-1) are special values.
  918.         ** Note: linear search is used since time is not a real
  919.         ** consideration while debugging.
  920.         */
  921.         if ( yydebug )
  922.         {
  923.             register int yy_i;
  924.  
  925.             (void)printf( "State %d, token ", yy_state );
  926.             if ( yychar == 0 )
  927.                 (void)printf( "end-of-file\n" );
  928.             else if ( yychar < 0 )
  929.                 (void)printf( "-none-\n" );
  930.             else
  931.             {
  932.                 for ( yy_i = 0; yytoks[yy_i].t_val >= 0;
  933.                     yy_i++ )
  934.                 {
  935.                     if ( yytoks[yy_i].t_val == yychar )
  936.                         break;
  937.                 }
  938.                 (void)printf( "%s\n", yytoks[yy_i].t_name );
  939.             }
  940.         }
  941. #endif /* YYDEBUG */
  942.         if ( ++yy_ps >= &yys[ yymaxdepth ] )    /* room on stack? */
  943.         {
  944.             /*
  945.             ** reallocate and recover.  Note that pointers
  946.             ** have to be reset, or bad things will happen
  947.             */
  948.             int yyps_index = (yy_ps - yys);
  949.             int yypv_index = (yy_pv - yyv);
  950.             int yypvt_index = (yypvt - yyv);
  951.             yymaxdepth += YYMAXDEPTH;
  952.             yyv = (YYSTYPE*)realloc((char*)yyv,
  953.                 yymaxdepth * sizeof(YYSTYPE));
  954.             yys = (int*)realloc((char*)yys,
  955.                 yymaxdepth * sizeof(int));
  956.             if (!yyv || !yys)
  957.             {
  958.                 yyerror( "yacc stack overflow" );
  959.                 return(1);
  960.             }
  961.             yy_ps = yys + yyps_index;
  962.             yy_pv = yyv + yypv_index;
  963.             yypvt = yyv + yypvt_index;
  964.         }
  965.         *yy_ps = yy_state;
  966.         *++yy_pv = yyval;
  967.  
  968.         /*
  969.         ** we have a new state - find out what to do
  970.         */
  971.     yy_newstate:
  972.         if ( ( yy_n = yypact[ yy_state ] ) <= YYFLAG )
  973.             goto yydefault;        /* simple state */
  974. #if YYDEBUG
  975.         /*
  976.         ** if debugging, need to mark whether new token grabbed
  977.         */
  978.         yytmp = yychar < 0;
  979. #endif
  980.         if ( ( yychar < 0 ) && ( ( yychar = yylex() ) < 0 ) )
  981.             yychar = 0;        /* reached EOF */
  982. #if YYDEBUG
  983.         if ( yydebug && yytmp )
  984.         {
  985.             register int yy_i;
  986.  
  987.             (void)printf( "Received token " );
  988.             if ( yychar == 0 )
  989.                 (void)printf( "end-of-file\n" );
  990.             else if ( yychar < 0 )
  991.                 (void)printf( "-none-\n" );
  992.             else
  993.             {
  994.                 for ( yy_i = 0; yytoks[yy_i].t_val >= 0;
  995.                     yy_i++ )
  996.                 {
  997.                     if ( yytoks[yy_i].t_val == yychar )
  998.                         break;
  999.                 }
  1000.                 (void)printf( "%s\n", yytoks[yy_i].t_name );
  1001.             }
  1002.         }
  1003. #endif /* YYDEBUG */
  1004.         if ( ( ( yy_n += yychar ) < 0 ) || ( yy_n >= YYLAST ) )
  1005.             goto yydefault;
  1006.         if ( yychk[ yy_n = yyact[ yy_n ] ] == yychar )    /*valid shift*/
  1007.         {
  1008.             yychar = -1;
  1009.             yyval = yylval;
  1010.             yy_state = yy_n;
  1011.             if ( yyerrflag > 0 )
  1012.                 yyerrflag--;
  1013.             goto yy_stack;
  1014.         }
  1015.  
  1016.     yydefault:
  1017.         if ( ( yy_n = yydef[ yy_state ] ) == -2 )
  1018.         {
  1019. #if YYDEBUG
  1020.             yytmp = yychar < 0;
  1021. #endif
  1022.             if ( ( yychar < 0 ) && ( ( yychar = yylex() ) < 0 ) )
  1023.                 yychar = 0;        /* reached EOF */
  1024. #if YYDEBUG
  1025.             if ( yydebug && yytmp )
  1026.             {
  1027.                 register int yy_i;
  1028.  
  1029.                 (void)printf( "Received token " );
  1030.                 if ( yychar == 0 )
  1031.                     (void)printf( "end-of-file\n" );
  1032.                 else if ( yychar < 0 )
  1033.                     (void)printf( "-none-\n" );
  1034.                 else
  1035.                 {
  1036.                     for ( yy_i = 0;
  1037.                         yytoks[yy_i].t_val >= 0;
  1038.                         yy_i++ )
  1039.                     {
  1040.                         if ( yytoks[yy_i].t_val
  1041.                             == yychar )
  1042.                         {
  1043.                             break;
  1044.                         }
  1045.                     }
  1046.                     (void)printf( "%s\n", yytoks[yy_i].t_name );
  1047.                 }
  1048.             }
  1049. #endif /* YYDEBUG */
  1050.             /*
  1051.             ** look through exception table
  1052.             */
  1053.             {
  1054.                 register int *yyxi = yyexca;
  1055.  
  1056.                 while ( ( *yyxi != -1 ) ||
  1057.                     ( yyxi[1] != yy_state ) )
  1058.                 {
  1059.                     yyxi += 2;
  1060.                 }
  1061.                 while ( ( *(yyxi += 2) >= 0 ) &&
  1062.                     ( *yyxi != yychar ) )
  1063.                     ;
  1064.                 if ( ( yy_n = yyxi[1] ) < 0 )
  1065.                     YYACCEPT;
  1066.             }
  1067.         }
  1068.  
  1069.         /*
  1070.         ** check for syntax error
  1071.         */
  1072.         if ( yy_n == 0 )    /* have an error */
  1073.         {
  1074.             /* no worry about speed here! */
  1075.             switch ( yyerrflag )
  1076.             {
  1077.             case 0:        /* new error */
  1078.                 yyerror( "syntax error" );
  1079.                 goto skip_init;
  1080.             yyerrlab:
  1081.                 /*
  1082.                 ** get globals into registers.
  1083.                 ** we have a user generated syntax type error
  1084.                 */
  1085.                 yy_pv = yypv;
  1086.                 yy_ps = yyps;
  1087.                 yy_state = yystate;
  1088.                 yynerrs++;
  1089.             skip_init:
  1090.             case 1:
  1091.             case 2:        /* incompletely recovered error */
  1092.                     /* try again... */
  1093.                 yyerrflag = 3;
  1094.                 /*
  1095.                 ** find state where "error" is a legal
  1096.                 ** shift action
  1097.                 */
  1098.                 while ( yy_ps >= yys )
  1099.                 {
  1100.                     yy_n = yypact[ *yy_ps ] + YYERRCODE;
  1101.                     if ( yy_n >= 0 && yy_n < YYLAST &&
  1102.                         yychk[yyact[yy_n]] == YYERRCODE)                    {
  1103.                         /*
  1104.                         ** simulate shift of "error"
  1105.                         */
  1106.                         yy_state = yyact[ yy_n ];
  1107.                         goto yy_stack;
  1108.                     }
  1109.                     /*
  1110.                     ** current state has no shift on
  1111.                     ** "error", pop stack
  1112.                     */
  1113. #if YYDEBUG
  1114. #    define _POP_ "Error recovery pops state %d, uncovers state %d\n"
  1115.                     if ( yydebug )
  1116.                         (void)printf( _POP_, *yy_ps,
  1117.                             yy_ps[-1] );
  1118. #    undef _POP_
  1119. #endif
  1120.                     yy_ps--;
  1121.                     yy_pv--;
  1122.                 }
  1123.                 /*
  1124.                 ** there is no state on stack with "error" as
  1125.                 ** a valid shift.  give up.
  1126.                 */
  1127.                 YYABORT;
  1128.             case 3:        /* no shift yet; eat a token */
  1129. #if YYDEBUG
  1130.                 /*
  1131.                 ** if debugging, look up token in list of
  1132.                 ** pairs.  0 and negative shouldn't occur,
  1133.                 ** but since timing doesn't matter when
  1134.                 ** debugging, it doesn't hurt to leave the
  1135.                 ** tests here.
  1136.                 */
  1137.                 if ( yydebug )
  1138.                 {
  1139.                     register int yy_i;
  1140.  
  1141.                     (void)printf( "Error recovery discards " );
  1142.                     if ( yychar == 0 )
  1143.                         (void)printf( "token end-of-file\n" );
  1144.                     else if ( yychar < 0 )
  1145.                         (void)printf( "token -none-\n" );
  1146.                     else
  1147.                     {
  1148.                         for ( yy_i = 0;
  1149.                             yytoks[yy_i].t_val >= 0;
  1150.                             yy_i++ )
  1151.                         {
  1152.                             if ( yytoks[yy_i].t_val
  1153.                                 == yychar )
  1154.                             {
  1155.                                 break;
  1156.                             }
  1157.                         }
  1158.                         (void)printf( "token %s\n",
  1159.                             yytoks[yy_i].t_name );
  1160.                     }
  1161.                 }
  1162. #endif /* YYDEBUG */
  1163.                 if ( yychar == 0 )    /* reached EOF. quit */
  1164.                     YYABORT;
  1165.                 yychar = -1;
  1166.                 goto yy_newstate;
  1167.             }
  1168.         }/* end if ( yy_n == 0 ) */
  1169.         /*
  1170.         ** reduction by production yy_n
  1171.         ** put stack tops, etc. so things right after switch
  1172.         */
  1173. #if YYDEBUG
  1174.         /*
  1175.         ** if debugging, print the string that is the user's
  1176.         ** specification of the reduction which is just about
  1177.         ** to be done.
  1178.         */
  1179.         if ( yydebug )
  1180.             (void)printf( "Reduce by (%d) \"%s\"\n",
  1181.                 yy_n, yyreds[ yy_n ] );
  1182. #endif
  1183.         yytmp = yy_n;            /* value to switch over */
  1184.         yypvt = yy_pv;            /* $vars top of value stack */
  1185.         /*
  1186.         ** Look in goto table for next state
  1187.         ** Sorry about using yy_state here as temporary
  1188.         ** register variable, but why not, if it works...
  1189.         ** If yyr2[ yy_n ] doesn't have the low order bit
  1190.         ** set, then there is no action to be done for
  1191.         ** this reduction.  So, no saving & unsaving of
  1192.         ** registers done.  The only difference between the
  1193.         ** code just after the if and the body of the if is
  1194.         ** the goto yy_stack in the body.  This way the test
  1195.         ** can be made before the choice of what to do is needed.
  1196.         */
  1197.         {
  1198.             /* length of production doubled with extra bit */
  1199.             register int yy_len = yyr2[ yy_n ];
  1200.  
  1201.             if ( !( yy_len & 01 ) )
  1202.             {
  1203.                 yy_len >>= 1;
  1204.                 yyval = ( yy_pv -= yy_len )[1];    /* $$ = $1 */
  1205.                 yy_state = yypgo[ yy_n = yyr1[ yy_n ] ] +
  1206.                     *( yy_ps -= yy_len ) + 1;
  1207.                 if ( yy_state >= YYLAST ||
  1208.                     yychk[ yy_state =
  1209.                     yyact[ yy_state ] ] != -yy_n )
  1210.                 {
  1211.                     yy_state = yyact[ yypgo[ yy_n ] ];
  1212.                 }
  1213.                 goto yy_stack;
  1214.             }
  1215.             yy_len >>= 1;
  1216.             yyval = ( yy_pv -= yy_len )[1];    /* $$ = $1 */
  1217.             yy_state = yypgo[ yy_n = yyr1[ yy_n ] ] +
  1218.                 *( yy_ps -= yy_len ) + 1;
  1219.             if ( yy_state >= YYLAST ||
  1220.                 yychk[ yy_state = yyact[ yy_state ] ] != -yy_n )
  1221.             {
  1222.                 yy_state = yyact[ yypgo[ yy_n ] ];
  1223.             }
  1224.         }
  1225.                     /* save until reenter driver code */
  1226.         yystate = yy_state;
  1227.         yyps = yy_ps;
  1228.         yypv = yy_pv;
  1229.     }
  1230.     /*
  1231.     ** code supplied by user is placed in this switch
  1232.     */
  1233.     switch( yytmp )
  1234.     {
  1235.         
  1236. case 7:
  1237. # line 193 "lev_comp.y"
  1238. {
  1239.               int fout, i;
  1240.  
  1241.             if (fatal_error > 0) {
  1242.                 fprintf(stderr,
  1243.                   "%s : %d errors detected. No output created!\n",
  1244.                     fname, fatal_error);
  1245.             } else {
  1246.                 char lbuf[20];
  1247.                 Strcpy(lbuf, yypvt[-4].map);
  1248.                 Strcat(lbuf, LEV_EXT);
  1249. #ifdef MAC_THINKC5
  1250.                 fout = open(lbuf, O_WRONLY|O_CREAT|O_BINARY);
  1251. #else
  1252.                 fout = open(lbuf, O_WRONLY|O_CREAT|O_BINARY, OMASK);
  1253. #endif
  1254.                 if (fout < 0) {
  1255.                     yyerror("Can't open output file!!");
  1256.                     exit(1);
  1257.                 }
  1258.                 maze.flags = yypvt[-3].i;
  1259.                 memcpy(&(maze.init_lev), &(init_lev),
  1260.                        sizeof(lev_init));
  1261.                 maze.numpart = npart;
  1262.                 maze.parts = NewTab(mazepart, npart);
  1263.                 for(i=0;i<npart;i++)
  1264.                     maze.parts[i] = tmppart[i];
  1265.                 write_maze(fout, &maze);
  1266.                 (void) close(fout);
  1267.                 npart = 0;
  1268.             }
  1269.           } break;
  1270. case 8:
  1271. # line 228 "lev_comp.y"
  1272. {
  1273.             int fout, i;
  1274.  
  1275.             if (fatal_error > 0) {
  1276.                 fprintf(stderr,
  1277.                   "%s : %d errors detected. No output created!\n",
  1278.                     fname, fatal_error);
  1279.             } else {
  1280.                 char lbuf[20];
  1281.                 Strcpy(lbuf, yypvt[-6].map);
  1282.                 Strcat(lbuf, LEV_EXT);
  1283. #ifdef MAC_THINKC5
  1284.                 fout = open(lbuf, O_WRONLY|O_CREAT|O_BINARY);
  1285. #else
  1286.                 fout = open(lbuf, O_WRONLY|O_CREAT|O_BINARY, OMASK);
  1287. #endif
  1288.                 if (fout < 0) {
  1289.                     yyerror("Can't open output file!!");
  1290.                     exit(1);
  1291.                 }
  1292.                 special_lev.flags = yypvt[-5].i;
  1293.                 memcpy(&(special_lev.init_lev), &(init_lev),
  1294.                        sizeof(lev_init));
  1295.                 special_lev.nroom = nrooms;
  1296.                 special_lev.rooms = NewTab(room, nrooms);
  1297.                 for(i=0; i<nrooms; i++)
  1298.                     special_lev.rooms[i] = tmproom[i];
  1299.                 special_lev.ncorr = ncorridor;
  1300.                 special_lev.corrs = NewTab(corridor, ncorridor);
  1301.                 for(i=0; i<ncorridor; i++)
  1302.                     special_lev.corrs[i] = tmpcor[i];
  1303.                 if (check_subrooms())
  1304.                     write_lev(fout, &special_lev);
  1305.                 free_rooms(special_lev.rooms,special_lev.nroom);
  1306.                 nrooms = 0;
  1307.                 ncorridor = 0;
  1308.                 (void) close(fout);
  1309.             }
  1310.           } break;
  1311. case 9:
  1312. # line 270 "lev_comp.y"
  1313. {
  1314.             if (index(yypvt[-0].map, '.'))
  1315.                 yyerror("Invalid dot ('.') in level name.");
  1316.             if (strlen(yypvt[-0].map) > 8)
  1317.                 yyerror("Level names limited to 8 characters.");
  1318.             yyval.map = yypvt[-0].map;
  1319.             special_lev.nrobjects = 0;
  1320.             special_lev.nrmonst = 0;
  1321.           } break;
  1322. case 10:
  1323. # line 282 "lev_comp.y"
  1324. {
  1325.             init_lev.init_present = FALSE;
  1326.             yyval.i = 0;
  1327.           } break;
  1328. case 11:
  1329. # line 287 "lev_comp.y"
  1330. {
  1331.             init_lev.init_present = TRUE;
  1332.             if((init_lev.fg = what_map_char(yypvt[-10].i)) == INVALID_TYPE)
  1333.                 yyerror("Invalid foreground type.");
  1334.             if((init_lev.bg = what_map_char(yypvt[-8].i)) == INVALID_TYPE)
  1335.                 yyerror("Invalid background type.");
  1336.             init_lev.smoothed = yypvt[-6].i;
  1337.             init_lev.joined = yypvt[-4].i;
  1338.             init_lev.lit = yypvt[-2].i;
  1339.             init_lev.walled = yypvt[-0].i;
  1340.             yyval.i = 1;
  1341.           } break;
  1342. case 14:
  1343. # line 306 "lev_comp.y"
  1344. {
  1345.             yyval.i = 0;
  1346.           } break;
  1347. case 15:
  1348. # line 310 "lev_comp.y"
  1349. {
  1350.             yyval.i = lev_flags;
  1351.           } break;
  1352. case 16:
  1353. # line 316 "lev_comp.y"
  1354. {
  1355.             lev_flags |= yypvt[-0].i;
  1356.           } break;
  1357. case 17:
  1358. # line 320 "lev_comp.y"
  1359. {
  1360.             lev_flags |= yypvt[-0].i;
  1361.           } break;
  1362. case 20:
  1363. # line 330 "lev_comp.y"
  1364. {
  1365.             int i, j;
  1366.  
  1367.             i = strlen(yypvt[-0].map) + 1;
  1368.             j = tmpmessage[0] ? strlen(tmpmessage) : 0;
  1369.             if(i+j > 255) {
  1370.                yyerror("Message string too long (>256 characters)");
  1371.             } else {
  1372.                 if(j) tmpmessage[j++] = '\n';
  1373.                 strncpy(tmpmessage+j, yypvt[-0].map, i-1);
  1374.                 tmpmessage[j+i-1] = 0;
  1375.             }
  1376.           } break;
  1377. case 23:
  1378. # line 350 "lev_comp.y"
  1379. {
  1380.             if(special_lev.nrobjects) {
  1381.                 yyerror("Object registers already initialized!");
  1382.             } else {
  1383.                 special_lev.nrobjects = n_olist;
  1384.                 special_lev.robjects = (char *) alloc(n_olist);
  1385.                 (void) memcpy((genericptr_t)special_lev.robjects,
  1386.                       (genericptr_t)olist, n_olist);
  1387.             }
  1388.           } break;
  1389. case 24:
  1390. # line 361 "lev_comp.y"
  1391. {
  1392.             if(special_lev.nrmonst) {
  1393.                 yyerror("Monster registers already initialized!");
  1394.             } else {
  1395.                 special_lev.nrmonst = n_mlist;
  1396.                 special_lev.rmonst = (char *) alloc(n_mlist);
  1397.                 (void) memcpy((genericptr_t)special_lev.rmonst,
  1398.                       (genericptr_t)mlist, n_mlist);
  1399.               }
  1400.           } break;
  1401. case 25:
  1402. # line 374 "lev_comp.y"
  1403. {
  1404.             tmproom[nrooms] = New(room);
  1405.             (void) memset((genericptr_t) tmproom[nrooms], 0,
  1406.                     sizeof *tmproom[nrooms]);
  1407.             tmproom[nrooms]->name = (char *) 0;
  1408.             tmproom[nrooms]->parent = (char *) 0;
  1409.             tmproom[nrooms]->rtype = 0;
  1410.             tmproom[nrooms]->rlit = 0;
  1411.             tmproom[nrooms]->xalign = ERR;
  1412.             tmproom[nrooms]->yalign = ERR;
  1413.             tmproom[nrooms]->x = 0;
  1414.             tmproom[nrooms]->y = 0;
  1415.             tmproom[nrooms]->w = 2;
  1416.             tmproom[nrooms]->h = 2;
  1417.             in_room = 1;
  1418.           } break;
  1419. case 31:
  1420. # line 402 "lev_comp.y"
  1421. {
  1422.             tmpcor[0] = New(corridor);
  1423.             tmpcor[0]->src.room = -1;
  1424.             ncorridor = 1;
  1425.           } break;
  1426. case 34:
  1427. # line 414 "lev_comp.y"
  1428. {
  1429.             tmpcor[ncorridor] = New(corridor);
  1430.             tmpcor[ncorridor]->src.room = yypvt[-2].corpos.room;
  1431.             tmpcor[ncorridor]->src.wall = yypvt[-2].corpos.wall;
  1432.             tmpcor[ncorridor]->src.door = yypvt[-2].corpos.door;
  1433.             tmpcor[ncorridor]->dest.room = yypvt[-0].corpos.room;
  1434.             tmpcor[ncorridor]->dest.wall = yypvt[-0].corpos.wall;
  1435.             tmpcor[ncorridor]->dest.door = yypvt[-0].corpos.door;
  1436.             ncorridor++;
  1437.           } break;
  1438. case 35:
  1439. # line 425 "lev_comp.y"
  1440. {
  1441.             tmpcor[ncorridor]->src.room = yypvt[-2].corpos.room;
  1442.             tmpcor[ncorridor]->src.wall = yypvt[-2].corpos.wall;
  1443.             tmpcor[ncorridor]->src.door = yypvt[-2].corpos.door;
  1444.             tmpcor[ncorridor]->dest.room = -1;
  1445.             tmpcor[ncorridor]->dest.wall = yypvt[-0].i;
  1446.             ncorridor++;
  1447.           } break;
  1448. case 36:
  1449. # line 436 "lev_comp.y"
  1450. {
  1451.             if (yypvt[-5].i >= nrooms)
  1452.                 yyerror("Wrong room number!");
  1453.             yyval.corpos.room = yypvt[-5].i;
  1454.             yyval.corpos.wall = yypvt[-3].i;
  1455.             yyval.corpos.door = yypvt[-1].i;
  1456.           } break;
  1457. case 37:
  1458. # line 446 "lev_comp.y"
  1459. {
  1460.             store_room();
  1461.           } break;
  1462. case 38:
  1463. # line 450 "lev_comp.y"
  1464. {
  1465.             store_room();
  1466.           } break;
  1467. case 39:
  1468. # line 456 "lev_comp.y"
  1469. {
  1470.             tmproom[nrooms] = New(room);
  1471.             (void) memset((genericptr_t) tmproom[nrooms], 0,
  1472.                     sizeof *tmproom[nrooms]);
  1473.             tmproom[nrooms]->parent = dup_string(yypvt[-1].map);
  1474.             tmproom[nrooms]->name = (char *) 0;
  1475.             tmproom[nrooms]->rtype = yypvt[-9].i;
  1476.             tmproom[nrooms]->rlit = yypvt[-7].i;
  1477.             tmproom[nrooms]->filled = yypvt[-0].i;
  1478.             tmproom[nrooms]->xalign = ERR;
  1479.             tmproom[nrooms]->yalign = ERR;
  1480.             tmproom[nrooms]->x = current_coord.x;
  1481.             tmproom[nrooms]->y = current_coord.y;
  1482.             tmproom[nrooms]->w = current_size.width;
  1483.             tmproom[nrooms]->h = current_size.height;
  1484.             in_room = 1;
  1485.           } break;
  1486. case 40:
  1487. # line 476 "lev_comp.y"
  1488. {
  1489.             tmproom[nrooms] = New(room);
  1490.             (void) memset((genericptr_t) tmproom[nrooms], 0,
  1491.                     sizeof *tmproom[nrooms]);
  1492.             tmproom[nrooms]->name = (char *) 0;
  1493.             tmproom[nrooms]->parent = (char *) 0;
  1494.             tmproom[nrooms]->rtype = yypvt[-9].i;
  1495.             tmproom[nrooms]->rlit = yypvt[-7].i;
  1496.             tmproom[nrooms]->filled = yypvt[-0].i;
  1497.             tmproom[nrooms]->xalign = current_align.x;
  1498.             tmproom[nrooms]->yalign = current_align.y;
  1499.             tmproom[nrooms]->x = current_coord.x;
  1500.             tmproom[nrooms]->y = current_coord.y;
  1501.             tmproom[nrooms]->w = current_size.width;
  1502.             tmproom[nrooms]->h = current_size.height;
  1503.             in_room = 1;
  1504.           } break;
  1505. case 41:
  1506. # line 496 "lev_comp.y"
  1507. {
  1508.             yyval.i = 1;
  1509.           } break;
  1510. case 42:
  1511. # line 500 "lev_comp.y"
  1512. {
  1513.             yyval.i = yypvt[-0].i;
  1514.           } break;
  1515. case 43:
  1516. # line 506 "lev_comp.y"
  1517. {
  1518.             if ( yypvt[-3].i < 1 || yypvt[-3].i > 5 ||
  1519.                 yypvt[-1].i < 1 || yypvt[-1].i > 5 ) {
  1520.                 yyerror("Room position should be between 1 & 5!");
  1521.             } else {
  1522.                 current_coord.x = yypvt[-3].i;
  1523.                 current_coord.y = yypvt[-1].i;
  1524.             }
  1525.           } break;
  1526. case 44:
  1527. # line 516 "lev_comp.y"
  1528. {
  1529.             current_coord.x = current_coord.y = ERR;
  1530.           } break;
  1531. case 45:
  1532. # line 522 "lev_comp.y"
  1533. {
  1534.             if ( yypvt[-3].i < 0 || yypvt[-1].i < 0) {
  1535.                 yyerror("Invalid subroom position !");
  1536.             } else {
  1537.                 current_coord.x = yypvt[-3].i;
  1538.                 current_coord.y = yypvt[-1].i;
  1539.             }
  1540.           } break;
  1541. case 46:
  1542. # line 531 "lev_comp.y"
  1543. {
  1544.             current_coord.x = current_coord.y = ERR;
  1545.           } break;
  1546. case 47:
  1547. # line 537 "lev_comp.y"
  1548. {
  1549.             current_align.x = yypvt[-3].i;
  1550.             current_align.y = yypvt[-1].i;
  1551.           } break;
  1552. case 48:
  1553. # line 542 "lev_comp.y"
  1554. {
  1555.             current_align.x = current_align.y = ERR;
  1556.           } break;
  1557. case 49:
  1558. # line 548 "lev_comp.y"
  1559. {
  1560.             current_size.width = yypvt[-3].i;
  1561.             current_size.height = yypvt[-1].i;
  1562.           } break;
  1563. case 50:
  1564. # line 553 "lev_comp.y"
  1565. {
  1566.             current_size.height = current_size.width = ERR;
  1567.           } break;
  1568. case 66:
  1569. # line 578 "lev_comp.y"
  1570. {
  1571.             if (tmproom[nrooms]->name)
  1572.                 yyerror("This room already has a name!");
  1573.             else
  1574.                 tmproom[nrooms]->name = dup_string(yypvt[-0].map);
  1575.           } break;
  1576. case 67:
  1577. # line 587 "lev_comp.y"
  1578. {
  1579.             if (tmproom[nrooms]->chance)
  1580.                 yyerror("This room already assigned a chance!");
  1581.             else if (tmproom[nrooms]->rtype == OROOM)
  1582.                 yyerror("Only typed rooms can have a chance!");
  1583.             else if (yypvt[-0].i < 1 || yypvt[-0].i > 99)
  1584.                 yyerror("The chance is supposed to be precentile.");
  1585.             else
  1586.                 tmproom[nrooms]->chance = yypvt[-0].i;
  1587.            } break;
  1588. case 68:
  1589. # line 600 "lev_comp.y"
  1590. {
  1591.             /* ERR means random here */
  1592.             if (yypvt[-2].i == ERR && yypvt[-0].i != ERR) {
  1593.              yyerror("If the door wall is random, so must be its pos!");
  1594.             } else {
  1595.                 tmprdoor[ndoor] = New(room_door);
  1596.                 tmprdoor[ndoor]->secret = yypvt[-6].i;
  1597.                 tmprdoor[ndoor]->mask = yypvt[-4].i;
  1598.                 tmprdoor[ndoor]->wall = yypvt[-2].i;
  1599.                 tmprdoor[ndoor]->pos = yypvt[-0].i;
  1600.                 ndoor++;
  1601.             }
  1602.           } break;
  1603. case 75:
  1604. # line 628 "lev_comp.y"
  1605. {
  1606.             maze.filling = yypvt[-0].i;
  1607.             if (index(yypvt[-2].map, '.'))
  1608.                 yyerror("Invalid dot ('.') in level name.");
  1609.             if (strlen(yypvt[-2].map) > 8)
  1610.                 yyerror("Level names limited to 8 characters.");
  1611.             yyval.map = yypvt[-2].map;
  1612.             in_room = 0;
  1613.           } break;
  1614. case 76:
  1615. # line 640 "lev_comp.y"
  1616. {
  1617.             yyval.i = get_floor_type((char)yypvt[-0].i);
  1618.           } break;
  1619. case 77:
  1620. # line 644 "lev_comp.y"
  1621. {
  1622.             yyval.i = -1;
  1623.           } break;
  1624. case 80:
  1625. # line 654 "lev_comp.y"
  1626. {
  1627.             store_part();
  1628.           } break;
  1629. case 81:
  1630. # line 660 "lev_comp.y"
  1631. {
  1632.             tmppart[npart] = New(mazepart);
  1633.             tmppart[npart]->halign = 1;
  1634.             tmppart[npart]->valign = 1;
  1635.             tmppart[npart]->nrobjects = 0;
  1636.             tmppart[npart]->nloc = 0;
  1637.             tmppart[npart]->nrmonst = 0;
  1638.             tmppart[npart]->xsize = 1;
  1639.             tmppart[npart]->ysize = 1;
  1640.             tmppart[npart]->map = (char **) alloc(sizeof(char *));
  1641.             tmppart[npart]->map[0] = (char *) alloc(1);
  1642.             tmppart[npart]->map[0][0] = STONE;
  1643.             max_x_map = COLNO-1;
  1644.             max_y_map = ROWNO;
  1645.           } break;
  1646. case 82:
  1647. # line 676 "lev_comp.y"
  1648. {
  1649.             tmppart[npart] = New(mazepart);
  1650.             tmppart[npart]->halign = yypvt[-1].i % 10;
  1651.             tmppart[npart]->valign = yypvt[-1].i / 10;
  1652.             tmppart[npart]->nrobjects = 0;
  1653.             tmppart[npart]->nloc = 0;
  1654.             tmppart[npart]->nrmonst = 0;
  1655.             scan_map(yypvt[-0].map);
  1656.           } break;
  1657. case 83:
  1658. # line 688 "lev_comp.y"
  1659. {
  1660.             yyval.i = yypvt[-2].i + (yypvt[-0].i * 10);
  1661.           } break;
  1662. case 90:
  1663. # line 706 "lev_comp.y"
  1664. {
  1665.             if (tmppart[npart]->nrobjects) {
  1666.                 yyerror("Object registers already initialized!");
  1667.             } else {
  1668.                 tmppart[npart]->robjects = (char *)alloc(n_olist);
  1669.                 (void) memcpy((genericptr_t)tmppart[npart]->robjects,
  1670.                       (genericptr_t)olist, n_olist);
  1671.                 tmppart[npart]->nrobjects = n_olist;
  1672.             }
  1673.           } break;
  1674. case 91:
  1675. # line 717 "lev_comp.y"
  1676. {
  1677.             if (tmppart[npart]->nloc) {
  1678.                 yyerror("Location registers already initialized!");
  1679.             } else {
  1680.                 register int i;
  1681.                 tmppart[npart]->rloc_x = (char *) alloc(n_plist);
  1682.                 tmppart[npart]->rloc_y = (char *) alloc(n_plist);
  1683.                 for(i=0;i<n_plist;i++) {
  1684.                 tmppart[npart]->rloc_x[i] = plist[i].x;
  1685.                 tmppart[npart]->rloc_y[i] = plist[i].y;
  1686.                 }
  1687.                 tmppart[npart]->nloc = n_plist;
  1688.             }
  1689.           } break;
  1690. case 92:
  1691. # line 732 "lev_comp.y"
  1692. {
  1693.             if (tmppart[npart]->nrmonst) {
  1694.                 yyerror("Monster registers already initialized!");
  1695.             } else {
  1696.                 tmppart[npart]->rmonst = (char *) alloc(n_mlist);
  1697.                 (void) memcpy((genericptr_t)tmppart[npart]->rmonst,
  1698.                       (genericptr_t)mlist, n_mlist);
  1699.                 tmppart[npart]->nrmonst = n_mlist;
  1700.             }
  1701.           } break;
  1702. case 93:
  1703. # line 745 "lev_comp.y"
  1704. {
  1705.             if (n_olist < MAX_REGISTERS)
  1706.                 olist[n_olist++] = yypvt[-0].i;
  1707.             else
  1708.                 yyerror("Object list too long!");
  1709.           } break;
  1710. case 94:
  1711. # line 752 "lev_comp.y"
  1712. {
  1713.             if (n_olist < MAX_REGISTERS)
  1714.                 olist[n_olist++] = yypvt[-2].i;
  1715.             else
  1716.                 yyerror("Object list too long!");
  1717.           } break;
  1718. case 95:
  1719. # line 761 "lev_comp.y"
  1720. {
  1721.             if (n_mlist < MAX_REGISTERS)
  1722.                 mlist[n_mlist++] = yypvt[-0].i;
  1723.             else
  1724.                 yyerror("Monster list too long!");
  1725.           } break;
  1726. case 96:
  1727. # line 768 "lev_comp.y"
  1728. {
  1729.             if (n_mlist < MAX_REGISTERS)
  1730.                 mlist[n_mlist++] = yypvt[-2].i;
  1731.             else
  1732.                 yyerror("Monster list too long!");
  1733.           } break;
  1734. case 97:
  1735. # line 777 "lev_comp.y"
  1736. {
  1737.             if (n_plist < MAX_REGISTERS)
  1738.                 plist[n_plist++] = current_coord;
  1739.             else
  1740.                 yyerror("Location list too long!");
  1741.           } break;
  1742. case 98:
  1743. # line 784 "lev_comp.y"
  1744. {
  1745.             if (n_plist < MAX_REGISTERS)
  1746.                 plist[n_plist++] = current_coord;
  1747.             else
  1748.                 yyerror("Location list too long!");
  1749.           } break;
  1750. case 121:
  1751. # line 819 "lev_comp.y"
  1752. {
  1753.             tmpmonst[nmons] = New(monster);
  1754.             tmpmonst[nmons]->x = current_coord.x;
  1755.             tmpmonst[nmons]->y = current_coord.y;
  1756.             tmpmonst[nmons]->class = yypvt[-4].i;
  1757.             tmpmonst[nmons]->peaceful = -1; /* no override */
  1758.             tmpmonst[nmons]->asleep = -1;
  1759.             tmpmonst[nmons]->align = - MAX_REGISTERS - 2;
  1760.             tmpmonst[nmons]->name = (char *) 0;
  1761.             tmpmonst[nmons]->appear = 0;
  1762.             tmpmonst[nmons]->appear_as = (char *) 0;
  1763.             if (!in_room)
  1764.                 check_coord(current_coord.x, current_coord.y,
  1765.                     "Monster");
  1766.             if (!yypvt[-2].map)
  1767.                 tmpmonst[nmons]->id = -1;
  1768.             else {
  1769.                 int token = get_monster_id(yypvt[-2].map, (char) yypvt[-4].i);
  1770.                 if (token == ERR) {
  1771.                     yywarning("Illegal monster name!  Making random monster.");
  1772.                     tmpmonst[nmons]->id = -1;
  1773.                 } else
  1774.                     tmpmonst[nmons]->id = token;
  1775.             }
  1776.           } break;
  1777. case 122:
  1778. # line 845 "lev_comp.y"
  1779. {
  1780.             nmons++;
  1781.           } break;
  1782. case 125:
  1783. # line 855 "lev_comp.y"
  1784. {
  1785.             tmpmonst[nmons]->name = dup_string(yypvt[-0].map);
  1786.           } break;
  1787. case 126:
  1788. # line 859 "lev_comp.y"
  1789. {
  1790.             tmpmonst[nmons]->peaceful = yypvt[-0].i;
  1791.           } break;
  1792. case 127:
  1793. # line 863 "lev_comp.y"
  1794. {
  1795.             tmpmonst[nmons]->asleep = yypvt[-0].i;
  1796.           } break;
  1797. case 128:
  1798. # line 867 "lev_comp.y"
  1799. {
  1800.             tmpmonst[nmons]->align = yypvt[-0].i;
  1801.           } break;
  1802. case 129:
  1803. # line 871 "lev_comp.y"
  1804. {
  1805.             tmpmonst[nmons]->appear = yypvt[-1].i;
  1806.             tmpmonst[nmons]->appear_as = dup_string(yypvt[-0].map);
  1807.           } break;
  1808. case 130:
  1809. # line 878 "lev_comp.y"
  1810. {
  1811.             tmpobj[nobj] = New(object);
  1812.             tmpobj[nobj]->x = current_coord.x;
  1813.             tmpobj[nobj]->y = current_coord.y;
  1814.             tmpobj[nobj]->class = yypvt[-4].i;
  1815.             tmpobj[nobj]->corpsenm = -1;    /* init as none */
  1816.             tmpobj[nobj]->curse_state = -1;
  1817.             tmpobj[nobj]->name = (char *) 0;
  1818.             if (!in_room)
  1819.                 check_coord(current_coord.x, current_coord.y,
  1820.                     "Object");
  1821.             if (!yypvt[-2].map)
  1822.                 tmpobj[nobj]->id = -1;
  1823.             else {
  1824.                 int token = get_object_id(yypvt[-2].map);
  1825.                 if (token == ERR) {
  1826.                     yywarning("Illegal object name!  Making random object.");
  1827.                     tmpobj[nobj]->id = -1;
  1828.                 } else
  1829.                     tmpobj[nobj]->id = token;
  1830.             }
  1831.           } break;
  1832. case 131:
  1833. # line 901 "lev_comp.y"
  1834. {
  1835.             nobj++;
  1836.           } break;
  1837. case 132:
  1838. # line 907 "lev_comp.y"
  1839. {
  1840.             tmpobj[nobj]->spe = -127;
  1841.           } break;
  1842. case 133:
  1843. # line 911 "lev_comp.y"
  1844. {
  1845.             int token = get_monster_id(yypvt[-2].map, (char)0);
  1846.             if (token == ERR)    /* "random" */
  1847.                 tmpobj[nobj]->corpsenm = -2;
  1848.             else
  1849.                 tmpobj[nobj]->corpsenm = token;
  1850.             tmpobj[nobj]->spe = yypvt[-0].i;
  1851.           } break;
  1852. case 134:
  1853. # line 920 "lev_comp.y"
  1854. {
  1855.             tmpobj[nobj]->curse_state = yypvt[-4].i;
  1856.             tmpobj[nobj]->spe = yypvt[-2].i;
  1857.             if (yypvt[-0].map)
  1858.                 tmpobj[nobj]->name = dup_string(yypvt[-0].map);
  1859.             else
  1860.                 tmpobj[nobj]->name = (char *) 0;
  1861.           } break;
  1862. case 138:
  1863. # line 936 "lev_comp.y"
  1864. {
  1865.             yyval.i = -127;
  1866.           } break;
  1867. case 139:
  1868. # line 942 "lev_comp.y"
  1869. {
  1870.             tmpdoor[ndoor] = New(door);
  1871.             tmpdoor[ndoor]->x = current_coord.x;
  1872.             tmpdoor[ndoor]->y = current_coord.y;
  1873.             tmpdoor[ndoor]->mask = yypvt[-2].i;
  1874.             if(current_coord.x >= 0 && current_coord.y >= 0 &&
  1875.                tmpmap[current_coord.y][current_coord.x] != DOOR &&
  1876.                tmpmap[current_coord.y][current_coord.x] != SDOOR)
  1877.                 yyerror("Door decl doesn't match the map");
  1878.             ndoor++;
  1879.           } break;
  1880. case 140:
  1881. # line 956 "lev_comp.y"
  1882. {
  1883.             tmptrap[ntrap] = New(trap);
  1884.             tmptrap[ntrap]->x = current_coord.x;
  1885.             tmptrap[ntrap]->y = current_coord.y;
  1886.             tmptrap[ntrap]->type = yypvt[-2].i;
  1887.             if (!in_room)
  1888.                 check_coord(current_coord.x, current_coord.y,
  1889.                     "Trap");
  1890.             ntrap++;
  1891.           } break;
  1892. case 141:
  1893. # line 969 "lev_comp.y"
  1894. {
  1895.                 int x, y, dir;
  1896.  
  1897.             tmpdb[ndb] = New(drawbridge);
  1898.             x = tmpdb[ndb]->x = current_coord.x;
  1899.             y = tmpdb[ndb]->y = current_coord.y;
  1900.             /* convert dir from a DIRECTION to a DB_DIR */
  1901.             dir = yypvt[-2].i;
  1902.             switch(dir) {
  1903.             case W_NORTH: dir = DB_NORTH; y--; break;
  1904.             case W_SOUTH: dir = DB_SOUTH; y++; break;
  1905.             case W_EAST:  dir = DB_EAST;  x++; break;
  1906.             case W_WEST:  dir = DB_WEST;  x--; break;
  1907.             default:
  1908.                 yyerror("Invalid drawbridge direction");
  1909.                 break;
  1910.             }
  1911.             tmpdb[ndb]->dir = dir;
  1912.             if (current_coord.x >= 0 && current_coord.y >= 0 &&
  1913.                 !IS_WALL(tmpmap[y][x])) {
  1914.                 char ebuf[60];
  1915.                 Sprintf(ebuf,
  1916.                     "Wall needed for drawbridge (%02d, %02d)",
  1917.                     current_coord.x, current_coord.y);
  1918.                 yyerror(ebuf);
  1919.             }
  1920.  
  1921.             if ( yypvt[-0].i == D_ISOPEN )
  1922.                 tmpdb[ndb]->db_open = 1;
  1923.             else if ( yypvt[-0].i == D_CLOSED )
  1924.                 tmpdb[ndb]->db_open = 0;
  1925.             else
  1926.                 yyerror("A drawbridge can only be open or closed!");
  1927.             ndb++;
  1928.            } break;
  1929. case 142:
  1930. # line 1007 "lev_comp.y"
  1931. {
  1932.             tmpwalk[nwalk] = New(walk);
  1933.             tmpwalk[nwalk]->x = current_coord.x;
  1934.             tmpwalk[nwalk]->y = current_coord.y;
  1935.             tmpwalk[nwalk]->dir = yypvt[-0].i;
  1936.             nwalk++;
  1937.           } break;
  1938. case 143:
  1939. # line 1017 "lev_comp.y"
  1940. {
  1941.             wallify_map();
  1942.           } break;
  1943. case 144:
  1944. # line 1023 "lev_comp.y"
  1945. {
  1946.             tmplad[nlad] = New(lad);
  1947.             tmplad[nlad]->x = current_coord.x;
  1948.             tmplad[nlad]->y = current_coord.y;
  1949.             tmplad[nlad]->up = yypvt[-0].i;
  1950.             if (!in_room)
  1951.                 check_coord(current_coord.x, current_coord.y,
  1952.                     "Ladder");
  1953.             nlad++;
  1954.           } break;
  1955. case 145:
  1956. # line 1036 "lev_comp.y"
  1957. {
  1958.             tmpstair[nstair] = New(stair);
  1959.             tmpstair[nstair]->x = current_coord.x;
  1960.             tmpstair[nstair]->y = current_coord.y;
  1961.             tmpstair[nstair]->up = yypvt[-0].i;
  1962.             if (!in_room)
  1963.                 check_coord(current_coord.x, current_coord.y,
  1964.                     "Stairway");
  1965.             nstair++;
  1966.           } break;
  1967. case 146:
  1968. # line 1049 "lev_comp.y"
  1969. {
  1970.             tmplreg[nlreg] = New(lev_region);
  1971.             tmplreg[nlreg]->in_islev = yypvt[-0].i;
  1972.             tmplreg[nlreg]->inarea.x1 = current_region.x1;
  1973.             tmplreg[nlreg]->inarea.y1 = current_region.y1;
  1974.             tmplreg[nlreg]->inarea.x2 = current_region.x2;
  1975.             tmplreg[nlreg]->inarea.y2 = current_region.y2;
  1976.           } break;
  1977. case 147:
  1978. # line 1058 "lev_comp.y"
  1979. {
  1980.             tmplreg[nlreg]->del_islev = yypvt[-2].i;
  1981.             tmplreg[nlreg]->delarea.x1 = current_region.x1;
  1982.             tmplreg[nlreg]->delarea.y1 = current_region.y1;
  1983.             tmplreg[nlreg]->delarea.x2 = current_region.x2;
  1984.             tmplreg[nlreg]->delarea.y2 = current_region.y2;
  1985.             if(yypvt[-0].i)
  1986.                 tmplreg[nlreg]->rtype = LR_UPSTAIR;
  1987.             else
  1988.                 tmplreg[nlreg]->rtype = LR_DOWNSTAIR;
  1989.             tmplreg[nlreg]->rname = 0;
  1990.             nlreg++;
  1991.           } break;
  1992. case 148:
  1993. # line 1074 "lev_comp.y"
  1994. {
  1995.             tmplreg[nlreg] = New(lev_region);
  1996.             tmplreg[nlreg]->in_islev = yypvt[-0].i;
  1997.             tmplreg[nlreg]->inarea.x1 = current_region.x1;
  1998.             tmplreg[nlreg]->inarea.y1 = current_region.y1;
  1999.             tmplreg[nlreg]->inarea.x2 = current_region.x2;
  2000.             tmplreg[nlreg]->inarea.y2 = current_region.y2;
  2001.           } break;
  2002. case 149:
  2003. # line 1083 "lev_comp.y"
  2004. {
  2005.             tmplreg[nlreg]->del_islev = yypvt[-2].i;
  2006.             tmplreg[nlreg]->delarea.x1 = current_region.x1;
  2007.             tmplreg[nlreg]->delarea.y1 = current_region.y1;
  2008.             tmplreg[nlreg]->delarea.x2 = current_region.x2;
  2009.             tmplreg[nlreg]->delarea.y2 = current_region.y2;
  2010.             tmplreg[nlreg]->rtype = LR_PORTAL;
  2011.             tmplreg[nlreg]->rname = yypvt[-0].map;
  2012.             nlreg++;
  2013.           } break;
  2014. case 150:
  2015. # line 1096 "lev_comp.y"
  2016. {
  2017.             tmplreg[nlreg] = New(lev_region);
  2018.             tmplreg[nlreg]->in_islev = yypvt[-0].i;
  2019.             tmplreg[nlreg]->inarea.x1 = current_region.x1;
  2020.             tmplreg[nlreg]->inarea.y1 = current_region.y1;
  2021.             tmplreg[nlreg]->inarea.x2 = current_region.x2;
  2022.             tmplreg[nlreg]->inarea.y2 = current_region.y2;
  2023.           } break;
  2024. case 151:
  2025. # line 1105 "lev_comp.y"
  2026. {
  2027.             tmplreg[nlreg]->del_islev = yypvt[-0].i;
  2028.             tmplreg[nlreg]->delarea.x1 = current_region.x1;
  2029.             tmplreg[nlreg]->delarea.y1 = current_region.y1;
  2030.             tmplreg[nlreg]->delarea.x2 = current_region.x2;
  2031.             tmplreg[nlreg]->delarea.y2 = current_region.y2;
  2032.           } break;
  2033. case 152:
  2034. # line 1113 "lev_comp.y"
  2035. {
  2036.             switch(yypvt[-0].i) {
  2037.             case -1: tmplreg[nlreg]->rtype = LR_TELE; break;
  2038.             case 0: tmplreg[nlreg]->rtype = LR_DOWNTELE; break;
  2039.             case 1: tmplreg[nlreg]->rtype = LR_UPTELE; break;
  2040.             }
  2041.             tmplreg[nlreg]->rname = 0;
  2042.             nlreg++;
  2043.           } break;
  2044. case 153:
  2045. # line 1125 "lev_comp.y"
  2046. {
  2047.             tmplreg[nlreg] = New(lev_region);
  2048.             tmplreg[nlreg]->in_islev = yypvt[-0].i;
  2049.             tmplreg[nlreg]->inarea.x1 = current_region.x1;
  2050.             tmplreg[nlreg]->inarea.y1 = current_region.y1;
  2051.             tmplreg[nlreg]->inarea.x2 = current_region.x2;
  2052.             tmplreg[nlreg]->inarea.y2 = current_region.y2;
  2053.           } break;
  2054. case 154:
  2055. # line 1134 "lev_comp.y"
  2056. {
  2057.             tmplreg[nlreg]->del_islev = yypvt[-0].i;
  2058.             tmplreg[nlreg]->delarea.x1 = current_region.x1;
  2059.             tmplreg[nlreg]->delarea.y1 = current_region.y1;
  2060.             tmplreg[nlreg]->delarea.x2 = current_region.x2;
  2061.             tmplreg[nlreg]->delarea.y2 = current_region.y2;
  2062.             tmplreg[nlreg]->rtype = LR_BRANCH;
  2063.             tmplreg[nlreg]->rname = 0;
  2064.             nlreg++;
  2065.           } break;
  2066. case 155:
  2067. # line 1147 "lev_comp.y"
  2068. {
  2069.             yyval.i = -1;
  2070.           } break;
  2071. case 156:
  2072. # line 1151 "lev_comp.y"
  2073. {
  2074.             yyval.i = yypvt[-0].i;
  2075.           } break;
  2076. case 157:
  2077. # line 1157 "lev_comp.y"
  2078. {
  2079.             yyval.i = 0;
  2080.           } break;
  2081. case 158:
  2082. # line 1161 "lev_comp.y"
  2083. {
  2084. /* This series of if statements is a hack for MSC 5.1.  It seems that its
  2085.    tiny little brain cannot compile if these are all one big if statement. */
  2086.             if (yypvt[-7].i <= 0 || yypvt[-7].i >= COLNO)
  2087.                 yyerror("Region out of level range!");
  2088.             else if (yypvt[-5].i < 0 || yypvt[-5].i >= ROWNO)
  2089.                 yyerror("Region out of level range!");
  2090.             else if (yypvt[-3].i <= 0 || yypvt[-3].i >= COLNO)
  2091.                 yyerror("Region out of level range!");
  2092.             else if (yypvt[-1].i < 0 || yypvt[-1].i >= ROWNO)
  2093.                 yyerror("Region out of level range!");
  2094.             current_region.x1 = yypvt[-7].i;
  2095.             current_region.y1 = yypvt[-5].i;
  2096.             current_region.x2 = yypvt[-3].i;
  2097.             current_region.y2 = yypvt[-1].i;
  2098.             yyval.i = 1;
  2099.           } break;
  2100. case 159:
  2101. # line 1181 "lev_comp.y"
  2102. {
  2103.             tmpfountain[nfountain] = New(fountain);
  2104.             tmpfountain[nfountain]->x = current_coord.x;
  2105.             tmpfountain[nfountain]->y = current_coord.y;
  2106.             if (!in_room)
  2107.                 check_coord(current_coord.x, current_coord.y,
  2108.                     "Fountain");
  2109.             nfountain++;
  2110.           } break;
  2111. case 160:
  2112. # line 1193 "lev_comp.y"
  2113. {
  2114.             tmpsink[nsink] = New(sink);
  2115.             tmpsink[nsink]->x = current_coord.x;
  2116.             tmpsink[nsink]->y = current_coord.y;
  2117.             nsink++;
  2118.           } break;
  2119. case 161:
  2120. # line 1202 "lev_comp.y"
  2121. {
  2122.             tmppool[npool] = New(pool);
  2123.             tmppool[npool]->x = current_coord.x;
  2124.             tmppool[npool]->y = current_coord.y;
  2125.             npool++;
  2126.           } break;
  2127. case 162:
  2128. # line 1211 "lev_comp.y"
  2129. {
  2130.             tmpdig[ndig] = New(digpos);
  2131.             tmpdig[ndig]->x1 = current_region.x1;
  2132.             tmpdig[ndig]->y1 = current_region.y1;
  2133.             tmpdig[ndig]->x2 = current_region.x2;
  2134.             tmpdig[ndig]->y2 = current_region.y2;
  2135.             ndig++;
  2136.           } break;
  2137. case 163:
  2138. # line 1222 "lev_comp.y"
  2139. {
  2140.             tmpreg[nreg] = New(region);
  2141.             tmpreg[nreg]->x1 = current_region.x1;
  2142.             tmpreg[nreg]->y1 = current_region.y1;
  2143.             tmpreg[nreg]->x2 = current_region.x2;
  2144.             tmpreg[nreg]->y2 = current_region.y2;
  2145.             tmpreg[nreg]->rlit = yypvt[-3].i;
  2146.             tmpreg[nreg]->rtype = yypvt[-1].i;
  2147.             if(yypvt[-0].i & 1) tmpreg[nreg]->rtype += MAXRTYPE+1;
  2148.             tmpreg[nreg]->rirreg = ((yypvt[-0].i & 2) != 0);
  2149.             if(current_region.x1 > current_region.x2 ||
  2150.                current_region.y1 > current_region.y2)
  2151.                yyerror("Region start > end!");
  2152.             if(tmpreg[nreg]->rtype == VAULT &&
  2153.                (tmpreg[nreg]->rirreg ||
  2154.                 (tmpreg[nreg]->x2 - tmpreg[nreg]->x1 != 1) ||
  2155.                 (tmpreg[nreg]->y2 - tmpreg[nreg]->y1 != 1)))
  2156.                 yyerror("Vaults must be exactly 2x2!");
  2157.             if(want_warnings && !tmpreg[nreg]->rirreg &&
  2158.                current_region.x1 > 0 && current_region.y1 > 0 &&
  2159.                current_region.x2 < max_x_map &&
  2160.                current_region.y2 < max_y_map) {
  2161.                 /* check for walls in the room */
  2162.                 char ebuf[60];
  2163.                 register int x, y, nrock = 0;
  2164.  
  2165.                 for(y=current_region.y1; y<=current_region.y2; y++)
  2166.                 for(x=current_region.x1;
  2167.                     x<=current_region.x2; x++)
  2168.                     if(IS_ROCK(tmpmap[y][x]) ||
  2169.                        IS_DOOR(tmpmap[y][x])) nrock++;
  2170.                 if(nrock) {
  2171.                 Sprintf(ebuf,
  2172.                     "Rock in room (%02d,%02d,%02d,%02d)?!",
  2173.                     current_region.x1, current_region.y1,
  2174.                     current_region.x2, current_region.y2);
  2175.                 yywarning(ebuf);
  2176.                 }
  2177.                 if (
  2178.         !IS_ROCK(tmpmap[current_region.y1-1][current_region.x1-1]) ||
  2179.         !IS_ROCK(tmpmap[current_region.y2+1][current_region.x1-1]) ||
  2180.         !IS_ROCK(tmpmap[current_region.y1-1][current_region.x2+1]) ||
  2181.         !IS_ROCK(tmpmap[current_region.y2+1][current_region.x2+1])) {
  2182.                 Sprintf(ebuf,
  2183.                 "NonRock edge in room (%02d,%02d,%02d,%02d)?!",
  2184.                     current_region.x1, current_region.y1,
  2185.                     current_region.x2, current_region.y2);
  2186.                 yywarning(ebuf);
  2187.                 }
  2188.             } else if(tmpreg[nreg]->rirreg &&
  2189.         !IS_ROOM(tmpmap[current_region.y1][current_region.x1])) {
  2190.                 char ebuf[60];
  2191.                 Sprintf(ebuf,
  2192.                     "Rock in irregular room (%02d,%02d)?!",
  2193.                     current_region.x1, current_region.y1);
  2194.                 yyerror(ebuf);
  2195.             }
  2196.             nreg++;
  2197.           } break;
  2198. case 164:
  2199. # line 1284 "lev_comp.y"
  2200. {
  2201.             tmpaltar[naltar] = New(altar);
  2202.             tmpaltar[naltar]->x = current_coord.x;
  2203.             tmpaltar[naltar]->y = current_coord.y;
  2204.             tmpaltar[naltar]->align = yypvt[-2].i;
  2205.             tmpaltar[naltar]->shrine = yypvt[-0].i;
  2206.             if (!in_room)
  2207.                 check_coord(current_coord.x, current_coord.y,
  2208.                     "Altar");
  2209.             naltar++;
  2210.           } break;
  2211. case 165:
  2212. # line 1298 "lev_comp.y"
  2213. {
  2214.             tmpgold[ngold] = New(gold);
  2215.             tmpgold[ngold]->x = current_coord.x;
  2216.             tmpgold[ngold]->y = current_coord.y;
  2217.             tmpgold[ngold]->amount = yypvt[-2].i;
  2218.             if (!in_room)
  2219.                 check_coord(current_coord.x, current_coord.y,
  2220.                     "Gold");
  2221.             ngold++;
  2222.           } break;
  2223. case 166:
  2224. # line 1311 "lev_comp.y"
  2225. {
  2226.             tmpengraving[nengraving] = New(engraving);
  2227.             tmpengraving[nengraving]->x = current_coord.x;
  2228.             tmpengraving[nengraving]->y = current_coord.y;
  2229.             tmpengraving[nengraving]->e.text = yypvt[-0].map;
  2230.             tmpengraving[nengraving]->etype = yypvt[-2].i;
  2231.             if (!in_room)
  2232.                 check_coord(current_coord.x, current_coord.y,
  2233.                     "Engraving");
  2234.             nengraving++;
  2235.           } break;
  2236. case 168:
  2237. # line 1326 "lev_comp.y"
  2238. {
  2239.             yyval.i = - MAX_REGISTERS - 1;
  2240.           } break;
  2241. case 171:
  2242. # line 1334 "lev_comp.y"
  2243. {
  2244.             yyval.i = - MAX_REGISTERS - 1;
  2245.           } break;
  2246. case 174:
  2247. # line 1342 "lev_comp.y"
  2248. {
  2249.             yyval.map = (char *) 0;
  2250.           } break;
  2251. case 176:
  2252. # line 1349 "lev_comp.y"
  2253. {
  2254.             yyval.map = (char *) 0;
  2255.           } break;
  2256. case 177:
  2257. # line 1355 "lev_comp.y"
  2258. {
  2259.             int token = get_trap_type(yypvt[-0].map);
  2260.             if (token == ERR)
  2261.                 yyerror("Unknown trap type!");
  2262.             yyval.i = token;
  2263.           } break;
  2264. case 179:
  2265. # line 1365 "lev_comp.y"
  2266. {
  2267.             int token = get_room_type(yypvt[-0].map);
  2268.             if (token == ERR) {
  2269.                 yywarning("Unknown room type!  Making ordinary room...");
  2270.                 yyval.i = OROOM;
  2271.             } else
  2272.                 yyval.i = token;
  2273.           } break;
  2274. case 181:
  2275. # line 1377 "lev_comp.y"
  2276. {
  2277.             yyval.i = 0;
  2278.           } break;
  2279. case 182:
  2280. # line 1381 "lev_comp.y"
  2281. {
  2282.             yyval.i = yypvt[-0].i;
  2283.           } break;
  2284. case 183:
  2285. # line 1385 "lev_comp.y"
  2286. {
  2287.             yyval.i = yypvt[-2].i + (yypvt[-0].i << 1);
  2288.           } break;
  2289. case 186:
  2290. # line 1393 "lev_comp.y"
  2291. {
  2292.             current_coord.x = current_coord.y = -MAX_REGISTERS-1;
  2293.           } break;
  2294. case 193:
  2295. # line 1409 "lev_comp.y"
  2296. {
  2297.             yyval.i = - MAX_REGISTERS - 1;
  2298.           } break;
  2299. case 196:
  2300. # line 1419 "lev_comp.y"
  2301. {
  2302.             if ( yypvt[-1].i >= MAX_REGISTERS )
  2303.                 yyerror("Register Index overflow!");
  2304.             else
  2305.                 current_coord.x = current_coord.y = - yypvt[-1].i - 1;
  2306.           } break;
  2307. case 197:
  2308. # line 1428 "lev_comp.y"
  2309. {
  2310.             if ( yypvt[-1].i >= MAX_REGISTERS )
  2311.                 yyerror("Register Index overflow!");
  2312.             else
  2313.                 yyval.i = - yypvt[-1].i - 1;
  2314.           } break;
  2315. case 198:
  2316. # line 1437 "lev_comp.y"
  2317. {
  2318.             if ( yypvt[-1].i >= MAX_REGISTERS )
  2319.                 yyerror("Register Index overflow!");
  2320.             else
  2321.                 yyval.i = - yypvt[-1].i - 1;
  2322.           } break;
  2323. case 199:
  2324. # line 1446 "lev_comp.y"
  2325. {
  2326.             if ( yypvt[-1].i >= 3 )
  2327.                 yyerror("Register Index overflow!");
  2328.             else
  2329.                 yyval.i = - yypvt[-1].i - 1;
  2330.           } break;
  2331. case 201:
  2332. # line 1458 "lev_comp.y"
  2333. {
  2334.             if (check_monster_char((char) yypvt[-0].i))
  2335.                 yyval.i = yypvt[-0].i ;
  2336.             else {
  2337.                 yyerror("Unknown monster class!");
  2338.                 yyval.i = ERR;
  2339.             }
  2340.           } break;
  2341. case 202:
  2342. # line 1469 "lev_comp.y"
  2343. {
  2344.             char c = yypvt[-0].i;
  2345.             if (check_object_char(c))
  2346.                 yyval.i = c;
  2347.             else {
  2348.                 yyerror("Unknown char class!");
  2349.                 yyval.i = ERR;
  2350.             }
  2351.           } break;
  2352. case 205:
  2353. # line 1485 "lev_comp.y"
  2354. {
  2355.             yyval.map = (char *) 0;
  2356.           } break;
  2357. case 210:
  2358. # line 1499 "lev_comp.y"
  2359. {
  2360.             if (!in_room && !init_lev.init_present &&
  2361.                 (yypvt[-3].i < 0 || yypvt[-3].i > max_x_map ||
  2362.                  yypvt[-1].i < 0 || yypvt[-1].i > max_y_map))
  2363.                 yyerror("Coordinates out of map range!");
  2364.             current_coord.x = yypvt[-3].i;
  2365.             current_coord.y = yypvt[-1].i;
  2366.           } break;
  2367. case 211:
  2368. # line 1510 "lev_comp.y"
  2369. {
  2370. /* This series of if statements is a hack for MSC 5.1.  It seems that its
  2371.    tiny little brain cannot compile if these are all one big if statement. */
  2372.             if (yypvt[-7].i < 0 || yypvt[-7].i > max_x_map)
  2373.                 yyerror("Region out of map range!");
  2374.             else if (yypvt[-5].i < 0 || yypvt[-5].i > max_y_map)
  2375.                 yyerror("Region out of map range!");
  2376.             else if (yypvt[-3].i < 0 || yypvt[-3].i > max_x_map)
  2377.                 yyerror("Region out of map range!");
  2378.             else if (yypvt[-1].i < 0 || yypvt[-1].i > max_y_map)
  2379.                 yyerror("Region out of map range!");
  2380.             current_region.x1 = yypvt[-7].i;
  2381.             current_region.y1 = yypvt[-5].i;
  2382.             current_region.x2 = yypvt[-3].i;
  2383.             current_region.y2 = yypvt[-1].i;
  2384.           } break;
  2385.     }
  2386.     goto yystack;        /* reset registers in driver code */
  2387. }
  2388.