aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/quasilyte/regex/syntax/errors.go
blob: beefba5f9c0729e7ee95b15b033b0ba32be40c34 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package syntax

type ParseError struct {
	Pos     Position
	Message string
}

func (e ParseError) Error() string { return e.Message }

func throw(pos Position, message string) {
	panic(ParseError{Pos: pos, Message: message})
}

func throwExpectedFound(pos Position, expected, found string) {
	throw(pos, "expected '"+expected+"', found '"+found+"'")
}

func throwUnexpectedToken(pos Position, token string) {
	throw(pos, "unexpected token: "+token)
}

func newPos(begin, end int) Position {
	return Position{
		Begin: uint16(begin),
		End:   uint16(end),
	}
}