/*
 * error.c
 *
 *  Scott Adkins
 *    sadkins@bigbird.cs.ohiou.edu
 *    sadkins@oucsace.cs.ohiou.edu
 *
 *  Purpose: Prints error messages for the program.
 *
 */

#include "corewar.h"


int PrintError(error, line, buffer)
int error;
int line;
char *buffer;
{
	if (error == 1) printf("-- Duplicate label found.\n");
	if (error == 2) printf("-- Invalid label or instruction.\n");
	if (error == 3) printf("-- Invalid instruction.\n");
	if (error == 4)	printf("-- Invalid mode in A-field.\n");
	if (error == 5) printf("-- Invalid mode in B-field.\n");
	if (error == 6) printf("-- Immediate mode is illegal in A-field.\n");
	if (error == 7) printf("-- Immediate mode is illegal in B-field.\n");
	if (error == 8) printf("-- Direct mode is illegal in A-field.\n");
	if (error == 9) printf("-- Direct mode is illegal in B-field.\n");
	if (error == 10) printf("-- Indirect mode is illegal in A-field.\n");
	if (error == 11) printf("-- Indirect mode is illegal in B-field.\n");
	if (error == 12) printf("-- Missing B-field, may need a comma.\n");

	if (error >= 0) printf("-- Line %d: \"%s\"\n",line,buffer);

	return (0);
}

int CleanUp(error, fp, labels)
int error;
FILE *fp;
LABEL **labels;
{
	FreeLabels(labels);
	fclose(fp);

	return (error);
}
