public override bool Parse(IItemFactory itemFactory, ITextProvider text, ITokenStream stream)
        {
            if (AtRule.IsRule(text, stream, "include"))
            {
                Rule = AtRule.CreateParsed(itemFactory, text, stream);
                if (Rule != null)
                {
                    Children.Add(Rule);
                }

                Name = MixinName.CreateParsed(itemFactory, text, stream, SassClassifierType.MixinReference);
                if (Name != null)
                {
                    Children.Add(Name);
                }

                if (stream.Current.Type == TokenType.OpenFunctionBrace)
                {
                    OpenBrace = Children.AddCurrentAndAdvance(stream, SassClassifierType.FunctionBrace);

                    while (!IsTerminator(stream.Current.Type))
                    {
                        var argument = itemFactory.CreateSpecific <FunctionArgument>(this, text, stream);
                        if (argument != null && argument.Parse(itemFactory, text, stream))
                        {
                            _Arguments.Add(argument);
                            Children.Add(argument);
                        }
                        else
                        {
                            Children.AddCurrentAndAdvance(stream);
                        }
                    }
                }

                if (stream.Current.Type == TokenType.CloseFunctionBrace)
                {
                    CloseBrace = Children.AddCurrentAndAdvance(stream, SassClassifierType.FunctionBrace);
                }

                if (stream.Current.Type == TokenType.Semicolon)
                {
                    Semicolon = Children.AddCurrentAndAdvance(stream);
                }
                else if (stream.Current.Type == TokenType.OpenCurlyBrace)
                {
                    var content = new MixinContentBlock();
                    if (content.Parse(itemFactory, text, stream))
                    {
                        Content = content;
                        Children.Add(content);
                    }
                }
            }

            return(Children.Count > 0);
        }
Exemple #2
0
        public override bool Parse(IItemFactory itemFactory, ITextProvider text, ITokenStream stream)
        {
            if (AtRule.IsRule(text, stream, "mixin"))
            {
                Rule = AtRule.CreateParsed(itemFactory, text, stream);
                if (Rule != null)
                {
                    Children.Add(Rule);
                }

                Name = MixinName.CreateParsed(itemFactory, text, stream, SassClassifierType.MixinDefinition);
                if (Name != null)
                {
                    Children.Add(Name);
                }

                if (stream.Current.Type == TokenType.OpenFunctionBrace)
                {
                    OpenBrace = Children.AddCurrentAndAdvance(stream, SassClassifierType.FunctionBrace);
                }

                while (!IsArgumentTerminator(stream.Current.Type))
                {
                    var argument = itemFactory.CreateSpecific <FunctionArgumentDefinition>(this, text, stream);
                    if (argument == null || !argument.Parse(itemFactory, text, stream))
                    {
                        break;
                    }

                    _Arguments.Add(argument);
                    Children.Add(argument);
                }

                if (stream.Current.Type == TokenType.CloseFunctionBrace)
                {
                    CloseBrace = Children.AddCurrentAndAdvance(stream, SassClassifierType.FunctionBrace);
                }

                var body = new MixinDefinitionBody();
                if (body.Parse(itemFactory, text, stream))
                {
                    Body = body;
                    Children.Add(body);
                }
            }

            return(Children.Count > 0);
        }