private Token ScanAnchor(bool isAlias)
{
// Eat the indicator character.
var start = cursor.Mark();
Skip();
// Consume the value.
var value = new StringBuilder();
while (analyzer.IsAlphaNumericDashOrUnderscore())
{
value.Append(ReadCurrentCharacter());
}
// Check if length of the anchor is greater than 0 and it is followed by
// a whitespace character or one of the indicators:
// '?', ':', ',', ']', '}', '%', '@', '`'.
if (value.Length == 0 || !(analyzer.IsWhiteBreakOrZero() || analyzer.Check("?:,]}%@`")))
{
throw new SyntaxErrorException(start, cursor.Mark(), "While scanning an anchor or alias, did not find expected alphabetic or numeric character.");
}
// Create a token.
if (isAlias)
{
return new AnchorAlias(value.ToString(), start, cursor.Mark());
}
else
{
return new Anchor(value.ToString(), start, cursor.Mark());
}
}