public void Visit(AdditionExpression ae)
 {
     sb.Append("(");
     ae.Left.Accept(this);
     sb.Append("+");
     ae.Right.Accept(this);
     sb.Append(")");
 }
        public void Visit(AdditionExpression ae)
        {
            ae.Left.Accept(this);
            var a = Result;

            ae.Right.Accept(this);
            var b = Result;

            Result = a + b;
        }
        static void Main(string[] args)
        {
            var e = new AdditionExpression(
                new DoubleExpression(4),
                new AdditionExpression(
                    new DoubleExpression(5),
                    new DoubleExpression(6)));
            var ep = new ExpressionPrinter();

            ep.Visit(e);
            //Console.WriteLine(ep);
            var calc = new ExpressionCalculator();

            calc.Visit(e);
            Console.WriteLine($"{ep} = {calc.Result}");
        }