public void Visit(AdditionExpresssion obj) { this.sb.Append("("); obj.Left.Accept(this); this.sb.Append("+"); obj.Right.Accept(this); this.sb.Append(")"); }
public void Run() { var e = new AdditionExpresssion( new DoubleExpresssion(1), new AdditionExpresssion( new DoubleExpresssion(2), new DoubleExpresssion(3) )); //ClassicVisitor(e); var acyclic = new ExpresssionPrinter(); acyclic.Visit(e); Console.WriteLine(acyclic); }