summaryrefslogtreecommitdiff
path: root/nodes.go
blob: 29dd58f7a993500c508a83e007d8de1b86245bb1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package parsec

import "fmt"

type Node interface {
}

type Error struct {
	pos     int
	Message string
}

func (e Error) Pos() int      { return e.pos }
func (e Error) Error() string { return fmt.Sprintf("offset %d: %s", e.pos, e.Message) }

func NewError(pos int, message string) Error {
	return Error{pos, message}
}

func IsError(n interface{}) bool {
	_, isErr := n.(Error)
	return isErr
}