private void Print(Expression e, int indentation)
 {
     if (e is UnaryMinus) {
         UnaryMinus x = e as UnaryMinus;
         AddLine(new String(' ', indentation) + x.GetType().Name);
         Print(x.Operand, indentation + DefaultIndentation);
     }
     else if (e is BinaryPlus) {
         BinaryPlus x = e as BinaryPlus;
         AddLine(new String(' ', indentation) + x.GetType().Name);
         Print(x.LeftOperand, indentation + DefaultIndentation);
         Print(x.RightOperand, indentation + DefaultIndentation);
     }
     else if (e is BinaryMinus) {
         BinaryMinus x = e as BinaryMinus;
         AddLine(new String(' ', indentation) + x.GetType().Name);
         Print(x.LeftOperand, indentation + DefaultIndentation);
         Print(x.RightOperand, indentation + DefaultIndentation);
     }
     else if (e is BinaryMul) {
         BinaryMul x = e as BinaryMul;
         AddLine(new String(' ', indentation) + x.GetType().Name);
         Print(x.LeftOperand, indentation + DefaultIndentation);
         Print(x.RightOperand, indentation + DefaultIndentation);
     }
     else if (e is BinaryDiv) {
         BinaryDiv x = e as BinaryDiv;
         AddLine(new String(' ', indentation) + x.GetType().Name);
         Print(x.LeftOperand, indentation + DefaultIndentation);
         Print(x.RightOperand, indentation + DefaultIndentation);
     }
     else if (e is BinaryExp) {
         BinaryExp x = e as BinaryExp;
         AddLine(new String(' ', indentation) + x.GetType().Name);
         Print(x.LeftOperand, indentation + DefaultIndentation);
         Print(x.RightOperand, indentation + DefaultIndentation);
     }
     else if (e is Literal) {
         Literal x = e as Literal;
         AddLine(new String(' ', indentation) + x.GetType().Name + " (" + x.Value + ")");
     }
     else {
         throw new ArgumentException("Unsupported type: " + e);
     }
 }
        public string Print(Expression e)
        {
            if (e is UnaryMinus) {
                UnaryMinus x = e as UnaryMinus;
                return string.Format("-({0})", Print(x.Operand));
            }
            else if (e is BinaryPlus) {
                BinaryPlus x = e as BinaryPlus;
                return string.Format("+({0}, {1})", Print(x.LeftOperand), Print(x.RightOperand));
            }
            else if (e is BinaryMinus) {
                BinaryMinus x = e as BinaryMinus;
                return string.Format("-({0}, {1})", Print(x.LeftOperand), Print(x.RightOperand));
            }
            else if (e is BinaryMul) {
                BinaryMul x = e as BinaryMul;
                return string.Format("*({0}, {1})", Print(x.LeftOperand), Print(x.RightOperand));
            }
            else if (e is BinaryDiv) {
                BinaryDiv x = e as BinaryDiv;
                return string.Format("/({0}, {1})", Print(x.LeftOperand), Print(x.RightOperand));

            }
            else if (e is BinaryExp) {
                BinaryExp x = e as BinaryExp;
                return string.Format("^({0}, {1})", Print(x.LeftOperand), Print(x.RightOperand));

            }
            else if (e is Literal) {
                Literal x = e as Literal;
                return x.Value.ToString();
            }
            else {
                throw new ArgumentException("Unsupported type: " + e);
            }
        }
 public string Print(Expression e)
 {
     Print(e, 0);
     return _result;
 }