예제 #1
0
        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}", "}");
                }
            }
        }
예제 #2
0
 public bool VisitNode(IfStatement node)
 {
     throw new NotImplementedException();
 }
예제 #3
0
        public bool VisitNode(IfStatement node)
        {
            // if (condition) { /n contents /n } [else...]
            VisitIf(node);

            return true;
        }