# include "macdefs"
# include "manifest"

/*
 *	storage classes
 */
# define SNULL		0
# define AUTO		1
# define EXTERN		2
# define STATIC		3
# define REGISTER	4
# define EXTDEF		5
# define LABEL		6
# define ULABEL		7
# define MOS		8
# define PARAM		9
# define STNAME		10
# define MOU		11
# define UNAME		12
# define TYPEDEF	13
# define FORTRAN	14
# define ENAME		15
# define MOE		16
# define UFORTRAN	17
# define USTATIC	18
/*
 * field size is ORed in
 */
# define FIELD		0100
# define FLDSIZ		077
extern char *scnames();

/*
 *	location counters
 */
# define PROG		0
# define DATA		1
# define ADATA		2
# define STRNG		3
# define ISTRNG		4
# define STAB		5

/*
 * symbol table flags
 */
# define SMOS		01
# define SHIDDEN	02
# define SHIDES		04
# define SSET		010
# define SREF		020

# ifndef FIXDEF
# define FIXDEF(p)
#endif

/*
 * alignment of initialized quantities
 */
# ifndef AL_INIT
#	define	AL_INIT ALINT
# endif

struct symtab {
	char	sname[NCHNAM+1];
	TWORD	stype;		/* type word */
	char	sclass;		/* storage class */
	char	slevel;		/* scope level */
	char	sflags;		/* flags for set, use, hidden, mos, etc. */
	int	offset;		/* offset or value */
	short	dimoff;		/* offset into the dimension table */
	short	sizoff;		/* offset into the size table */
	short	suse;		/* line number of last use of the variable */
};


# ifdef ONEPASS
/*
 * NOPREF must be defined for use in first pass tree machine
 */
# define NOPREF	020000		/* no preference for register assignment */
#else

union ndu {
	struct {
		int	op;
		TWORD	type;
		int	cdim,
			csiz;
		NODE	*left,
			*right;
	};
	
	/*
	 * this structure is the same as above,
	 *  but is used when a value, rather than
	 *  address, is kept in +left
	 *
	 * Changed for /6 compiler, by adding member sym_x ---
	 *	reason was we need to know symbol table index after
	 *	it's been changed to a label number (for statics).
	 * Also used to indicate whether constants stored in node's
	 * lval is byte offset or word offset.
	 */
	struct {
		int	op;
		TWORD	type;
		int	cdim,
			csiz;
		CONSZ	lval;
		int	rval;
		int	sym_x;	/* added so we know old rval for statics */
	};
	
	/*
	 * this structure is used when a floating point constant
	 *  is being computed
	 */
	struct {
		int	op;
		TWORD	type;
		int	cdim,
			csiz;
		double	dval;
	};

};
# endif

/*
 * Table entry used to build switch statements
 */
struct sw {
	CONSZ	sval;
	int	slab;
};

extern struct sw	swtab[],
			*swp;
extern int		swx;

extern int		blevel,
			ftnno,
			instruct,
			lineno,
			nerrors,
			stwart;

/*
 * YACC interface to the parse stack
 */
typedef union {
	int	intval;
	NODE	*nodep;
} YYSTYPE;
#if vulcan
YYSTYPE	yylval;
#else
extern YYSTYPE	yylval;
#endif

extern CONSZ	lastcon;
extern double	dcon;

extern char	ftitle[];
extern struct symtab stab[];
extern int	curftn,
		curclass,
		curdim,
		dimtab[],
		paramstk[],
		paramno,
		autooff,
		argoff,
		strucoff,
		regvar,
		minrvar,
		strflg,
		reached,
		brkflag;
extern char	yytext[];

extern OFFSZ	inoff;

/*
 *	tunnel to buildtree for name id's
 */
extern int	idname;

#if vulcan
NODE	node[TREESZ];
extern NODE	*lastfree;
#else
extern NODE	node[],
		*lastfree;
#endif

extern int	cflag,
		hflag,
		pflag;

/*
 * various labels
 */
extern int	brklab,
		contlab,
		flostat,
		retlab,
		retstat,
		asavbc[],
		*psavbc;

/*
 *	flags used in structures/unions
 */
# define SEENAME	01
# define INSTRUCT	02
# define INUNION	04
# define FUNNYNAME	010

/*
 *	flags used in the (elementary) flow analysis ...
 */
# define FBRK	02
# define FCONT	04
# define FDEF	010
# define FLOOP	020

/*
 *	flags used for return status
 */
# define RETVAL		1
# define NRETVAL	2

/*
 *	used to mark a constant with no name field
 */
# define NONAME	040000

/*
 * mark an offset which is undefined
 */
# define NOOFFSET (-10201)

/*
 *	declarations of various functions
 */
extern NODE
	*buildtree(),
	*bdty(),
	*mkty(),
	*rstruct(),
	*dclstruct(),
	*getstr(),
	*tymerge(),
	*stref(),
	*offcon(),
	*bcon(),
	*bpsize(),
	*convert(),
	*pconvert(),
	*oconvert(),
	*ptmatch(),
	*tymatch(),
	*makety(),
	*block(),
	*doszof(),
	*talloc(),
	*optim(),
	*strargs(),
	*clocal();

OFFSZ	tsize(),
	psize();

TWORD	types();


double atof();

char	*exname(),
	*exdcon();

# define checkst(x)

# ifndef CHARCAST
/*
 * to make character constants into character connstants
 * this is a macro to defend against cross-compilers, etc.
 */
# define CHARCAST(x) (char)(x)
# endif

