Extra Features
Some checks failed
Build / build (push) Failing after 1m40s
Test / build (push) Failing after 11m47s

This commit is contained in:
Chuck Smith
2024-03-14 21:25:47 -04:00
parent 36f04713bd
commit 997f0865f4
20 changed files with 757 additions and 128 deletions

View File

@@ -356,3 +356,26 @@ func (hl HashLiteral) String() string {
}
func (hl HashLiteral) expressionNode() {}
type WhileExpression struct {
Token token.Token // The 'while' token
Condition Expression
Consequence *BlockStatement
}
func (we *WhileExpression) expressionNode() {}
// TokenLiteral prints the literal value of the token associated with this node
func (we *WhileExpression) TokenLiteral() string { return we.Token.Literal }
// String returns a stringified version of the AST for debugging
func (we *WhileExpression) String() string {
var out bytes.Buffer
out.WriteString("while")
out.WriteString(we.Condition.String())
out.WriteString(" ")
out.WriteString(we.Consequence.String())
return out.String()
}