
/*  A Bison parser, made from lev_comp.y with Bison version GNU Bison version 1.24
  */

#define YYBISON 1  /* Identify Bison output.  */

#define	CHAR	258
#define	INTEGER	259
#define	BOOLEAN	260
#define	PERCENT	261
#define	MESSAGE_ID	262
#define	MAZE_ID	263
#define	LEVEL_ID	264
#define	LEV_INIT_ID	265
#define	GEOMETRY_ID	266
#define	NOMAP_ID	267
#define	OBJECT_ID	268
#define	COBJECT_ID	269
#define	MONSTER_ID	270
#define	TRAP_ID	271
#define	DOOR_ID	272
#define	DRAWBRIDGE_ID	273
#define	MAZEWALK_ID	274
#define	WALLIFY_ID	275
#define	REGION_ID	276
#define	FILLING	277
#define	RANDOM_OBJECTS_ID	278
#define	RANDOM_MONSTERS_ID	279
#define	RANDOM_PLACES_ID	280
#define	ALTAR_ID	281
#define	LADDER_ID	282
#define	STAIR_ID	283
#define	NON_DIGGABLE_ID	284
#define	NON_PASSWALL_ID	285
#define	ROOM_ID	286
#define	PORTAL_ID	287
#define	TELEPRT_ID	288
#define	BRANCH_ID	289
#define	LEV	290
#define	CHANCE_ID	291
#define	CORRIDOR_ID	292
#define	GOLD_ID	293
#define	ENGRAVING_ID	294
#define	FOUNTAIN_ID	295
#define	POOL_ID	296
#define	SINK_ID	297
#define	NONE	298
#define	RAND_CORRIDOR_ID	299
#define	DOOR_STATE	300
#define	LIGHT_STATE	301
#define	CURSE_TYPE	302
#define	ENGRAVING_TYPE	303
#define	ROOMSHAPE	304
#define	DIRECTION	305
#define	RANDOM_TYPE	306
#define	O_REGISTER	307
#define	M_REGISTER	308
#define	P_REGISTER	309
#define	A_REGISTER	310
#define	ALIGNMENT	311
#define	LEFT_OR_RIGHT	312
#define	CENTER	313
#define	TOP_OR_BOT	314
#define	ALTAR_TYPE	315
#define	UP_OR_DOWN	316
#define	SUBROOM_ID	317
#define	NAME_ID	318
#define	FLAGS_ID	319
#define	FLAG_TYPE	320
#define	MON_ATTITUDE	321
#define	MON_ALERTNESS	322
#define	MON_APPEARANCE	323
#define	CONTAINED	324
#define	MPICKUP	325
#define	MINVENT	326
#define	BURIED	327
#define	OBJ_RANK	328
#define	STRING	329
#define	MAP_ID	330

#line 1 "lev_comp.y"

/*	SCCS Id: @(#)lev_yacc.c	3.4	2000/01/17	*/
/*	Copyright (c) 1989 by Jean-Christophe Collet */
/* NetHack may be freely redistributed.  See license for details. */

/*
 * This file contains the Level Compiler code
 * It may handle special mazes & special room-levels
 */

/* In case we're using bison in AIX.  This definition must be
 * placed before any other C-language construct in the file
 * excluding comments and preprocessor directives (thanks IBM
 * for this wonderful feature...).
 *
 * Note: some cpps barf on this 'undefined control' (#pragma).
 * Addition of the leading space seems to prevent barfage for now,
 * and AIX will still see the directive.
 */
#ifdef _AIX
 #pragma alloca		/* keep leading space! */
#endif

#include "hack.h"
#include "sp_lev.h"

#define MAX_REGISTERS	10
#define ERR		(-1)
/* many types of things are put in chars for transference to NetHack.
 * since some systems will use signed chars, limit everybody to the
 * same number for portability.
 */
#define MAX_OF_TYPE	128

#define New(type)		\
	(type *) memset((genericptr_t)alloc(sizeof(type)), 0, sizeof(type))
#define NewTab(type, size)	(type **) alloc(sizeof(type *) * size)
#define Free(ptr)		free((genericptr_t)ptr)

extern void FDECL(yyerror, (const char *));
extern void FDECL(yywarning, (const char *));
extern int NDECL(yylex);
int NDECL(yyparse);

extern int FDECL(get_floor_type, (CHAR_P));
extern int FDECL(get_room_type, (char *));
extern int FDECL(get_trap_type, (char *));
extern int FDECL(get_monster_id, (char *,CHAR_P));
extern int FDECL(get_object_id, (char *,CHAR_P));
extern boolean FDECL(check_monster_char, (CHAR_P));
extern boolean FDECL(check_object_char, (CHAR_P));
extern char FDECL(what_map_char, (CHAR_P));
extern void FDECL(scan_map, (char *));
extern void NDECL(wallify_map);
extern boolean NDECL(check_subrooms);
extern void FDECL(check_coord, (int,int,const char *));
extern void NDECL(store_part);
extern void NDECL(store_room);
extern boolean FDECL(write_level_file, (char *,splev *,specialmaze *));
extern void FDECL(free_rooms, (splev *));

static struct reg {
	int x1, y1;
	int x2, y2;
}		current_region;

static struct coord {
	int x;
	int y;
}		current_coord, current_align;

static struct size {
	int height;
	int width;
}		current_size;

char tmpmessage[256];
digpos *tmppass[32];
char *tmpmap[ROWNO];

digpos *tmpdig[MAX_OF_TYPE];
region *tmpreg[MAX_OF_TYPE];
lev_region *tmplreg[MAX_OF_TYPE];
door *tmpdoor[MAX_OF_TYPE];
drawbridge *tmpdb[MAX_OF_TYPE];
walk *tmpwalk[MAX_OF_TYPE];

room_door *tmprdoor[MAX_OF_TYPE];
trap *tmptrap[MAX_OF_TYPE];
monster *tmpmonst[MAX_OF_TYPE];
object *tmpobj[MAX_OF_TYPE];
altar *tmpaltar[MAX_OF_TYPE];
lad *tmplad[MAX_OF_TYPE];
stair *tmpstair[MAX_OF_TYPE];
gold *tmpgold[MAX_OF_TYPE];
engraving *tmpengraving[MAX_OF_TYPE];
fountain *tmpfountain[MAX_OF_TYPE];
sink *tmpsink[MAX_OF_TYPE];
pool *tmppool[MAX_OF_TYPE];

mazepart *tmppart[10];
room *tmproom[MAXNROFROOMS*2];
corridor *tmpcor[MAX_OF_TYPE];

static specialmaze maze;
static splev special_lev;
static lev_init init_lev;

static char olist[MAX_REGISTERS], mlist[MAX_REGISTERS];
static struct coord plist[MAX_REGISTERS];

int n_olist = 0, n_mlist = 0, n_plist = 0;

unsigned int nlreg = 0, nreg = 0, ndoor = 0, ntrap = 0, nmons = 0, nobj = 0;
unsigned int ndb = 0, nwalk = 0, npart = 0, ndig = 0, nlad = 0, nstair = 0;
unsigned int naltar = 0, ncorridor = 0, nrooms = 0, ngold = 0, nengraving = 0;
unsigned int nfountain = 0, npool = 0, nsink = 0, npass = 0;

static int lev_flags = 0;

unsigned int max_x_map, max_y_map;

static xchar in_room;

extern int fatal_error;
extern int want_warnings;
extern const char *fname;


#line 131 "lev_comp.y"
typedef union
{
	int	i;
	char*	map;
	struct {
		xchar room;
		xchar wall;
		xchar door;
	} corpos;
} YYSTYPE;

#ifndef YYLTYPE
typedef
  struct yyltype
    {
      int timestamp;
      int first_line;
      int first_column;
      int last_line;
      int last_column;
      char *text;
   }
  yyltype;

#define YYLTYPE yyltype
#endif

#include <stdio.h>

#ifndef __cplusplus
#ifndef __STDC__
#define const
#endif
#endif



#define	YYFINAL		491
#define	YYFLAG		-32768
#define	YYNTBASE	82

#define YYTRANSLATE(x) ((unsigned)(x) <= 330 ? yytranslate[x] : 200)

static const char yytranslate[] = {     0,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,    76,
    77,     2,     2,    74,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,    75,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
    78,     2,    79,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     1,     2,     3,     4,     5,
     6,     7,     8,     9,    10,    11,    12,    13,    14,    15,
    16,    17,    18,    19,    20,    21,    22,    23,    24,    25,
    26,    27,    28,    29,    30,    31,    32,    33,    34,    35,
    36,    37,    38,    39,    40,    41,    42,    43,    44,    45,
    46,    47,    48,    49,    50,    51,    52,    53,    54,    55,
    56,    57,    58,    59,    60,    61,    62,    63,    64,    65,
    66,    67,    68,    69,    70,    71,    72,    73,    80,    81
};

#if YYDEBUG != 0
static const short yyprhs[] = {     0,
     0,     1,     3,     5,     8,    10,    12,    18,    26,    30,
    31,    45,    57,    59,    61,    62,    66,    70,    72,    73,
    76,    80,    81,    84,    88,    92,    93,    95,    97,   100,
   102,   104,   106,   107,   110,   116,   122,   130,   133,   136,
   149,   162,   163,   166,   172,   174,   180,   182,   188,   190,
   196,   198,   199,   202,   204,   206,   208,   210,   212,   214,
   216,   218,   220,   222,   224,   226,   228,   232,   236,   246,
   248,   250,   252,   254,   256,   258,   264,   266,   268,   270,
   272,   275,   279,   281,   284,   290,   292,   294,   296,   298,
   300,   302,   303,   306,   310,   314,   318,   320,   324,   326,
   330,   332,   333,   338,   339,   342,   344,   346,   348,   350,
   352,   354,   356,   358,   360,   362,   364,   366,   368,   370,
   372,   374,   376,   378,   380,   382,   383,   394,   395,   398,
   401,   404,   407,   410,   414,   417,   420,   421,   431,   433,
   435,   437,   439,   441,   444,   446,   449,   450,   458,   464,
   470,   472,   474,   476,   478,   480,   481,   484,   487,   493,
   500,   508,   514,   516,   522,   528,   529,   538,   539,   548,
   549,   550,   559,   560,   567,   568,   571,   573,   584,   588,
   592,   596,   600,   604,   613,   621,   627,   635,   637,   639,
   641,   643,   645,   647,   649,   651,   653,   655,   657,   659,
   661,   663,   664,   667,   672,   677,   679,   681,   683,   685,
   687,   689,   691,   693,   695,   697,   699,   701,   706,   711,
   716,   721,   723,   725,   727,   729,   731,   733,   734,   736,
   738,   740,   746
};

static const short yyrhs[] = {    -1,
    83,     0,    84,     0,    84,    83,     0,    85,     0,    86,
     0,   119,    90,    88,    92,   121,     0,    87,    90,    88,
    92,    94,    96,    98,     0,     9,    75,   194,     0,     0,
    10,    75,     3,    74,     3,    74,     5,    74,     5,    74,
   184,    74,    89,     0,    10,    75,     3,    74,     3,    74,
     4,    74,     4,    74,   184,     0,     5,     0,    51,     0,
     0,    64,    75,    91,     0,    65,    74,    91,     0,    65,
     0,     0,    93,    92,     0,     7,    75,    80,     0,     0,
    94,    95,     0,    23,    75,   129,     0,    24,    75,   130,
     0,     0,    97,     0,   103,     0,   103,    97,     0,    99,
     0,   100,     0,    44,     0,     0,   100,   101,     0,    37,
    75,   102,    74,   102,     0,    37,    75,   102,    74,     4,
     0,    76,     4,    74,    50,    74,   118,    77,     0,   105,
   111,     0,   104,   111,     0,    62,    75,   180,    74,   184,
    74,   108,    74,   110,    74,   194,   106,     0,    31,    75,
   180,    74,   184,    74,   107,    74,   109,    74,   110,   106,
     0,     0,    74,     5,     0,    76,     4,    74,     4,    77,
     0,    51,     0,    76,     4,    74,     4,    77,     0,    51,
     0,    76,   125,    74,   126,    77,     0,    51,     0,    76,
     4,    74,     4,    77,     0,    51,     0,     0,   111,   112,
     0,   113,     0,   114,     0,   115,     0,   135,     0,   139,
     0,   150,     0,   173,     0,   167,     0,   168,     0,   169,
     0,   174,     0,   175,     0,   155,     0,    63,    75,   194,
     0,    36,    75,     4,     0,    17,    75,   116,    74,   183,
    74,   117,    74,   118,     0,     5,     0,    51,     0,    50,
     0,    51,     0,     4,     0,    51,     0,     8,    75,   194,
    74,   120,     0,     3,     0,    51,     0,    43,     0,   122,
     0,   122,   121,     0,   123,   127,   133,     0,    12,     0,
   124,    81,     0,    11,    75,   125,    74,   126,     0,    57,
     0,    58,     0,    51,     0,    59,     0,    58,     0,    51,
     0,     0,   127,   128,     0,    23,    75,   129,     0,    25,
    75,   131,     0,    24,    75,   130,     0,   193,     0,   193,
    74,   129,     0,   192,     0,   192,    74,   130,     0,   191,
     0,     0,   191,   132,    74,   131,     0,     0,   133,   134,
     0,   135,     0,   139,     0,   149,     0,   150,     0,   151,
     0,   172,     0,   156,     0,   158,     0,   160,     0,   163,
     0,   173,     0,   167,     0,   152,     0,   153,     0,   154,
     0,   155,     0,   174,     0,   175,     0,   170,     0,   171,
     0,     0,    15,   196,    75,   176,    74,   178,    74,   182,
   136,   137,     0,     0,   137,   138,     0,    74,   194,     0,
    74,    66,     0,    74,    67,     0,    74,   185,     0,    74,
    68,   194,     0,    13,   140,     0,    14,   140,     0,     0,
   196,    75,   177,   141,    74,   142,    74,   143,   144,     0,
   194,     0,    51,     0,    73,     0,   182,     0,    69,     0,
    70,   182,     0,    71,     0,    72,   182,     0,     0,    74,
   145,    74,   146,    74,   147,   148,     0,    74,   145,    74,
   147,   148,     0,    74,   146,    74,   147,   148,     0,    51,
     0,    47,     0,    80,     0,    51,     0,     4,     0,     0,
    74,    43,     0,    74,    80,     0,    17,    75,   183,    74,
   182,     0,    16,   196,    75,   179,    74,   182,     0,    18,
    75,   182,    74,    50,    74,   183,     0,    19,    75,   182,
    74,    50,     0,    20,     0,    27,    75,   182,    74,    61,
     0,    28,    75,   182,    74,    61,     0,     0,    28,    75,
   166,   157,    74,   166,    74,    61,     0,     0,    32,    75,
   166,   159,    74,   166,    74,   194,     0,     0,     0,    33,
    75,   166,   161,    74,   166,   162,   165,     0,     0,    34,
    75,   166,   164,    74,   166,     0,     0,    74,    61,     0,
   199,     0,    35,    76,     4,    74,     4,    74,     4,    74,
     4,    77,     0,    40,    75,   182,     0,    42,    75,   182,
     0,    41,    75,   182,     0,    29,    75,   199,     0,    30,
    75,   199,     0,    21,    75,   199,    74,   184,    74,   180,
   181,     0,    26,    75,   182,    74,   185,    74,   186,     0,
    38,    75,   195,    74,   182,     0,    39,    75,   182,    74,
   197,    74,   194,     0,   192,     0,    51,     0,   189,     0,
   193,     0,    51,     0,   188,     0,   194,     0,    51,     0,
   194,     0,    51,     0,   194,     0,    51,     0,   194,     0,
    51,     0,     0,    74,    22,     0,    74,    22,    74,     5,
     0,    74,    22,    74,    49,     0,   198,     0,   187,     0,
    51,     0,    45,     0,    51,     0,    46,     0,    51,     0,
    56,     0,   190,     0,    51,     0,    60,     0,    51,     0,
    54,    78,     4,    79,     0,    52,    78,     4,    79,     0,
    53,    78,     4,    79,     0,    55,    78,     4,    79,     0,
   198,     0,     3,     0,     3,     0,    80,     0,     4,     0,
    51,     0,     0,     6,     0,    48,     0,    51,     0,    76,
     4,    74,     4,    77,     0,    76,     4,    74,     4,    74,
     4,    74,     4,    77,     0
};

