refactor: bringing in ast and error changes
This commit is contained in:
parent
8583a815a8
commit
731692d95a
@ -28,11 +28,11 @@ def printError(error: Error)(using errorContent: String): Unit = {
|
|||||||
s"Undefined ${identType.toString.toLowerCase()} ${ident.v}"
|
s"Undefined ${identType.toString.toLowerCase()} ${ident.v}"
|
||||||
)
|
)
|
||||||
highlight(ident.getPosition, ident.v.length)
|
highlight(ident.getPosition, ident.v.length)
|
||||||
case Error.FunctionParamsMismatch(ident, expected, got) =>
|
case Error.FunctionParamsMismatch(pos, expected, got) =>
|
||||||
printPosition(ident.getPosition)
|
printPosition(pos)
|
||||||
println(s"Function ${ident.v} expects $expected parameters, got $got")
|
println(s"Function expects $expected parameters, got $got")
|
||||||
highlight(ident.getPosition, ident.v.length)
|
highlight(pos, 1)
|
||||||
case Error.TypeMismatch(expected, got) =>
|
case Error.TypeMismatch(pos, expected, got, msg) =>
|
||||||
println(s"Type mismatch: expected $expected, got $got")
|
println(s"Type mismatch: expected $expected, got $got")
|
||||||
case Error.SemanticError(pos, msg) =>
|
case Error.SemanticError(pos, msg) =>
|
||||||
printPosition(pos)
|
printPosition(pos)
|
||||||
|
@ -30,7 +30,9 @@ object ast {
|
|||||||
object StrLiter extends ParserBridgePos1[String, StrLiter]
|
object StrLiter extends ParserBridgePos1[String, StrLiter]
|
||||||
case class PairLiter()(val pos: Position) extends Expr6
|
case class PairLiter()(val pos: Position) extends Expr6
|
||||||
object PairLiter extends ParserBridgePos0[PairLiter]
|
object PairLiter extends ParserBridgePos0[PairLiter]
|
||||||
case class Ident(v: String, var uid: Int = -1)(val pos: Position) extends Expr6 with LValue
|
case class Ident(v: String, var uid: Int = -1)(val pos: Position) extends Expr6 with LValue {
|
||||||
|
def getPosition: Position = pos
|
||||||
|
}
|
||||||
object Ident extends ParserBridgePos1[String, Ident] {
|
object Ident extends ParserBridgePos1[String, Ident] {
|
||||||
def apply(v: String)(pos: Position): Ident = new Ident(v)(pos)
|
def apply(v: String)(pos: Position): Ident = new Ident(v)(pos)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user