-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherrors_handler.h
More file actions
113 lines (97 loc) · 6.12 KB
/
errors_handler.h
File metadata and controls
113 lines (97 loc) · 6.12 KB
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#ifndef ERRORS_HANDLER_H
#define ERRORS_HANDLER_H
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
/**
* @brief Prints an external error message.
*
* Prints to stdout only errors in the source file
* Prints the name of the file the error and the line number
* @param error_msg error message
* @param file pointer to the source file name and line number
* in case the line is irrelevant will be printed -1
*/
void error_log(char *file_name, int line, char *error_msg);
#define ERROR_STRUCT "--ERROR--: In file %s at line: %d\n The error is: %s\n"
/* Preprocessor errors */
#define LONG_LINE "Line is too long, more than 80 characters\n"
#define MACRO_MULTI_DEF "Multi definitions for the same MACRO\n"
#define ILLEGAL_MACRO_NAME "Macro name can not be instruction, directive, register " \
"or char different than letters, digits and underscore\n"
#define MACRO_NAME_AS_LABEL "MACRO name is the same as exising label name"
#define MACROEND_WITHOUT_START "mcroend without mcro start\n"
#define MACRO_WITHOUT_NAME "MCRO name is missing\n"
#define EXTRA_TEXT_AFTER_MCRO_START "Extra text after macro name\n"
#define EXTRA_TEXT_AFTER_MCROEND "Extra text after macro end\n"
#define FAIL_EXTRACT_MACROS "Fail to extract macros from as file\n"
#define FAIL_TO_SWITCH_MCRO_NAME "Fail to switch mcro name by it's content\n"
/* Internal errors */
#define INTERNAL "internal"
#define FILE_NOT_OPEN_READING "Can not open file for reading\n"
#define FILE_NOT_OPEN_WRITING "Can not open file for writing\n"
#define MEMORY_FAIL "Fail to allocate memory\n"
#define FAIL_CLEAN_FILE "Can not create clean file with no spaces, empty line or note line\n"
#define FAIL_TO_SET_POSITION_IN_FILE "Failed to set file position\n"
/* First Pass and Second Pass Errors */
#define IMM_LADDER "Immediate value must start with an #\n"
#define IMM_NUM_AFTER_LADDER "Immediate value must have num after #\n"
#define NOT_DIGIT "Char is not digit\n"
#define NOT_LETTER "Char is not letter\n"
#define NOT_DIGIT_LETTER "Char is not digit or letter\n"
#define MISSING_LABEL_NAME "Missing Label name\n"
#define LONG_LABEL "Label is too long \n"
#define LABEL_STARTS_WITH_LETTER "Label must starts with letter\n"
#define LABEL_LETTER_DIGIT "Label must contain only digits or letters \n"
#define MISSING_INSTRUCTION_ARG "Missing argument for instruction\n"
#define EMPTY_STRING_DIR "String directive can not be empty\n"
#define MANY_OP "Too many operands\n"
#define IMM_NOT_VALID_ARG_DEST_MOV "Immediate is not valid argument for dest in mov instruction\n"
#define IMM_NOT_VALID_ARG_DEST_ADD_SUB "Immediate is not valid argument for dest in add and sub instructions\n"
#define IMM_NOT_VALID_ARG_SRC_LEA "Immediate is not valid argument for source in lea instruction\n"
#define IMM_NOT_VALID_ARG_DEST_LEA "Immediate is not valid argument for dest in lea instruction\n"
#define IMM_NOT_VALID_ARG_DEST_REST_OP "Immediate is not valid argument for dest in clr,not"\
" inc, dec,jmp,bne,jsr and red instructions\n"
#define INVALID_SOURCE_ADDRESSING_MODE "Invalid source operand addressing mode for this instruction\n"
#define INVALID_DEST_ADDRESSING_MODE "Invalid destination operand addressing mode for this instruction\n"
#define INVALID_MATRIX_FORMAT_FIRST_BRACKET "Invalid matrix format - missing first bracket\n"
#define INVALID_MATRIX_FORMAT_FIRST_CLOSING "Invalid matrix format - missing first closing bracket\n"
#define INVALID_MATRIX_FORMAT_SECOND_BRACKET "Invalid matrix format - missing second bracket\n"
#define INVALID_MATRIX_FORMAT_SECOND_CLOSING "Invalid matrix format - missing second closing bracket\n"
#define MATRIX_INVALID_WHITESPACE "Invalid whitespace between matrix register brackets [] []\n"
#define INVALID_MATRIX_FIRST_REGISTER "Invalid register name in matrix first index\n"
#define INVALID_MATRIX_SECOND_REGISTER "Invalid register name in matrix second index\n"
#define INVALID_OPCODE "Invalid opcode name\n"
#define ILLEGAL_DIRECTIVE "Illegal directive name\n"
#define INVALID_LABEL_NAME "Invalid label name\n"
#define EMPTY_AFTER_LABEL "No continue after label name\n"
#define FAIL_CONVERT_STRING_TO_NUM "Can not convert string to num\n"
#define DUPLICATE_LABEL "Label is already defined\n"
#define FAILED_ADD_INSTRUCTION_LABEL "Failed to add instruction label\n"
#define FAILED_ADD_DATA_LABEL "Failed to add data label\n"
#define ILLEGAL_EXTERN_LABEL "Label cannot be defined for .extern\n"
#define INVALID_OPERANDS_COUNT "Num of operands does not match instruction name\n"
#define EXTERN_SYNTAX_ERROR "Invalid .extern syntax\n"
#define DUPLICATE_EXTERN "Duplicate .extern definition\n"
#define INVALID_MATRIX_DIMENSIONS "Invalid matrix dimensions in .mat directive\n"
#define MATRIX_VALUE_COUNT_MISMATCH "Number of matrix values does not match dimensions\n"
#define DATA_IMAGE_OVERFLOW "Data image overflow – too much .data/.string/.mat content\n"
#define CODE_IMAGE_OVERFLOW "Code image overflow – exceeded MAX_CODE_SIZE\n"
#define EXTRANEOUS_TEXT_AFTER_COMMAND "Extra text after end of command\n"
#define INVALID_STRING ".string label values contain invalid char\n"
#define REGISTER_NAME_AS_LABEL "Register name cannot be used as label\n"
#define SAVED_WORD_AS_LABEL "Assemble saved word cannot be used as label name\n"
#define STRING_MISSING_QUOTES "String must be enclosed in quotation marks\n"
#define MISSING_OPERAND_EXTERN "Missing operand for .extern directive\n"
#define MISSING_OPERANDS_DATA "Missing operands for .data directive\n"
#define MATRIX_DIMENSION_FORMAT "[n][m] format is required for .mat dimensions\n"
#define MULTIPLE_COMMAS "It's illegal to have multiple consecutive commas\n"
#define COMMA_END_OF_LINE "Unnecessary comma in the end of the line\n"
#define TOTAL_MEMORY_OVERFLOW "Total memory exceeded: IC + DC > 255\n"
#define IMMEDIATE_OUT_OF_RANGE "Immediate value out of range (-512 to +511)\n"
#define ENTRY_LABEL_NO_DEF "Entry label was not defined\n"
#define SAME_NAME_ENTRY_AND_EXTERNAL_LABEL "Same label is external and entry\n"
#define WORD_NOT_IN_ADDRESS "Could not find word at address \n"
#define UNDEFINED_LABEL "Label is not defined\n"
#endif