Extra Features
This commit is contained in:
23
ast/ast.go
23
ast/ast.go
@@ -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()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user