Ejemplo n.º 1
0
        public double Visit(PlusOpNode caller)
        {
            double left  = caller.LeftSon.Accept(this);
            double right = caller.RightSon.Accept(this);

            return(left + right);
        }
Ejemplo n.º 2
0
        public int Visit(PlusOpNode caller)
        {
            int left  = caller.LeftSon.Accept(this);
            int right = caller.RightSon.Accept(this);

            return(checked (left + right));
        }
Ejemplo n.º 3
0
        public string Visit(PlusOpNode visited)
        {
            var sb = new StringBuilder();

            // + has lowest priority and is associative - no need for parentheses around either child
            sb.Append(visited.LeftSon.Accept(this));
            sb.Append("+");
            sb.Append(visited.RightSon.Accept(this));
            return(sb.ToString());
        }
Ejemplo n.º 4
0
        public string Visit(PlusOpNode 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());
        }
Ejemplo n.º 5
0
 public int Visit(PlusOpNode visited)
 {
     return(0);
 }