refactor: make functions non-semantic types

This commit is contained in:
2025-02-07 12:19:52 +00:00
parent 0f87725f62
commit f143f685c4
5 changed files with 90 additions and 90 deletions

View File

@@ -5,7 +5,9 @@ import wacc.types._
enum Error {
case DuplicateDeclaration(ident: ast.Ident)
case UndefinedIdentifier(ident: ast.Ident, identType: renamer.IdentType)
case UndeclaredVariable(ident: ast.Ident)
case UndefinedFunction(ident: ast.Ident)
case FunctionParamsMismatch(pos: Position, expected: Int, got: Int)
case SemanticError(pos: Position, msg: String)
case TypeMismatch(pos: Position, expected: SemType, got: SemType, msg: String)
@@ -19,9 +21,13 @@ def printError(error: Error)(using errorContent: String): Unit = {
printPosition(ident.pos)
println(s"Duplicate declaration of identifier ${ident.v}")
highlight(ident.pos, ident.v.length)
case Error.UndefinedIdentifier(ident, identType) =>
case Error.UndeclaredVariable(ident) =>
printPosition(ident.pos)
println(s"Undefined ${identType.toString.toLowerCase()} ${ident.v}")
println(s"Undeclared variable ${ident.v}")
highlight(ident.pos, ident.v.length)
case Error.UndefinedFunction(ident) =>
printPosition(ident.pos)
println(s"Undefined function ${ident.v}")
highlight(ident.pos, ident.v.length)
case Error.FunctionParamsMismatch(pos, expected, got) =>
printPosition(pos)