#! /bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #! /bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create the files:
#	attrib.h
#	dlgauto.h
#	dlgdef.h
#	trax.h
# This archive created: Fri Mar 23 17:48:53 1990
# By:	CARP Research Group ()
export PATH; PATH=/bin:$PATH
if test -f 'attrib.h'
then
	echo shar: will not over-write existing file "'attrib.h'"
else
cat << \SHAR_EOF > 'attrib.h'
/*
 * a t t r i b . h
 *
 * Define all of the stack setup and manipulation of $i variables.
 *
 *	Notes:
 *
 *		The type 'Attrib' must be defined before entry into this .h file.
 *		OR, the follow default attrib types have been defined for use:
 *
 *	Available Default Attribute Types:
 *
 *			D_Text -- Attributes are Text buffers
 *				Must #def D_Text and #def D_TextSize to max size of
 *				string to be used as attribute.
 *
 *			D_String -- Attributes are String Pointers
 *				Must #def D_String
 *
 *			D_Integer -- Attributes are signed 32-bit integers
 *				Must #def D_Integer
 *
 * ANTLR 1.0B
 * Terence John Parr (c) 1989, 1990
 * Purdue University
 *
 * Enhanced Version				-- July 1989
 * Added $$,$rule,EnterRule		-- Sept 1989
 * Added aDestroy()				-- Nov  1989
 * Make $0 before entering blk	-- Jan  1990
 * Changed aCreate()			-- Feb	1990
 */

/* D e f a u l t  S t a c k  A t t r ' s  D e f i n i t i o n s */
#ifdef D_Text
#ifndef D_TextSize
#define D_TextSize	30
#endif
typedef struct { char text[D_TextSize]; } Attrib;
#define aCreate(a)		strncpy((a)->text, LexText, D_TextSize-1);
#endif

#ifdef D_String
typedef char *Attrib;
#define aCreate(a)
#endif

#ifdef D_Integer
typedef long Attrib;
#define aCreate(a)		*(a) = atoi(LexText);
#endif

/*
 * The following error message is repeated often and therefore only one
 * copy is made to save space.  Here, we actually allocate space which
 * I don't like to do in an include file (ick).
 */
static char argStackOvfMsg[]="Antlr Attribute Stack OverFlow %s(%d)!\n";

/*
 * A t t r i b u t e  C o n v e r s i o n
 *
 * The user must specify the type of and how to create ANTLR attributes.
 *
 * The type is always specified with 'Attrib'.
 *
 * The attributes that are associated with TERMINAL elements of rule
 * definitions ($i variables) must be a function of LexText and Token
 * (filled by dlg).  The user must define a function or macro that
 * has the following format:
 *
 *		aCreate(attr)
 *		Attrib *attr;
 *		{
 *			*attr = attribute for LexText/Token;
 *		}
 *
 * aCreate() is called from lex() with 'aCreate(&(aStack[_asp]))'.
 *
 * aCreate() can also be a macro.
 */

#ifndef DESTROY
#define Restore(t)		_asp=(t);
#else
#define Restore(t)		WipeOut(t);
#endif

#define WipeOut(t)		for (; _asp<(t); _asp++) { aDestroy(&(aStack[_asp])); }
			
#define RULEvars		Attrib *aRetPtr
#define BLKvars         int _tasp
#define sMARK           _tasp=_asp			/* Save state of stack */
#define sREL            Restore(_tasp)		/* Return state of stack */

#define EnterRule		aRetPtr = (&(aArg(0)));
#define EnterBLK		sMARK;
#define ExitBLK			sREL;
#define Make0			aOvfChk; --_asp;
#define aOvfChk															\
            if ( _asp == 0 )                                            \
            {                                                           \
                fprintf(stderr, argStackOvfMsg, __FILE__, __LINE__);    \
                exit(-1);                                               \
            }
#define aPush(v)														\
			aOvfChk; aStack[--_asp] = v;

/* R u l e  T e r m i n a t i o n */
#define SUCCESS {sREL; return(1);}				/* Leave $0 & Return */
#define FAILURE {Restore(_tasp+1); return(0);}	/* Kill $0 & Return */

/*
 * A r g u m e n t  A c c e s s
 *
 * $i is converted to 'aStack[_tasp-i]'
 * $0 is return value of current block (sometimes $0 is the return of rule)
 * $$, $r, $rule are always the return value of the current RULE!
 */
#define aRet				(*aRetPtr)
#define aArg(n)             aStack[_tasp-n]

/*
 * This Munches the current input token by pushing it on the stack
 * and getting the next token from the input stream.
 * --_asp is out in front because aCreate() could be a macro.
 */
#define Munch   	MakeAttr; GetToken();
#define MakeAttr	aOvfChk; --_asp; aCreate(&(aStack[_asp]));

/* S t a n d a r d  B e f o r e / A f t e r  S t a r t  R u l e  M a c r o s */
#define enterANTLR(f)					\
    SetLexInputStream( f );             \
    advance();                          \
    GetToken();                         \

#define exitANTLR		sREL;

#define ANTLRi(start, a, f)				\
    {	BLKvars;						\
		sMARK;							\
		enterANTLR(f);					\
    	aPush(a);						\
		start();                        \
		exitANTLR;						\
	}

