本文整理汇总了C#中TokenStream.LookAhead方法的典型用法代码示例。如果您正苦于以下问题:C# TokenStream.LookAhead方法的具体用法?C# TokenStream.LookAhead怎么用?C# TokenStream.LookAhead使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TokenStream
的用法示例。
在下文中一共展示了TokenStream.LookAhead方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IsUnaryOperator
/// <summary>
/// Given token stream and operator type determines if operator is unary
/// </summary>
/// <param name="tokens">Token stream</param>
/// <param name="textProvider">Text provider</param>
/// <param name="operatorType">Operator type</param>
/// <param name="offset">Offset to look back</param>
public static bool IsUnaryOperator(TokenStream<RToken> tokens, ITextProvider textProvider,
OperatorType operatorType, int offset) {
if (!IsPossibleUnary(operatorType)) {
return false;
}
// If operator is preceded by an operator, it is then unary
var precedingTokenType = tokens.LookAhead(offset).TokenType;
switch (precedingTokenType) {
case RTokenType.Operator:
case RTokenType.OpenBrace:
case RTokenType.OpenCurlyBrace:
case RTokenType.OpenSquareBracket:
case RTokenType.OpenDoubleSquareBracket:
case RTokenType.Semicolon:
case RTokenType.Keyword:
return true;
}
return false;
}