Pop removes and returns a token from the TokenStack.
()
| 16 | |
| 17 | // Pop removes and returns a token from the TokenStack. |
| 18 | func (s *TokenStack) Pop() (TokenInfo, error) { |
| 19 | if len(s.stack) == 0 { |
| 20 | return TokenInfo{}, errors.New("stack is empty") |
| 21 | } |
| 22 | l := len(s.stack) |
| 23 | token := s.stack[l-1] |
| 24 | s.stack = s.stack[:l-1] |
| 25 | return token, nil |
| 26 | } |
| 27 | |
| 28 | // Len returns the current length of the TokenStack. |
| 29 | func (s *TokenStack) Len() int { |
no outgoing calls