-
Notifications
You must be signed in to change notification settings - Fork 0
/
data.c
51 lines (49 loc) · 1.38 KB
/
data.c
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
#include "data.h"
#include <stdio.h>
/*
* print status code.
*/
void printStatus(int status)
{
switch (status)
{
case ERROR_COULD_NOT_ALLOCATE:
fprintf(stderr, "Error: Could not allocate.\n");
break;
case ERROR_EXPECTED_MORE_ARGUMENTS:
fprintf(stderr, "Error: Expected more arguments.\n");
break;
case ERROR_EXPECTED_LESS_ARGUMENTS:
fprintf(stderr, "Error: Expected less arguments.\n");
break;
case ERROR_NOT_AN_INTEGER:
fprintf(stderr, "Error: Not an integer\n");
break;
case ERROR_NOT_A_STRING:
fprintf(stderr, "Error: Expected a string.\n");
break;
case ERROR_LABEL_DEFINED:
fprintf(stderr, "Error: Label already defined.\n");
break;
case ERROR_INSTRUCTION_DOES_NOT_EXIST:
fprintf(stderr, "Error: Instruction does not exist.\n");
break;
case ERROR_NOT_A_PARAMETER:
fprintf(stderr, "Error: Parameter is invalid.\n");
break;
case ERROR_INVALID_ADDRESSING_METHOD:
fprintf(stderr, "Error: Invalid addressing method for this instruction.\n");
break;
case ERROR_LABEL_DOES_NOT_EXIST:
fprintf(stderr, "Error: Label does not exist.\n");
break;
}
}
/*
* print line and status code.
*/
void printLineStatus(int line, int status)
{
fprintf(stderr, "Line %d, ", line);
printStatus(status);
}