-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherrorMsg.java
More file actions
281 lines (221 loc) · 11.4 KB
/
Copy patherrorMsg.java
File metadata and controls
281 lines (221 loc) · 11.4 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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
/*
* Copyright (c) 2025 - 2026 PCazzaniga (github.com)
*
* errorMsg.java is part of SIMPLE.
*
* SIMPLE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* SIMPLE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with SIMPLE. If not, see <http://www.gnu.org/licenses/>.
*/
import java.util.List;
class errorMsg {
public static String accKitNoField(String fieldName, String kitName, List<String> suggestions) {
return "Attempting to access non-existent field '" + fieldName + "' in Kit " + kitName + "." + didYouMean(suggestions);
}
public static String accKitDynamic() {
return "Attempting to access kit structure with a dynamic positional value.";
}
public static String accNotKit(String structType) {
return "Attempting to access non-kit structure of type " + structType + " with a field name.";
}
public static String accNotNum(String varType) {
return "Attempting to use non-number variable of type " + varType + " as positional access to a structure.";
}
public static String accNotStruct(String varType) {
return "Attempting to access non-structured variable of type " + varType + ".";
}
public static String accOverSize(int position, int size) {
return "Attempting to access position " + position + " out of structure's size " + size + ".";
}
public static String accRandom() {
return "Attempting to access structure at purely random position, which could be invalid.";
}
public static String accUnderSize(int position) {
return "Attempting to access structure at invalid position " + position + ".";
}
public static String assignInputToStruct(String typeString) {
return "Attempting to assign from input to variable of non-basic type " + typeString + ".";
}
public static String assignTypeWrong(String varType, String valType) {
return "Attempting to assign to variable of type " + varType + " value of mismatched type " + valType + ".";
}
public static String assignTypeUnk(String valueString) {
return "Unable to recognize type of assigned value " + valueString + ".";
}
public static String assignUseless(String from, String to) {
return "Attempting useless assignment from " + from + " to " + to + ".";
}
public static String condTypeUnk(String condUse, String condString) {
return "Unable to recognize type of " + condUse + " condition " + condString + ".";
}
public static String equalityTypeWrong(String firstType, String secondType) {
return "Attempting to compare value of type " + firstType + " with value of mismatched type " + secondType + ".";
}
public static String funAlreadyExist(String funName, int definedLine) {
return "Procedure '" + funName + "' is already defined at line " + definedLine + ".";
}
public static String funArgTypeUnk(String argType, String argString) {
return "Unable to recognize type " + argType + " of argument " + argString + ".";
}
public static String funArgsNumWrong(String funName, int gotN, int wantN) {
return "Attempting to call procedure " + funName + " with " + gotN + " argument" + (gotN != 1 ? "s" : "") + " but it requires " + wantN + " parameter" + (wantN != 1 ? "s" : "") + ".";
}
public static String funArgsTypeWrong(String funName, List<String> gotTypes, List<String> wantTypes) {
StringBuilder msg = new StringBuilder("Attempting to call procedure " + funName + " with argument");
if (gotTypes.size() > 1) msg.append("s");
msg.append(" of type");
for (String g : gotTypes) {
msg.append(" ").append(g).append(",");
}
msg.delete(msg.length() - 1, msg.length());
msg.append(" but it requires parameter");
if (wantTypes.size() > 1) msg.append("s");
msg.append(" of type");
for (String w : wantTypes) {
msg.append(" ").append(w).append(",");
}
msg.replace(msg.length() - 1, msg.length(), ".");
return msg.toString();
}
public static String funParAlreadyExist(String funName, String paramName) {
return "Procedure " + funName + " already has a parameter variable with name " + paramName + ".";
}
public static String funParAlreadyVar(String paramName, int declaredLine) {
return "Name for parameter variable '" + paramName + "' is already used for a variable at line " + declaredLine + ".";
}
public static String funParTypeUnk(String paramType, String paramName) {
return "Unable to recognize type " + paramType + " of parameter variable " + paramName + ".";
}
public static String funResNotVoid(String typeString) {
return "Attempting to use as instruction a procedure call that produces a value of type " + typeString + " instead of Nothing.";
}
public static String funResTypeUnk(String resType, String funName) {
return "Unable to recognize result type " + resType + " of procedure " + funName + ".";
}
public static String funUndefined(String funName, List<String> suggestions) {
return "Procedure '" + funName + "' is undefined." + didYouMean(suggestions);
}
public static String funUnused(String funName, int definedLine) {
return "Procedure " + funName + " defined at line " + definedLine + " but never used.";
}
public static String invalidCounterUse() {
return "Attempting to use Counter outside of any loop.";
}
public static String invalidSizeOf(String varType) {
return "Attempting to get size of non-structured variable of type " + varType + ".";
}
public static String invalidSizeOfEmpty() {
return "Attempting to get size of structured variable but it has none because it appears to have no value yet.";
}
public static String listInsertTypeWrong(typeVisitor.dataType gotType, typeVisitor.dataType wantType) {
return "Attempting to insert value of type " + gotType + " in a list of " + wantType + ".";
}
public static String listOpNotList(typeVisitor.dataType structType) {
return "Attempting to use structure of type " + structType + " in list operation.";
}
public static String litStructTypeMixed(String structKind, String foundType1, String foundType2) {
return "Attempting to use " + structKind + " literal with heterogeneous elements, found type " + foundType1 + " but also type " + foundType2 + ".";
}
public static String litStructTypeUnk(String valueString, String structKind) {
return "Unable to recognize type of element " + valueString + " in " + structKind + " literal.";
}
public static String loopQuantTypeWrong(String typeString) {
return "Attempting to use value of mismatched type " + typeString + " as loop quantifier.";
}
public static String loopQuantTypeUnk(String valueString) {
return "Unable to recognize type of loop quantifier value " + valueString + ".";
}
public static String mainParStruct(String paramName, String paramType) {
return "Attempting to define Main with structured parameter " + paramName + " of type " + paramType + ".";
}
public static String mergeNotFromTextList(String typeString) {
return "Attempting to use variable of mismatched type " + typeString + " as list of Text to merge into Text.";
}
public static String mergeNotToText(String typeString) {
return "Attempting to use variable of mismatched type " + typeString + " as Text to merge a list of Text into.";
}
public static String operandTypeWrong(String operandType, String operationKind) {
return "Attempting to use operand of mismatched type " + operandType + " in " + operationKind + " operation.";
}
public static String operandTypeUnk(String operandString) {
return "Unable to recognize type of operand " + operandString + ".";
}
public static String retTypeWrong(String gotType, String funName, String wantType) {
return "Attempting to return value of mismatched type " + gotType + " but procedure " + funName + " should return " + wantType + ".";
}
public static String retTypeUnk(String valueString) {
return "Unable to recognize type of returned value " + valueString + ".";
}
public static String splitNotFromText(String typeString) {
return "Attempting to use variable of mismatched type " + typeString + " as Text to split into a list of Text.";
}
public static String splitNotToTextList(String typeString) {
return "Attempting to use variable of mismatched type " + typeString + " as s list of Text to split Text into.";
}
public static String structNoValue(String structName) {
return "Attempting to access structure " + structName + " but it appears to have no value yet.";
}
public static String structTypeUnk(String structName) {
return "Unable to recognize if " + structName + " is a variable of structured type.";
}
public static String typeAlreadyExist(String typeName, int declaredLine) {
return "Type '" + typeName + "' is already defined at line " + declaredLine + ".";
}
public static String typeDefRecInvalid(String nameStr) {
return "Attempting to define type " + nameStr + " as an invalid recursive type.";
}
public static String typeDefUnk(String typeString) {
return "Unable to recognize aliased type " + typeString + ".";
}
public static String typeUndefined(String typeName, List<String> suggestions) {
return "Type '" + typeName + "' is undefined." + didYouMean(suggestions);
}
public static String typeUnused(String typeName, int declaredLine) {
return "Type " + typeName + " declared at line " + declaredLine + " but never used.";
}
public static String varAlreadyExist(String varName, int declaredLine) {
return "Variable " + varName + " is already declared at line " + declaredLine + ".";
}
public static String varInitTypeWrong(String varType, String valType) {
return "Attempting to initialize variable of type " + varType + " with value of mismatched type " + valType + ".";
}
public static String varInitTypeUnk(String valueString, String varName) {
return "Unable to recognize type of initialization value " + valueString + " for variable " + varName + ".";
}
public static String varNoValue(String varName) {
return "Attempting to use value of variable " + varName + " but it appears to have no value yet.";
}
public static String varTypeUnk(String typeString, String varName) {
return "Unable to recognize type " + typeString + " of variable " + varName + ".";
}
public static String varUndefined(String varName, List<String> suggestions) {
return "Variable '" + varName + "' is undefined." + didYouMean(suggestions);
}
public static String varUnused(String varName) {
return "Variable " + varName + " declared but never used.";
}
private static String didYouMean(List<String> suggestions){
if(!suggestions.isEmpty()){
StringBuilder sb = new StringBuilder(" Did you mean ");
sb.append(suggestions.get(0));
if(suggestions.size() > 1){
for(String s : suggestions.subList(1, suggestions.size() - 1)){
sb.append(", ").append(s);
}
sb.append(" or ").append(suggestions.get(suggestions.size() - 1));
}
sb.append(" ?");
return sb.toString();
}
return null;
}
}