parser: introduce NewError() and ErrPlusPosition() #8

Merged
amery merged 3 commits from pr-amery-error into main 2023-09-04 19:33:25 +02:00
Showing only changes of commit 8f3e59ec36 - Show all commits
+11
View File
@@ -14,3 +14,14 @@ func NewError(pos lexer.Position, content, hint string, err error) *lexer.Error
Err: err,
}
}
// ErrPlusPosition returns a copy of the given [lexer.Error]
// offsetting the Line/Column information.
func ErrPlusPosition(pos lexer.Position, e *lexer.Error) *lexer.Error {
pos.Add(lexer.Position{
Line: e.Line,
Column: e.Column,
})
return NewError(pos, e.Content, e.Hint, e.Err)
}