Skip to content

Commit 4211b2a

Browse files
flofridaykper
andauthored
ast: Fix bad suggestions for assembly description
Co-authored-by: kper <kevin.per@protonmail.com> --------- Co-authored-by: kper <kevin.per@protonmail.com>
1 parent 24752ba commit 4211b2a

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

vadl/main/vadl/ast/SymbolTable.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,20 @@ Macro getMacro(String name) {
286286
if (origin != null) {
287287
return origin;
288288
}
289-
errors.add(error("Unknown name " + usage.pathToString(), usage).build());
289+
290+
// FIXME: This rewrite should probably be expanded and live in a shared place.
291+
var definitionNames = Map.of(
292+
InstructionDefinition.class, "instruction",
293+
InstructionSetDefinition.class, "ISA",
294+
AssemblyDefinition.class, "assembly",
295+
ApplicationBinaryInterfaceDefinition.class, "ABI",
296+
FormatDefinition.class, "format",
297+
MemoryDefinition.class, "memory"
298+
);
299+
var definitionName = definitionNames.getOrDefault(type, type.getSimpleName());
300+
301+
var suggestions = Levenshtein.suggestions(usage.pathToString(), allSymbolNamesOf(type));
302+
reportUnkownError(definitionName, usage.pathToString(), usage, suggestions);
290303
return null;
291304
}
292305

0 commit comments

Comments
 (0)