public TemplateParser(Lexer lexer) { this.lexer = lexer; nodes = new List<Node>(); }
public static Template Parse(string name, string text) { Lexer lexer = new Lexer(text); TemplateParser parser = new TemplateParser(lexer); List<Node> nodes = parser.Parse(); TagParser tagParser = new TagParser(nodes); nodes = tagParser.CreateHierarchy(); Template template = new Template(name, nodes, null); foreach (Node elem in nodes) { if (elem is TagNode) { TagNode tag = (TagNode)elem; if (string.Compare(tag.TagName, "template", true) == 0) { Expression ename = tag.GetAttributeValue("name"); string tname; if (ename is StringLiteralExpression) tname = ((StringLiteralExpression)ename).Value; else tname = "?"; template.childTemplates.Add(new Template(tname, tag.ChildNodes, template)); } } } return template; }