about summary refs log tree commit diff
path: root/pkg/lang/parser/errors.go
blob: a020e0129c07d18fc7abc0bbfd5ff92c0e802b7f (plain)
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
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)
}