Improved instruction parser
This commit is contained in:
parent
a4ecaf0622
commit
78cde0d0bd
7 changed files with 114 additions and 54 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue