Exemple #1
0
 public void Visit(AdditionExpression ae)
 {
     this.sb.Append("(");
     ae.left.Accept(this);
     this.sb.Append("+");
     ae.right.Accept(this);
     this.sb.Append(")");
 }
Exemple #2
0
        private static void ClassicVisitor(AdditionExpression e)
        {
            var ev = new ExpressionPrinter();

            ev.Visit(e);

            Console.WriteLine(ev);

            var ec = new ExpressionCalculator();

            ec.Visit(e);

            Console.WriteLine(ec.Result);
        }