Improved instruction parser
This commit is contained in:
@ -1,5 +1,7 @@
|
||||
package token
|
||||
|
||||
import "fmt"
|
||||
|
||||
// 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.
|
||||
@ -9,6 +11,11 @@ type Token struct {
|
||||
Bytes []byte
|
||||
}
|
||||
|
||||
// String creates a human readable representation for debugging purposes.
|
||||
func (t Token) String() string {
|
||||
return fmt.Sprintf("%s %s", t.Kind, t.Text())
|
||||
}
|
||||
|
||||
// Text returns the token text.
|
||||
func (t Token) Text() string {
|
||||
return string(t.Bytes)
|
||||
|
Reference in New Issue
Block a user