2025-01-13 19:51:49 -08:00
|
|
|
package ast
|
|
|
|
|
|
2025-01-13 19:56:56 -08:00
|
|
|
import "code.jmug.me/jmug/compiler-in-go/pkg/token"
|
2025-01-13 19:51:49 -08:00
|
|
|
|
|
|
|
|
// Identifier is treated as an expression because in certain
|
|
|
|
|
// circumstances they can return values (think `let some = other` where `other`
|
|
|
|
|
// is actually an expression returning a value) and this makes them easier to
|
|
|
|
|
// handle (according to the author).
|
|
|
|
|
type Identifier struct {
|
|
|
|
|
Token token.Token
|
|
|
|
|
Value string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (i *Identifier) expressionNode() {}
|
|
|
|
|
func (i *Identifier) TokenLiteral() string {
|
|
|
|
|
return i.Token.Literal
|
|
|
|
|
}
|
|
|
|
|
func (i *Identifier) String() string {
|
|
|
|
|
return i.Value
|
|
|
|
|
}
|