#endif

#if YYDEBUG != 0
static const short yyrline[] = { 0,
   172,   173,   176,   177,   180,   181,   184,   211,   248,   260,
   269,   287,   305,   306,   309,   313,   320,   324,   330,   331,
   334,   351,   352,   355,   366,   379,   394,   397,   398,   401,
   402,   405,   413,   414,   417,   432,   448,   458,   462,   468,
   486,   504,   508,   514,   524,   530,   539,   545,   550,   556,
   561,   567,   568,   571,   572,   573,   574,   575,   576,   577,
   578,   579,   580,   581,   582,   583,   586,   595,   608,   628,
   629,   632,   633,   636,   637,   640,   655,   659,   663,   669,
   670,   673,   679,   695,   708,   715,   716,   717,   720,   721,
   722,   725,   726,   729,   740,   755,   768,   775,   784,   791,
   800,   807,   814,   817,   818,   821,   822,   823,   824,   825,
   826,   827,   828,   829,   830,   831,   832,   833,   834,   835,
   836,   837,   838,   839,   840,   843,   871,   879,   880,   883,
   887,   891,   895,   899,   906,   909,   918,   929,   938,   957,
   961,   967,   976,   983,   992,   999,  1010,  1020,  1023,  1026,
  1031,  1035,  1041,  1052,  1056,  1062,  1063,  1066,  1072,  1090,
  1107,  1149,  1163,  1169,  1186,  1203,  1212,  1232,  1241,  1258,
  1267,  1276,  1291,  1300,  1317,  1321,  1327,  1331,  1351,  1367,
  1380,  1393,  1408,  1423,  1489,  1507,  1524,  1542,  1543,  1547,
  1550,  1551,  1555,  1558,  1559,  1565,  1566,  1572,  1580,  1583,
  1593,  1596,  1600,  1604,  1608,  1614,  1615,  1616,  1622,  1623,
  1626,  1627,  1630,  1631,  1632,  1638,  1639,  1642,  1651,  1660,
  1669,  1678,  1681,  1692,  1704,  1707,  1708,  1711,  1715,  1723,
  1724,  1727,  1738
};

static const char * const yytname[] = {   "$","error","$undefined.","CHAR","INTEGER",
"BOOLEAN","PERCENT","MESSAGE_ID","MAZE_ID","LEVEL_ID","LEV_INIT_ID","GEOMETRY_ID",
"NOMAP_ID","OBJECT_ID","COBJECT_ID","MONSTER_ID","TRAP_ID","DOOR_ID","DRAWBRIDGE_ID",
"MAZEWALK_ID","WALLIFY_ID","REGION_ID","FILLING","RANDOM_OBJECTS_ID","RANDOM_MONSTERS_ID",
"RANDOM_PLACES_ID","ALTAR_ID","LADDER_ID","STAIR_ID","NON_DIGGABLE_ID","NON_PASSWALL_ID",
"ROOM_ID","PORTAL_ID","TELEPRT_ID","BRANCH_ID","LEV","CHANCE_ID","CORRIDOR_ID",
"GOLD_ID","ENGRAVING_ID","FOUNTAIN_ID","POOL_ID","SINK_ID","NONE","RAND_CORRIDOR_ID",
"DOOR_STATE","LIGHT_STATE","CURSE_TYPE","ENGRAVING_TYPE","ROOMSHAPE","DIRECTION",
"RANDOM_TYPE","O_REGISTER","M_REGISTER","P_REGISTER","A_REGISTER","ALIGNMENT",
"LEFT_OR_RIGHT","CENTER","TOP_OR_BOT","ALTAR_TYPE","UP_OR_DOWN","SUBROOM_ID",
"NAME_ID","FLAGS_ID","FLAG_TYPE","MON_ATTITUDE","MON_ALERTNESS","MON_APPEARANCE",
"CONTAINED","MPICKUP","MINVENT","BURIED","OBJ_RANK","','","':'","'('","')'",
"'['","']'","STRING","MAP_ID","file","levels","level","maze_level","room_level",
"level_def","lev_init","walled","flags","flag_list","messages","message","rreg_init",
"init_rreg","rooms","roomlist","corridors_def","random_corridors","corridors",
"corridor","corr_spec","aroom","subroom_def","room_def","roomfill","room_pos",
"subroom_pos","room_align","room_size","room_details","room_detail","room_name",
"room_chance","room_door","secret","door_wall","door_pos","maze_def","filling",
"regions","aregion","map_definition","map_geometry","h_justif","v_justif","reg_init",
"init_reg","object_list","monster_list","place_list","@1","map_details","map_detail",
"monster_detail","@2","monster_infos","monster_info","object_detail","object_desc",
"@3","object_id","object_where","object_infos","curse_state","monster_id","enchantment",
"optional_name","door_detail","trap_detail","drawbridge_detail","mazewalk_detail",
"wallify_detail","ladder_detail","stair_detail","stair_region","@4","portal_region",
"@5","teleprt_region","@6","@7","branch_region","@8","teleprt_detail","lev_region",
"fountain_detail","sink_detail","pool_detail","diggable_detail","passwall_detail",
"region_detail","altar_detail","gold_detail","engraving_detail","monster_c",
"object_c","m_name","trap_name","room_type","prefilled","coordinate","door_state",
"light_state","alignment","altar_type","p_register","o_register","m_register",
"a_register","place","monster","object","string","amount","chance","engraving_type",
"coord","region","region"
};
#endif

static const short yyr1[] = {     0,
    82,    82,    83,    83,    84,    84,    85,    86,    87,    88,
    88,    88,    89,    89,    90,    90,    91,    91,    92,    92,
    93,    94,    94,    95,    95,    96,    96,    97,    97,    98,
    98,    99,   100,   100,   101,   101,   102,   103,   103,   104,
   105,   106,   106,   107,   107,   108,   108,   109,   109,   110,
   110,   111,   111,   112,   112,   112,   112,   112,   112,   112,
   112,   112,   112,   112,   112,   112,   113,   114,   115,   116,
   116,   117,   117,   118,   118,   119,   120,   120,   120,   121,
   121,   122,   123,   123,   124,   125,   125,   125,   126,   126,
   126,   127,   127,   128,   128,   128,   129,   129,   130,   130,
   131,   132,   131,   133,   133,   134,   134,   134,   134,   134,
   134,   134,   134,   134,   134,   134,   134,   134,   134,   134,
   134,   134,   134,   134,   134,   136,   135,   137,   137,   138,
   138,   138,   138,   138,   139,   139,   141,   140,   142,   142,
   142,   143,   143,   143,   143,   143,   144,   144,   144,   144,
   145,   145,   146,   147,   147,   148,   148,   148,   149,   150,
   151,   152,   153,   154,   155,   157,   156,   159,   158,   161,
   162,   160,   164,   163,   165,   165,   166,   166,   167,   168,
   169,   170,   171,   172,   173,   174,   175,   176,   176,   176,
   177,   177,   177,   178,   178,    -1,    -1,   179,   179,   180,
   180,   181,   181,   181,   181,   182,   182,   182,   183,   183,
   184,   184,   185,   185,   185,   186,   186,   187,   188,   189,
   190,   191,   192,   193,   194,   195,   195,   196,   196,   197,
   197,   198,   199
};

static const short yyr2[] = {     0,
     0,     1,     1,     2,     1,     1,     5,     7,     3,     0,
    13,    11,     1,     1,     0,     3,     3,     1,     0,     2,
     3,     0,     2,     3,     3,     0,     1,     1,     2,     1,
     1,     1,     0,     2,     5,     5,     7,     2,     2,    12,
    12,     0,     2,     5,     1,     5,     1,     5,     1,     5,
     1,     0,     2,     1,     1,     1,     1,     1,     1,     1,
     1,     1,     1,     1,     1,     1,     3,     3,     9,     1,
     1,     1,     1,     1,     1,     5,     1,     1,     1,     1,
     2,     3,     1,     2,     5,     1,     1,     1,     1,     1,
     1,     0,     2,     3,     3,     3,     1,     3,     1,     3,
     1,     0,     4,     0,     2,     1,     1,     1,     1,     1,
     1,     1,     1,     1,     1,     1,     1,     1,     1,     1,
     1,     1,     1,     1,     1,     0,    10,     0,     2,     2,
     2,     2,     2,     3,     2,     2,     0,     9,     1,     1,
     1,     1,     1,     2,     1,     2,     0,     7,     5,     5,
     1,     1,     1,     1,     1,     0,     2,     2,     5,     6,
     7,     5,     1,     5,     5,     0,     8,     0,     8,     0,
     0,     8,     0,     6,     0,     2,     1,    10,     3,     3,
     3,     3,     3,     8,     7,     5,     7,     1,     1,     1,
     1,     1,     1,     1,     1,     1,     1,     1,     1,     1,
     1,     0,     2,     4,     4,     1,     1,     1,     1,     1,
     1,     1,     1,     1,     1,     1,     1,     4,     4,     4,
     4,     1,     1,     1,     1,     1,     1,     0,     1,     1,
     1,     5,     9
};

static const short yydefact[] = {     1,
     0,     0,     2,     3,     5,     6,    15,    15,     0,     0,
     4,     0,    10,    10,   225,     0,     9,     0,     0,    19,
    19,     0,    18,    16,     0,     0,    22,    19,     0,    77,
    79,    78,    76,     0,     0,     0,    26,    20,     0,    83,
     7,    80,    92,     0,    17,     0,    21,     0,     0,     0,
     0,    23,    33,    27,    28,    52,    52,     0,    81,   104,
    84,     0,     0,     0,     0,     0,    32,     8,    30,    31,
    29,    39,    38,    88,    86,    87,     0,     0,     0,     0,
    93,    82,     0,   224,    24,    97,   223,    25,    99,   201,
     0,   200,     0,     0,    34,   228,   228,   228,   228,     0,
     0,     0,     0,     0,     0,     0,     0,     0,     0,    53,
    54,    55,    56,    57,    58,    59,    66,    61,    62,    63,
    60,    64,    65,     0,     0,     0,     0,     0,     0,     0,
   163,     0,     0,     0,     0,     0,     0,     0,     0,   105,
   106,   107,   108,   109,   110,   118,   119,   120,   121,   112,
   113,   114,   115,   117,   124,   125,   111,   116,   122,   123,
     0,     0,     0,     0,     0,     0,     0,   229,   135,     0,
   136,     0,     0,     0,     0,     0,     0,     0,     0,     0,
     0,     0,     0,    91,    90,    89,    85,    94,    96,     0,
    95,   101,   222,     0,     0,     0,     0,     0,     0,     0,
     0,     0,     0,     0,     0,     0,    98,   100,   211,   212,
     0,     0,     0,     0,     0,     0,     0,    70,    71,     0,
   208,     0,     0,   207,   206,     0,    68,   226,   227,     0,
     0,   179,   181,   180,    67,     0,     0,   209,   210,     0,
     0,     0,     0,     0,     0,     0,     0,   166,   177,   182,
   183,   168,   170,   173,     0,     0,     0,     0,     0,     0,
   192,     0,   137,   193,   191,   189,     0,     0,   190,   188,
   199,     0,   198,     0,     0,     0,     0,     0,     0,     0,
     0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
     0,     0,     0,     0,     0,    45,     0,     0,    47,     0,
     0,     0,    36,    35,     0,     0,     0,     0,     0,     0,
     0,   215,     0,   213,     0,   214,   165,   186,   230,   231,
     0,     0,   103,   159,     0,   162,     0,     0,   164,     0,
     0,     0,     0,     0,     0,    12,     0,     0,     0,     0,
     0,     0,     0,     0,     0,   195,     0,   194,   160,     0,
   218,     0,     0,     0,   232,     0,     0,     0,     0,     0,
     0,     0,   171,   174,     0,     0,    49,     0,     0,     0,
    51,     0,     0,     0,   219,   140,   141,     0,   139,   220,
     0,    72,    73,     0,     0,   217,   216,   185,   187,   161,
     0,   202,     0,     0,     0,   175,    13,    14,    11,     0,
     0,     0,     0,     0,     0,    74,    75,     0,     0,   126,
     0,   221,     0,     0,   184,     0,   167,   169,     0,   172,
    44,     0,    42,    46,     0,    42,    37,   143,     0,   145,
     0,   147,   142,   128,    69,     0,   203,     0,   176,     0,
     0,    41,     0,    40,   144,   146,     0,   138,   127,     0,
     0,     0,    48,    43,    50,   152,   151,   153,     0,     0,
     0,   129,   233,   204,   205,     0,     0,     0,   131,   132,
     0,   133,   130,   178,   155,   154,     0,   156,   156,   134,
     0,     0,   149,   150,   156,   157,   158,   148,     0,     0,
     0
};

