aboutsummaryrefslogtreecommitdiff
path: root/parse_error.go
blob: 9bd778f2e931b69eb01b3a0196423da1c0b6d866 (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
43
44
package main

import "fmt"

type expected struct {
	want tokenKind
	got  token
}

func (e expected) Error() string {
	return fmt.Sprintf("%d: expected %s, got %s", e.got.line, e.want, e.got)
}

type expectedToplevel struct {
	got token
}

func (e expectedToplevel) Error() string {
	return fmt.Sprintf("%d: expected top-level declaration, got %s", e.got.line, e.got)
}

type expectedStatement struct {
	got token
}

func (e expectedStatement) Error() string {
	return fmt.Sprintf("%d: expected statement, got %s", e.got.line, e.got)
}

type expectedUnaryOperand struct {
	got token
}

func (e expectedUnaryOperand) Error() string {
	return fmt.Sprintf("%d: expected unary operand, got %s", e.got.line, e.got)
}

type expectedPrimary struct {
	got token
}

func (e expectedPrimary) Error() string {
	return fmt.Sprintf("%d: expected primary expression, got %s", e.got.line, e.got)
}