private string ScanTagHandle(bool isDirective, Mark start)
{
// Check the initial '!' character.
if (!analyzer.Check('!'))
{
throw new SyntaxErrorException(start, cursor.Mark(), "While scanning a tag, did not find expected '!'.");
}
// Copy the '!' character.
var tagHandle = new StringBuilder();
tagHandle.Append(ReadCurrentCharacter());
// Copy all subsequent alphabetical and numerical characters.
while (analyzer.IsAlphaNumericDashOrUnderscore())
{
tagHandle.Append(ReadCurrentCharacter());
}
// Check if the trailing character is '!' and copy it.
if (analyzer.Check('!'))
{
tagHandle.Append(ReadCurrentCharacter());
}
else
{
// It's either the '!' tag or not really a tag handle. If it's a %TAG
// directive, it's an error. If it's a tag token, it must be a part of
// URI.
if (isDirective && (tagHandle.Length != 1 || tagHandle[0] != '!'))
{
throw new SyntaxErrorException(start, cursor.Mark(), "While parsing a tag directive, did not find expected '!'.");
}
}
return tagHandle.ToString();
}