reassign values
Some checks failed
Build / build (push) Failing after 1m46s
Test / build (push) Has been cancelled

This commit is contained in:
Chuck Smith
2024-03-15 15:24:48 -04:00
parent c818591f79
commit 2988719c9c
13 changed files with 327 additions and 17 deletions

View File

@@ -379,3 +379,29 @@ func (we *WhileExpression) String() string {
return out.String()
}
// AssignmentStatement the `=` statement represents the AST node that rebinds
// an expression to an identifier (assigning a new value).
type AssignmentStatement struct {
Token token.Token // the token.ASSIGN token
Name *Identifier
Value Expression
}
func (as AssignmentStatement) TokenLiteral() string {
return as.Token.Literal
}
func (as AssignmentStatement) String() string {
var out bytes.Buffer
out.WriteString(as.Name.String())
out.WriteString(as.TokenLiteral() + " ")
out.WriteString(as.Value.String())
out.WriteString(";")
return out.String()
}
func (as AssignmentStatement) statementNode() {}