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


C# ITokenStream.Peek方法代码示例

本文整理汇总了C#中ITokenStream.Peek方法的典型用法代码示例。如果您正苦于以下问题:C# ITokenStream.Peek方法的具体用法?C# ITokenStream.Peek怎么用?C# ITokenStream.Peek使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ITokenStream的用法示例。


在下文中一共展示了ITokenStream.Peek方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: IsValidName

        public static bool IsValidName(ITokenStream stream)
        {
            if (stream.Current.Type == TokenType.Period)
                return stream.Peek(1).Type == TokenType.Identifier;

            return false;
        }
开发者ID:profet23,项目名称:SassyStudio,代码行数:7,代码来源:ClassName.cs

示例2: ParseCombinator

        protected virtual bool ParseCombinator(IItemFactory itemFactory, ITextProvider text, ITokenStream stream)
        {
            SelectorCombinator combinator = null;
            switch (stream.Current.Type)
            {
                case TokenType.GreaterThan:
                    combinator = new ChildCombinator();
                    break;
                case TokenType.Plus:
                    combinator = new AdjacentSiblingCombinator();
                    break;
                case TokenType.Tilde:
                    combinator = new GeneralSiblingCombinator();
                    break;
            }

            if (combinator != null)
            {
                if (combinator.Parse(itemFactory, text, stream))
                {
                    Children.Add(combinator);
                    Combinator = combinator;
                }
            }
            else if (stream.Current.Type != TokenType.OpenCurlyBrace)
            {
                // whitespace only combinator means no adding to children or parsing
                // we just want to know that there was a combinator
                if (stream.Current.Start >= (stream.Peek(-1).End + 1))
                    Combinator = new DescendantCombinator();
            }

            return Combinator != null;
        }
开发者ID:profet23,项目名称:SassyStudio,代码行数:34,代码来源:SimpleSelector.cs

示例3: CreateFunctionArgument

        static ParseItem CreateFunctionArgument(ComplexItem parent, IItemFactory itemFactory, ITextProvider text, ITokenStream stream)
        {
            if (parent is MixinReference || parent is SystemFunctionReference || parent is UserFunctionReference)
                if (VariableName.IsVariable(text, stream) && stream.Peek(2).Type == TokenType.Colon)
                    return new NamedFunctionArgument();

            return null;
        }
开发者ID:profet23,项目名称:SassyStudio,代码行数:8,代码来源:DefaultSassItemFactory.cs

示例4: Parse

        public override bool Parse(IItemFactory itemFactory, ITextProvider text, ITokenStream stream)
        {
            if (stream.Current.Type == TokenType.At && IsValidTokenType(stream.Peek(1).Type))
            {
                At = Children.AddCurrentAndAdvance(stream);
                Name = Children.AddCurrentAndAdvance(stream);
            }

            return Children.Count > 0;
        }
开发者ID:profet23,项目名称:SassyStudio,代码行数:10,代码来源:AtRule.cs

示例5: Parse

        public override bool Parse(IItemFactory itemFactory, ITextProvider text, ITokenStream stream)
        {
            if (stream.Current.Type == TokenType.Bang && IsValidModifier(text, stream.Peek(1), FlagName))
            {
                Bang = Children.AddCurrentAndAdvance(stream);
                Flag = Children.AddCurrentAndAdvance(stream);
            }

            return Children.Count > 0;
        }
开发者ID:profet23,项目名称:SassyStudio,代码行数:10,代码来源:BangModifier.cs

示例6: Parse

        public override bool Parse(IItemFactory itemFactory, ITextProvider text, ITokenStream stream)
        {
            if (stream.Current.Type == TokenType.PercentSign && stream.Peek(1).Type == TokenType.Identifier)
            {
                Prefix = Children.AddCurrentAndAdvance(stream);
                Name = Children.AddCurrentAndAdvance(stream);
            }

            return Children.Count > 0;
        }
开发者ID:profet23,项目名称:SassyStudio,代码行数:10,代码来源:PlaceholderSelectorName.cs

示例7: ParseSelectorToken

        protected override bool ParseSelectorToken(IItemFactory itemFactory, ITextProvider text, ITokenStream stream)
        {
            if (stream.Current.Type == TokenType.DoubleColon && stream.Peek(1).Type == TokenType.Identifier)
            {
                Prefix = Children.AddCurrentAndAdvance(stream, SassClassifierType.PseudoElement);
                Name = Children.AddCurrentAndAdvance(stream, SassClassifierType.PseudoElement);
            }

            return Children.Count > 0;
        }
开发者ID:profet23,项目名称:SassyStudio,代码行数:10,代码来源:PseudoElementSelector.cs

