예제 #1
0
 public void Visit(AdditionExpresssion obj)
 {
     this.sb.Append("(");
     obj.Left.Accept(this);
     this.sb.Append("+");
     obj.Right.Accept(this);
     this.sb.Append(")");
 }
예제 #2
0
        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);
        }