Locations and tokens are now capable of creating errors on their own
This commit is contained in:
parent
7914f0df45
commit
accf528869
@ -22,9 +22,9 @@ func NewError (
|
|||||||
message string,
|
message string,
|
||||||
kind ErrorKind,
|
kind ErrorKind,
|
||||||
) (
|
) (
|
||||||
err *Error,
|
err Error,
|
||||||
) {
|
) {
|
||||||
return &Error {
|
return Error {
|
||||||
Location: location,
|
Location: location,
|
||||||
message: message,
|
message: message,
|
||||||
kind: kind,
|
kind: kind,
|
||||||
|
@ -8,3 +8,8 @@ type Location struct {
|
|||||||
column int
|
column int
|
||||||
width int
|
width int
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewError creates a new error at this location.
|
||||||
|
func (location Location) NewError (message string, kind ErrorKind) (err Error) {
|
||||||
|
return NewError(location, message, kind)
|
||||||
|
}
|
||||||
|
@ -86,6 +86,11 @@ func (token Token) Location () (location file.Location) {
|
|||||||
return token.location
|
return token.location
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewError creates a new error at this token's location.
|
||||||
|
func (token Token) NewError (message string, kind file.ErrorKind) (err file.Error) {
|
||||||
|
return token.location.NewError(message, kind)
|
||||||
|
}
|
||||||
|
|
||||||
// Describe generates a textual description of the token to be used in debug
|
// Describe generates a textual description of the token to be used in debug
|
||||||
// logs.
|
// logs.
|
||||||
func (token Token) Describe () (description string) {
|
func (token Token) Describe () (description string) {
|
||||||
|
Reference in New Issue
Block a user