static const short yydefgoto[] = {   489,
     3,     4,     5,     6,     7,    20,   399,    13,    24,    27,
    28,    37,    52,    53,    54,    68,    69,    70,    95,   214,
    55,    56,    57,   442,   298,   301,   369,   373,    72,   110,
   111,   112,   113,   220,   384,   408,     8,    33,    41,    42,
    43,    44,    77,   187,    60,    81,    85,    88,   191,   237,
    82,   140,   114,   434,   449,   462,   115,   169,   306,   378,
   432,   448,   459,   460,   478,   483,   143,   116,   145,   146,
   147,   148,   117,   150,   290,   151,   291,   152,   292,   396,
   153,   293,   420,   248,   118,   119,   120,   155,   156,   157,
   121,   122,   123,   268,   263,   347,   272,    91,   415,   226,
   240,   211,   315,   388,   224,   264,   269,   316,   192,    89,
    86,    92,   230,   170,   321,   225,   249
};

static const short yypact[] = {   160,
    -3,    36,-32768,   160,-32768,-32768,    63,    63,    42,    42,
-32768,    65,    94,    94,-32768,    90,-32768,   105,   114,   183,
   183,    19,   117,-32768,   189,   122,-32768,   183,   170,-32768,
-32768,-32768,-32768,   105,   125,   118,    23,-32768,   126,-32768,
-32768,   170,-32768,   121,-32768,   200,-32768,   129,   130,   131,
   136,-32768,   163,-32768,     5,-32768,-32768,    72,-32768,   132,
-32768,   138,   207,   210,    14,    14,-32768,-32768,-32768,   177,
-32768,     3,     3,-32768,-32768,-32768,   141,   142,   143,   144,
-32768,   133,   179,-32768,-32768,   146,-32768,-32768,   147,-32768,
   148,-32768,   149,   150,-32768,   218,   218,   218,   218,   151,
   152,   153,   154,   155,   156,   157,   158,   159,   161,-32768,
-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
-32768,-32768,-32768,    58,   207,   210,   140,   164,   165,   166,
-32768,   167,   168,   169,   171,   172,   173,   174,   175,-32768,
-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
   178,   180,   207,   210,     6,     6,   162,-32768,-32768,   176,
-32768,   181,   185,    29,    45,    45,   231,    24,    45,    45,
    45,    45,    42,-32768,-32768,-32768,-32768,-32768,-32768,   241,
-32768,   184,-32768,    87,    45,    45,   186,    45,     2,   186,
   186,    -8,    -8,    -8,   249,   250,-32768,-32768,-32768,-32768,
   187,   190,   259,   191,    22,    18,    40,-32768,-32768,   192,
-32768,   193,   194,-32768,-32768,   195,-32768,-32768,-32768,   196,
   198,-32768,-32768,-32768,-32768,   199,   201,-32768,-32768,   202,
   203,   204,   263,   205,   206,   208,   270,-32768,-32768,-32768,
-32768,-32768,-32768,-32768,   209,   211,   -18,     8,   212,    11,
-32768,   213,-32768,-32768,-32768,-32768,   214,   215,-32768,-32768,
-32768,   216,-32768,    87,   277,    80,   221,    45,   128,   283,
   140,    45,   238,   243,   222,     6,   234,   293,   224,   226,
   227,   228,   229,     6,     6,-32768,   300,   232,-32768,   301,
   233,   258,-32768,-32768,   305,   236,   307,    44,    45,   239,
   235,-32768,   237,-32768,   242,-32768,-32768,-32768,-32768,-32768,
   244,   240,-32768,-32768,   245,-32768,   308,   246,-32768,   247,
   318,    -8,    -8,    -8,    -8,-32768,   251,   252,    32,   253,
    52,   254,   255,    25,   257,-32768,   256,-32768,-32768,   135,
-32768,   319,   -11,    42,-32768,    87,   264,    14,   320,   103,
   265,   266,-32768,-32768,    30,   325,-32768,    72,   267,   327,
-32768,   328,   268,    26,-32768,-32768,-32768,   269,-32768,-32768,
    45,-32768,-32768,   272,   271,-32768,-32768,-32768,-32768,-32768,
   329,   273,   274,   276,    42,   275,-32768,-32768,-32768,   278,
   279,    52,   280,   282,    42,-32768,-32768,   281,   124,-32768,
    26,-32768,   285,   322,-32768,   347,-32768,-32768,   291,-32768,
-32768,    58,   286,-32768,   350,   286,-32768,-32768,    45,-32768,
    45,   287,-32768,-32768,-32768,   358,   289,   290,-32768,   288,
   361,-32768,   292,-32768,-32768,-32768,    13,-32768,   294,   295,
    33,   363,-32768,-32768,-32768,-32768,-32768,-32768,   296,   297,
    46,-32768,-32768,-32768,-32768,   298,    10,    28,-32768,-32768,
    42,-32768,-32768,-32768,-32768,-32768,   299,   302,   302,-32768,
    28,    12,-32768,-32768,   302,-32768,-32768,-32768,   374,   377,
-32768
};

static const short yypgoto[] = {-32768,
   375,-32768,-32768,-32768,-32768,   364,-32768,   372,   348,    79,
-32768,-32768,-32768,-32768,   326,-32768,-32768,-32768,-32768,   123,
-32768,-32768,-32768,   -42,-32768,-32768,-32768,   -17,   330,-32768,
-32768,-32768,-32768,-32768,-32768,   -23,-32768,-32768,   349,-32768,
-32768,-32768,    21,   -32,-32768,-32768,   -77,   -75,   111,-32768,
-32768,-32768,   311,-32768,-32768,-32768,   312,   303,-32768,-32768,
-32768,-32768,-32768,   -72,  -418,  -340,-32768,   315,-32768,-32768,
-32768,-32768,   316,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
-32768,-32768,-32768,  -191,   317,-32768,-32768,-32768,-32768,-32768,
   321,   323,   324,-32768,-32768,-32768,-32768,   -64,-32768,  -172,
  -268,  -161,   -60,-32768,-32768,-32768,-32768,-32768,-32768,   188,
   197,    -9,-32768,    89,-32768,  -123,   -82
};


#define	YYLAST		462


static const short yytable[] = {    16,
    17,    93,   223,   193,   212,   310,   231,   232,   233,   234,
   252,   253,   254,   475,   303,    96,    97,    98,    99,   100,
    87,    30,   241,   242,    84,   245,   246,   228,   101,   406,
   102,   475,   296,   218,   397,    50,   246,   464,   103,   386,
   104,   105,   106,   107,   108,    48,    49,   188,   387,   479,
   189,   209,   221,    50,   486,   222,   210,   297,   299,   456,
   476,    31,   485,   457,    90,   109,    51,   243,   266,    32,
   267,     9,   261,   262,   229,   376,   407,   247,   476,   219,
   398,   465,   367,   300,    51,   207,   213,   390,   208,   458,
   271,   487,   458,    15,   346,   221,   312,   377,   222,    29,
   313,   314,   371,    19,    15,   318,    38,   368,   184,   324,
    10,   469,   470,   471,   244,   185,   186,   250,   251,    15,
   190,    15,    74,    15,   328,    15,    12,   372,    75,    76,
   312,   238,   336,   337,   313,   314,   349,   239,   484,    18,
   361,   362,   363,   364,   488,    96,    97,    98,    99,   128,
   129,   130,   131,   132,    78,    79,    80,   193,   101,   133,
   134,   135,   136,    22,   137,   138,   139,     1,     2,    23,
   104,   105,   106,   235,   221,   319,   391,   222,   320,   355,
    39,    40,   161,   162,   382,   383,   172,   173,    25,    26,
    34,    35,   428,   429,   430,   431,    36,    47,    46,   190,
    58,    61,    62,    63,    64,    65,    67,   273,   410,    84,
    66,    83,    87,    94,   124,   190,   125,   126,   127,   163,
   164,   165,   166,   168,   167,   174,   175,   176,   177,   178,
   179,   180,   181,   182,   227,   183,   433,   213,   194,   195,
   196,   197,   198,   199,   236,   200,   201,   202,   203,   204,
   215,   205,   255,   206,   256,   216,   445,  -102,   446,   217,
   257,   243,   259,   258,   260,   274,   285,   276,   277,   278,
   275,   279,   280,   289,   281,   282,   283,   284,   286,   287,
   311,   317,   294,   288,   295,   302,   322,   325,   308,   309,
   305,   307,   326,   392,   329,   327,   330,   331,   348,   332,
   333,   334,   335,   338,   340,   339,   341,   342,   343,   344,
   345,   357,   350,   351,   352,   353,   355,   354,   356,   358,
   359,   360,   385,   393,   365,   366,   370,   374,   400,   381,
   403,   404,   413,   375,   379,   380,   417,   391,   394,   395,
   402,   405,   409,   437,   389,   411,   414,   416,   419,   412,
   438,   439,   422,   443,   421,   425,   424,   427,   436,   441,
   447,   450,   451,   452,   453,   454,   466,   461,   455,   467,
   468,   463,   481,   490,   474,   482,   491,    21,    11,    14,
    71,    45,   304,   444,   423,   418,    73,   435,   401,   440,
    59,   323,   141,   142,   477,   426,   144,   149,   154,   171,
   472,     0,   158,   270,   159,   160,     0,     0,     0,     0,
     0,   265,     0,     0,     0,     0,     0,     0,     0,     0,
     0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
     0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
     0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
     0,   473,     0,     0,     0,     0,     0,     0,     0,     0,
     0,   480
};

static const short yycheck[] = {     9,
    10,    66,   175,   127,   166,   274,   179,   180,   181,   182,
   202,   203,   204,     4,     4,    13,    14,    15,    16,    17,
     3,     3,   195,   196,     3,   198,    35,     4,    26,     4,
    28,     4,    51,     5,     5,    31,    35,     5,    36,    51,
    38,    39,    40,    41,    42,    23,    24,   125,    60,   468,
   126,    46,    51,    31,    43,    54,    51,    76,    51,    47,
    51,    43,   481,    51,    51,    63,    62,    76,    51,    51,
    53,    75,    51,    52,    51,    51,    51,    76,    51,    51,
    51,    49,    51,    76,    62,   163,    76,   356,   164,    80,
    51,    80,    80,    80,    51,    51,    51,    73,    54,    21,
    55,    56,    51,    10,    80,   278,    28,    76,    51,   282,
    75,    66,    67,    68,   197,    58,    59,   200,   201,    80,
    76,    80,    51,    80,   286,    80,    64,    76,    57,    58,
    51,    45,   294,   295,    55,    56,   309,    51,   479,    75,
   332,   333,   334,   335,   485,    13,    14,    15,    16,    17,
    18,    19,    20,    21,    23,    24,    25,   281,    26,    27,
    28,    29,    30,    74,    32,    33,    34,     8,     9,    65,
    38,    39,    40,   183,    51,    48,    74,    54,    51,    77,
    11,    12,     4,     5,    50,    51,    98,    99,    75,     7,
    74,     3,    69,    70,    71,    72,    75,    80,    74,    76,
    75,    81,     3,    75,    75,    75,    44,   217,   381,     3,
    75,    74,     3,    37,    74,    76,    75,    75,    75,    74,
    74,    74,    74,     6,    75,    75,    75,    75,    75,    75,
    75,    75,    75,    75,     4,    75,   409,    76,    75,    75,
    75,    75,    75,    75,     4,    75,    75,    75,    75,    75,
    75,    74,     4,    74,     5,    75,   429,    74,   431,    75,
    74,    76,     4,    74,    74,    74,     4,    74,    74,    74,
    78,    74,    74,     4,    74,    74,    74,    74,    74,    74,
     4,    61,    74,    76,    74,    74,     4,    50,    74,    74,
    78,    78,    50,   358,    61,    74,     4,    74,   308,    74,
    74,    74,    74,     4,     4,    74,    74,    50,     4,    74,
     4,     4,    74,    79,    78,    74,    77,    74,    74,    74,
    74,     4,     4,     4,    74,    74,    74,    74,     4,    74,
     4,     4,     4,    79,   344,    79,    61,    74,    74,    74,
    74,    74,    74,    22,   354,    74,    74,    74,    74,    79,
     4,    61,    74,     4,    77,    74,    77,    77,    74,    74,
    74,     4,    74,    74,    77,     5,     4,    74,    77,    74,
    74,    77,    74,     0,    77,    74,     0,    14,     4,     8,
    55,    34,   260,   426,   402,   395,    57,   411,   368,   422,
    42,   281,    82,    82,   467,   405,    82,    82,    82,    97,
   461,    -1,    82,   216,    82,    82,    -1,    -1,    -1,    -1,
    -1,   215,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
    -1,   461,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
    -1,   471
};
/* -*-C-*-  Note some compilers choke on comments on `#line' lines.  */
#line 3 "bison.simple"