示例8: IsConditionalDirective

        public static bool IsConditionalDirective(ITextProvider text, ITokenStream stream)
        {
            if (stream.Current.Type == TokenType.At)
            {
                var name = stream.Peek(1);
                if (name.Type == TokenType.Identifier || name.Type == TokenType.Function)
                    return text.CompareOrdinal(name.Start, "if");
            }

            return false;
        }
开发者ID:profet23,项目名称:SassyStudio,代码行数:11,代码来源:ConditionalControlDirective.cs

示例9: IsConditionalContinuationDirective

        public static bool IsConditionalContinuationDirective(ITextProvider text, ITokenStream stream)
        {
            if (stream.Current.Type == TokenType.At)
            {
                var name = stream.Peek(1);
                if (name.Type == TokenType.Identifier)
                    return text.StartsWithOrdinal(name.Start, "else");
            }

            return false;
        }
开发者ID:profet23,项目名称:SassyStudio,代码行数:11,代码来源:ConditionalControlDirective.cs

示例10: IsRule

        public static bool IsRule(ITextProvider text, ITokenStream stream, string name)
        {
            if (stream.Current.Type == TokenType.At)
            {
                var nameToken = stream.Peek(1);
                if (nameToken.Type == TokenType.Identifier)
                    return text.GetText(nameToken.Start, name.Length) == name;
            }

            return false;
        }
开发者ID:profet23,项目名称:SassyStudio,代码行数:11,代码来源:AtRule.cs

示例11: ParseDirective

 protected override void ParseDirective(IItemFactory itemFactory, ITextProvider text, ITokenStream stream)
 {
     if (stream.Current.Type == TokenType.Semicolon && stream.Peek(1).Type == TokenType.Identifier)
     {
         var selector = itemFactory.CreateSpecific<PseudoClassSelector>(this, text, stream);
         if (selector.Parse(itemFactory, text, stream))
         {
             Selector = selector;
             Children.Add(selector);
         }
     }
 }
开发者ID:profet23,项目名称:SassyStudio,代码行数:12,代码来源:PageDirective.cs

示例12: ParseSelectorToken

        protected override bool ParseSelectorToken(IItemFactory itemFactory, ITextProvider text, ITokenStream stream)
        {
            if (stream.Current.Type == TokenType.Colon && stream.Peek(1).Type == TokenType.Function)
            {
                Prefix = Children.AddCurrentAndAdvance(stream);
                var function = itemFactory.CreateSpecific<PseduoFunction>(this, text, stream);
                if (function.Parse(itemFactory, text, stream))
                {
                    Function = function;
                    Children.Add(function);
                }
            }

            return Children.Count > 0;
        }
开发者ID:profet23,项目名称:SassyStudio,代码行数:15,代码来源:PseudoFunctionSelector.cs

示例13: CreateDocumentationTag

        static ParseItem CreateDocumentationTag(ComplexItem parent, IItemFactory itemFactory, ITextProvider text, ITokenStream stream)
        {
            if (!(parent is XmlDocumentationComment))
                return null;

            if (stream.Current.Type == TokenType.LessThan)
            {
                var next = stream.Peek(1);
                if (next.Type != TokenType.Identifier)
                    return null;

                switch (text.GetText(next.Start, next.Length))
                {
                    case "reference": return new FileReferenceTag();
                }
            }

            return null;
        }
开发者ID:profet23,项目名称:SassyStudio,代码行数:19,代码来源:DefaultSassItemFactory.cs

示例14: Parse

        public override bool Parse(IItemFactory itemFactory, ITextProvider text, ITokenStream stream)
        {
            if (stream.Current.Type == TokenType.Identifier && IsValidNamedRange(text.GetText(stream.Current.Start, stream.Current.Length)))
            {
                AnimationBegin = Children.AddCurrentAndAdvance(stream, SassClassifierType.Keyword);
            }
            else if (stream.Current.Type == TokenType.Number && stream.Peek(1).Type == TokenType.PercentSign)
            {
                ParseItem begin = itemFactory.Create<PercentageUnit>(this, text, stream);
                if (begin.Parse(itemFactory, text, stream))
                {
                    AnimationBegin = begin;
                    Children.Add(begin);

                    if (stream.Current.Type == TokenType.Comma)
                        Comma = Children.AddCurrentAndAdvance(stream, SassClassifierType.Punctuation);

                    ParseItem end = itemFactory.Create<PercentageUnit>(this, text, stream);
                    if (end.Parse(itemFactory, text, stream))
                    {
                        AnimationEnd = end;
                        Children.Add(end);
                    }
                }
            }

            if (AnimationBegin != null)
            {
                var block = itemFactory.CreateSpecific<RuleBlock>(this, text, stream);
                if (block.Parse(itemFactory, text, stream))
                {
                    Body = block;
                    Children.Add(block);
                }
            }

            return Children.Count > 0;
        }
开发者ID:profet23,项目名称:SassyStudio,代码行数:38,代码来源:KeyframeSelector.cs

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