示例#1
0
        public double Visit(MinusOpNode caller)
        {
            double left  = caller.LeftSon.Accept(this);
            double right = caller.RightSon.Accept(this);

            return(left - right);
        }
示例#2
0
        public int Visit(MinusOpNode caller)
        {
            int left  = caller.LeftSon.Accept(this);
            int right = caller.RightSon.Accept(this);

            return(checked (left - right));
        }
示例#3
0
        public string Visit(MinusOpNode visited)
        {
            var sb = new StringBuilder();

            sb.Append("(");
            sb.Append(visited.LeftSon.Accept(this));
            sb.Append("-");
            sb.Append(visited.RightSon.Accept(this));
            sb.Append(")");
            return(sb.ToString());
        }
示例#4
0
        public string Visit(MinusOpNode visited)
        {
            var sb = new StringBuilder();

            // - has lowest priority - no need for parentheses around left child
            sb.Append(visited.LeftSon.Accept(this));
            sb.Append("-");

            // - is not associative - parentheses needed if right child has same priority
            int thisPriority     = visited.Accept(priorityGetter);
            int rightSonPriority = visited.RightSon.Accept(priorityGetter);

            if (rightSonPriority <= thisPriority)
            {
                sb.Append("(");
            }
            sb.Append(visited.RightSon.Accept(this));
            if (rightSonPriority <= thisPriority)
            {
                sb.Append(")");
            }

            return(sb.ToString());
        }
示例#5
0
 public int Visit(MinusOpNode visited)
 {
     return(0);
 }