/************************************************************************/
/*                                                                      */
/* Copyright (c) 1988 -                                                 */
/*     The Rector and Visitors of the University of Virginia            */
/*                                                                      */
/* This code may not be distributed further without permission          */
/*      from the University of Virginia.                                */
/* This code is distributed WITHOUT ANY WARRANTY.  No claims are        */
/*      made as to whether it serves any particular purpose or even     */
/*      works at all.                                                   */
/*                                                                      */
/************************************************************************/

#include <stdio.h>
#include "types.h"
#include "scan.h"
#include "stopset.h"
#include "error.h"

extern void exit();
extern char *optarg;
extern int optind, opterr;

int
	opeep = 1,
	opt_g = 0,
	opt_p = 0,
	opt_s = 0,
	opt_t = 0,
	opt_w = 0
;


/*
 * main() parses command line arguments, passes the source file name
 * to the scanner, calls the compiler initialization function, and
 * calls the parser.
 */

main(argc, argv)
	int argc; char **argv;
{
	int c, errflag=0;
	STOPBUF stop;

	while ((c = getopt(argc, argv, "Ngpstw")) != -1) {
		switch(c) {
		case 'N':
			opeep = 0;
			break;
		case 'g':
			opt_g = 1;
			break;
		case 'p':
			opt_p = 1;
			break;
		case 's':
			opt_s = 1;
			break;
		case 't':
			opt_t = 1;
			break;
		case 'w':
			opt_w = 1;
			break;
		case '?':
			errflag++;
			break;
		}
	}
	if (errflag || optind != argc-1) {
		fprintf(stderr, "Usage: pcomp [ -Ngpstw ] file\n");
		exit(1);
	}
	src_set(argv[optind]);
	p_init();
	set_or(stop, set_cons(SY_ENDFILE, 0), S0);
	p_program(stop);
	exit(err_fatal ? 1 : 0);
	/* NOTREACHED */
}
