Added a tokenizer
This commit is contained in:
parent
16690d390f
commit
21cf4b5c6d
7 changed files with 274 additions and 12 deletions
15
src/token/Token.go
Normal file
15
src/token/Token.go
Normal 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)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue