public static void Expect(TokenList tl, TokenType type, string value)
{
Token t = tl.Next();
if ((t.Type == type) && (t.Value == value))
{
tl.Consume();
}
else
{
string expectedType = TokenTypeToString(type);
string expectedValue = value;
string foundType = TokenTypeToString(t.Type);
string foundValue = t.Value;
ExceptionType exceptionType = (type == TokenType.KEYWORD)
? ExceptionType.UnknownSymbol
: ExceptionType.Syntax;
throw new EngineException(exceptionType,
string.Format("Expected '{0}' with Value '{1}' found '{2}' with Value '{3}'", expectedType,
expectedValue, foundType, foundValue), t);
}
}