scanner.getToken();
}
// Parse an explicit document.
Event event;
if (!scanner.checkToken(Token.ID.StreamEnd)) {
Token token = scanner.peekToken();
Mark startMark = token.getStartMark();
VersionTagsTuple tuple = processDirectives();
if (!scanner.checkToken(Token.ID.DocumentStart)) {
throw new ParserException(null, null, "expected '<document start>', but found "
+ scanner.peekToken().getTokenId(), scanner.peekToken().getStartMark());
}
token = scanner.getToken();
Mark endMark = token.getEndMark();
event = new DocumentStartEvent(startMark, endMark, true, tuple.getVersion(),
tuple.getTags());
states.push(new ParseDocumentEnd());
state = new ParseDocumentContent();
} else {
// Parse the end of the stream.
StreamEndToken token = (StreamEndToken) scanner.getToken();
event = new StreamEndEvent(token.getStartMark(), token.getEndMark());
if (!states.isEmpty()) {
throw new YAMLException("Unexpected end of stream. States left: " + states);
}
if (!marks.isEmpty()) {
throw new YAMLException("Unexpected end of stream. Marks left: " + marks);