-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprint_error.h
73 lines (64 loc) · 2.34 KB
/
print_error.h
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*********************************FILE__HEADER*********************************\
*
* File: print_error.h
* Author: Daniel Brodsky & Lior Katav
* Date: August-2023
* Description: This header file includes definitions of various enums used for
* identifying types of errors in our compiler. It also
* declares several functions used to print error messages based on these error types.
\******************************************************************************/
#ifndef MAMAN14_PRINT_ERROR_H
#define MAMAN14_PRINT_ERROR_H
/**
* An enum of types of errors that can occur with labels in assembly code.
*/
typedef enum {
LABEL_LENGTH_EXCEEDS_LIMIT = 0,
LABEL_IS_RESERVED_COMMAND_WORD,
LABEL_IS_RESERVED_INSTRUCTION_WORD,
LABEL_IS_RESERVED_REGISTER_WORD,
INVALID_LABEL_FORMAT,
LABEL_MUST_START_WITH_LETTER,
DUPLICATE_LABEL,
LABEL_DOES_NOT_EXIST,
ENTRY_REQUIRES_EXISTING_LABEL,
EXTERN_REQUIRES_NONEXISTING_LABEL
} LabelErrorType;
/**
* An enum of types of errors that can occur with command and instruction
* parsing and validation in assembly code.
*/
typedef enum {
INCORRECT_NUM_OF_PARAMS_FOR_COMMAND = 0,
TOO_MANY_PARAMS_FOR_COMMAND,
INVALID_PARAM_FOR_COMMAND,
INCORRECT_NUM_OF_PARAMS_FOR_INSTRUCTION,
NOT_VALID_COMMAND_OR_INSTRUCTION
} CommandInstructionErrorType;
/**
* An enum of types of errors that can occur with comma usage in assembly code.
*/
typedef enum {
ILLEGAL_COMMA = 0,
MISSING_COMMA,
MULTIPLE_CONSECUTIVE_COMMAS,
EXTRA_COMMA_END_OF_LINE
} CommaErrorType;
/**
* Function to print an error message based on a given CommaErrorType.
*/
void PrintCommaErrorMessage(int lineNumber, CommaErrorType errorMessageId,
char character);
/**
* Function to print an error message based on a given LabelErrorType.
*/
void PrintLabelErrorMessage(int lineNumber, LabelErrorType errorMessageId,
char *labelName);
/**
* Function to print an error message based on a given CommandInstructionErrorType.
*/
void PrintCommandInstructionErrorMessage(int lineNumber,
CommandInstructionErrorType errorMessageId,
char *commandOrInstructionName,
char *additionalParam);
#endif