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( new DoubleExpression(7), new AdditionExpression( new DoubleExpression(8), new DoubleExpression(9))); var ep = new ExpressionPrinter(); ep.Visit(e); Console.WriteLine(ep.ToString()); }
public static void Main(string[] args) { var e = new AdditionExpression( new DoubleExpression(1), new AdditionExpression( new DoubleExpression(2), new DoubleExpression(3) ) ); var ep = new ExpressionPrinter(); ep.Visit(e); Console.WriteLine(ep); }