-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherrors.go
45 lines (36 loc) · 1.32 KB
/
errors.go
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package peg
import (
"fmt"
)
var (
errorDismatch = errorf("the pattern is dismatched")
errorNotFullMatched = errorf("the pattern is not full matched")
errorReferDisabled = errorf("group text referring when grouping is disabled")
errorCornerCase = errorf("this corner case should never be reached")
errorCallstackOverflow = errorf("callstack overflow")
errorReachedRepeatLimit = errorf("repeatition limit is reached")
errorExecuteWhenConsumed = errorf("unable to execute pattern when some text already consumed by caller")
errorNilConstructor = errorf("capture constructor is nil")
errorNilMainPattern = errorf("the main pattern is nil")
errorCaseInsensitive = func(name string) error {
return errorf("case insensitive is not implemented for %q", name)
}
errorUndefinedUnicodeRanges = func(name string) error {
return errorf("unicode class name %q undefined", name)
}
errorUndefinedVar = func(name string) error {
return errorf("variable %q is undefined", name)
}
errorInvalidVarName = func(name string) error {
return errorf("variable name %q is invalid", name)
}
)
type pegError struct {
value string
}
func errorf(format string, v ...interface{}) error {
return &pegError{fmt.Sprintf(format, v...)}
}
func (err *pegError) Error() string {
return "peg: " + err.value
}