2017-08-06 06:31:35 +02:00
|
|
|
package parsec
|
|
|
|
|
2017-08-06 07:43:23 +02:00
|
|
|
import "fmt"
|
|
|
|
|
2017-08-06 06:31:35 +02:00
|
|
|
type Node interface {
|
|
|
|
}
|
|
|
|
|
|
|
|
type Error struct {
|
2017-08-06 07:43:23 +02:00
|
|
|
pos int
|
|
|
|
Message string
|
2017-08-06 06:31:35 +02:00
|
|
|
}
|
|
|
|
|
2017-08-06 07:43:23 +02:00
|
|
|
func (e Error) Pos() int { return e.pos }
|
|
|
|
func (e Error) Error() string { return fmt.Sprintf("offset %d: %s", e.pos, e.Message) }
|
2017-08-06 06:31:35 +02:00
|
|
|
|
|
|
|
func NewError(pos int, message string) Error {
|
|
|
|
return Error{pos, message}
|
|
|
|
}
|
|
|
|
|
2017-08-06 09:02:39 +02:00
|
|
|
func IsError(n interface{}) bool {
|
2017-08-06 06:31:35 +02:00
|
|
|
_, isErr := n.(Error)
|
|
|
|
return isErr
|
|
|
|
}
|