aboutsummaryrefslogtreecommitdiff
path: root/ast/ast.go
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2018-03-25 01:50:10 +0100
committerDimitri Sokolyuk <demon@dim13.org>2018-03-25 01:50:10 +0100
commite5ed6e13a4adbbe61317194af36c33c82b33c90f (patch)
tree790b5c954959ac852f0072f8bb2bd3137a4dac48 /ast/ast.go
parent88efa3eb20001d1dc23e6b5a8413ea7adf10294e (diff)
lost chapter
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()
+}