本文整理汇总了C#中TokenType.Contains方法的典型用法代码示例。如果您正苦于以下问题:C# TokenType.Contains方法的具体用法?C# TokenType.Contains怎么用?C# TokenType.Contains使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TokenType
的用法示例。
在下文中一共展示了TokenType.Contains方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Expect
private void Expect(TokenType[] types, bool identifierAllowed = true)
{
var next = _scanner.PeekToken();
if (next == null)
{
throw new EvaluatorException(_scanner.Column,
string.Format("Unexpected end of input, instead of token(s): {0}{1}.", identifierAllowed ? "'IDENT', " : "" ,Token.StringOf(types)));
}
if ((identifierAllowed && next.Type == TokenType.Identifier) ||
types.Contains(next.Type))
{
Consume();
}
else
{
throw new EvaluatorException(_scanner.Column,
string.Format("Syntax error, expected token(s): {0}{1}; but found '{2}'.", identifierAllowed ? "'IDENT', " : "", Token.StringOf(types), Token.StringOf(next)));
}
}
示例2: Ensure
private void Ensure(TokenType[] types, bool identifierAllowed = true)
{
if (_current == null)
{
throw new EvaluatorException(_scanner.Column,
string.Format("Unexpected end of input, instead of token(s): {0}{1}.", identifierAllowed ? "'IDENT', " : "", Token.StringOf(types)));
}
if (!((identifierAllowed && _current.Type == TokenType.Identifier) ||
types.Contains(_current.Type)))
{
throw new EvaluatorException(_scanner.Column,
string.Format("Syntax error, expected token(s): 'IDENT', {0}; but found '{1}'.", Token.StringOf(types), Token.StringOf(_current)));
}
}