コード例 #1
0
        public override bool Parse(IItemFactory itemFactory, ITextProvider text, ITokenStream stream)
        {
            var name = new VariableName(SassClassifierType.VariableDefinition);

            if (name.Parse(itemFactory, text, stream))
            {
                Name = name;
                Children.Add(name);
            }

            if (stream.Current.Type == TokenType.Colon)
            {
                Colon = Children.AddCurrentAndAdvance(stream);
            }

            while (!IsValueTerminator(Mode, stream))
            {
                ParseItem item;
                if (itemFactory.TryCreateParsedOrDefault(this, text, stream, out item))
                {
                    Values.Add(item);
                    Children.Add(item);
                }
            }

            if (stream.Current.Type == TokenType.Bang)
            {
                var modifier = new DefaultModifier();
                if (modifier.Parse(itemFactory, text, stream))
                {
                    Modifier = modifier;
                    Children.Add(modifier);
                }
                else
                {
                    Children.AddCurrentAndAdvance(stream);
                }
            }

            if (stream.Current.Type == TokenType.Semicolon)
            {
                Semicolon = Children.AddCurrentAndAdvance(stream);
            }

            return(Children.Count > 0);
        }
コード例 #2
0
        public override bool Parse(IItemFactory itemFactory, ITextProvider text, ITokenStream stream)
        {
            var name = new VariableName(SassClassifierType.VariableDefinition);
            if (name.Parse(itemFactory, text, stream))
            {
                Name = name;
                Children.Add(name);
            }

            if (stream.Current.Type == TokenType.Colon)
                Colon = Children.AddCurrentAndAdvance(stream);

            while (!IsValueTerminator(Mode, stream))
            {
                ParseItem item;
                if (itemFactory.TryCreateParsedOrDefault(this, text, stream, out item))
                {
                    Values.Add(item);
                    Children.Add(item);
                }
            }

            if (stream.Current.Type == TokenType.Bang)
            {
                var modifier = new DefaultModifier();
                if (modifier.Parse(itemFactory, text, stream))
                {
                    Modifier = modifier;
                    Children.Add(modifier);
                }
                else
                {
                    Children.AddCurrentAndAdvance(stream);
                }
            }

            if (stream.Current.Type == TokenType.Semicolon)
                Semicolon = Children.AddCurrentAndAdvance(stream);

            return Children.Count > 0;
        }