about summary refs log tree commit diff
path: root/pkg/lang/scanner/token/token.go
blob: a39df8ab14b76018ef1c1f9ec5fe2e53fdbae3d9 (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
package token

import "jinx/pkg/libs/source"

type Token struct {
	Kind TokenKind
	At   source.Loc
	Data any
}

func Simple(kind TokenKind, at source.Loc) Token {
	return Token{
		Kind: kind,
		At:   at,
	}
}

func New(kind TokenKind, at source.Loc, data any) Token {
	return Token{
		Kind: kind,
		At:   at,
		Data: data,
	}
}

func (t Token) CanEndStmt() bool {
	switch t.Kind {
	case EOF, EOL, SemiColon:
		return true
	default:
		return false
	}
}