Rewrite error handling logic

This commit is contained in:
2023-12-17 16:55:13 -08:00
parent ba23bf512c
commit 01047706b6
12 changed files with 468 additions and 431 deletions

View File

@@ -19,8 +19,8 @@ package ast
import "fmt"
func PosError(n Node, filename, format string, v ...any) error {
return fmt.Errorf(filename+":"+n.Pos().String()+": "+format, v...)
func PosError(n Node, format string, v ...any) error {
return fmt.Errorf(n.Pos().String()+": "+format, v...)
}
type Node interface {
@@ -28,12 +28,13 @@ type Node interface {
}
type Position struct {
Name string
Line int
Col int
}
func (p Position) String() string {
return fmt.Sprintf("%d:%d", p.Line, p.Col)
return fmt.Sprintf("%s: line %d, col %d", p.Name, p.Line, p.Col)
}
type Tag struct {