Exemplo n.º 1
0
        public override bool Parse(IItemFactory itemFactory, ITextProvider text, ITokenStream stream)
        {
            while (!IsSelectorTerminator(stream.Current.Type))
            {
                var selector = itemFactory.CreateSpecific <SelectorGroup>(this, text, stream);
                if (!selector.Parse(itemFactory, text, stream))
                {
                    break;
                }

                _Selectors.Add(selector);
                Children.Add(selector);

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

            if (stream.Current.Type == TokenType.OpenCurlyBrace)
            {
                var block = itemFactory.CreateSpecific <RuleBlock>(this, text, stream);
                if (block.Parse(itemFactory, text, stream))
                {
                    Block = block;
                    Children.Add(block);
                }
            }

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

                while (!IsTerminator(stream.Current.Type))
                {
                    var query = itemFactory.CreateSpecific<MediaQuery>(this, text, stream);
                    if (query.Parse(itemFactory, text, stream))
                    {
                        _Queries.Add(query);
                        Children.Add(query);
                    }
                    else
                    {
                        Children.AddCurrentAndAdvance(stream);
                    }
                }

                var block = itemFactory.CreateSpecific<MediaQueryBlock>(this, text, stream);
                if (block.Parse(itemFactory, text, stream))
                {
                    Body = block;
                    Children.Add(block);
                }
            }

            return Children.Count > 0;
        }
Exemplo n.º 3
0
        public override bool Parse(IItemFactory itemFactory, ITextProvider text, ITokenStream stream)
        {
            if (AtRule.IsRule(text, stream, "media"))
            {
                Rule = AtRule.CreateParsed(itemFactory, text, stream);
                if (Rule != null)
                {
                    Children.Add(Rule);
                }

                while (!IsTerminator(stream.Current.Type))
                {
                    var query = itemFactory.CreateSpecific <MediaQuery>(this, text, stream);
                    if (query.Parse(itemFactory, text, stream))
                    {
                        _Queries.Add(query);
                        Children.Add(query);
                    }
                    else
                    {
                        Children.AddCurrentAndAdvance(stream);
                    }
                }

                var block = itemFactory.CreateSpecific <MediaQueryBlock>(this, text, stream);
                if (block.Parse(itemFactory, text, stream))
                {
                    Body = block;
                    Children.Add(block);
                }
            }

            return(Children.Count > 0);
        }
Exemplo n.º 4
0
        public override bool Parse(IItemFactory itemFactory, ITextProvider text, ITokenStream stream)
        {
            if (stream.Current.Type == TokenType.LessThan)
            {
                OpenTag = Children.AddCurrentAndAdvance(stream, SassClassifierType.XmlDocumentationTag);
                if (stream.Current.Type == TokenType.Identifier)
                {
                    Name = Children.AddCurrentAndAdvance(stream, SassClassifierType.XmlDocumentationTag);

                    while (!IsTagTerminator(stream.Current.Type))
                    {
                        var attribute = itemFactory.CreateSpecific<XmlAttribute>(this, text, stream);
                        if (!attribute.Parse(itemFactory, text, stream))
                            break;

                        Children.Add(attribute);
                        _Attributes.Add(attribute);
                        OnAttributeParsed(attribute, text);
                    }
                }

                if (stream.Current.Type == TokenType.Slash)
                    CloseSlash = Children.AddCurrentAndAdvance(stream, SassClassifierType.XmlDocumentationTag);

                if (stream.Current.Type == TokenType.GreaterThan)
                    CloseTag = Children.AddCurrentAndAdvance(stream, SassClassifierType.XmlDocumentationTag);
            }

            return Children.Count > 0;
        }
