本文整理汇总了C#中ITokenStream.SeekTo方法的典型用法代码示例。如果您正苦于以下问题:C# ITokenStream.SeekTo方法的具体用法?C# ITokenStream.SeekTo怎么用?C# ITokenStream.SeekTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITokenStream
的用法示例。
在下文中一共展示了ITokenStream.SeekTo方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IsValidName
public static bool IsValidName(ITokenStream stream)
{
int start = stream.Position;
var lastToken = stream.Current;
bool valid = false;
while (IsValidNameComponent(stream.Current.Type))
{
valid = true;
if (stream.Advance().Start != lastToken.End)
break;
lastToken = stream.Current;
}
stream.SeekTo(start);
return valid;
}
示例2: IsValidRuleSet
public static bool IsValidRuleSet(ITokenStream stream)
{
int position = stream.Position;
try
{
bool seenColon = false;
var previous = stream.Current;
while (stream.Advance().Type != TokenType.EndOfFile)
{
var curent = stream.Current;
// selector body
if (curent.Type == TokenType.OpenCurlyBrace) return true;
// parent terminator
if (curent.Type == TokenType.CloseCurlyBrace) return false;
// property terminator
if (curent.Type == TokenType.Semicolon) return false;
if (curent.Type == TokenType.Colon)
{
seenColon = true;
var next = stream.Advance();
// if space after colon, then we are in a property
if (curent.End != next.Start) return false;
// if next value is not identifer or function, then we are a property
if (!(next.Type == TokenType.Identifier || next.Type == TokenType.Function)) return false;
}
// check for space
if (curent.Start != previous.End && !seenColon) return true;
previous = stream.Current;
}
}
finally
{
stream.SeekTo(position);
}
return false;
}
示例3: IsDeclaration
public static bool IsDeclaration(ITextProvider text, ITokenStream stream)
{
int position = stream.Position;
bool validPropertyName = false;
while (true)
{
var last = stream.Current;
var next = stream.Advance();
if (next.Start > last.End || IsDeclarationTerminator(last.Type))
break;
if (next.Type == TokenType.Colon)
{
var value = stream.Peek(1);
switch (value.Type)
{
case TokenType.Ampersand:
validPropertyName = false;
break;
case TokenType.Identifier:
case TokenType.Function:
validPropertyName = value.Start > next.End || !IsPseudoSelector(text, value);
break;
default:
validPropertyName = true;
break;
}
break;
}
}
stream.SeekTo(position);
return validPropertyName;
}