blob: df8977dca59d20a5e07520f362def7f28c624491 (
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
33
34
35
36
37
38
39
40
|
package compiler
import "fmt"
type SyntaxError struct {
Message string
}
func newSyntaxError(msg string) *SyntaxError {
return &SyntaxError{
Message: msg,
}
}
func (e *SyntaxError) Error() string {
return fmt.Sprintf("syntax error: %s", e.Message)
}
var (
// lexical errors
synErrIncompletedEscSeq = newSyntaxError("incompleted escape sequence; unexpected EOF following \\")
synErrInvalidEscSeq = newSyntaxError("invalid escape sequence")
synErrInvalidCodePoint = newSyntaxError("code points must consist of just 4 or 6 hex digits")
// syntax errors
synErrUnexpectedToken = newSyntaxError("unexpected token")
synErrNullPattern = newSyntaxError("a pattern must be a non-empty byte sequence")
synErrAltLackOfOperand = newSyntaxError("an alternation expression must have operands")
synErrRepNoTarget = newSyntaxError("a repeat expression must have an operand")
synErrGroupNoElem = newSyntaxError("a grouping expression must include at least one character")
synErrGroupUnclosed = newSyntaxError("unclosed grouping expression")
synErrGroupNoInitiator = newSyntaxError(") needs preceding (")
synErrGroupInvalidForm = newSyntaxError("invalid grouping expression")
synErrBExpNoElem = newSyntaxError("a bracket expression must include at least one character")
synErrBExpUnclosed = newSyntaxError("unclosed bracket expression")
synErrBExpInvalidForm = newSyntaxError("invalid bracket expression")
synErrRangeInvalidOrder = newSyntaxError("a range expression with invalid order")
synErrCPExpInvalidForm = newSyntaxError("invalid code point expression")
synErrCPExpOutOfRange = newSyntaxError("a code point must be between U+0000 to U+10FFFF")
)
|