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); }
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; }
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"); }