-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy patherror.py
More file actions
165 lines (134 loc) · 4.55 KB
/
Copy patherror.py
File metadata and controls
165 lines (134 loc) · 4.55 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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
import sys
class Error:
""" Error class
Static class to centralize error displays.
"""
@staticmethod
def syntax(t, lineno):
" syntax error "
print("Syntax error: Unexpected token '%s' in line %d." % (t, lineno))
exit(0)
@staticmethod
def type_mismatch(t, lineno):
" type mismatch error "
print("Error: type mismatch in assignment for '%s' in line %d." % (t, lineno))
exit(0)
@staticmethod
def condition_type_mismatch(lineno):
"if expression type mismatch error"
print("Error: type mismatch in condition expression in line %d." % lineno)
exit(0)
@staticmethod
def operation_type_mismatch(lineno):
" operation type mismatch error "
print("Error: type mismatch in an operation in line %d." % (lineno))
exit(0)
@staticmethod
def undefined_variable(t, lineno):
" use of undeclared variable error "
print("Error: use of undefined variable '%s' in line %d." % (t, lineno))
exit(0)
@staticmethod
def redefinition_of_variable(t, lineno):
" variable redefinition error "
print("Error: redefinition of variable '%s' in line %d." % (t, lineno))
exit(0)
@staticmethod
def variable_has_no_assigned_value(t, lineno):
" variable no assigned value error "
print("Error: variable '%s' in line %d has not been assigned a value." % (t, lineno))
exit(0)
@staticmethod
def undefined_module(t, lineno):
" undefined module error "
print("Error: use of undefined module '%s' in line %d." % (t, lineno))
exit(0)
@staticmethod
def unexpected_number_of_arguments(t, lineno):
" wrong number of arguments error"
print("Error: unexpected number of arguments in module '%s' call in line %d." % (t, lineno))
exit(0)
@staticmethod
def type_mismatch_module(t, lineno):
print("Error: type mismatch in module '%s' call in line %d." % (t, lineno))
exit(0)
@staticmethod
def return_on_void_function(t, lineno):
print("Error: return statement on void function in line %d." % (lineno))
exit(0)
@staticmethod
def no_return_on_function(t, lineno):
print("Error: no return statement on function with return type in line %d." % (lineno))
exit(0)
@staticmethod
def matrix_accessed_as_array(t, lineno):
print("Error: matrix '%s' accessed as an array in line %d." % (t, lineno))
exit(0)
@staticmethod
def type_mismatch_in_index(t, lineno):
print("Error: type mismatch in variable '%s' indexation in line %d." % (t, lineno))
exit(0)
@staticmethod
def variable_not_subscriptable_as_matrix(t, lineno):
print("Error: variable '%s' in line %d is not subscriptable as a matrix." % (t, lineno))
exit(0)
@staticmethod
def variable_not_subscriptable_as_array(t, lineno):
print("Error: variable '%s' in line %d is not subscriptable as an array." % (t, lineno))
exit(0)
@staticmethod
def array_parameter_in_module_call(lineno):
print("Error: array parameter in module call in line %d." % (lineno))
exit(0)
@staticmethod
def invalid_print_on_array_variable(lineno):
print("Error: invalid print on array variable in line %d." % (lineno))
exit(0)
@staticmethod
def invalid_operator_on_arrays(lineno):
print("Error: invalid operator on arrays in line %d." % (lineno))
exit(0)
@staticmethod
def invalid_operation_in_line(lineno):
print("Error: invalid operation in line %d." % (lineno))
exit(0)
@staticmethod
def dimensions_do_not_match(lineno):
print("Error: operation between variables with dimensions that don't match in line %d." % (lineno))
exit(0)
@staticmethod
def invalid_assignment_to_array_variable(lineno):
print("Error: invalid assignment to array variable in line %d." % (lineno))
exit(0)
@staticmethod
def array_size_must_be_positive(t, lineno):
print("Error: array '%s' size in line %d must be positive." % (t, lineno))
exit(0)
@staticmethod
def index_out_of_bounds():
print("Error: index out of bounds.")
exit(0)
@staticmethod
def invalid_determinant_calculation(lineno):
print("Error: invalid array dimensions for determinant calculation in line %d." % (lineno))
exit(0)
@staticmethod
def division_by_zero():
print("Error: division by zero.")
exit(0)
@staticmethod
def invalid_inverse_calculation(lineno):
print("Error: invalid array dimensions for inverse calculation in line %d." % (lineno))
exit(0)
@staticmethod
def type_mismatch_array_assignment(lineno):
print("Error: type mismatch in array assignment in line %d." % (lineno))
exit(0)
@staticmethod
def inverse_determinant_zero():
print("Error: determinant of the inverse is zero.")
exit(0)
@staticmethod
def type_mismatch_on_return(lineno):
print("Error: type mismatch on return in line %d." % (lineno))
exit(0)