Implemented expression parsing

This commit is contained in:
Eduard Urbach 2024-06-16 16:57:33 +02:00
parent 1b99722cd8
commit 0ed071a7ee
Signed by: eduard
GPG key ID: 49226B848C78F6C8
18 changed files with 618 additions and 99 deletions

View file

@ -12,16 +12,23 @@ type Token struct {
}
// After returns the position after the token.
func (t Token) After() int {
func (t *Token) After() int {
return t.Position + len(t.Bytes)
}
// String creates a human readable representation for debugging purposes.
func (t Token) String() string {
func (t *Token) String() string {
return fmt.Sprintf("%s %s", t.Kind, t.Text())
}
// Reset resets the token to default values.
func (t *Token) Reset() {
t.Kind = Invalid
t.Position = 0
t.Bytes = nil
}
// Text returns the token text.
func (t Token) Text() string {
func (t *Token) Text() string {
return string(t.Bytes)
}