Alejandro Mery
1 year ago
3 changed files with 31 additions and 21 deletions
@ -0,0 +1,27 @@
|
||||
package parser |
||||
|
||||
import ( |
||||
"asciigoat.org/core/lexer" |
||||
) |
||||
|
||||
// NewError creates a lexer.Error using a lexer.Position
|
||||
func NewError(pos lexer.Position, content, hint string, err error) *lexer.Error { |
||||
return &lexer.Error{ |
||||
Line: pos.Line, |
||||
Column: pos.Column, |
||||
Content: content, |
||||
Hint: hint, |
||||
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) |
||||
} |
Loading…
Reference in new issue