(at int)
| 55 | } |
| 56 | |
| 57 | func (s *stack) tryPop(at int) (bool, *Token, error) { |
| 58 | // no open types |
| 59 | if len(s.open) == 0 { |
| 60 | return false, nil, nil |
| 61 | } |
| 62 | last := len(s.closeat) - 1 |
| 63 | next := s.closeat[last] |
| 64 | switch { |
| 65 | case next == 0: // indefinite |
| 66 | return false, nil, nil |
| 67 | case next == at: |
| 68 | t, err := s.pop() |
| 69 | return true, t, err |
| 70 | case next > at: |
| 71 | return false, nil, SyntaxError{"read past end of previous type"} |
| 72 | } |
| 73 | return false, nil, nil |
| 74 | } |
| 75 | |
| 76 | func NewDecoder(r io.Reader) *Decoder { |
| 77 | return &Decoder{ |