closures and they can recurse!!!
This commit is contained in:
@@ -2,6 +2,7 @@ package ast
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"monkey/token"
|
||||
"strings"
|
||||
)
|
||||
@@ -220,6 +221,7 @@ type FunctionLiteral struct {
|
||||
Token token.Token // The 'fn' token
|
||||
Parameters []*Identifier
|
||||
Body *BlockStatement
|
||||
Name string
|
||||
}
|
||||
|
||||
func (fl *FunctionLiteral) expressionNode() {}
|
||||
@@ -233,6 +235,9 @@ func (fl *FunctionLiteral) String() string {
|
||||
}
|
||||
|
||||
out.WriteString(fl.TokenLiteral())
|
||||
if fl.Name != "" {
|
||||
out.WriteString(fmt.Sprintf("<%s>", fl.Name))
|
||||
}
|
||||
out.WriteString("(")
|
||||
out.WriteString(strings.Join(params, ", "))
|
||||
out.WriteString(") ")
|
||||
|
||||
Reference in New Issue
Block a user