github.com/turtlemonvh/terraform@v0.6.9-0.20151204001754-8e40b6b855e8/config/lang/ast/concat.go (about)

     1  package ast
     2  
     3  import (
     4  	"bytes"
     5  	"fmt"
     6  )
     7  
     8  // Concat represents a node where the result of two or more expressions are
     9  // concatenated. The result of all expressions must be a string.
    10  type Concat struct {
    11  	Exprs []Node
    12  	Posx  Pos
    13  }
    14  
    15  func (n *Concat) Accept(v Visitor) Node {
    16  	for i, expr := range n.Exprs {
    17  		n.Exprs[i] = expr.Accept(v)
    18  	}
    19  
    20  	return v(n)
    21  }
    22  
    23  func (n *Concat) Pos() Pos {
    24  	return n.Posx
    25  }
    26  
    27  func (n *Concat) GoString() string {
    28  	return fmt.Sprintf("*%#v", *n)
    29  }
    30  
    31  func (n *Concat) String() string {
    32  	var b bytes.Buffer
    33  	for _, expr := range n.Exprs {
    34  		b.WriteString(fmt.Sprintf("%s", expr))
    35  	}
    36  
    37  	return b.String()
    38  }
    39  
    40  func (n *Concat) Type(Scope) (Type, error) {
    41  	return TypeString, nil
    42  }