package shsh

type TokenStack struct {
    buffer []*Token
    capacity int
}

func (s *TokenStack) Push(v *Token) {
    s.capacity++
    s.buffer = append(s.buffer, v)
}

func (s *TokenStack) Pop() *Token {
    if s.capacity <= 0 {
        return nil
    }

    s.capacity--
    res := s.buffer[len(s.buffer) - 1]
    s.buffer = s.buffer[:len(s.buffer) - 1]
    return res
}
