summaryrefslogtreecommitdiff
path: root/tools/spasm/error.c
blob: 019c3dab09d3308824958aa8d1be0ed222fde016 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include "spasm.h"

static void show_line(void)
{
	printf("%s\n", curLine);
	printf("^^^^^^^^^^^^^^\n");
}
	
void instruction_error(char *format, ...)
{
	va_list ap;
	
	va_start(ap, format);
	
	printf("Line %d: Error(%s) - ", line_number, curIns);
	vprintf(format, ap);
	printf("\n");
	show_line();

	va_end(ap);
	
	exit(EXIT_FAILURE);
}

void instruction_warning(char *format, ...)
{
	if(curPass <= 0)
		return;
	
	va_list ap;
	
	va_start(ap, format);
	
	printf("Line %d: Warning (%s) - ", line_number, curIns);
	vprintf(format, ap);
	printf("\n");
	show_line();
	
	va_end(ap);
}

void assembler_error(char *format, ...)
{
	va_list ap;
	
	va_start(ap, format);

	printf("Line %d, assembler error: ", line_number);
	vprintf(format, ap);
	printf("\n");
	show_line();
	
	va_end(ap);
	
	exit(EXIT_FAILURE);
}