private Token ScanDirective()
{
// Eat '%'.
var start = cursor.Mark();
Skip();
// Scan the directive name.
var name = ScanDirectiveName(start);
// Is it a YAML directive?
Token directive;
switch (name)
{
case "YAML":
directive = ScanVersionDirectiveValue(start);
break;
case "TAG":
directive = ScanTagDirectiveValue(start);
break;
default:
throw new SyntaxErrorException(start, cursor.Mark(), "While scanning a directive, find uknown directive name.");
}
// Eat the rest of the line including any comments.
while (analyzer.IsWhite())
{
Skip();
}
ProcessComment();
// Check if we are at the end of the line.
if (!analyzer.IsBreakOrZero())
{
throw new SyntaxErrorException(start, cursor.Mark(), "While scanning a directive, did not find expected comment or line break.");
}
// Eat a line break.
if (analyzer.IsBreak())
{
SkipLine();
}
return directive;
}