aboutsummaryrefslogtreecommitdiff
path: root/ast/ast.go
diff options
context:
space:
mode:
Diffstat (limited to 'ast/ast.go')
-rw-r--r--ast/ast.go25
1 files changed, 25 insertions, 0 deletions
diff --git a/ast/ast.go b/ast/ast.go
index 95b0986..1338f14 100644
--- a/ast/ast.go
+++ b/ast/ast.go
@@ -338,3 +338,28 @@ func (hl *HashLiteral) String() string {
return out.String()
}
+
+type MacroLiteral struct {
+ Token token.Token // The 'macro' token
+ Parameters []*Identifier
+ Body *BlockStatement
+}
+
+func (ml *MacroLiteral) expressionNode() {}
+func (ml *MacroLiteral) TokenLiteral() string { return ml.Token.Literal }
+func (ml *MacroLiteral) String() string {
+ var out bytes.Buffer
+
+ params := []string{}
+ for _, p := range ml.Parameters {
+ params = append(params, p.String())
+ }
+
+ out.WriteString(ml.TokenLiteral())
+ out.WriteString("(")
+ out.WriteString(strings.Join(params, ", "))
+ out.WriteString(") ")
+ out.WriteString(ml.Body.String())
+
+ return out.String()
+}