示例#1
0
        protected static void ParseBlock(ScssParserContext context, RuleSetNode node)
        {
            context.Tokens.SkipWhiteAndComments();
            context.Tokens.Read(TokenType.OpenCurlyBracket);
            var stop = false;

            while (!context.Tokens.Empty && !stop) {
                context.Tokens.SkipWhiteAndComments();
                var preview = context.Tokens.Peek();
                switch (preview.Type) {
                    case TokenType.Semicolon:
                    case TokenType.Whitespace:
                        context.Tokens.Read();
                        break;
                    case TokenType.CloseCurlyBracket:
                        stop = true;
                        break;
                    default:
                        if (IsPropertyName(context)) {
                            var rule = ScssDeclarationNode.Parse(context);
                            node.Rules.Nodes.Add(rule);
                        } else {
                            var ruleSet = Parse(context);
                            node.RuleSets.Nodes.Add(ruleSet);
                        }
                        break;
                }
            }
            context.Tokens.Read(TokenType.CloseCurlyBracket);
        }
示例#2
0
 public static RuleSetNode Parse(ScssParserContext context)
 {
     var raw = SelectorExpression.Parse(context.Tokens, context.Selector);
     context.PushSelector(raw);
     var res = new RuleSetNode {
         RawSelector = raw,
         Selector = context.Selector
     };
     ParseBlock(context, res);
     context.PopSelector();
     return res;
 }
示例#3
0
 public static void AreEqual(RuleSetNode expected, RuleSetNode actual, string message = "")
 {
     Assert.AreEqual(expected.RuleSets.Nodes.Count, actual.RuleSets.Nodes.Count, message + "/Count");
     for (var i = 0; i < expected.RuleSets.Nodes.Count; i++) {
         var expectedRuleSet = expected.RuleSets.Nodes[i];
         AreEqual(expectedRuleSet, actual.RuleSets.Nodes[i], message + "RuleSets[" + i + "]");
     }
     for (var i = 0; i < expected.Rules.Nodes.Count; i++) {
         var expectedRule = expected.Rules.Nodes[i];
         AreEqual(expectedRule, actual.Rules.Nodes[i], message + "Rules[" + i + "]");
     }
     AreEqual(expected.RawSelector, actual.RawSelector, message + "/RawSelector");
 }