aboutsummaryrefslogtreecommitdiff
path: root/parse_error.go
blob: 0f369579b1c7f211719c593b138ed0d541862802 (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
45
46
47
48
// SPDX-FileCopyrightText: 2024 Himbeer <himbeer@disroot.org>
//
// SPDX-License-Identifier: GPL-3.0-or-later

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)
}