aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/quasilyte/regex/syntax/errors.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/quasilyte/regex/syntax/errors.go')
-rw-r--r--vendor/github.com/quasilyte/regex/syntax/errors.go27
1 files changed, 27 insertions, 0 deletions
diff --git a/vendor/github.com/quasilyte/regex/syntax/errors.go b/vendor/github.com/quasilyte/regex/syntax/errors.go
new file mode 100644
index 000000000..beefba5f9
--- /dev/null
+++ b/vendor/github.com/quasilyte/regex/syntax/errors.go
@@ -0,0 +1,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),
+ }
+}