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

     1  package ast
     2  
     3  // Stack is a stack of Node.
     4  type Stack struct {
     5  	stack []Node
     6  }
     7  
     8  func (s *Stack) Len() int {
     9  	return len(s.stack)
    10  }
    11  
    12  func (s *Stack) Push(n Node) {
    13  	s.stack = append(s.stack, n)
    14  }
    15  
    16  func (s *Stack) Pop() Node {
    17  	x := s.stack[len(s.stack)-1]
    18  	s.stack[len(s.stack)-1] = nil
    19  	s.stack = s.stack[:len(s.stack)-1]
    20  	return x
    21  }
    22  
    23  func (s *Stack) Reset() {
    24  	s.stack = nil
    25  }