refactor: improvements to semantic error printing format #14

Merged
gc1523 merged 12 commits from semantic-error-messages into master 2025-02-07 13:38:35 +00:00
4 changed files with 58 additions and 6 deletions
Showing only changes of commit 31bb23480b - Show all commits

View File

@@ -16,13 +16,13 @@ def printError(error: Error)(using errorContent: String): Unit = {
println("Semantic error:")
error match {
case Error.DuplicateDeclaration(ident) =>
printPosition(ident.getPosition)
printPosition(ident.pos)
println(s"Duplicate declaration of identifier ${ident.v}")
highlight(ident.getPosition, ident.v.length)
highlight(ident.pos, ident.v.length)
case Error.UndefinedIdentifier(ident, identType) =>
printPosition(ident.getPosition)
printPosition(ident.pos)
println(s"Undefined ${identType.toString.toLowerCase()} ${ident.v}")
highlight(ident.getPosition, ident.v.length)
highlight(ident.pos, ident.v.length)
case Error.FunctionParamsMismatch(pos, expected, got) =>
printPosition(pos)
println(s"Function expects $expected parameters, got $got")