private void visitTagClose(StatementClose tagClose) { WriteLine("StatementClose:" + tagClose.Name); }
private Tag CollectForTag(Tag tag, ref int index) { if (tag.IsClosed) { return(tag); } if (string.Compare(tag.Name, "if", true) == 0) { tag = new IfStatement(tag.Line, tag.Col, tag.AttributeValue("test")); } Tag collectTag = tag; for (index++; index < elements.Count; index++) { Token elem = elements[index]; if (elem is Text) { collectTag.InnerTokens.Add(elem); } else if (elem is Expression) { collectTag.InnerTokens.Add(elem); } else if (elem is Tag) { Tag innerTag = (Tag)elem; if (string.Compare(innerTag.Name, "else", true) == 0) { if (collectTag is IfStatement) { ((IfStatement)collectTag).FalseBranch = innerTag; collectTag = innerTag; } else { throw new TmplException("else tag has to be positioned inside of if or elseif tag " + innerTag.Line + "," + innerTag.Col, innerTag.Line, innerTag.Col); } } else if (string.Compare(innerTag.Name, "elseif", true) == 0) { if (collectTag is IfStatement) { Tag newTag = new IfStatement(innerTag.Line, innerTag.Col, innerTag.AttributeValue("test")); ((IfStatement)collectTag).FalseBranch = newTag; collectTag = newTag; } else { throw new TmplException("elseif tag is not positioned properly" + innerTag.Line + "," + innerTag.Col, innerTag.Line, innerTag.Col); } } else { collectTag.InnerTokens.Add(CollectForTag(innerTag, ref index)); } } else if (elem is StatementClose) { StatementClose tagClose = (StatementClose)elem; return(tag); } else { throw new TmplException("Invalid element: [" + elem.GetType().ToString() + "] " + elem.Line + "," + elem.Col, elem.Line, elem.Col); } } throw new TmplException("Start tag: [" + tag.Name + "] does not have matching end tag." + tag.Line + "," + tag.Col, tag.Line, tag.Col); }