diff options
Diffstat (limited to 'pkg/lang/parser/errors.go')
| -rw-r--r-- | pkg/lang/parser/errors.go | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/pkg/lang/parser/errors.go b/pkg/lang/parser/errors.go new file mode 100644 index 0000000..a020e01 --- /dev/null +++ b/pkg/lang/parser/errors.go @@ -0,0 +1,60 @@ +package parser + +import ( + "fmt" + "jinx/pkg/lang/scanner/token" + "jinx/pkg/libs/source" +) + +type ErrFunctionNoThisAllowed struct { + At source.Loc +} + +func (e ErrFunctionNoThisAllowed) Error() string { + return fmt.Sprintf("non-method function cannot have 'this' as parameter at %v", e.At) +} + +type ErrFunctionLiteralNoThisAllowed struct { + At source.Loc +} + +func (e ErrFunctionLiteralNoThisAllowed) Error() string { + return fmt.Sprintf("function literal cannot have 'this' as parameter at %v", e.At) +} + +type ErrExpectedToken struct { + At source.Loc + Wanted token.TokenKind + Got token.Token +} + +func (e ErrExpectedToken) Error() string { + return fmt.Sprintf("unexpected token %v, wanted %v at %v", e.Got, e.Wanted, e.At) +} + +type ErrExpectedStatementEnd struct { + At source.Loc + Got token.Token +} + +func (e ErrExpectedStatementEnd) Error() string { + return fmt.Sprintf("expected statement end, got %v at %v", e.Got, e.At) +} + +type ErrExpectedUnitExpressionStart struct { + At source.Loc + Got token.Token +} + +func (e ErrExpectedUnitExpressionStart) Error() string { + return fmt.Sprintf("unexpected token %v, wanted unit expression start at %v", e.Got, e.At) +} + +type ErrExpectedValueLiteral struct { + At source.Loc + Got token.Token +} + +func (e ErrExpectedValueLiteral) Error() string { + return fmt.Sprintf("unexpected token %v, wanted value literal %v", e.Got, e.At) +} |