/* Skeleton output parser for bison,
   Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2, or (at your option)
   any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */

/* As a special exception, when this file is copied by Bison into a
   Bison output file, you may use that output file without restriction.
   This special exception was added by the Free Software Foundation
   in version 1.24 of Bison.  */

#ifndef alloca
#ifdef __GNUC__
#define alloca __builtin_alloca
#else /* not GNU C.  */
#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi)
#include <alloca.h>
#else /* not sparc */
#if defined (MSDOS) && !defined (__TURBOC__)
#include <malloc.h>
#else /* not MSDOS, or __TURBOC__ */
#if defined(_AIX)
#include <malloc.h>
 #pragma alloca
#else /* not MSDOS, __TURBOC__, or _AIX */
#ifdef __hpux
#ifdef __cplusplus
extern "C" {
void *alloca (unsigned int);
};
#else /* not __cplusplus */
void *alloca ();
#endif /* not __cplusplus */
#endif /* __hpux */
#endif /* not _AIX */
#endif /* not MSDOS, or __TURBOC__ */
#endif /* not sparc.  */
#endif /* not GNU C.  */
#endif /* alloca not defined.  */

/* This is the parser code that is written into each bison parser
  when the %semantic_parser declaration is not specified in the grammar.
  It was written by Richard Stallman by simplifying the hairy parser
  used when %semantic_parser is specified.  */

/* Note: there must be only one dollar sign in this file.
   It is replaced by the list of actions, each action
   as one case of the switch.  */

#define yyerrok		(yyerrstatus = 0)
#define yyclearin	(yychar = YYEMPTY)
#define YYEMPTY		-2
#define YYEOF		0
#define YYACCEPT	return(0)
#define YYABORT 	return(1)
#define YYERROR		goto yyerrlab1
/* Like YYERROR except do call yyerror.
   This remains here temporarily to ease the
   transition to the new meaning of YYERROR, for GCC.
   Once GCC version 2 has supplanted version 1, this can go.  */
#define YYFAIL		goto yyerrlab
#define YYRECOVERING()  (!!yyerrstatus)
#define YYBACKUP(token, value) \
do								\
  if (yychar == YYEMPTY && yylen == 1)				\
    { yychar = (token), yylval = (value);			\
      yychar1 = YYTRANSLATE (yychar);				\
      YYPOPSTACK;						\
      goto yybackup;						\
    }								\
  else								\
    { yyerror ("syntax error: cannot back up"); YYERROR; }	\
while (0)

#define YYTERROR	1
#define YYERRCODE	256

#ifndef YYPURE
#define YYLEX		yylex()
#endif

#ifdef YYPURE
#ifdef YYLSP_NEEDED
#ifdef YYLEX_PARAM
#define YYLEX		yylex(&yylval, &yylloc, YYLEX_PARAM)
#else
#define YYLEX		yylex(&yylval, &yylloc)
#endif
#else /* not YYLSP_NEEDED */
#ifdef YYLEX_PARAM
#define YYLEX		yylex(&yylval, YYLEX_PARAM)
#else
#define YYLEX		yylex(&yylval)
#endif
#endif /* not YYLSP_NEEDED */
#endif

/* If nonreentrant, generate the variables here */

#ifndef YYPURE

int	yychar;			/*  the lookahead symbol		*/
YYSTYPE	yylval;			/*  the semantic value of the		*/
				/*  lookahead symbol			*/

#ifdef YYLSP_NEEDED
YYLTYPE yylloc;			/*  location data for the lookahead	*/
				/*  symbol				*/
#endif

int yynerrs;			/*  number of parse errors so far       */
#endif  /* not YYPURE */

#if YYDEBUG != 0
int yydebug;			/*  nonzero means print parse trace	*/
/* Since this is uninitialized, it does not stop multiple parsers
   from coexisting.  */
#endif

/*  YYINITDEPTH indicates the initial size of the parser's stacks	*/

#ifndef	YYINITDEPTH
#define YYINITDEPTH 200
#endif

/*  YYMAXDEPTH is the maximum size the stacks can grow to
    (effective only if the built-in stack extension method is used).  */

#if YYMAXDEPTH == 0
#undef YYMAXDEPTH
#endif

#ifndef YYMAXDEPTH
#define YYMAXDEPTH 10000
#endif

/* Prevent warning if -Wstrict-prototypes.  */
#ifdef __GNUC__
int yyparse (void);
#endif

#if __GNUC__ > 1		/* GNU C and GNU C++ define this.  */
#define __yy_memcpy(FROM,TO,COUNT)	__builtin_memcpy(TO,FROM,COUNT)
#else				/* not GNU C or C++ */
#ifndef __cplusplus

/* This is the most reliable way to avoid incompatibilities
   in available built-in functions on various systems.  */
static void
__yy_memcpy (from, to, count)
     char *from;
     char *to;
     int count;
{
  register char *f = from;
  register char *t = to;
  register int i = count;

  while (i-- > 0)
    *t++ = *f++;
}

#else /* __cplusplus */

/* This is the most reliable way to avoid incompatibilities
   in available built-in functions on various systems.  */
static void
__yy_memcpy (char *from, char *to, int count)
{
  register char *f = from;
  register char *t = to;
  register int i = count;

  while (i-- > 0)
    *t++ = *f++;
}

#endif
#endif

#line 192 "bison.simple"

/* The user can define YYPARSE_PARAM as the name of an argument to be passed
   into yyparse.  The argument should have type void *.
   It should actually point to an object.
   Grammar actions can access the variable by casting it
   to the proper pointer type.  */

#ifdef YYPARSE_PARAM
#define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
#else
#define YYPARSE_PARAM
#define YYPARSE_PARAM_DECL
#endif

