当前位置: 首页>>代码示例>>C#>>正文


C# ITokenStream.SeekTo方法代码示例

本文整理汇总了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;
        }
开发者ID:profet23,项目名称:SassyStudio,代码行数:17,代码来源:PropertyName.cs

示例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;
        }
开发者ID:profet23,项目名称:SassyStudio,代码行数:39,代码来源:RuleSet.cs

示例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;
        }
开发者ID:profet23,项目名称:SassyStudio,代码行数:36,代码来源:PropertyDeclaration.cs


注:本文中的ITokenStream.SeekTo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。