phi/lex/token.go
Felix Angell b654a4918d go fmt
2018-04-21 19:50:31 +01:00

24 lines
371 B
Go

package lex
import "fmt"
type TokenType uint
const (
Word TokenType = iota
)
type Token struct {
Lexeme string
Type TokenType
Start int
}
func NewToken(lexeme string, kind TokenType, start int) *Token {
return &Token{lexeme, kind, start}
}
func (t *Token) String() string {
return fmt.Sprintf("lexeme: %s, type %s, at pos %d", t.Lexeme, t.Type, t.Start)
}