Exemplo n.º 1
0
        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;
        }
Exemplo n.º 2
0
        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);
        }