int
yyparse(YYPARSE_PARAM)
     YYPARSE_PARAM_DECL
{
  register int yystate;
  register int yyn;
  register short *yyssp;
  register YYSTYPE *yyvsp;
  int yyerrstatus;	/*  number of tokens to shift before error messages enabled */
  int yychar1 = 0;		/*  lookahead token as an internal (translated) token number */

  short	yyssa[YYINITDEPTH];	/*  the state stack			*/
  YYSTYPE yyvsa[YYINITDEPTH];	/*  the semantic value stack		*/

  short *yyss = yyssa;		/*  refer to the stacks thru separate pointers */
  YYSTYPE *yyvs = yyvsa;	/*  to allow yyoverflow to reallocate them elsewhere */

#ifdef YYLSP_NEEDED
  YYLTYPE yylsa[YYINITDEPTH];	/*  the location stack			*/
  YYLTYPE *yyls = yylsa;
  YYLTYPE *yylsp;

#define YYPOPSTACK   (yyvsp--, yyssp--, yylsp--)
#else
#define YYPOPSTACK   (yyvsp--, yyssp--)
#endif

  int yystacksize = YYINITDEPTH;

#ifdef YYPURE
  int yychar;
  YYSTYPE yylval;
  int yynerrs;
#ifdef YYLSP_NEEDED
  YYLTYPE yylloc;
#endif
#endif

  YYSTYPE yyval;		/*  the variable used to return		*/
				/*  semantic values from the action	*/
				/*  routines				*/

  int yylen;

#if YYDEBUG != 0
  if (yydebug)
    fprintf(stderr, "Starting parse\n");
#endif

  yystate = 0;
  yyerrstatus = 0;
  yynerrs = 0;
  yychar = YYEMPTY;		/* Cause a token to be read.  */

  /* Initialize stack pointers.
     Waste one element of value and location stack
     so that they stay on the same level as the state stack.
     The wasted elements are never initialized.  */

  yyssp = yyss - 1;
  yyvsp = yyvs;
#ifdef YYLSP_NEEDED
  yylsp = yyls;
#endif

/* Push a new state, which is found in  yystate  .  */
/* In all cases, when you get here, the value and location stacks
   have just been pushed. so pushing a state here evens the stacks.  */
yynewstate:

  *++yyssp = yystate;

  if (yyssp >= yyss + yystacksize - 1)
    {
      /* Give user a chance to reallocate the stack */
      /* Use copies of these so that the &'s don't force the real ones into memory. */
      YYSTYPE *yyvs1 = yyvs;
      short *yyss1 = yyss;
#ifdef YYLSP_NEEDED
      YYLTYPE *yyls1 = yyls;
#endif

      /* Get the current used size of the three stacks, in elements.  */
      int size = yyssp - yyss + 1;

#ifdef yyoverflow
      /* Each stack pointer address is followed by the size of
	 the data in use in that stack, in bytes.  */
#ifdef YYLSP_NEEDED
      /* This used to be a conditional around just the two extra args,
	 but that might be undefined if yyoverflow is a macro.  */
      yyoverflow("parser stack overflow",
		 &yyss1, size * sizeof (*yyssp),
		 &yyvs1, size * sizeof (*yyvsp),
		 &yyls1, size * sizeof (*yylsp),
		 &yystacksize);
#else
      yyoverflow("parser stack overflow",
		 &yyss1, size * sizeof (*yyssp),
		 &yyvs1, size * sizeof (*yyvsp),
		 &yystacksize);
#endif

      yyss = yyss1; yyvs = yyvs1;
#ifdef YYLSP_NEEDED
      yyls = yyls1;
#endif
#else /* no yyoverflow */
      /* Extend the stack our own way.  */
      if (yystacksize >= YYMAXDEPTH)
	{
	  yyerror("parser stack overflow");
	  return 2;
	}
      yystacksize *= 2;
      if (yystacksize > YYMAXDEPTH)
	yystacksize = YYMAXDEPTH;
      yyss = (short *) alloca (yystacksize * sizeof (*yyssp));
      __yy_memcpy ((char *)yyss1, (char *)yyss, size * sizeof (*yyssp));
      yyvs = (YYSTYPE *) alloca (yystacksize * sizeof (*yyvsp));
      __yy_memcpy ((char *)yyvs1, (char *)yyvs, size * sizeof (*yyvsp));
#ifdef YYLSP_NEEDED
      yyls = (YYLTYPE *) alloca (yystacksize * sizeof (*yylsp));
      __yy_memcpy ((char *)yyls1, (char *)yyls, size * sizeof (*yylsp));
#endif
#endif /* no yyoverflow */

      yyssp = yyss + size - 1;
      yyvsp = yyvs + size - 1;
#ifdef YYLSP_NEEDED
      yylsp = yyls + size - 1;
#endif

#if YYDEBUG != 0
      if (yydebug)
	fprintf(stderr, "Stack size increased to %d\n", yystacksize);
#endif

      if (yyssp >= yyss + yystacksize - 1)
	YYABORT;
    }

#if YYDEBUG != 0
  if (yydebug)
    fprintf(stderr, "Entering state %d\n", yystate);
#endif

  goto yybackup;
 yybackup:

/* Do appropriate processing given the current state.  */
/* Read a lookahead token if we need one and don't already have one.  */
/* yyresume: */

  /* First try to decide what to do without reference to lookahead token.  */

  yyn = yypact[yystate];
  if (yyn == YYFLAG)
    goto yydefault;

  /* Not known => get a lookahead token if don't already have one.  */

  /* yychar is either YYEMPTY or YYEOF
     or a valid token in external form.  */

  if (yychar == YYEMPTY)
    {
#if YYDEBUG != 0
      if (yydebug)
	fprintf(stderr, "Reading a token: ");
#endif
      yychar = YYLEX;
    }

  /* Convert token to internal form (in yychar1) for indexing tables with */

  if (yychar <= 0)		/* This means end of input. */
    {
      yychar1 = 0;
      yychar = YYEOF;		/* Don't call YYLEX any more */

#if YYDEBUG != 0
      if (yydebug)
	fprintf(stderr, "Now at end of input.\n");
#endif
    }
  else
    {
      yychar1 = YYTRANSLATE(yychar);

#if YYDEBUG != 0
      if (yydebug)
	{
	  fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
	  /* Give the individual parser a way to print the precise meaning
	     of a token, for further debugging info.  */
#ifdef YYPRINT
	  YYPRINT (stderr, yychar, yylval);
#endif
	  fprintf (stderr, ")\n");
	}
#endif
    }

  yyn += yychar1;
  if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
    goto yydefault;

  yyn = yytable[yyn];

  /* yyn is what to do for this token type in this state.
     Negative => reduce, -yyn is rule number.
     Positive => shift, yyn is new state.
       New state is final state => don't bother to shift,
       just return success.
     0, or most negative number => error.  */

  if (yyn < 0)
    {
      if (yyn == YYFLAG)
	goto yyerrlab;
      yyn = -yyn;
      goto yyreduce;
    }
  else if (yyn == 0)
    goto yyerrlab;

  if (yyn == YYFINAL)
    YYACCEPT;

  /* Shift the lookahead token.  */

#if YYDEBUG != 0
  if (yydebug)
    fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
#endif

  /* Discard the token being shifted unless it is eof.  */
  if (yychar != YYEOF)
    yychar = YYEMPTY;

  *++yyvsp = yylval;
#ifdef YYLSP_NEEDED
  *++yylsp = yylloc;
#endif

  /* count tokens shifted since error; after three, turn off error status.  */
  if (yyerrstatus) yyerrstatus--;

  yystate = yyn;
  goto yynewstate;

/* Do the default action for the current state.  */
yydefault:

  yyn = yydefact[yystate];
  if (yyn == 0)
    goto yyerrlab;

/* Do a reduction.  yyn is the number of a rule to reduce with.  */
yyreduce:
  yylen = yyr2[yyn];
  if (yylen > 0)
    yyval = yyvsp[1-yylen]; /* implement default value of the action */

#if YYDEBUG != 0
  if (yydebug)
    {
      int i;

      fprintf (stderr, "Reducing via rule %d (line %d), ",
	       yyn, yyrline[yyn]);

      /* Print the symbols being reduced, and their result.  */
      for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
	fprintf (stderr, "%s ", yytname[yyrhs[i]]);
      fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
    }
#endif


  switch (yyn) {

case 7:
#line 185 "lev_comp.y"
{
			unsigned i;

			if (fatal_error > 0) {
				(void) fprintf(stderr,
				"%s : %d errors detected. No output created!\n",
					fname, fatal_error);
			} else {
				maze.flags = yyvsp[-3].i;
				(void) memcpy((genericptr_t)&(maze.init_lev),
						(genericptr_t)&(init_lev),
						sizeof(lev_init));
				maze.numpart = npart;
				maze.parts = NewTab(mazepart, npart);
				for(i=0;i<npart;i++)
				    maze.parts[i] = tmppart[i];
				if (!write_level_file(yyvsp[-4].map, (splev *)0, &maze)) {
					yyerror("Can't write output file!!");
					exit(EXIT_FAILURE);
				}
				npart = 0;
			}
			Free(yyvsp[-4].map);
		  ;
    break;}
case 8:
#line 212 "lev_comp.y"
{
			unsigned i;

			if (fatal_error > 0) {
			    (void) fprintf(stderr,
			      "%s : %d errors detected. No output created!\n",
					fname, fatal_error);
			} else {
				special_lev.flags = (long) yyvsp[-5].i;
				(void) memcpy(
					(genericptr_t)&(special_lev.init_lev),
					(genericptr_t)&(init_lev),
					sizeof(lev_init));
				special_lev.nroom = nrooms;
				special_lev.rooms = NewTab(room, nrooms);
				for(i=0; i<nrooms; i++)
				    special_lev.rooms[i] = tmproom[i];
				special_lev.ncorr = ncorridor;
				special_lev.corrs = NewTab(corridor, ncorridor);
				for(i=0; i<ncorridor; i++)
				    special_lev.corrs[i] = tmpcor[i];
				if (check_subrooms()) {
				    if (!write_level_file(yyvsp[-6].map, &special_lev,
							  (specialmaze *)0)) {
					yyerror("Can't write output file!!");
					exit(EXIT_FAILURE);
				    }
				}
				free_rooms(&special_lev);
				nrooms = 0;
				ncorridor = 0;
			}
			Free(yyvsp[-6].map);
		  ;
    break;}
case 9:
#line 249 "lev_comp.y"
{
			if (index(yyvsp[0].map, '.'))
			    yyerror("Invalid dot ('.') in level name.");
			if ((int) strlen(yyvsp[0].map) > 8)
			    yyerror("Level names limited to 8 characters.");
			yyval.map = yyvsp[0].map;
			special_lev.nrmonst = special_lev.nrobjects = 0;
			n_mlist = n_olist = 0;
		  ;
    break;}
case 10:
#line 261 "lev_comp.y"
{
			/* in case we're processing multiple files,
			   explicitly clear any stale settings */
			(void) memset((genericptr_t) &init_lev, 0,
					sizeof init_lev);
			init_lev.init_present = FALSE;
			yyval.i = 0;
		  ;
    break;}
case 11:
#line 270 "lev_comp.y"
{
			init_lev.init_present = 1;
			init_lev.fg = what_map_char((char) yyvsp[-10].i);
			if (init_lev.fg == INVALID_TYPE)
			    yyerror("Invalid foreground type.");
			init_lev.bg = what_map_char((char) yyvsp[-8].i);
			if (init_lev.bg == INVALID_TYPE)
			    yyerror("Invalid background type.");
			init_lev.smoothed = yyvsp[-6].i;
			init_lev.joined = yyvsp[-4].i;
			if (init_lev.joined &&
			    init_lev.fg != CORR && !IS_FLOOR(init_lev.fg)/*init_lev.fg != ROOM*/)
			    yyerror("Invalid foreground type for joined map.");
			init_lev.lit = yyvsp[-2].i;
			init_lev.walled = yyvsp[0].i;
			yyval.i = 1;
		  ;
    break;}
case 12:
#line 288 "lev_comp.y"
{
			init_lev.init_present = yyvsp[-4].i;
			init_lev.arg = yyvsp[-2].i;
			init_lev.fg = what_map_char((char) yyvsp[-8].i);
			if (init_lev.fg == INVALID_TYPE)
			    yyerror("Invalid foreground type.");
			init_lev.bg = what_map_char((char) yyvsp[-6].i);
			if (init_lev.bg == INVALID_TYPE)
			    yyerror("Invalid background type.");
			init_lev.lit = yyvsp[0].i;
			init_lev.smoothed = 0;
			init_lev.joined = 0;
			init_lev.walled = 0;
			yyval.i = 1;
		  ;
    break;}
case 15:
#line 310 "lev_comp.y"
{
			yyval.i = 0;
		  ;
    break;}
case 16:
#line 314 "lev_comp.y"
{
			yyval.i = lev_flags;
			lev_flags = 0;	/* clear for next user */
		  ;
    break;}
case 17:
#line 321 "lev_comp.y"
{
			lev_flags |= yyvsp[-2].i;
		  ;
    break;}
case 18:
#line 325 "lev_comp.y"
{
			lev_flags |= yyvsp[0].i;
		  ;
    break;}
case 21:
#line 335 "lev_comp.y"
{
			int i, j;

			i = (int) strlen(yyvsp[0].map) + 1;
			j = (int) strlen(tmpmessage);
			if (i + j > 255) {
			   yyerror("Message string too long (>256 characters)");
			} else {
			    if (j) tmpmessage[j++] = '\n';
			    (void) strncpy(tmpmessage+j, yyvsp[0].map, i - 1);
			    tmpmessage[j + i - 1] = 0;
			}
			Free(yyvsp[0].map);
		  ;
    break;}
case 24:
#line 356 "lev_comp.y"
{
			if(special_lev.nrobjects) {
			    yyerror("Object registers already initialized!");
			} else {
			    special_lev.nrobjects = n_olist;
			    special_lev.robjects = (char *) alloc(n_olist);
			    (void) memcpy((genericptr_t)special_lev.robjects,
					  (genericptr_t)olist, n_olist);
			}
		  ;
    break;}
case 25:
#line 367 "lev_comp.y"
{
			if(special_lev.nrmonst) {
			    yyerror("Monster registers already initialized!");
			} else {
			    special_lev.nrmonst = n_mlist;
			    special_lev.rmonst = (char *) alloc(n_mlist);
			    (void) memcpy((genericptr_t)special_lev.rmonst,
					  (genericptr_t)mlist, n_mlist);
			  }
		  ;
    break;}
case 26:
#line 380 "lev_comp.y"
{
			tmproom[nrooms] = New(room);
			tmproom[nrooms]->name = (char *) 0;
			tmproom[nrooms]->parent = (char *) 0;
			tmproom[nrooms]->rtype = 0;
			tmproom[nrooms]->rlit = 0;
			tmproom[nrooms]->xalign = ERR;
			tmproom[nrooms]->yalign = ERR;
			tmproom[nrooms]->x = 0;
			tmproom[nrooms]->y = 0;
			tmproom[nrooms]->w = 2;
			tmproom[nrooms]->h = 2;
			in_room = 1;
		  ;
    break;}
case 32:
#line 406 "lev_comp.y"
{
			tmpcor[0] = New(corridor);
			tmpcor[0]->src.room = -1;
			ncorridor = 1;
		  ;
    break;}
case 35:
#line 418 "lev_comp.y"
{
			tmpcor[ncorridor] = New(corridor);
			tmpcor[ncorridor]->src.room = yyvsp[-2].corpos.room;
			tmpcor[ncorridor]->src.wall = yyvsp[-2].corpos.wall;
			tmpcor[ncorridor]->src.door = yyvsp[-2].corpos.door;
			tmpcor[ncorridor]->dest.room = yyvsp[0].corpos.room;
			tmpcor[ncorridor]->dest.wall = yyvsp[0].corpos.wall;
			tmpcor[ncorridor]->dest.door = yyvsp[0].corpos.door;
			ncorridor++;
			if (ncorridor >= MAX_OF_TYPE) {
				yyerror("Too many corridors in level!");
				ncorridor--;
			}
		  ;
    break;}
case 36:
#line 433 "lev_comp.y"
{
			tmpcor[ncorridor] = New(corridor);
			tmpcor[ncorridor]->src.room = yyvsp[-2].corpos.room;
			tmpcor[ncorridor]->src.wall = yyvsp[-2].corpos.wall;
			tmpcor[ncorridor]->src.door = yyvsp[-2].corpos.door;
			tmpcor[ncorridor]->dest.room = -1;
			tmpcor[ncorridor]->dest.wall = yyvsp[0].i;
			ncorridor++;
			if (ncorridor >= MAX_OF_TYPE) {
				yyerror("Too many corridors in level!");
				ncorridor--;
			}
		  ;
    break;}
case 37:
#line 449 "lev_comp.y"
{
			if ((unsigned) yyvsp[-5].i >= nrooms)
			    yyerror("Wrong room number!");
			yyval.corpos.room = yyvsp[-5].i;
			yyval.corpos.wall = yyvsp[-3].i;
			yyval.corpos.door = yyvsp[-1].i;
		  ;
    break;}
case 38:
#line 459 "lev_comp.y"
{
			store_room();
		  ;
    break;}
case 39:
#line 463 "lev_comp.y"
{
			store_room();
		  ;
    break;}
case 40:
#line 469 "lev_comp.y"
{
			tmproom[nrooms] = New(room);
			tmproom[nrooms]->parent = yyvsp[-1].map;
			tmproom[nrooms]->name = (char *) 0;
			tmproom[nrooms]->rtype = yyvsp[-9].i;
			tmproom[nrooms]->rlit = yyvsp[-7].i;
			tmproom[nrooms]->filled = yyvsp[0].i;
			tmproom[nrooms]->xalign = ERR;
			tmproom[nrooms]->yalign = ERR;
			tmproom[nrooms]->x = current_coord.x;
			tmproom[nrooms]->y = current_coord.y;
			tmproom[nrooms]->w = current_size.width;
			tmproom[nrooms]->h = current_size.height;
			in_room = 1;
		  ;
    break;}
case 41:
#line 487 "lev_comp.y"
{
			tmproom[nrooms] = New(room);
			tmproom[nrooms]->name = (char *) 0;
			tmproom[nrooms]->parent = (char *) 0;
			tmproom[nrooms]->rtype = yyvsp[-9].i;
			tmproom[nrooms]->rlit = yyvsp[-7].i;
			tmproom[nrooms]->filled = yyvsp[0].i;
			tmproom[nrooms]->xalign = current_align.x;
			tmproom[nrooms]->yalign = current_align.y;
			tmproom[nrooms]->x = current_coord.x;
			tmproom[nrooms]->y = current_coord.y;
			tmproom[nrooms]->w = current_size.width;
			tmproom[nrooms]->h = current_size.height;
			in_room = 1;
		  ;
    break;}
case 42:
#line 505 "lev_comp.y"
{
			yyval.i = 1;
		  ;
    break;}
case 43:
#line 509 "lev_comp.y"
{
			yyval.i = yyvsp[0].i;
		  ;
    break;}
case 44:
#line 515 "lev_comp.y"
{
			if ( yyvsp[-3].i < 1 || yyvsp[-3].i > 5 ||
			    yyvsp[-1].i < 1 || yyvsp[-1].i > 5 ) {
			    yyerror("Room position should be between 1 & 5!");
			} else {
			    current_coord.x = yyvsp[-3].i;
			    current_coord.y = yyvsp[-1].i;
			}
		  ;
    break;}
case 45:
#line 525 "lev_comp.y"
{
			current_coord.x = current_coord.y = ERR;
		  ;
    break;}
case 46:
#line 531 "lev_comp.y"
{
			if ( yyvsp[-3].i < 0 || yyvsp[-1].i < 0) {
			    yyerror("Invalid subroom position !");
			} else {
			    current_coord.x = yyvsp[-3].i;
			    current_coord.y = yyvsp[-1].i;
			}
		  ;
    break;}
case 47:
#line 540 "lev_comp.y"
{
			current_coord.x = current_coord.y = ERR;
		  ;
    break;}
case 48:
#line 546 "lev_comp.y"
{
			current_align.x = yyvsp[-3].i;
			current_align.y = yyvsp[-1].i;
		  ;
    break;}
case 49:
#line 551 "lev_comp.y"
{
			current_align.x = current_align.y = ERR;
		  ;
    break;}
case 50:
#line 557 "lev_comp.y"
{
			current_size.width = yyvsp[-3].i;
			current_size.height = yyvsp[-1].i;
		  ;
    break;}
case 51:
#line 562 "lev_comp.y"
{
			current_size.height = current_size.width = ERR;
		  ;
    break;}
case 67:
#line 587 "lev_comp.y"
{
			if (tmproom[nrooms]->name)
			    yyerror("This room already has a name!");
			else
			    tmproom[nrooms]->name = yyvsp[0].map;
		  ;
    break;}
case 68:
#line 596 "lev_comp.y"
{
			if (tmproom[nrooms]->chance)
			    yyerror("This room already assigned a chance!");
			else if (tmproom[nrooms]->rtype == OROOM)
			    yyerror("Only typed rooms can have a chance!");
			else if (yyvsp[0].i < 1 || yyvsp[0].i > 99)
			    yyerror("The chance is supposed to be percentile.");
			else
			    tmproom[nrooms]->chance = yyvsp[0].i;
		   ;
    break;}
case 69:
#line 609 "lev_comp.y"
{
			/* ERR means random here */
			if (yyvsp[-2].i == ERR && yyvsp[0].i != ERR) {
		     yyerror("If the door wall is random, so must be its pos!");
			} else {
			    tmprdoor[ndoor] = New(room_door);
			    tmprdoor[ndoor]->secret = yyvsp[-6].i;
			    tmprdoor[ndoor]->mask = yyvsp[-4].i;
			    tmprdoor[ndoor]->wall = yyvsp[-2].i;
			    tmprdoor[ndoor]->pos = yyvsp[0].i;
			    ndoor++;
			    if (ndoor >= MAX_OF_TYPE) {
				    yyerror("Too many doors in room!");
				    ndoor--;
			    }
			}
		  ;
    break;}
case 76:
#line 641 "lev_comp.y"
{
			maze.filling = (schar) yyvsp[0].i;
			if (index(yyvsp[-2].map, '.'))
			    yyerror("Invalid dot ('.') in level name.");
			if (index(yyvsp[-2].map, '?'))
			    add_serial_no(yyvsp[-2].map);
			if ((int) strlen(yyvsp[-2].map) > 8)
			    yyerror("Level names limited to 8 characters.");
			yyval.map = yyvsp[-2].map;
			in_room = 0;
			n_plist = n_mlist = n_olist = 0;
		  ;
    break;}
case 77:
#line 656 "lev_comp.y"
{
			yyval.i = get_floor_type((char)yyvsp[0].i);
		  ;
    break;}
case 78:
#line 660 "lev_comp.y"
{
			yyval.i = -1;
		  ;
    break;}
case 79:
#line 664 "lev_comp.y"
{
			yyval.i = -2;
		  ;
    break;}
case 82:
#line 674 "lev_comp.y"
{
			store_part();
		  ;
    break;}
case 83:
#line 680 "lev_comp.y"
{
			tmppart[npart] = New(mazepart);
			tmppart[npart]->halign = 1;
			tmppart[npart]->valign = 1;
			tmppart[npart]->nrobjects = 0;
			tmppart[npart]->nloc = 0;
			tmppart[npart]->nrmonst = 0;
			tmppart[npart]->xsize = 1;
			tmppart[npart]->ysize = 1;
			tmppart[npart]->map = (char **) alloc(sizeof(char *));
			tmppart[npart]->map[0] = (char *) alloc(1);
			tmppart[npart]->map[0][0] = STONE;
			max_x_map = COLNO-1;
			max_y_map = ROWNO;
		  ;
    break;}
case 84:
#line 696 "lev_comp.y"
{
			tmppart[npart] = New(mazepart);
			tmppart[npart]->halign = (yyvsp[-1].i & 15);
			tmppart[npart]->valign = (yyvsp[-1].i >> 4);
			tmppart[npart]->nrobjects = 0;
			tmppart[npart]->nloc = 0;
			tmppart[npart]->nrmonst = 0;
			scan_map(yyvsp[0].map);
			Free(yyvsp[0].map);
		  ;
    break;}
case 85:
#line 709 "lev_comp.y"
{
			yyval.i =  ((yyvsp[-2].i == -1) ? 0 : yyvsp[-2].i) +
				(((yyvsp[0].i == -1) ? 0 : yyvsp[0].i) << 4);
		  ;
    break;}
case 94:
#line 730 "lev_comp.y"
{
			if (tmppart[npart]->nrobjects) {
			    yyerror("Object registers already initialized!");
			} else {
			    tmppart[npart]->robjects = (char *)alloc(n_olist);
			    (void) memcpy((genericptr_t)tmppart[npart]->robjects,
					  (genericptr_t)olist, n_olist);
			    tmppart[npart]->nrobjects = n_olist;
			}
		  ;
    break;}
case 95:
#line 741 "lev_comp.y"
{
			if (tmppart[npart]->nloc) {
			    yyerror("Location registers already initialized!");
			} else {
			    register int i;
			    tmppart[npart]->rloc_x = (char *) alloc(n_plist);
			    tmppart[npart]->rloc_y = (char *) alloc(n_plist);
			    for(i=0;i<n_plist;i++) {
				tmppart[npart]->rloc_x[i] = plist[i].x;
				tmppart[npart]->rloc_y[i] = plist[i].y;
			    }
			    tmppart[npart]->nloc = n_plist;
			}
		  ;
    break;}
case 96:
#line 756 "lev_comp.y"
{
			if (tmppart[npart]->nrmonst) {
			    yyerror("Monster registers already initialized!");
			} else {
			    tmppart[npart]->rmonst = (char *) alloc(n_mlist);
			    (void) memcpy((genericptr_t)tmppart[npart]->rmonst,
					  (genericptr_t)mlist, n_mlist);
			    tmppart[npart]->nrmonst = n_mlist;
			}
		  ;
    break;}
case 97:
#line 769 "lev_comp.y"
{
			if (n_olist < MAX_REGISTERS)
			    olist[n_olist++] = yyvsp[0].i;
			else
			    yyerror("Object list too long!");
		  ;
    break;}
case 98:
#line 776 "lev_comp.y"
{
			if (n_olist < MAX_REGISTERS)
			    olist[n_olist++] = yyvsp[-2].i;
			else
			    yyerror("Object list too long!");
		  ;
    break;}
case 99:
#line 785 "lev_comp.y"
{
			if (n_mlist < MAX_REGISTERS)
			    mlist[n_mlist++] = yyvsp[0].i;
			else
			    yyerror("Monster list too long!");
		  ;
    break;}
case 100:
#line 792 "lev_comp.y"
{
			if (n_mlist < MAX_REGISTERS)
			    mlist[n_mlist++] = yyvsp[-2].i;
			else
			    yyerror("Monster list too long!");
		  ;
    break;}
case 101:
#line 801 "lev_comp.y"
{
			if (n_plist < MAX_REGISTERS)
			    plist[n_plist++] = current_coord;
			else
			    yyerror("Location list too long!");
		  ;
    break;}
case 102:
#line 808 "lev_comp.y"
{
			if (n_plist < MAX_REGISTERS)
			    plist[n_plist++] = current_coord;
			else
			    yyerror("Location list too long!");
		  ;
    break;}
case 126:
#line 844 "lev_comp.y"
{
			tmpmonst[nmons] = New(monster);
			tmpmonst[nmons]->x = current_coord.x;
			tmpmonst[nmons]->y = current_coord.y;
			tmpmonst[nmons]->class = yyvsp[-4].i;
			tmpmonst[nmons]->peaceful = -1; /* no override */
			tmpmonst[nmons]->asleep = -1;
			tmpmonst[nmons]->align = - MAX_REGISTERS - 2;
			tmpmonst[nmons]->name.str = 0;
			tmpmonst[nmons]->appear = 0;
			tmpmonst[nmons]->appear_as.str = 0;
			tmpmonst[nmons]->chance = yyvsp[-6].i;
			tmpmonst[nmons]->id = NON_PM;
			if (!in_room)
			    check_coord(current_coord.x, current_coord.y,
					"Monster");
			if (yyvsp[-2].map) {
			    int token = get_monster_id(yyvsp[-2].map, (char) yyvsp[-4].i);
			    if (token == ERR)
				yywarning(
			      "Invalid monster name!  Making random monster.");
			    else
				tmpmonst[nmons]->id = token;
			    Free(yyvsp[-2].map);
			}
		  ;
    break;}
case 127:
#line 871 "lev_comp.y"
{
			if (++nmons >= MAX_OF_TYPE) {
			    yyerror("Too many monsters in room or mazepart!");
			    nmons--;
			}
		  ;
    break;}
case 130:
#line 884 "lev_comp.y"
{
			tmpmonst[nmons]->name.str = yyvsp[0].map;
		  ;
    break;}
case 131:
#line 888 "lev_comp.y"
{
			tmpmonst[nmons]->peaceful = yyvsp[0].i;
		  ;
    break;}
case 132:
#line 892 "lev_comp.y"
{
			tmpmonst[nmons]->asleep = yyvsp[0].i;
		  ;
    break;}
case 133:
#line 896 "lev_comp.y"
{
			tmpmonst[nmons]->align = yyvsp[0].i;
		  ;
    break;}
case 134:
#line 900 "lev_comp.y"
{
			tmpmonst[nmons]->appear = yyvsp[-1].i;
			tmpmonst[nmons]->appear_as.str = yyvsp[0].map;
		  ;
    break;}
case 135:
#line 907 "lev_comp.y"
{
		  ;
    break;}
case 136:
#line 910 "lev_comp.y"
{
			/* 1: is contents of preceeding object with 2 */
			/* 2: is a container */
			/* 0: neither */
			tmpobj[nobj-1]->containment = 2;
		  ;
    break;}
case 137:
#line 919 "lev_comp.y"
{
			tmpobj[nobj] = New(object);
			tmpobj[nobj]->class = yyvsp[0].i;
			tmpobj[nobj]->corpsenm = NON_PM;
			tmpobj[nobj]->curse_state = -1;
			tmpobj[nobj]->name.str = 0;
			tmpobj[nobj]->chance = yyvsp[-2].i;
			tmpobj[nobj]->material = -127;
			tmpobj[nobj]->id = -1;
		  ;
    break;}
case 138:
#line 930 "lev_comp.y"
{
			if (++nobj >= MAX_OF_TYPE) {
			    yyerror("Too many objects in room or mazepart!");
			    nobj--;
			}
		  ;
    break;}
case 139:
#line 939 "lev_comp.y"
{
			if (yyvsp[0].map) {
			    int token = get_object_id(yyvsp[0].map, tmpobj[nobj]->class);
			    if (token == ERR)
				yywarning(
				"Illegal object name!  Making random object.");
			     else
				tmpobj[nobj]->id = token;
			    /* material patch */
			    token = get_material_id(yyvsp[0].map);
			    if (token == ERR)
				yywarning(
				"Illegal material name!  Making random object.");
			     else
				tmpobj[nobj]->material = token;
			    Free(yyvsp[0].map);
			}
		  ;
    break;}
case 140:
#line 958 "lev_comp.y"
{
			tmpobj[nobj]->id = -1;
		  ;
    break;}
case 141:
#line 962 "lev_comp.y"
{
			tmpobj[nobj]->id = -1 - yyvsp[0].i;
		  ;
    break;}
case 142:
#line 968 "lev_comp.y"
{
			tmpobj[nobj]->containment = 0;
			tmpobj[nobj]->x = current_coord.x;
			tmpobj[nobj]->y = current_coord.y;
			if (!in_room)
			    check_coord(current_coord.x, current_coord.y,
					"Object");
		  ;
    break;}
case 143:
#line 977 "lev_comp.y"
{
			tmpobj[nobj]->containment = 1;
			/* random coordinate, will be overridden anyway */
			tmpobj[nobj]->x = -MAX_REGISTERS-1;
			tmpobj[nobj]->y = -MAX_REGISTERS-1;
		  ;
    break;}
case 144:
#line 984 "lev_comp.y"
{
			tmpobj[nobj]->containment = 3; /* mon picks it up during making level */
			tmpobj[nobj]->x = current_coord.x;
			tmpobj[nobj]->y = current_coord.y;
			if (!in_room)
			    check_coord(current_coord.x, current_coord.y,
					"Object");
		  ;
    break;}
case 145:
#line 993 "lev_comp.y"
{
			/* added into the previous monster's inventory */
			tmpobj[nobj]->containment = -nmons;
			tmpobj[nobj]->x = -MAX_REGISTERS-1;
			tmpobj[nobj]->y = -MAX_REGISTERS-1;
		  ;
    break;}
case 146:
#line 1000 "lev_comp.y"
{
			tmpobj[nobj]->containment = 4;
			tmpobj[nobj]->x = current_coord.x;
			tmpobj[nobj]->y = current_coord.y;
			if (!in_room)
			    check_coord(current_coord.x, current_coord.y,
					"Object");
		  ;
    break;}
case 147:
#line 1011 "lev_comp.y"
{
			tmpobj[nobj]->spe = -127;
	/* Note below: we're trying to make as many of these optional as
	 * possible.  We clearly can't make curse_state, enchantment, and
	 * monster_id _all_ optional, since ",random" would be ambiguous.
	 * We can't even just make enchantment mandatory, since if we do that
	 * alone, ",random" requires too much lookahead to parse.
	 */
		  ;
    break;}
case 148:
#line 1021 "lev_comp.y"
{
		  ;
    break;}
case 149:
#line 1024 "lev_comp.y"
{
		  ;
    break;}
case 150:
#line 1027 "lev_comp.y"
{
		  ;
    break;}
case 151:
#line 1032 "lev_comp.y"
{
			tmpobj[nobj]->curse_state = -1;
		  ;
    break;}
case 152:
#line 1036 "lev_comp.y"
{
			tmpobj[nobj]->curse_state = yyvsp[0].i;
		  ;
    break;}
case 153:
#line 1042 "lev_comp.y"
{
			int token = get_monster_id(yyvsp[0].map, (char)0);
			if (token == ERR)	/* "random" */
			    tmpobj[nobj]->corpsenm = NON_PM - 1;
			else
			    tmpobj[nobj]->corpsenm = token;
			Free(yyvsp[0].map);
		  ;
    break;}
case 154:
#line 1053 "lev_comp.y"
{
			tmpobj[nobj]->spe = -127;
		  ;
    break;}
case 155:
#line 1057 "lev_comp.y"
{
			tmpobj[nobj]->spe = yyvsp[0].i;
		  ;
    break;}
case 157:
#line 1064 "lev_comp.y"
{
		  ;
    break;}
case 158:
#line 1067 "lev_comp.y"
{
			tmpobj[nobj]->name.str = yyvsp[0].map;
		  ;
    break;}
case 159:
#line 1073 "lev_comp.y"
{
			tmpdoor[ndoor] = New(door);
			tmpdoor[ndoor]->x = current_coord.x;
			tmpdoor[ndoor]->y = current_coord.y;
			tmpdoor[ndoor]->mask = yyvsp[-2].i;
			if(current_coord.x >= 0 && current_coord.y >= 0 &&
			   tmpmap[current_coord.y][current_coord.x] != DOOR &&
			   tmpmap[current_coord.y][current_coord.x] != SDOOR)
			    yyerror("Door decl doesn't match the map");
			ndoor++;
			if (ndoor >= MAX_OF_TYPE) {
				yyerror("Too many doors in mazepart!");
				ndoor--;
			}
		  ;
    break;}
case 160:
#line 1091 "lev_comp.y"
{
			tmptrap[ntrap] = New(trap);
			tmptrap[ntrap]->x = current_coord.x;
			tmptrap[ntrap]->y = current_coord.y;
			tmptrap[ntrap]->type = yyvsp[-2].i;
			tmptrap[ntrap]->chance = yyvsp[-4].i;
			if (!in_room)
			    check_coord(current_coord.x, current_coord.y,
					"Trap");
			if (++ntrap >= MAX_OF_TYPE) {
				yyerror("Too many traps in room or mazepart!");
				ntrap--;
			}
		  ;
    break;}
case 161:
#line 1108 "lev_comp.y"
{
		        int x, y, dir;

			tmpdb[ndb] = New(drawbridge);
			x = tmpdb[ndb]->x = current_coord.x;
			y = tmpdb[ndb]->y = current_coord.y;
			/* convert dir from a DIRECTION to a DB_DIR */
			dir = yyvsp[-2].i;
			switch(dir) {
			case W_NORTH: dir = DB_NORTH; y--; break;
			case W_SOUTH: dir = DB_SOUTH; y++; break;
			case W_EAST:  dir = DB_EAST;  x++; break;
			case W_WEST:  dir = DB_WEST;  x--; break;
			default:
			    yyerror("Invalid drawbridge direction");
			    break;
			}
			tmpdb[ndb]->dir = dir;
			if (current_coord.x >= 0 && current_coord.y >= 0 &&
			    !IS_WALL(tmpmap[y][x])) {
			    char ebuf[60];
			    Sprintf(ebuf,
				    "Wall needed for drawbridge (%02d, %02d)",
				    current_coord.x, current_coord.y);
			    yyerror(ebuf);
			}

			if ( yyvsp[0].i == D_ISOPEN )
			    tmpdb[ndb]->db_open = 1;
			else if ( yyvsp[0].i == D_CLOSED )
			    tmpdb[ndb]->db_open = 0;
			else
			    yyerror("A drawbridge can only be open or closed!");
			ndb++;
			if (ndb >= MAX_OF_TYPE) {
				yyerror("Too many drawbridges in mazepart!");
				ndb--;
			}
		   ;
    break;}
case 162:
#line 1150 "lev_comp.y"
{
			tmpwalk[nwalk] = New(walk);
			tmpwalk[nwalk]->x = current_coord.x;
			tmpwalk[nwalk]->y = current_coord.y;
			tmpwalk[nwalk]->dir = yyvsp[0].i;
			nwalk++;
			if (nwalk >= MAX_OF_TYPE) {
				yyerror("Too many mazewalks in mazepart!");
				nwalk--;
			}
		  ;
    break;}
case 163:
#line 1164 "lev_comp.y"
{
			wallify_map();
		  ;
    break;}
case 164:
#line 1170 "lev_comp.y"
{
			tmplad[nlad] = New(lad);
			tmplad[nlad]->x = current_coord.x;
			tmplad[nlad]->y = current_coord.y;
			tmplad[nlad]->up = yyvsp[0].i;
			if (!in_room)
			    check_coord(current_coord.x, current_coord.y,
					"Ladder");
			nlad++;
			if (nlad >= MAX_OF_TYPE) {
				yyerror("Too many ladders in mazepart!");
				nlad--;
			}
		  ;
    break;}
case 165:
#line 1187 "lev_comp.y"
{
			tmpstair[nstair] = New(stair);
			tmpstair[nstair]->x = current_coord.x;
			tmpstair[nstair]->y = current_coord.y;
			tmpstair[nstair]->up = yyvsp[0].i;
			if (!in_room)
			    check_coord(current_coord.x, current_coord.y,
					"Stairway");
			nstair++;
			if (nstair >= MAX_OF_TYPE) {
				yyerror("Too many stairs in room or mazepart!");
				nstair--;
			}
		  ;
    break;}
case 166:
#line 1204 "lev_comp.y"
{
			tmplreg[nlreg] = New(lev_region);
			tmplreg[nlreg]->in_islev = yyvsp[0].i;
			tmplreg[nlreg]->inarea.x1 = current_region.x1;
			tmplreg[nlreg]->inarea.y1 = current_region.y1;
			tmplreg[nlreg]->inarea.x2 = current_region.x2;
			tmplreg[nlreg]->inarea.y2 = current_region.y2;
		  ;
    break;}
case 167:
#line 1213 "lev_comp.y"
{
			tmplreg[nlreg]->del_islev = yyvsp[-2].i;
			tmplreg[nlreg]->delarea.x1 = current_region.x1;
			tmplreg[nlreg]->delarea.y1 = current_region.y1;
			tmplreg[nlreg]->delarea.x2 = current_region.x2;
			tmplreg[nlreg]->delarea.y2 = current_region.y2;
			if(yyvsp[0].i)
			    tmplreg[nlreg]->rtype = LR_UPSTAIR;
			else
			    tmplreg[nlreg]->rtype = LR_DOWNSTAIR;
			tmplreg[nlreg]->rname.str = 0;
			nlreg++;
			if (nlreg >= MAX_OF_TYPE) {
				yyerror("Too many levregions in mazepart!");
				nlreg--;
			}
		  ;
    break;}
case 168:
#line 1233 "lev_comp.y"
{
			tmplreg[nlreg] = New(lev_region);
			tmplreg[nlreg]->in_islev = yyvsp[0].i;
			tmplreg[nlreg]->inarea.x1 = current_region.x1;
			tmplreg[nlreg]->inarea.y1 = current_region.y1;
			tmplreg[nlreg]->inarea.x2 = current_region.x2;
			tmplreg[nlreg]->inarea.y2 = current_region.y2;
		  ;
    break;}
case 169:
#line 1242 "lev_comp.y"
{
			tmplreg[nlreg]->del_islev = yyvsp[-2].i;
			tmplreg[nlreg]->delarea.x1 = current_region.x1;
			tmplreg[nlreg]->delarea.y1 = current_region.y1;
			tmplreg[nlreg]->delarea.x2 = current_region.x2;
			tmplreg[nlreg]->delarea.y2 = current_region.y2;
			tmplreg[nlreg]->rtype = LR_PORTAL;
			tmplreg[nlreg]->rname.str = yyvsp[0].map;
			nlreg++;
			if (nlreg >= MAX_OF_TYPE) {
				yyerror("Too many levregions in mazepart!");
				nlreg--;
			}
		  ;
    break;}
case 170:
#line 1259 "lev_comp.y"
{
			tmplreg[nlreg] = New(lev_region);
			tmplreg[nlreg]->in_islev = yyvsp[0].i;
			tmplreg[nlreg]->inarea.x1 = current_region.x1;
			tmplreg[nlreg]->inarea.y1 = current_region.y1;
			tmplreg[nlreg]->inarea.x2 = current_region.x2;
			tmplreg[nlreg]->inarea.y2 = current_region.y2;
		  ;
    break;}
case 171:
#line 1268 "lev_comp.y"
{
			tmplreg[nlreg]->del_islev = yyvsp[0].i;
			tmplreg[nlreg]->delarea.x1 = current_region.x1;
			tmplreg[nlreg]->delarea.y1 = current_region.y1;
			tmplreg[nlreg]->delarea.x2 = current_region.x2;
			tmplreg[nlreg]->delarea.y2 = current_region.y2;
		  ;
    break;}
case 172:
#line 1276 "lev_comp.y"
{
			switch(yyvsp[0].i) {
			case -1: tmplreg[nlreg]->rtype = LR_TELE; break;
			case 0: tmplreg[nlreg]->rtype = LR_DOWNTELE; break;
			case 1: tmplreg[nlreg]->rtype = LR_UPTELE; break;
			}
			tmplreg[nlreg]->rname.str = 0;
			nlreg++;
			if (nlreg >= MAX_OF_TYPE) {
				yyerror("Too many levregions in mazepart!");
				nlreg--;
			}
		  ;
    break;}
case 173:
#line 1292 "lev_comp.y"
{
			tmplreg[nlreg] = New(lev_region);
			tmplreg[nlreg]->in_islev = yyvsp[0].i;
			tmplreg[nlreg]->inarea.x1 = current_region.x1;
			tmplreg[nlreg]->inarea.y1 = current_region.y1;
			tmplreg[nlreg]->inarea.x2 = current_region.x2;
			tmplreg[nlreg]->inarea.y2 = current_region.y2;
		  ;
    break;}
case 174:
#line 1301 "lev_comp.y"
{
			tmplreg[nlreg]->del_islev = yyvsp[0].i;
			tmplreg[nlreg]->delarea.x1 = current_region.x1;
			tmplreg[nlreg]->delarea.y1 = current_region.y1;
			tmplreg[nlreg]->delarea.x2 = current_region.x2;
			tmplreg[nlreg]->delarea.y2 = current_region.y2;
			tmplreg[nlreg]->rtype = LR_BRANCH;
			tmplreg[nlreg]->rname.str = 0;
			nlreg++;
			if (nlreg >= MAX_OF_TYPE) {
				yyerror("Too many levregions in mazepart!");
				nlreg--;
			}
		  ;
    break;}
case 175:
#line 1318 "lev_comp.y"
{
			yyval.i = -1;
		  ;
    break;}
case 176:
#line 1322 "lev_comp.y"
{
			yyval.i = yyvsp[0].i;
		  ;
    break;}
case 177:
#line 1328 "lev_comp.y"
{
			yyval.i = 0;
		  ;
    break;}
case 178:
#line 1332 "lev_comp.y"
{
/* This series of if statements is a hack for MSC 5.1.  It seems that its
   tiny little brain cannot compile if these are all one big if statement. */
			if (yyvsp[-7].i <= 0 || yyvsp[-7].i >= COLNO)
				yyerror("Region out of level range!");
			else if (yyvsp[-5].i < 0 || yyvsp[-5].i >= ROWNO)
				yyerror("Region out of level range!");
			else if (yyvsp[-3].i <= 0 || yyvsp[-3].i >= COLNO)
				yyerror("Region out of level range!");
			else if (yyvsp[-1].i < 0 || yyvsp[-1].i >= ROWNO)
				yyerror("Region out of level range!");
			current_region.x1 = yyvsp[-7].i;
			current_region.y1 = yyvsp[-5].i;
			current_region.x2 = yyvsp[-3].i;
			current_region.y2 = yyvsp[-1].i;
			yyval.i = 1;
		  ;
    break;}
case 179:
#line 1352 "lev_comp.y"
{
			tmpfountain[nfountain] = New(fountain);
			tmpfountain[nfountain]->x = current_coord.x;
			tmpfountain[nfountain]->y = current_coord.y;
			if (!in_room)
			    check_coord(current_coord.x, current_coord.y,
					"Fountain");
			nfountain++;
			if (nfountain >= MAX_OF_TYPE) {
			    yyerror("Too many fountains in room or mazepart!");
			    nfountain--;
			}
		  ;
    break;}
case 180:
#line 1368 "lev_comp.y"
{
			tmpsink[nsink] = New(sink);
			tmpsink[nsink]->x = current_coord.x;
			tmpsink[nsink]->y = current_coord.y;
			nsink++;
			if (nsink >= MAX_OF_TYPE) {
				yyerror("Too many sinks in room!");
				nsink--;
			}
		  ;
    break;}
case 181:
#line 1381 "lev_comp.y"
{
			tmppool[npool] = New(pool);
			tmppool[npool]->x = current_coord.x;
			tmppool[npool]->y = current_coord.y;
			npool++;
			if (npool >= MAX_OF_TYPE) {
				yyerror("Too many pools in room!");
				npool--;
			}
		  ;
    break;}
case 182:
#line 1394 "lev_comp.y"
{
			tmpdig[ndig] = New(digpos);
			tmpdig[ndig]->x1 = current_region.x1;
			tmpdig[ndig]->y1 = current_region.y1;
			tmpdig[ndig]->x2 = current_region.x2;
			tmpdig[ndig]->y2 = current_region.y2;
			ndig++;
			if (ndig >= MAX_OF_TYPE) {
				yyerror("Too many diggables in mazepart!");
				ndig--;
			}
		  ;
    break;}
case 183:
#line 1409 "lev_comp.y"
{
			tmppass[npass] = New(digpos);
			tmppass[npass]->x1 = current_region.x1;
			tmppass[npass]->y1 = current_region.y1;
			tmppass[npass]->x2 = current_region.x2;
			tmppass[npass]->y2 = current_region.y2;
			npass++;
			if (npass >= 32) {
				yyerror("Too many passwalls in mazepart!");
				npass--;
			}
		  ;
    break;}
case 184:
#line 1424 "lev_comp.y"
{
			tmpreg[nreg] = New(region);
			tmpreg[nreg]->x1 = current_region.x1;
			tmpreg[nreg]->y1 = current_region.y1;
			tmpreg[nreg]->x2 = current_region.x2;
			tmpreg[nreg]->y2 = current_region.y2;
			tmpreg[nreg]->rlit = yyvsp[-3].i;
			tmpreg[nreg]->rtype = yyvsp[-1].i;
			if(yyvsp[0].i & 1) tmpreg[nreg]->rtype += MAXRTYPE+1;
			tmpreg[nreg]->rirreg = ((yyvsp[0].i >> 1/*& 2*/)/* != 0*/);
			if(current_region.x1 > current_region.x2 ||
			   current_region.y1 > current_region.y2)
			   yyerror("Region start > end!");
			if(tmpreg[nreg]->rtype == VAULT &&
			   (tmpreg[nreg]->rirreg ||
			    (tmpreg[nreg]->x2 - tmpreg[nreg]->x1 != 1) ||
			    (tmpreg[nreg]->y2 - tmpreg[nreg]->y1 != 1)))
				yyerror("Vaults must be exactly 2x2!");
			if(want_warnings && !tmpreg[nreg]->rirreg &&
			   current_region.x1 > 0 && current_region.y1 > 0 &&
			   current_region.x2 < (int)max_x_map &&
			   current_region.y2 < (int)max_y_map) {
			    /* check for walls in the room */
			    char ebuf[60];
			    register int x, y, nrock = 0;

			    for(y=current_region.y1; y<=current_region.y2; y++)
				for(x=current_region.x1;
				    x<=current_region.x2; x++)
				    if(IS_ROCK(tmpmap[y][x]) ||
				       IS_DOOR(tmpmap[y][x])) nrock++;
			    if(nrock) {
				Sprintf(ebuf,
					"Rock in room (%02d,%02d,%02d,%02d)?!",
					current_region.x1, current_region.y1,
					current_region.x2, current_region.y2);
				yywarning(ebuf);
			    }
			    if (
		!IS_ROCK(tmpmap[current_region.y1-1][current_region.x1-1]) ||
		!IS_ROCK(tmpmap[current_region.y2+1][current_region.x1-1]) ||
		!IS_ROCK(tmpmap[current_region.y1-1][current_region.x2+1]) ||
		!IS_ROCK(tmpmap[current_region.y2+1][current_region.x2+1])) {
				Sprintf(ebuf,
				"NonRock edge in room (%02d,%02d,%02d,%02d)?!",
					current_region.x1, current_region.y1,
					current_region.x2, current_region.y2);
				yywarning(ebuf);
			    }
			} else if(tmpreg[nreg]->rirreg == 1 &&
		!IS_ROOM(tmpmap[current_region.y1][current_region.x1])) {
			    char ebuf[60];
			    Sprintf(ebuf,
				    "Rock in irregular room (%02d,%02d)?!",
				    current_region.x1, current_region.y1);
			    yyerror(ebuf);
			}
			nreg++;
			if (nreg >= MAX_OF_TYPE) {
				yyerror("Too many regions in mazepart!");
				nreg--;
			}
		  ;
    break;}
case 185:
#line 1490 "lev_comp.y"
{
			tmpaltar[naltar] = New(altar);
			tmpaltar[naltar]->x = current_coord.x;
			tmpaltar[naltar]->y = current_coord.y;
			tmpaltar[naltar]->align = yyvsp[-2].i;
			tmpaltar[naltar]->shrine = yyvsp[0].i;
			if (!in_room)
			    check_coord(current_coord.x, current_coord.y,
					"Altar");
			naltar++;
			if (naltar >= MAX_OF_TYPE) {
				yyerror("Too many altars in room or mazepart!");
				naltar--;
			}
		  ;
    break;}
case 186:
#line 1508 "lev_comp.y"
{
			tmpgold[ngold] = New(gold);
			tmpgold[ngold]->x = current_coord.x;
			tmpgold[ngold]->y = current_coord.y;
			tmpgold[ngold]->amount = yyvsp[-2].i;
			if (!in_room)
			    check_coord(current_coord.x, current_coord.y,
					"Gold");
			ngold++;
			if (ngold >= MAX_OF_TYPE) {
				yyerror("Too many golds in room or mazepart!");
				ngold--;
			}
		  ;
    break;}
case 187:
#line 1525 "lev_comp.y"
{
			tmpengraving[nengraving] = New(engraving);
			tmpengraving[nengraving]->x = current_coord.x;
			tmpengraving[nengraving]->y = current_coord.y;
			tmpengraving[nengraving]->engr.str = yyvsp[0].map;
			tmpengraving[nengraving]->etype = yyvsp[-2].i;
			if (!in_room)
			    check_coord(current_coord.x, current_coord.y,
					"Engraving");
			nengraving++;
			if (nengraving >= MAX_OF_TYPE) {
			    yyerror("Too many engravings in room or mazepart!");
			    nengraving--;
			}
		  ;
    break;}
case 189:
#line 1544 "lev_comp.y"
{
			yyval.i = - MAX_REGISTERS - 1;
		  ;
    break;}
case 192:
#line 1552 "lev_comp.y"
{
			yyval.i = - MAX_REGISTERS - 1;
		  ;
    break;}
case 195:
#line 1560 "lev_comp.y"
{
			yyval.map = (char *) 0;
		  ;
    break;}
case 197:
#line 1567 "lev_comp.y"
{
			yyval.map = (char *) 0;
		  ;
    break;}
case 198:
#line 1573 "lev_comp.y"
{
			int token = get_trap_type(yyvsp[0].map);
			if (token == ERR)
				yyerror("Unknown trap type!");
			yyval.i = token;
			Free(yyvsp[0].map);
		  ;
    break;}
case 200:
#line 1584 "lev_comp.y"
{
			int token = get_room_type(yyvsp[0].map);
			if (token == ERR) {
				yywarning("Unknown room type!  Making ordinary room...");
				yyval.i = OROOM;
			} else
				yyval.i = token;
			Free(yyvsp[0].map);
		  ;
    break;}
case 202:
#line 1597 "lev_comp.y"
{
			yyval.i = 0;
		  ;
    break;}
case 203:
#line 1601 "lev_comp.y"
{
			yyval.i = yyvsp[0].i;
		  ;
    break;}
case 204:
#line 1605 "lev_comp.y"
{
			yyval.i = yyvsp[-2].i + (yyvsp[0].i << 1);
		  ;
    break;}
case 205:
#line 1609 "lev_comp.y"
{
			yyval.i = yyvsp[-2].i + (yyvsp[0].i << 1);
		  ;
    break;}
case 208:
#line 1617 "lev_comp.y"
{
			current_coord.x = current_coord.y = -MAX_REGISTERS-1;
		  ;
    break;}
case 215:
#line 1633 "lev_comp.y"
{
			yyval.i = - MAX_REGISTERS - 1;
		  ;
    break;}
case 218:
#line 1643 "lev_comp.y"
{
			if ( yyvsp[-1].i >= MAX_REGISTERS )
				yyerror("Register Index overflow!");
			else
				current_coord.x = current_coord.y = - yyvsp[-1].i - 1;
		  ;
    break;}
case 219:
#line 1652 "lev_comp.y"
{
			if ( yyvsp[-1].i >= MAX_REGISTERS )
				yyerror("Register Index overflow!");
			else
				yyval.i = - yyvsp[-1].i - 1;
		  ;
    break;}
case 220:
#line 1661 "lev_comp.y"
{
			if ( yyvsp[-1].i >= MAX_REGISTERS )
				yyerror("Register Index overflow!");
			else
				yyval.i = - yyvsp[-1].i - 1;
		  ;
    break;}
case 221:
#line 1670 "lev_comp.y"
{
			if ( yyvsp[-1].i >= 3 )
				yyerror("Register Index overflow!");
			else
				yyval.i = - yyvsp[-1].i - 1;
		  ;
    break;}
case 223:
#line 1682 "lev_comp.y"
{
			if (check_monster_char((char) yyvsp[0].i))
				yyval.i = yyvsp[0].i ;
			else {
				yyerror("Unknown monster class!");
				yyval.i = ERR;
			}
		  ;
    break;}
case 224:
#line 1693 "lev_comp.y"
{
			char c = yyvsp[0].i;
			if (check_object_char(c))
				yyval.i = c;
			else {
				yyerror("Unknown char class!");
				yyval.i = ERR;
			}
		  ;
    break;}
case 228:
#line 1712 "lev_comp.y"
{
			yyval.i = 100;	/* default is 100% */
		  ;
    break;}
case 229:
#line 1716 "lev_comp.y"
{
			if (yyvsp[0].i <= 0 || yyvsp[0].i > 100)
			    yyerror("Expected percentile chance.");
			yyval.i = yyvsp[0].i;
		  ;
    break;}
case 232:
#line 1728 "lev_comp.y"
{
			if (!in_room && !init_lev.init_present &&
			    (yyvsp[-3].i < 0 || yyvsp[-3].i > (int)max_x_map ||
			     yyvsp[-1].i < 0 || yyvsp[-1].i > (int)max_y_map))
			    yyerror("Coordinates out of map range!");
			current_coord.x = yyvsp[-3].i;
			current_coord.y = yyvsp[-1].i;
		  ;
    break;}
case 233:
#line 1739 "lev_comp.y"
{
/* This series of if statements is a hack for MSC 5.1.  It seems that its
   tiny little brain cannot compile if these are all one big if statement. */
			if (yyvsp[-7].i < 0 || yyvsp[-7].i > (int)max_x_map)
				yyerror("Region out of map range!");
			else if (yyvsp[-5].i < 0 || yyvsp[-5].i > (int)max_y_map)
				yyerror("Region out of map range!");
			else if (yyvsp[-3].i < 0 || yyvsp[-3].i > (int)max_x_map)
				yyerror("Region out of map range!");
			else if (yyvsp[-1].i < 0 || yyvsp[-1].i > (int)max_y_map)
				yyerror("Region out of map range!");
			current_region.x1 = yyvsp[-7].i;
			current_region.y1 = yyvsp[-5].i;
			current_region.x2 = yyvsp[-3].i;
			current_region.y2 = yyvsp[-1].i;
		  ;
    break;}
}
   /* the action file gets copied in in place of this dollarsign */
#line 487 "bison.simple"

  yyvsp -= yylen;
  yyssp -= yylen;
#ifdef YYLSP_NEEDED
  yylsp -= yylen;
#endif

#if YYDEBUG != 0
  if (yydebug)
    {
      short *ssp1 = yyss - 1;
      fprintf (stderr, "state stack now");
      while (ssp1 != yyssp)
	fprintf (stderr, " %d", *++ssp1);
      fprintf (stderr, "\n");
    }
#endif

  *++yyvsp = yyval;

#ifdef YYLSP_NEEDED
  yylsp++;
  if (yylen == 0)
    {
      yylsp->first_line = yylloc.first_line;
      yylsp->first_column = yylloc.first_column;
      yylsp->last_line = (yylsp-1)->last_line;
      yylsp->last_column = (yylsp-1)->last_column;
      yylsp->text = 0;
    }
  else
    {
      yylsp->last_line = (yylsp+yylen-1)->last_line;
      yylsp->last_column = (yylsp+yylen-1)->last_column;
    }
#endif

  /* Now "shift" the result of the reduction.
     Determine what state that goes to,
     based on the state we popped back to
     and the rule number reduced by.  */

  yyn = yyr1[yyn];

  yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
  if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
    yystate = yytable[yystate];
  else
    yystate = yydefgoto[yyn - YYNTBASE];

  goto yynewstate;

yyerrlab:   /* here on detecting error */

  if (! yyerrstatus)
    /* If not already recovering from an error, report this error.  */
    {
      ++yynerrs;

#ifdef YYERROR_VERBOSE
      yyn = yypact[yystate];

      if (yyn > YYFLAG && yyn < YYLAST)
	{
	  int size = 0;
	  char *msg;
	  int x, count;

	  count = 0;
	  /* Start X at -yyn if nec to avoid negative indexes in yycheck.  */
	  for (x = (yyn < 0 ? -yyn : 0);
	       x < (sizeof(yytname) / sizeof(char *)); x++)
	    if (yycheck[x + yyn] == x)
	      size += strlen(yytname[x]) + 15, count++;
	  msg = (char *) malloc(size + 15);
	  if (msg != 0)
	    {
	      strcpy(msg, "parse error");

	      if (count < 5)
		{
		  count = 0;
		  for (x = (yyn < 0 ? -yyn : 0);
		       x < (sizeof(yytname) / sizeof(char *)); x++)
		    if (yycheck[x + yyn] == x)
		      {
			strcat(msg, count == 0 ? ", expecting `" : " or `");
			strcat(msg, yytname[x]);
			strcat(msg, "'");
			count++;
		      }
		}
	      yyerror(msg);
	      free(msg);
	    }
	  else
	    yyerror ("parse error; also virtual memory exceeded");
	}
      else
#endif /* YYERROR_VERBOSE */
	yyerror("parse error");
    }

  goto yyerrlab1;
yyerrlab1:   /* here on error raised explicitly by an action */

  if (yyerrstatus == 3)
    {
      /* if just tried and failed to reuse lookahead token after an error, discard it.  */

      /* return failure if at end of input */
      if (yychar == YYEOF)
	YYABORT;

#if YYDEBUG != 0
      if (yydebug)
	fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
#endif

      yychar = YYEMPTY;
    }

  /* Else will try to reuse lookahead token
     after shifting the error token.  */

  yyerrstatus = 3;		/* Each real token shifted decrements this */

  goto yyerrhandle;

yyerrdefault:  /* current state does not do anything special for the error token. */

#if 0
  /* This is wrong; only states that explicitly want error tokens
     should shift them.  */
  yyn = yydefact[yystate];  /* If its default is to accept any token, ok.  Otherwise pop it.*/
  if (yyn) goto yydefault;
#endif

yyerrpop:   /* pop the current state because it cannot handle the error token */

  if (yyssp == yyss) YYABORT;
  yyvsp--;
  yystate = *--yyssp;
#ifdef YYLSP_NEEDED
  yylsp--;
#endif

#if YYDEBUG != 0
  if (yydebug)
    {
      short *ssp1 = yyss - 1;
      fprintf (stderr, "Error: state stack now");
      while (ssp1 != yyssp)
	fprintf (stderr, " %d", *++ssp1);
      fprintf (stderr, "\n");
    }
#endif

yyerrhandle:

  yyn = yypact[yystate];
  if (yyn == YYFLAG)
    goto yyerrdefault;

  yyn += YYTERROR;
  if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
    goto yyerrdefault;

  yyn = yytable[yyn];
  if (yyn < 0)
    {
      if (yyn == YYFLAG)
	goto yyerrpop;
      yyn = -yyn;
      goto yyreduce;
    }
  else if (yyn == 0)
    goto yyerrpop;

  if (yyn == YYFINAL)
    YYACCEPT;

#if YYDEBUG != 0
  if (yydebug)
    fprintf(stderr, "Shifting error token, ");
#endif

  *++yyvsp = yylval;
#ifdef YYLSP_NEEDED
  *++yylsp = yylloc;
#endif

  yystate = yyn;
  goto yynewstate;
}
#line 1757 "lev_comp.y"


/*lev_comp.y*/
