blob: 815b38f4fe2a6d0bc6403ad5c4bdf93fb06d0468 (
plain) (
blame)
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
|
package spec
import "fmt"
type SyntaxError struct {
message string
}
func newSyntaxError(message string) *SyntaxError {
return &SyntaxError{
message: message,
}
}
func (e *SyntaxError) Error() string {
return fmt.Sprintf("syntax error: %s", e.message)
}
var (
// lexical errors
synErrUnclosedTerminal = newSyntaxError("unclosed terminal")
synErrInvalidEscSeq = newSyntaxError("invalid escape sequence")
synErrIncompletedEscSeq = newSyntaxError("incompleted escape sequence; unexpected EOF following \\")
// syntax errors
synErrInvalidToken = newSyntaxError("invalid token")
synErrNoProduction = newSyntaxError("a grammar must have at least one production")
synErrNoProductionName = newSyntaxError("a production name is missing")
synErrNoColon = newSyntaxError("the colon must precede alternatives")
synErrNoSemicolon = newSyntaxError("the semicolon is missing at the last of an alternative")
synErrNoElement = newSyntaxError("an alternative must have at least one element")
)
|