Exemplo n.º 5
0
        public override bool Parse(IItemFactory itemFactory, ITextProvider text, ITokenStream stream)
        {
            if (stream.Current.Type == TokenType.XmlDocumentationComment)
            {
                Opening = Children.AddCurrentAndAdvance(stream, SassClassifierType.XmlDocumentationTag);

                // look for <reference
                if (stream.Current.Type == TokenType.LessThan)
                {
                    var tag = itemFactory.CreateSpecific <XmlDocumentationTag>(this, text, stream);
                    if (tag.Parse(itemFactory, text, stream))
                    {
                        Tag = tag;
                        Children.Add(tag);
                    }
                    else
                    {
                        Children.AddCurrentAndAdvance(stream, SassClassifierType.XmlDocumentationComment);
                    }
                }
                else
                {
                    while (!IsCommentTerminator(stream.Current.Type))
                    {
                        Children.AddCurrentAndAdvance(stream, SassClassifierType.XmlDocumentationComment);
                    }
                }

                //if (stream.Current.Type == TokenType.NewLine)
                //    NewLine = Children.AddCurrentAndAdvance(stream);
            }

            return(Children.Count > 0);
        }
Exemplo n.º 6
0
        public override bool Parse(IItemFactory itemFactory, ITextProvider text, ITokenStream stream)
        {
            if (AtRule.IsRule(text, stream, "each"))
            {
                ParseRule(itemFactory, text, stream);
                while (!IsListTerminator(stream.Current.Type))
                {
                    var item = itemFactory.CreateSpecific<ListItem>(this, text, stream);
                    if (item != null && item.Parse(itemFactory, text, stream))
                    {
                        _Items.Add(item);
                        Children.Add(item);
                    }
                    else
                    {
                        // bad news bears
                        Children.AddCurrentAndAdvance(stream);
                    }
                }

                ParseBody(itemFactory, text, stream);
            }

            return Children.Count > 0;
        }
Exemplo n.º 7
0
        public override bool Parse(IItemFactory itemFactory, ITextProvider text, ITokenStream stream)
        {
            if (AtRule.IsRule(text, stream, "each"))
            {
                ParseRule(itemFactory, text, stream);
                while (!IsListTerminator(stream.Current.Type))
                {
                    var item = itemFactory.CreateSpecific <ListItem>(this, text, stream);
                    if (item != null && item.Parse(itemFactory, text, stream))
                    {
                        _Items.Add(item);
                        Children.Add(item);
                    }
                    else
                    {
                        // bad news bears
                        Children.AddCurrentAndAdvance(stream);
                    }
                }

                ParseBody(itemFactory, text, stream);
            }

            return(Children.Count > 0);
        }
Exemplo n.º 8
0
        public override bool Parse(IItemFactory itemFactory, ITextProvider text, ITokenStream stream)
        {
            if (stream.Current.Type == TokenType.Identifier && IsModifier(text.GetText(stream.Current.Start, stream.Current.Length)))
                Modifier = Children.AddCurrentAndAdvance(stream);

            ParseItem mediaType;
            if (itemFactory.TryCreateParsedOrDefault(this, text, stream, out mediaType))
            {
                MediaType = mediaType;
                Children.Add(mediaType);
            }

            while (!IsTerminator(text, stream))
            {
                var expression = itemFactory.CreateSpecific<MediaQueryExpression>(this, text, stream);
                if (expression.Parse(itemFactory, text, stream))
                {
                    _Expressions.Add(expression);
                    Children.Add(expression);
                }
                else
                {
                    Children.AddCurrentAndAdvance(stream);
                }
            }

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

            return Children.Count > 0;
        }
        public override bool Parse(IItemFactory itemFactory, ITextProvider text, ITokenStream stream)
        {
            if (stream.Current.Type == TokenType.XmlDocumentationComment)
            {
                Opening = Children.AddCurrentAndAdvance(stream, SassClassifierType.XmlDocumentationTag);

                // look for <reference
                if (stream.Current.Type == TokenType.LessThan)
                {
                    var tag = itemFactory.CreateSpecific<XmlDocumentationTag>(this, text, stream);
                    if (tag.Parse(itemFactory, text, stream))
                    {
                        Tag = tag;
                        Children.Add(tag);
                    }
                    else
                    {
                        Children.AddCurrentAndAdvance(stream, SassClassifierType.XmlDocumentationComment);
                    }
                }
                else
                {
                    while (!IsCommentTerminator(stream.Current.Type))
                    {
                        Children.AddCurrentAndAdvance(stream, SassClassifierType.XmlDocumentationComment);
                    }
                }

                //if (stream.Current.Type == TokenType.NewLine)
                //    NewLine = Children.AddCurrentAndAdvance(stream);
            }

            return Children.Count > 0;
        }
