예제 #1
0
        public string Visit(NegateOpNode visited)
        {
            var sb = new StringBuilder();

            sb.Append("(");
            sb.Append("-");
            sb.Append(visited.Son.Accept(this));
            sb.Append(")");
            return(sb.ToString());
        }
예제 #2
0
        public string Visit(NegateOpNode visited)
        {
            var sb = new StringBuilder();

            sb.Append("-");

            int thisPriority = visited.Accept(priorityGetter);
            int sonPriority  = visited.Son.Accept(priorityGetter);

            //everything except value nodes needs parentheses
            if (sonPriority < thisPriority)
            {
                sb.Append("(");
            }
            sb.Append(visited.Son.Accept(this));
            if (sonPriority < thisPriority)
            {
                sb.Append(")");
            }

            return(sb.ToString());
        }
예제 #3
0
 public int Visit(NegateOpNode visited)
 {
     return(10);
 }
예제 #4
0
        public double Visit(NegateOpNode caller)
        {
            double son = caller.Son.Accept(this);

            return(-son);
        }
예제 #5
0
        public int Visit(NegateOpNode caller)
        {
            int son = caller.Son.Accept(this);

            return(checked (-son));
        }