Ejemplo n.º 1
0
        public override bool Parse(IItemFactory itemFactory, ITextProvider text, ITokenStream stream)
        {
            //if (IsDeclaration(text, stream))
            if (stream.Current.Type == TokenType.Identifier || stream.Current.Type == TokenType.OpenInterpolation)
            {
                var name = itemFactory.CreateSpecific<PropertyName>(this, text, stream);
                if (name.Parse(itemFactory, text, stream))
                {
                    Name = name;
                    Children.Add(name);
                }

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

                while (!IsValueTerminator(stream.Current.Type))
                {
                    ParseItem value;
                    if (itemFactory.TryCreateParsedOrDefault(this, text, stream, out value))
                    {
                        Values.Add(value);
                        Children.Add(value);

                        // bind all unknown values as property values
                        if (value.ClassifierType == SassClassifierType.Default && value is TokenItem)
                            value.ClassifierType = SassClassifierType.PropertyValue;
                    }
                }

                // nested property block support
                if (stream.Current.Type == TokenType.OpenCurlyBrace)
                {
                    var block = itemFactory.CreateSpecific<NestedPropertyBlock>(this, text, stream);
                    if (block.Parse(itemFactory, text, stream))
                        Children.Add(block);
                }

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

                if (stream.Current.Type == TokenType.Semicolon)
                    Semicolon = Children.AddCurrentAndAdvance(stream, SassClassifierType.Punctuation);
            }

            return Children.Count > 0;
        }
Ejemplo n.º 2
0
        public override bool Parse(IItemFactory itemFactory, ITextProvider text, ITokenStream stream)
        {
            //if (IsDeclaration(text, stream))
            if (stream.Current.Type == TokenType.Identifier || stream.Current.Type == TokenType.OpenInterpolation)
            {
                var name = itemFactory.CreateSpecific <PropertyName>(this, text, stream);
                if (name.Parse(itemFactory, text, stream))
                {
                    Name = name;
                    Children.Add(name);
                }

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

                while (!IsValueTerminator(stream.Current.Type))
                {
                    ParseItem value;
                    if (itemFactory.TryCreateParsedOrDefault(this, text, stream, out value))
                    {
                        Values.Add(value);
                        Children.Add(value);

                        // bind all unknown values as property values
                        if (value.ClassifierType == SassClassifierType.Default && value is TokenItem)
                        {
                            value.ClassifierType = SassClassifierType.PropertyValue;
                        }
                    }
                }

                // nested property block support
                if (stream.Current.Type == TokenType.OpenCurlyBrace)
                {
                    var block = itemFactory.CreateSpecific <NestedPropertyBlock>(this, text, stream);
                    if (block.Parse(itemFactory, text, stream))
                    {
                        Children.Add(block);
                    }
                }

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

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

            return(Children.Count > 0);
        }