Add Block and BlockArguments field to CallExpression.
@@ -364,6 +364,8 @@ type CallExpression struct {
Token token.Token
Method string
Arguments []Expression
+ Block *BlockStatement
+ BlockArguments []Expression
}
func (ce *CallExpression) expressionNode() {}
@@ -386,6 +388,24 @@ func (ce *CallExpression) String() string {
out.WriteString(strings.Join(args, ", "))
out.WriteString(")")
+ if ce.Block != nil {
+ var blockArgs []string
+ out.WriteString(" do")
+
+ if len(ce.BlockArguments) > 0 {
+ for _, arg := range ce.BlockArguments {
+ blockArgs = append(blockArgs, arg.String())
+ }
+ out.WriteString(" |")
+ out.WriteString(strings.Join(blockArgs, ", "))
+ out.WriteString("|")
+ }
+
+ out.WriteString("\n")
+ out.WriteString(ce.Block.String())
+ out.WriteString("\nend")
+ }
+
return out.String()
}
