private SimpleSelectorSequence ParseSimpleSelectorSequence()
        {
            ParseErrorIfEnd();

            TypeSelector typeSelector = ParseTypeSelector() ?? ParseUniversalSelector();

            List <IFilter> filters = new List <IFilter>();

            while (true)
            {
                if (End)
                {
                    break;
                }
                IFilter filterSelector = ParseIDFilter() ?? ParseClassFilter() ??
                                         ParseAttributeFilter() ?? ParsePseudoFilter() ?? ParseNegationFilter();
                if (filterSelector != null)
                {
                    filters.Add(filterSelector);
                }
                else
                {
                    break;
                }
            }
            if (typeSelector == null)
            {
                if (filters.Count == 0)
                {
                    ParseError("Expected hash, class, attrib, pseudo, or negation");
                }
                typeSelector = new UniversalSelector();
            }
            return(new SimpleSelectorSequence(typeSelector, filters));
        }
        private TypeSelector ParseUniversalSelector()
        {
            TypeSelector            selector = null;
            SelectorNamespacePrefix prefix   = ParseNamespacePrefix();

            if (CurrentToken != null && CurrentToken.Text == "*")
            {
                selector = new UniversalSelector(prefix);
                currentPosition++;
            }

            return(selector);
        }
Beispiel #3
0
        private TypeSelector ParseUniversalSelector()
        {
            TypeSelector selector = null;
            SelectorNamespacePrefix prefix = ParseNamespacePrefix();

            if (CurrentToken != null && CurrentToken.Text == "*")
            {
                selector = new UniversalSelector(prefix);
                currentPosition++;
            }

            return selector;
        }
Beispiel #4
0
        private SimpleSelectorSequence ParseSimpleSelectorSequence()
        {
            ParseErrorIfEnd();

            TypeSelector typeSelector = ParseTypeSelector() ?? ParseUniversalSelector();

            List<IFilter> filters = new List<IFilter>();
            while (true)
            {
                if (End)
                {
                    break;
                }
                IFilter filterSelector = ParseIDFilter() ?? ParseClassFilter() ??
                    ParseAttributeFilter() ?? ParsePseudoFilter() ?? ParseNegationFilter();
                if (filterSelector != null)
                {
                    filters.Add(filterSelector);
                }
                else
                {
                    break;
                }
            }
            if (typeSelector == null)
            {
                if (filters.Count == 0)
                {
                    ParseError("Expected hash, class, attrib, pseudo, or negation");
                }
                typeSelector = new UniversalSelector();
            }
            return new SimpleSelectorSequence(typeSelector, filters);
        }