shithub: scc

ref: 169c191fd3a86d22ae6847311dcd82a6483a4aa9
dir: /cc2/main.c/

View raw version

#include <stdarg.h>
#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>

#include "../inc/cc.h"

#include "cc2.h"
#include "error.h"

char odebug;

void
error(unsigned nerror, ...)
{
	va_list va;
	va_start(va, nerror);
	if (nerror >= ENUMERR)
		fprintf(stderr, "incorrect error number '%d'", nerror);
	else
		vfprintf(stderr, errlist[nerror], va);
	va_end(va);
	putc('\n', stderr);
	exit(EXIT_FAILURE);
}

int
main(void)
{
	Symbol *fun;

	while (!feof(stdin) && (fun = parse())) {
		apply(fun->u.f.body, optimize);
		apply(fun->u.f.body, genaddable);
		generate(fun);
		writeout();
	}
}