Пример #1
0
 protected virtual void ParseAfterName(ItemFactory itemFactory, ITextProvider text, TokenStream tokens)
 {
     if (HashName.Length < 2) // need more than just a "#"
     {
         HashName.AddParseError(ParseErrorType.IdMissing, ParseErrorLocation.AfterItem);
     }
 }
        public override bool Parse(ItemFactory itemFactory, ITextProvider text, TokenStream tokens)
        {
            ParseArgument(itemFactory, text, tokens);

            if (tokens.CurrentToken.TokenType == CssTokenType.Comma)
            {
                Comma = Children.AddCurrentAndAdvance(tokens, null);

                if (ArgumentItems.Count == 0)
                {
                    Comma.AddParseError(ParseErrorType.FunctionArgumentMissing, ParseErrorLocation.BeforeItem);
                }
            }

            return(Children.Count > 0);
        }
Пример #3
0
        public override bool Parse(ItemFactory itemFactory, ITextProvider text, TokenStream tokens)
        {
            while (!IsAtSelectorGroupTerminator(tokens))
            {
                SimpleSelector simpleSelector = itemFactory.CreateSpecific <SimpleSelector>(this);
                if (!simpleSelector.Parse(itemFactory, text, tokens))
                {
                    break;
                }

                SimpleSelectors.Add(simpleSelector);
                Children.Add(simpleSelector);
            }

            if (tokens.CurrentToken.TokenType == CssTokenType.Comma)
            {
                Comma = Children.AddCurrentAndAdvance(tokens, CssClassifierContextType.Punctuation);

                if (SimpleSelectors.Count == 0)
                {
                    Comma.AddParseError(ParseErrorType.SelectorBeforeCommaMissing, ParseErrorLocation.BeforeItem);
                }
            }

            if (SimpleSelectors.Count > 0)
            {
                SimpleSelector lastSimpleSelector = SimpleSelectors[SimpleSelectors.Count - 1];

                if (lastSimpleSelector.SelectorCombineOperator != null)
                {
                    lastSimpleSelector.AddParseError(ParseErrorType.SelectorAfterCombineOperatorMissing, ParseErrorLocation.AfterItem);
                }
            }

            return(Children.Count > 0);
        }