peek peeks at the next event in the event stream, puts the results into p.event and returns the event type.
()
| 97 | // peek peeks at the next event in the event stream, |
| 98 | // puts the results into p.event and returns the event type. |
| 99 | func (p *parser) peek() yaml_event_type_t { |
| 100 | if p.event.typ != yaml_NO_EVENT { |
| 101 | return p.event.typ |
| 102 | } |
| 103 | // It's curious choice from the underlying API to generally return a |
| 104 | // positive result on success, but on this case return true in an error |
| 105 | // scenario. This was the source of bugs in the past (issue #666). |
| 106 | if !yaml_parser_parse(&p.parser, &p.event) || p.parser.error != yaml_NO_ERROR { |
| 107 | p.fail() |
| 108 | } |
| 109 | return p.event.typ |
| 110 | } |
| 111 | |
| 112 | func (p *parser) fail() { |
| 113 | var where string |