github.com/franklinhu/terraform@v0.6.9-0.20151202232446-81f7fb1e6f9e/config/lang/ast/literal.go (about)

     1  package ast
     2  
     3  import (
     4  	"fmt"
     5  )
     6  
     7  // LiteralNode represents a single literal value, such as "foo" or
     8  // 42 or 3.14159. Based on the Type, the Value can be safely cast.
     9  type LiteralNode struct {
    10  	Value interface{}
    11  	Typex Type
    12  	Posx  Pos
    13  }
    14  
    15  func (n *LiteralNode) Accept(v Visitor) Node {
    16  	return v(n)
    17  }
    18  
    19  func (n *LiteralNode) Pos() Pos {
    20  	return n.Posx
    21  }
    22  
    23  func (n *LiteralNode) GoString() string {
    24  	return fmt.Sprintf("*%#v", *n)
    25  }
    26  
    27  func (n *LiteralNode) String() string {
    28  	return fmt.Sprintf("Literal(%s, %v)", n.Typex, n.Value)
    29  }
    30  
    31  func (n *LiteralNode) Type(Scope) (Type, error) {
    32  	return n.Typex, nil
    33  }