/* main.c */
#include "codegen.h"
#include "diagnostics.h"
#include "driver.h"
#include "error.h"
#include "parse.h"
#include "vars.h"

int main()
{
	/* Compiler begins execution here */
	staticptr	= startstatic;	/* clear global symbols */
	autoptr		= startauto;	/* clear local symbols */
	wsptr		= ws;		/* clear while stack */
	macptr		=		/* clear the macro pool */
	litptr		=		/* clear literal pool */
  	Msp		=		/* stack ptr (maximum) */
  	Csp		=		/* stack ptr (relative) */
	errcnt		=		/* no errors */
	errstop		= 		/* keep going after an error */
	eof_flg		=		/* not eof yet */
	ncmp		=		/* no open compound states */
	lastst		=		/* no last statement yet */
	mainflg		=		/* not first file to asm */
	fnstart		=		/* current "function" started at line 0 */
	lineno		=		/* no lines read from file */
	infunc		=		/* not in function now */
	quote[1]	= 0;		/*  ...all set to zero.... */
	quote[0]	='"';		/* fake a quote literal */
	currfn		= NULL;		/* no function yet */
	cmode		= 1;		/* enable preprocessing */
	fp_input	=		/* no input file */
	fp_input2	=		/* or include file */
	fp_output	= 		/* no open units */
	saveout		= 0;		/* no diverted output */

	/* Compiler body */
	ask();				/* get user options */
	openout();			/* get an output file */
	openin();			/* and initial input file */
	header();			/* write intro code */
	parse();			/* process ALL input */
	dumpstatics();			/* and all static memory */
	trailer();			/* follow-up code */
	closeout();			/* close the output (if any) */
	errorsummary();			/* summarize errors */
}