Exemplo n.º 1
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));
        }
Exemplo n.º 2
0
        private TypeSelector ParseUniversalSelector()
        {
            TypeSelector            selector = null;
            SelectorNamespacePrefix prefix   = ParseNamespacePrefix();

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

            return(selector);
        }
Exemplo n.º 3
0
        private TypeSelector ParseUniversalSelector()
        {
            TypeSelector selector = null;
            SelectorNamespacePrefix prefix = ParseNamespacePrefix();

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

            return selector;
        }
Exemplo n.º 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);
        }