blob: 589e324b5e10a215ed4f3b2e4b6107de2b512e49 (
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
41
42
|
package grammar
type SemanticError struct {
message string
}
func newSemanticError(message string) *SemanticError {
return &SemanticError{
message: message,
}
}
func (e *SemanticError) Error() string {
return e.message
}
var (
semErrNoGrammarName = newSemanticError("name is missing")
semErrSpellingInconsistency = newSemanticError("the identifiers are treated as the same. please use the same spelling")
semErrDuplicateAssoc = newSemanticError("associativity and precedence cannot be specified multiple times for a symbol")
semErrUndefinedPrec = newSemanticError("symbol must has precedence")
semErrUndefinedOrdSym = newSemanticError("undefined ordered symbol")
semErrUnusedProduction = newSemanticError("unused production")
semErrUnusedTerminal = newSemanticError("unused terminal")
semErrTermCannotBeSkipped = newSemanticError("a terminal used in productions cannot be skipped")
semErrNoProduction = newSemanticError("a grammar needs at least one production")
semErrUndefinedSym = newSemanticError("undefined symbol")
semErrDuplicateProduction = newSemanticError("duplicate production")
semErrDuplicateTerminal = newSemanticError("duplicate terminal")
semErrDuplicateFragment = newSemanticError("duplicate fragment")
semErrDuplicateName = newSemanticError("duplicate names are not allowed between terminals and non-terminals")
semErrErrSymIsReserved = newSemanticError("symbol 'error' is reserved as a terminal symbol")
semErrDuplicateLabel = newSemanticError("a label must be unique in an alternative")
semErrInvalidLabel = newSemanticError("a label must differ from terminal symbols or non-terminal symbols")
semErrDirInvalidName = newSemanticError("invalid directive name")
semErrDirInvalidParam = newSemanticError("invalid parameter")
semErrDuplicateDir = newSemanticError("a directive must not be duplicated")
semErrDuplicateElem = newSemanticError("duplicate element")
semErrAmbiguousElem = newSemanticError("ambiguous element")
semErrInvalidProdDir = newSemanticError("invalid production directive")
semErrInvalidAltDir = newSemanticError("invalid alternative directive")
)
|