20 lines
531 B
Go
20 lines
531 B
Go
package internal
|
|
|
|
import "fmt"
|
|
|
|
// PosError is an internal error type that carries source position information.
|
|
// Lexer and parser return this so that the public wrapParseError can extract the position.
|
|
type PosError struct {
|
|
Line int
|
|
Col int
|
|
Message string
|
|
}
|
|
|
|
func (e *PosError) Error() string {
|
|
return fmt.Sprintf("line %d, col %d: %s", e.Line, e.Col, e.Message)
|
|
}
|
|
|
|
func PosErrorf(line, col int, format string, args ...any) *PosError {
|
|
return &PosError{Line: line, Col: col, Message: fmt.Sprintf(format, args...)}
|
|
}
|