Exemplo n.º 10
0
        public override bool Parse(IItemFactory itemFactory, ITextProvider text, ITokenStream stream)
        {
            if (AtRule.IsRule(text, stream, "extend"))
            {
                Rule = AtRule.CreateParsed(itemFactory, text, stream);
                if (Rule != null)
                {
                    Children.Add(Rule);
                }

                var selector = itemFactory.CreateSpecific <SelectorGroup>(this, text, stream);
                if (selector.Parse(itemFactory, text, stream))
                {
                    Selector = selector;
                    Children.Add(selector);
                }

                if (stream.Current.Type == TokenType.Bang)
                {
                    var modifier = new OptionalModifier();
                    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);
        }
Exemplo n.º 11
0
        public override bool Parse(IItemFactory itemFactory, ITextProvider text, ITokenStream stream)
        {
            while (!IsSelectorTerminator(stream.Current.Type))
            {
                var selector = itemFactory.CreateSpecific<SelectorGroup>(this, text, stream);
                if (!selector.Parse(itemFactory, text, stream))
                    break;

                _Selectors.Add(selector);
                Children.Add(selector);

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

            if (stream.Current.Type == TokenType.OpenCurlyBrace)
            {
                var block = itemFactory.CreateSpecific<RuleBlock>(this, text, stream);
                if (block.Parse(itemFactory, text, stream))
                {
                    Block = block;
                    Children.Add(block);
                }
            }

            return Children.Count > 0;
        }
Exemplo n.º 12
0
        public override bool Parse(IItemFactory itemFactory, ITextProvider text, ITokenStream stream)
        {
            if (AtRule.IsRule(text, stream, "extend"))
            {
                Rule = AtRule.CreateParsed(itemFactory, text, stream);
                if (Rule != null)
                    Children.Add(Rule);

                var selector = itemFactory.CreateSpecific<SelectorGroup>(this, text, stream);
                if (selector.Parse(itemFactory, text, stream))
                {
                    Selector = selector;
                    Children.Add(selector);
                }

                if (stream.Current.Type == TokenType.Bang)
                {
                    var modifier = new OptionalModifier();
                    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;
        }
Exemplo n.º 13
0
 protected virtual void ParseBlock(IItemFactory itemFactory, ITextProvider text, ITokenStream stream)
 {
     var block = itemFactory.CreateSpecific<RuleBlock>(this, text, stream);
     if (block.Parse(itemFactory, text, stream))
     {
         Body = block;
         Children.Add(block);
     }
 }
Exemplo n.º 14
0
 protected override void ParseBlock(IItemFactory itemFactory, ITextProvider text, ITokenStream stream)
 {
     var block = itemFactory.CreateSpecific<KeyframeRuleBlock>(this, text, stream);
     if (block.Parse(itemFactory, text, stream))
     {
         KeyframeList = block;
         Children.Add(block);
     }
 }
Exemplo n.º 15
0
        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);
        }
Exemplo n.º 16
0
        protected virtual void ParseBlock(IItemFactory itemFactory, ITextProvider text, ITokenStream stream)
        {
            var block = itemFactory.CreateSpecific <RuleBlock>(this, text, stream);

            if (block.Parse(itemFactory, text, stream))
            {
                Body = block;
                Children.Add(block);
            }
        }
Exemplo n.º 17
0
        protected override void ParseBlock(IItemFactory itemFactory, ITextProvider text, ITokenStream stream)
        {
            var block = itemFactory.CreateSpecific <KeyframeRuleBlock>(this, text, stream);

            if (block.Parse(itemFactory, text, stream))
            {
                KeyframeList = block;
                Children.Add(block);
            }
        }
Exemplo n.º 18
0
        protected override bool ParseSelectorToken(IItemFactory itemFactory, ITextProvider text, ITokenStream stream)
        {
            var name = itemFactory.CreateSpecific<IdName>(this, text, stream);
            if (name.Parse(itemFactory, text, stream))
            {
                Name = name;
                Children.Add(name);
            }

            return Children.Count > 0;
        }
Exemplo n.º 19
0
 protected override void ParseDirective(IItemFactory itemFactory, ITextProvider text, ITokenStream stream)
 {
     if (stream.Current.Type == TokenType.Semicolon && stream.Peek(1).Type == TokenType.Identifier)
     {
         var selector = itemFactory.CreateSpecific <PseudoClassSelector>(this, text, stream);
         if (selector.Parse(itemFactory, text, stream))
         {
             Selector = selector;
             Children.Add(selector);
         }
     }
 }
Exemplo n.º 20
0
        protected override void ParseBody(IItemFactory itemFactory, ITextProvider text, ITokenStream stream)
        {
            while (!IsTerminator(stream.Current.Type))
            {
                var selector = itemFactory.CreateSpecific<KeyframeSelector>(this, text, stream);
                if (!selector.Parse(itemFactory, text, stream))
                    break;

                Children.Add(selector);
                _Selectors.Add(selector);
            }
        }
Exemplo n.º 21
0
 protected override void ParseDirective(IItemFactory itemFactory, ITextProvider text, ITokenStream stream)
 {
     if (stream.Current.Type == TokenType.Semicolon && stream.Peek(1).Type == TokenType.Identifier)
     {
         var selector = itemFactory.CreateSpecific<PseudoClassSelector>(this, text, stream);
         if (selector.Parse(itemFactory, text, stream))
         {
             Selector = selector;
             Children.Add(selector);
         }
     }
 }
Exemplo n.º 22
0
        protected override bool ParseSelectorToken(IItemFactory itemFactory, ITextProvider text, ITokenStream stream)
        {
            var name = itemFactory.CreateSpecific <IdName>(this, text, stream);

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

            return(Children.Count > 0);
        }
Exemplo n.º 23
0
        protected override void ParseBody(IItemFactory itemFactory, ITextProvider text, ITokenStream stream)
        {
            while (!IsTerminator(stream.Current.Type))
            {
                var selector = itemFactory.CreateSpecific<KeyframeSelector>(this, text, stream);
                if (!selector.Parse(itemFactory, text, stream))
                    break;

                Children.Add(selector);
                _Selectors.Add(selector);
            }
        }
Exemplo n.º 24
0
        protected virtual void ParseArguments(IItemFactory itemFactory, ITextProvider text, ITokenStream stream)
        {
            while (!IsTerminator(stream.Current.Type))
            {
                var argument = itemFactory.CreateSpecific <FunctionArgument>(this, text, stream);
                if (argument == null || !argument.Parse(itemFactory, text, stream))
                {
                    break;
                }

                Arguments.Add(argument);
                Children.Add(argument);
            }
        }
        protected override bool ParseSelectorToken(IItemFactory itemFactory, ITextProvider text, ITokenStream stream)
        {
            if (stream.Current.Type == TokenType.OpenInterpolation)
            {
                var interpolation = itemFactory.CreateSpecific <StringInterpolation>(this, text, stream);
                if (interpolation.Parse(itemFactory, text, stream))
                {
                    Interpolation = interpolation;
                    Children.Add(interpolation);
                }
            }

            return(Children.Count > 0);
        }
        protected override bool ParseSelectorToken(IItemFactory itemFactory, ITextProvider text, ITokenStream stream)
        {
            if (stream.Current.Type == TokenType.OpenInterpolation)
            {
                var interpolation = itemFactory.CreateSpecific<StringInterpolation>(this, text, stream);
                if (interpolation.Parse(itemFactory, text, stream))
                {
                    Interpolation = interpolation;
                    Children.Add(interpolation);
                }
            }

            return Children.Count > 0;
        }
Exemplo n.º 27
0
        protected override bool ParseSelectorToken(IItemFactory itemFactory, ITextProvider text, ITokenStream stream)
        {
            if (stream.Current.Type == TokenType.Colon && stream.Peek(1).Type == TokenType.Function)
            {
                Prefix = Children.AddCurrentAndAdvance(stream);
                var function = itemFactory.CreateSpecific <PseduoFunction>(this, text, stream);
                if (function.Parse(itemFactory, text, stream))
                {
                    Function = function;
                    Children.Add(function);
                }
            }

            return(Children.Count > 0);
        }
Exemplo n.º 28
0
        protected override bool ParseSelectorToken(IItemFactory itemFactory, ITextProvider text, ITokenStream stream)
        {
            if (stream.Current.Type == TokenType.Colon && stream.Peek(1).Type == TokenType.Function)
            {
                Prefix = Children.AddCurrentAndAdvance(stream);
                var function = itemFactory.CreateSpecific<PseduoFunction>(this, text, stream);
                if (function.Parse(itemFactory, text, stream))
                {
                    Function = function;
                    Children.Add(function);
                }
            }

            return Children.Count > 0;
        }
Exemplo n.º 29
0
        public override bool Parse(IItemFactory itemFactory, ITextProvider text, ITokenStream stream)
        {
            if (AtRule.IsRule(text, stream, "function"))
            {
                Rule = AtRule.CreateParsed(itemFactory, text, stream);
                if (Rule != null)
                {
                    Children.Add(Rule);
                }

                if (stream.Current.Type == TokenType.Function)
                {
                    Name         = Children.AddCurrentAndAdvance(stream, SassClassifierType.UserFunctionDefinition);
                    FunctionName = text.GetText(Name.Start, Name.Length);
                }

                if (stream.Current.Type == TokenType.OpenFunctionBrace)
                {
                    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)
                {
                    Children.AddCurrentAndAdvance(stream, SassClassifierType.FunctionBrace);
                }

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

            return(Children.Count > 0);
        }
Exemplo n.º 30
0
        protected override void ParseImport(IItemFactory itemFactory, ITextProvider text, ITokenStream stream)
        {
            while (!IsTerminator(stream.Current.Type))
            {
                if (stream.Current.Type == TokenType.NewLine)
                {
                    Children.AddCurrentAndAdvance(stream);
                    continue;
                }

                var file = itemFactory.CreateSpecific<ImportFile>(this, text, stream) ?? new ImportFile();
                if (!file.Parse(itemFactory, text, stream))
                    break;

                Children.Add(file);
                Files.Add(file);
            }
        }
Exemplo n.º 31
0
        public override bool Parse(IItemFactory itemFactory, ITextProvider text, ITokenStream stream)
        {
            if (IsNamedArgument(text, stream))
            {
                var variable = itemFactory.CreateSpecific<VariableReference>(this, text, stream);
                if (variable.Parse(itemFactory, text, stream))
                {
                    Variable = variable;
                    Children.Add(variable);
                }

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

                base.Parse(itemFactory, text, stream);
                return true;
            }

            return false;
        }
Exemplo n.º 32
0
        protected override void ParseImport(IItemFactory itemFactory, ITextProvider text, ITokenStream stream)
        {
            while (!IsTerminator(stream.Current.Type))
            {
                if (stream.Current.Type == TokenType.NewLine)
                {
                    Children.AddCurrentAndAdvance(stream);
                    continue;
                }

                var file = itemFactory.CreateSpecific <ImportFile>(this, text, stream) ?? new ImportFile();
                if (!file.Parse(itemFactory, text, stream))
                {
                    break;
                }

                Children.Add(file);
                Files.Add(file);
            }
        }
Exemplo n.º 33
0
        public override bool Parse(IItemFactory itemFactory, ITextProvider text, ITokenStream stream)
        {
            if (stream.Current.Type == TokenType.Identifier && IsValidNamedRange(text.GetText(stream.Current.Start, stream.Current.Length)))
            {
                AnimationBegin = Children.AddCurrentAndAdvance(stream, SassClassifierType.Keyword);
            }
            else if (stream.Current.Type == TokenType.Number && stream.Peek(1).Type == TokenType.PercentSign)
            {
                ParseItem begin = itemFactory.Create <PercentageUnit>(this, text, stream);
                if (begin.Parse(itemFactory, text, stream))
                {
                    AnimationBegin = begin;
                    Children.Add(begin);

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

                    ParseItem end = itemFactory.Create <PercentageUnit>(this, text, stream);
                    if (end.Parse(itemFactory, text, stream))
                    {
                        AnimationEnd = end;
                        Children.Add(end);
                    }
                }
            }

            if (AnimationBegin != null)
            {
                var block = itemFactory.CreateSpecific <RuleBlock>(this, text, stream);
                if (block.Parse(itemFactory, text, stream))
                {
                    Body = block;
                    Children.Add(block);
                }
            }

            return(Children.Count > 0);
        }
Exemplo n.º 34
0
        public override bool Parse(IItemFactory itemFactory, ITextProvider text, ITokenStream stream)
        {
            if (IsNamedArgument(text, stream))
            {
                var variable = itemFactory.CreateSpecific <VariableReference>(this, text, stream);
                if (variable.Parse(itemFactory, text, stream))
                {
                    Variable = variable;
                    Children.Add(variable);
                }

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

                base.Parse(itemFactory, text, stream);
                return(true);
            }

            return(false);
        }
Exemplo n.º 35
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;
        }
Exemplo n.º 36
0
        public override bool Parse(IItemFactory itemFactory, ITextProvider text, ITokenStream stream)
        {
            if (stream.Current.Type == TokenType.Identifier && IsValidNamedRange(text.GetText(stream.Current.Start, stream.Current.Length)))
            {
                AnimationBegin = Children.AddCurrentAndAdvance(stream, SassClassifierType.Keyword);
            }
            else if (stream.Current.Type == TokenType.Number && stream.Peek(1).Type == TokenType.PercentSign)
            {
                ParseItem begin = itemFactory.Create<PercentageUnit>(this, text, stream);
                if (begin.Parse(itemFactory, text, stream))
                {
                    AnimationBegin = begin;
                    Children.Add(begin);

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

                    ParseItem end = itemFactory.Create<PercentageUnit>(this, text, stream);
                    if (end.Parse(itemFactory, text, stream))
                    {
                        AnimationEnd = end;
                        Children.Add(end);
                    }
                }
            }

            if (AnimationBegin != null)
            {
                var block = itemFactory.CreateSpecific<RuleBlock>(this, text, stream);
                if (block.Parse(itemFactory, text, stream))
                {
                    Body = block;
                    Children.Add(block);
                }
            }

            return Children.Count > 0;
        }
Exemplo n.º 37
0
        public override bool Parse(IItemFactory itemFactory, ITextProvider text, ITokenStream stream)
        {
            if ((IsConditionalDirective(text, stream) || IsConditionalContinuationDirective(text, stream)))
            {
                ParseRule(itemFactory, text, stream);

                while (!IsConditionTerminator(stream.Current.Type))
                {
                    ParseItem item;
                    if (itemFactory.TryCreateParsedOrDefault(this, text, stream, out item))
                    {
                        Children.Add(item);
                        ConditionStatements.Add(item);
                    }
                    else
                    {
                        Children.AddCurrentAndAdvance(stream);
                    }
                }

                ParseBody(itemFactory, text, stream);

                while (IsConditionalContinuationDirective(text, stream))
                {
                    var subsequentConditional = itemFactory.CreateSpecific <ConditionalControlDirective>(this, text, stream);
                    if (!subsequentConditional.Parse(itemFactory, text, stream))
                    {
                        break;
                    }

                    ElseStatements.Add(subsequentConditional);
                    Children.Add(subsequentConditional);
                }
            }

            return(Children.Count > 0);
        }
Exemplo n.º 38
0
        public override bool Parse(IItemFactory itemFactory, ITextProvider text, ITokenStream stream)
        {
            if (stream.Current.Type == TokenType.LessThan)
            {
                OpenTag = Children.AddCurrentAndAdvance(stream, SassClassifierType.XmlDocumentationTag);
                if (stream.Current.Type == TokenType.Identifier)
                {
                    Name = Children.AddCurrentAndAdvance(stream, SassClassifierType.XmlDocumentationTag);

                    while (!IsTagTerminator(stream.Current.Type))
                    {
                        var attribute = itemFactory.CreateSpecific <XmlAttribute>(this, text, stream);
                        if (!attribute.Parse(itemFactory, text, stream))
                        {
                            break;
                        }

                        Children.Add(attribute);
                        _Attributes.Add(attribute);
                        OnAttributeParsed(attribute, text);
                    }
                }

                if (stream.Current.Type == TokenType.Slash)
                {
                    CloseSlash = Children.AddCurrentAndAdvance(stream, SassClassifierType.XmlDocumentationTag);
                }

                if (stream.Current.Type == TokenType.GreaterThan)
                {
                    CloseTag = Children.AddCurrentAndAdvance(stream, SassClassifierType.XmlDocumentationTag);
                }
            }

            return(Children.Count > 0);
        }
Exemplo n.º 39
0
        public override bool Parse(IItemFactory itemFactory, ITextProvider text, ITokenStream stream)
        {
            if (stream.Current.Type == TokenType.Identifier && IsModifier(text.GetText(stream.Current.Start, stream.Current.Length)))
            {
                Modifier = Children.AddCurrentAndAdvance(stream);
            }

            ParseItem mediaType;

            if (itemFactory.TryCreateParsedOrDefault(this, text, stream, out mediaType))
            {
                MediaType = mediaType;
                Children.Add(mediaType);
            }

            while (!IsTerminator(text, stream))
            {
                var expression = itemFactory.CreateSpecific <MediaQueryExpression>(this, text, stream);
                if (expression.Parse(itemFactory, text, stream))
                {
                    _Expressions.Add(expression);
                    Children.Add(expression);
                }
                else
                {
                    Children.AddCurrentAndAdvance(stream);
                }
            }

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

            return(Children.Count > 0);
        }
        public override bool Parse(IItemFactory itemFactory, ITextProvider text, ITokenStream stream)
        {
            if ((IsConditionalDirective(text, stream) || IsConditionalContinuationDirective(text, stream)))
            {
                ParseRule(itemFactory, text, stream);

                while (!IsConditionTerminator(stream.Current.Type))
                {
                    ParseItem item;
                    if (itemFactory.TryCreateParsedOrDefault(this, text, stream, out item))
                    {
                        Children.Add(item);
                        ConditionStatements.Add(item);
                    }
                    else
                    {
                        Children.AddCurrentAndAdvance(stream);
                    }
                }

                ParseBody(itemFactory, text, stream);

                while (IsConditionalContinuationDirective(text, stream))
                {
                    var subsequentConditional = itemFactory.CreateSpecific<ConditionalControlDirective>(this, text, stream);
                    if (!subsequentConditional.Parse(itemFactory, text, stream))
                        break;

                    ElseStatements.Add(subsequentConditional);
                    Children.Add(subsequentConditional);
                }
            }

            return Children.Count > 0;
        }
Exemplo n.º 41
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;
        }
Exemplo n.º 42
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);
        }
Exemplo n.º 43
0
        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;
        }
Exemplo n.º 44
0
        protected virtual void ParseArguments(IItemFactory itemFactory, ITextProvider text, ITokenStream stream)
        {
            while (!IsTerminator(stream.Current.Type))
            {
                var argument = itemFactory.CreateSpecific<FunctionArgument>(this, text, stream);
                if (argument == null || !argument.Parse(itemFactory, text, stream))
                    break;

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