-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCG_debug.cpp
109 lines (108 loc) · 3.66 KB
/
CG_debug.cpp
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
#include <iostream>
#include <string>
void throw_error ( int v , std::string s )
{
switch ( v )
{
case 0 : //一般这个错误是只要不乱搞就不会出现的。如果出现了,那就代表我也不知道哪里出了问题。
{
std::cout << "ERROR: Unknown type error\n" ;
break ;
}
case 1 : //被零除
{
std::cout << "ERROR: Division by zero\n" ;
break ;
}
case 2 : //有依赖结点未赋值
{
std::cout << "ERROR: Placeholder missing\n" ;
break ;
}
case 3 : //未定义运算符
{
std::cout << "ERROR: No matching operator for '" << s << "'\n" ;
break ;
}
case 4 : //LOG函数传入非正数
{
std::cout << "ERROR: LOG operator's input must be positive\n" ;
break ;
}
case 5 : //。。。算了我也不知道我定义这个干什么的
{
std::cout << "ERROR: No matching operators\n" ;
break ;
}
case 6 : //调用eval函数访问非Placeholder结点或非Var结点
{
std::cout << "ERROR: Cannot evaluate a non-Placeholder or a non-Var type node\n" ;
break ;
}
case 7 : //试图调用不存在的结点
{
std::cout << "ERROR: Cannot find node called '" << s << "'\n" ;
break ;
}
case 8 : //由于未知运算符导致无法计算。其实我觉得这个触发不了。。。
{
std::cout << "ERROR: Cannot compute. Please check if you have added new operators. " ;
break ;
}
case 9 : //我为啥要定义这个???
{
std::cout << "ERROR: Unknown operator type\n" ;
break ;
}
case 10 : //不规范表达式
{
std::cout << "ERROR: illegal expression\n" ;
break ;
}
case 11 : //不存在结点(我才发现和7重复了。。。)
{
std::cout << "ERROR: Non-existent node '" << s << "'\n" ;
break ;
}
case 12 : //试图用get_value函数访问运算符结点
{
std::cout << "ERROR: Type '" << s << "' does not have value\n" ;
break ;
}
case 13 : //调用SETCONSTANT或SETANSWER给一个非Variable结点赋值
{
std::cout << "ERROR: Cannot use 'SETCONSTANT' or 'SETANSWER' to evaluate a non-Variable node\n" ;
break ;
}
case 14 : //试图在EVAL语句中给非Placeholder结点赋值
{
std::cout << "ERROR: Cannot evaluate a non-Placeholder node\n" ;
break ;
}
case 15 : //未知结点类型
{
std::cout << "ERROR: Unknown node type\n" ;
break ;
}
case 16 : //EVAL时第三个参数缺失(赋值Placeholder结点个数)
{
std::cout << "ERROR: Please enter the number of Placeholders\n" ;
break ;
}
case 17 : //赋值过大,超过数据类型范围
{
std::cout << "ERROR: OUT OF RANGE!\n" ;
break ;
}
case 19 : //重复定义结点(非Var结点)
{
std::cout << "ERROR: Node redefined\n" ;
break ;
}
default : //如果你自己写了throw_error并且随意写参数值。。。那就不知道你想要调用哪个错误类型了
{
std::cout << "Unknown type error! Please check if you give function 'throw_error' correct parameters\n" ;
break ;
}
}
}