forked from justinmeza/lci
-
Notifications
You must be signed in to change notification settings - Fork 0
/
error.h
111 lines (102 loc) · 2.67 KB
/
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
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
/**
* Error type definitions.
*
* \file error.h
*
* \author Justin J. Meza
*
* \date 2012
*/
#ifndef __ERROR_H__
#define __ERROR_H__
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
/**
* Represents an error type. The error types are organized based on which
* module they occur in:
*
* - MN_* for the main body,
* - LX_* for the lexer,
* - TK_* for the tokenizer,
* - PR_* for the parser,
* - IN_* for the interpreter
*
* \note Remember to update the error message and error code arrays (in the
* error C file) with the appropriate error message and code.
*/
typedef enum {
MN_ERROR_OPENING_FILE,
MN_ERROR_CLOSING_FILE,
LX_LINE_CONTINUATION,
LX_MULTIPLE_LINE_COMMENT,
LX_EXPECTED_TOKEN_DELIMITER,
TK_EXPECTED_FLOATING_POINT,
TK_EXPECTED_INTEGER,
TK_UNKNOWN_TOKEN,
PR_UNKNOWN_IDENTIFIER_TYPE,
PR_UNKNOWN_STATEMENT_TYPE,
PR_UNKNOWN_EXPRESSION_TYPE,
PR_EXPECTED_BOOLEAN,
PR_EXPECTED_INTEGER,
PR_EXPECTED_FLOAT,
PR_EXPECTED_STRING,
PR_EXPECTED_CONSTANT,
PR_EXPECTED_TYPE,
PR_EXPECTED_IDENTIFIER,
PR_EXPECTED_TOKEN,
PR_INVALID_OPERATOR,
PR_EXPECTED_EXPRESSION,
PR_EXPECTED_END_OF_EXPRESSION,
PR_EXPECTED_END_OF_STATEMENT,
PR_CANNOT_USE_STR_AS_LITERAL,
PR_LITERAL_MUST_BE_UNIQUE,
PR_EXPECTED_LOOP_NAME,
PR_EXPECTED_EITHER_TOKEN,
PR_EXPECTED_UNARY_FUNCTION,
PR_EXPECTED_MATCHING_LOOP_NAME,
PR_EXPECTED_STATEMENT,
PR_UNHANDLED_STRING,
IN_INVALID_IDENTIFIER_TYPE,
IN_UNABLE_TO_STORE_VARIABLE,
IN_VARIABLE_DOES_NOT_EXIST,
IN_CANNOT_IMPLICITLY_CAST_NIL,
IN_CANNOT_CAST_FUNCTION_TO_BOOLEAN,
IN_CANNOT_CAST_ARRAY_TO_BOOLEAN,
IN_UNKNOWN_VALUE_DURING_BOOLEAN_CAST,
IN_UNABLE_TO_CAST_VALUE,
IN_EXPECTED_INTEGER_VALUE,
IN_CANNOT_CAST_FUNCTION_TO_INTEGER,
IN_CANNOT_CAST_ARRAY_TO_INTEGER,
IN_UNKNOWN_VALUE_DURING_INTEGER_CAST,
IN_EXPECTED_DECIMAL,
IN_CANNOT_CAST_FUNCTION_TO_DECIMAL,
IN_CANNOT_CAST_ARRAY_TO_DECIMAL,
IN_UNKNOWN_VALUE_DURING_DECIMAL_CAST,
IN_CANNOT_CAST_BOOLEAN_TO_STRING,
IN_EXPECTED_CLOSING_PAREN,
IN_INVALID_HEX_NUMBER,
IN_CODE_POINT_MUST_BE_POSITIVE,
IN_EXPECTED_CLOSING_SQUARE_BRACKET,
IN_EXPECTED_CLOSING_CURLY_BRACE,
IN_VARIABLE_NOT_AN_ARRAY,
IN_CANNOT_CAST_FUNCTION_TO_STRING,
IN_CANNOT_CAST_ARRAY_TO_STRING,
IN_UNKNOWN_VALUE_DURING_STRING_CAST,
IN_UNKNOWN_CAST_TYPE,
IN_UNDEFINED_FUNCTION,
IN_INCORRECT_NUMBER_OF_ARGUMENTS,
IN_INVALID_RETURN_TYPE,
IN_UNKNOWN_CONSTANT_TYPE,
IN_DIVISION_BY_ZERO,
IN_INVALID_OPERAND_TYPE,
IN_INVALID_BOOLEAN_OPERATION_TYPE,
IN_INVALID_EQUALITY_OPERATION_TYPE,
IN_REDEFINITION_OF_VARIABLE,
IN_INVALID_DECLARATION_TYPE,
IN_INVALID_TYPE,
IN_FUNCTION_NAME_USED_BY_VARIABLE,
IN_CANNOT_CAST_VALUE_TO_ARRAY,
} ErrorType;
void error(ErrorType, ...);
#endif /* __ERROR_H__ */