parser: introduce ErrPlusPosition to apply a position offset to a lexer.Error
Signed-off-by: Alejandro Mery <amery@jpi.io>
This commit is contained in:
@@ -14,3 +14,14 @@ func NewError(pos lexer.Position, content, hint string, err error) *lexer.Error
|
|||||||
Err: err,
|
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)
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user