diff options
author | Ryo Nihei <nihei.dev@gmail.com> | 2021-07-18 22:15:35 +0900 |
---|---|---|
committer | Ryo Nihei <nihei.dev@gmail.com> | 2021-07-18 22:15:35 +0900 |
commit | e4a5958fc8d9e131ab083215a51a1b60acf91410 (patch) | |
tree | 6ca224a42915135e8f5427d62fc52455b1a1bc59 /grammar/semantic_error.go | |
parent | Add token positions to an AST (diff) | |
download | cotia-e4a5958fc8d9e131ab083215a51a1b60acf91410.tar.gz cotia-e4a5958fc8d9e131ab083215a51a1b60acf91410.tar.xz |
Detect multiple semantic errors in a single parse
Diffstat (limited to 'grammar/semantic_error.go')
-rw-r--r-- | grammar/semantic_error.go | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/grammar/semantic_error.go b/grammar/semantic_error.go new file mode 100644 index 0000000..01446ed --- /dev/null +++ b/grammar/semantic_error.go @@ -0,0 +1,22 @@ +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 ( + semErrNoProduction = newSemanticError("a grammar needs at least one production") + semErrUndefinedSym = newSemanticError("undefined symbol") + semErrDirInvalidName = newSemanticError("invalid directive name") + semErrDirInvalidParam = newSemanticError("invalid parameter") +) |