documentVersion = null;
while (tokenizer.peekNextTokenType() == DIRECTIVE) {
DirectiveToken token = (DirectiveToken)tokenizer.getNextToken();
if (token.getDirective().equals("YAML")) {
if (documentVersion != null) throw new ParserException("Duplicate YAML directive.");
documentVersion = new Version(token.getValue());
if (documentVersion.major != 1)
throw new ParserException("Unsupported YAML version (1.x is required): " + documentVersion);
} else if (token.getDirective().equals("TAG")) {
String[] values = token.getValue().split(" ");
String handle = values[0];
String prefix = values[1];
if (tagHandles.containsKey(handle)) throw new ParserException("Duplicate tag directive: " + handle);
tagHandles.put(handle, prefix);
}
}
Version version;
if (documentVersion != null)
version = documentVersion;
else
version = defaultVersion;