private void VisitIf(IfStatement node, bool ifElse = false) { if (!ifElse) Write(""); // New line only if we're not chaining ifElse = false; Append("if ("); node.Condition.AcceptVisitor(this); Append(") {0}", "{"); NestingLevel++; node.Then.AcceptVisitor(this); NestingLevel--; Write("{0}", "}"); if (node.Else != null) { if (node.Else.Statements.Count == 1 && node.Else.Statements[0] is IfStatement) { Append(" else "); VisitIf(node.Else.Statements[0] as IfStatement, true); } else { Append(" else {0}", "{"); NestingLevel++; node.Else.AcceptVisitor(this); NestingLevel--; Write("{0}", "}"); } } }
public bool VisitNode(IfStatement node) { throw new NotImplementedException(); }
public bool VisitNode(IfStatement node) { // if (condition) { /n contents /n } [else...] VisitIf(node); return true; }