private StyleFunctionNode ParsePropertyFunction(string identifier) { StyleFunctionNode functionNode = StyleASTNodeFactory.StyleFunctionNode(identifier); while (tokenStream.HasMoreTokens && !AdvanceIfTokenType(StyleTokenType.ParenClose)) { functionNode.AddChildNode(ParsePropertyValue()); // we just ignore the comma for now AdvanceIfTokenType(StyleTokenType.Comma); } return(functionNode); }
public void ParseGridTemplateComplex() { LightList <StyleASTNode> nodes = StyleParser.Parse(@" style grid-thing { GridLayoutRowTemplate = repeat(4, 1mx) repeat(auto-fill, grow(1cnt, 300px) 300px) repeat(2, shrink(200px, 1fr)); } "); Assert.AreEqual(1, nodes.Count); StyleRootNode rootNode = nodes[0] as StyleRootNode; Assert.AreEqual(1, rootNode.children.Count); PropertyNode propertyNode0 = (PropertyNode)rootNode.children[0]; Assert.AreEqual(3, propertyNode0.children.Count); Assert.IsInstanceOf <StyleFunctionNode>(propertyNode0.children[0]); StyleFunctionNode repeat0 = propertyNode0.children[0] as StyleFunctionNode; StyleFunctionNode repeat1 = propertyNode0.children[1] as StyleFunctionNode; StyleFunctionNode repeat2 = propertyNode0.children[2] as StyleFunctionNode; AssertStyleNodesEqual(new StyleNodeTestDef() { type = typeof(StyleFunctionNode), identifier = "repeat", children = new[] { new StyleNodeTestDef() { type = typeof(StyleLiteralNode), nodeType = StyleASTNodeType.NumericLiteral, rawValue = "4" }, StyleNodeTestDef.CreateMeasurementNode("1", "mx") } }, repeat0); AssertStyleNodesEqual(new StyleNodeTestDef() { type = typeof(StyleFunctionNode), identifier = "repeat", children = new[] { new StyleNodeTestDef() { type = typeof(StyleIdentifierNode), nodeType = StyleASTNodeType.Identifier, identifier = "auto-fill" }, new StyleNodeTestDef() { type = typeof(StyleFunctionNode), identifier = "grow", children = new[] { StyleNodeTestDef.CreateMeasurementNode("1", "cnt"), StyleNodeTestDef.CreateMeasurementNode("300", "px") } }, StyleNodeTestDef.CreateMeasurementNode("300", "px") } }, repeat1); AssertStyleNodesEqual(new StyleNodeTestDef() { type = typeof(StyleFunctionNode), identifier = "repeat", children = new[] { new StyleNodeTestDef() { type = typeof(StyleLiteralNode), nodeType = StyleASTNodeType.NumericLiteral, rawValue = "2" }, new StyleNodeTestDef() { type = typeof(StyleFunctionNode), identifier = "shrink", children = new[] { StyleNodeTestDef.CreateMeasurementNode("200", "px"), StyleNodeTestDef.CreateMeasurementNode("1", "fr") } } } }, repeat2); }