Added a tokenizer

This commit is contained in:
Eduard Urbach 2023-10-31 11:57:37 +01:00
parent 16690d390f
commit 21cf4b5c6d
Signed by: eduard
GPG key ID: 49226B848C78F6C8
7 changed files with 274 additions and 12 deletions

15
src/token/Token.go Normal file
View file

@ -0,0 +1,15 @@
package token
// Token represents a single element in a source file.
// The characters that make up an identifier are grouped into a single token.
// This makes parsing easier and allows us to do better syntax checks.
type Token struct {
Kind Kind
Position int
Bytes []byte
}
// String returns the token text.
func (t Token) String() string {
return string(t.Bytes)
}