#define ANTLR(start, f)					\
    {	BLKvars;						\
		sMARK;							\
		enterANTLR(f);					\
		Make0;							\
		start();                        \
		exitANTLR;						\
	}

/* E x t e r n  S t a c k  D e f s */
extern int  _asp;
extern Attrib aStack[];
extern char *aSourceFile;

#ifdef D_aTrax
#define aTrax(f,t) fprintf(stderr, "%s(%s)\n", f, t);
#endif
SHAR_EOF
fi # end of overwriting check
if test -f 'dlgauto.h'
then
	echo shar: will not over-write existing file "'dlgauto.h'"
else
cat << \SHAR_EOF > 'dlgauto.h'

static int nextpos;

int cur_char;
static int cur_class;
static char ebuf[70];

#define _GETC \
	while ((cur_class = (((cur_char = getc(inputStream)) == EOF) ? \
	       _SHIFT(LEX_EOF) : _SHIFT(cur_char))) == NumAtoms) { \
		sprintf(ebuf,"illegal character ('%c') ignored", cur_char); \
		lex_err( ebuf ); \
	}

/*
 * Same as _GETC, but don't do illegal char check and return the character
 */
int nextChar() 
{
	(cur_class = (((cur_char = getc(inputStream)) == EOF) ?
	 _SHIFT(LEX_EOF) : _SHIFT(cur_char)));
	return cur_char;
}

SetLexInputStream( f )
FILE *f;
{
	inputStream = f;
	lex_line = 1;
}

CloseLexInputStream()
{
	fclose( inputStream );
}

LexSkip()
{
	lex_mode = 1;
}

LexMore()
{
	lex_mode = 2;
}

GetToken()
{
	register int state, newstate;
	int temp;

lex_skip:
	nextpos = 0;
lex_more:
	state = 0;
	while ((newstate = dfa[state][_SHIFT(cur_char)]) != DfaStates) {
		state = newstate;
		/* Truncate matching buffer to size (not an error) */
		if (nextpos < LEX_BUF-1) LexText[nextpos++] = cur_char;
		_GETC;
	}
	if ( state != 0 )
	{
		LexText[nextpos] = '\0';
	}
	else
	{
		LexText[nextpos] = cur_char;
		LexText[nextpos+1] = '\0';
	}

	lex_mode = 0;
	temp = (*actions[accepts[state]])();
	switch (lex_mode) {
		case 1: goto lex_skip;
		case 2: goto lex_more;
	}
	return(temp);
}

advance()
{
	_GETC;
}



lex_err(s)
char *s;
{
        fprintf(stderr,
                "%s near line %d (Token was '%s')\n",
                ((s == NULL) ? "Lexical error" : s),
                lex_line,
				LexText);
}
SHAR_EOF
fi # end of overwriting check
if test -f 'dlgdef.h'
then
	echo shar: will not over-write existing file "'dlgdef.h'"
else
cat << \SHAR_EOF > 'dlgdef.h'
extern char	LexText[];  		/* Lexical match buffer */
extern int	lex_line;
extern int	Token;
extern int	cur_char;
SHAR_EOF
fi # end of overwriting check
if test -f 'trax.h'
then
	echo shar: will not over-write existing file "'trax.h'"
else
cat << \SHAR_EOF > 'trax.h'
/* Trax.h -- Trace Allocation functions */

#ifndef NULL
#define NULL	0
#endif

typedef struct _trax {
			int size, line, code;
			char *file;
			unsigned long mword;
			struct _trax *prev, *next;
		} Trax;

#define ValidBuf		((unsigned long) 0x12345678)
#define MagicWd1		((char) 0x12)
#define MagicWd2		((char) 0x34)
#define odd(addr)		(((unsigned)(addr)) & 1)
/*
#define alignUP(p)		((p)+odd(p))
#define alignDN(p)		((p)-odd(p))
*/
#define mInfo(p)		((Trax *) (((char *)(p))-sizeof(Trax)))
#define magic1(p)		( *(((char *)(p)) + sizeof(Trax) + msize(p)) )
#define magic2(p)		( *(((char *)(p)) + sizeof(Trax) + msize(p) + 1) )
#define corrupt(p)		(magic1(p) != MagicWd1 && magic2(p) != MagicWd1)
#define valid(p)		(mInfo(p)->mword == ValidBuf)
#define msize(p)		(mInfo(p)->size)

#define malloc(n)		mMalloc(n, 0, __FILE__, __LINE__)
#define realloc(p, n)	mRealloc(p, n, __FILE__, __LINE__)
#define mallocx(n,t)	mMalloc(n, t, __FILE__, __LINE__)
#define calloc(n,s)		mCalloc(n, s, 0, __FILE__, __LINE__)
#define callocx(n,s,t)	mCalloc(n, s, t, __FILE__, __LINE__)
#define free(p)			mFree(p, __FILE__, __LINE__)

char	*mMalloc(),
		*mCalloc(),
		*mRealloc();
unsigned	mMax, mCur, mTotal;

SHAR_EOF
fi # end of overwriting check
#	End of shell archive
exit 0
