-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherrType.hpp
104 lines (98 loc) · 2.95 KB
/
errType.hpp
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
#ifndef TEENC_TYPE_ERROR_REPORTING_HH
#define TEENC_TYPE_ERROR_REPORTING_HH
#include "err.hpp"
namespace lake{
class TypeErr {
public:
static void writeFn(size_t line, size_t col){
Err::semanticReport(line, col, "Attempt to write a function");
}
static void writePtr(size_t line, size_t col){
Err::semanticReport(line, col,
"Attempt to write a raw pointer");
}
static void writeVoid(size_t line, size_t col){
Err::semanticReport(line, col,
"Attempt to write void");
}
static void readFn(size_t line, size_t col){
Err::semanticReport(line, col,
"Attempt to read a function");
}
static void readPtr(size_t line, size_t col){
Err::semanticReport(line, col,
"Attempt to read an array variable");
}
static void callNonFn(size_t line, size_t col){
Err::semanticReport(line, col,
"Attempt to call a non-function");
}
static void badArgCount(size_t line, size_t col){
Err::semanticReport(line, col,
"Function call with wrong number of args");
}
static void badArgType(size_t line, size_t col){
Err::semanticReport(line, col,
"Type of actual does not match type of formal");
}
static bool missRetValue(size_t line, size_t col){
Err::semanticReport(line, col,
"Missing return value");
return false;
}
static bool extraRetValue(size_t line, size_t col){
Err::semanticReport(line, col,
"Return with a value in void function");
return false;
}
static void badRetValue(size_t line, size_t col){
Err::semanticReport(line, col,
"Bad return value");
}
static void badMath(size_t line, size_t col){
Err::semanticReport(line, col,
"Arithmetic operator applied to non-numeric operand");
}
static void badRelation(size_t line, size_t col){
Err::semanticReport(line, col,
"Relational operator applied to non-numeric operand");
}
static void badLogic(size_t line, size_t col){
Err::semanticReport(line, col,
"Logical operator applied to non-bool operand");
}
static void badIf(size_t line, size_t col){
Err::semanticReport(line, col,
"Non-bool expression used as an if condition");
}
static void badWhile(size_t line, size_t col){
Err::semanticReport(line, col,
"Non-bool expression used as a while condition");
}
static void mismatch(size_t line, size_t col){
Err::semanticReport(line, col, "Type mismatch");
}
static void voidEq(size_t line, size_t col){
Err::semanticReport(line, col,
"Equality operator applied" " to void functions");
}
static void fnEq(size_t line, size_t col){
Err::semanticReport(line, col,
"Equality operator applied to functions");
}
static void arrEq(size_t line, size_t col){
Err::semanticReport(line, col,
"Equality operator applied to arrays");
}
static void fnAssign(size_t line, size_t col){
Err::semanticReport(line, col, "Function assignment");
}
static void arrAssign(size_t line, size_t col){
Err::semanticReport(line, col, "Array variable assignment");
}
static void badDeref(size_t line, size_t col){
Err::semanticReport(line, col, "Invalid operand for dereference");
}
};
} //End namespace lake
#endif