public void Visit(AdditionExpression obj) { sb.Append("("); obj.Left.Accept(this); sb.Append("+"); obj.Right.Accept(this); sb.Append(")"); }
static void Main(string[] args) { var e = new AdditionExpression( left: new DoubleExpression(1), right: new AdditionExpression( left: new DoubleExpression(2), right: new DoubleExpression(3))); var ep = new ExpressionPrinter(); ep.Visit(e); Console.WriteLine(ep.ToString()); }