public override void Visit(AdditionExpression ae)
 {
     _stringBuilder.Append("(");
     VisitForExpression(ae.LHS);
     _stringBuilder.Append("+");
     VisitForExpression(ae.RHS);
     _stringBuilder.Append(")");
 }
 public void Visit(AdditionExpression obj)
 {
     _sb.Append("(");
     obj.Left.Accept(this);
     _sb.Append("+");
     obj.Right.Accept(this);
     _sb.Append(")");
 }
 public void Visit(AdditionExpression additionExpression)
 {
     stringBuilder.Append("(");
     additionExpression.Left.Accept(this);
     stringBuilder.Append("+");
     additionExpression.Right.Accept(this);
     stringBuilder.Append(")");
 }
 public void Visit(AdditionExpression ae)
 {
     sb.Append("(");
     ae.Left.Accept(this);
     sb.Append("+");
     ae.Right.Accept(this);
     sb.Append(")");
 }
Exemple #5
0
 public void Print(AdditionExpression ae, StringBuilder sb)
 {
     sb.Append("(");
     Print((dynamic)ae.Left, sb);
     sb.Append("+");
     Print((dynamic)ae.Right, sb);
     sb.Append(")");
 }
Exemple #6
0
        public static void Main()
        {
            var simple = new AdditionExpression(new Value(2), new Value(3));
            var ep     = new ExpressionPrinter();

            ep.Accept(simple);
            Console.WriteLine(ep.ToString());
        }
Exemple #7
0
 public override void Accept(AdditionExpression ae)
 {
     sb.Append("(");
     ae.LHS.Visit(this);
     sb.Append("+");
     ae.RHS.Visit(this);
     sb.Append(")");
 }
Exemple #8
0
        private static void Test1()
        {
            var additionExpression = new AdditionExpression(new DoubleExpression(1),
                                                            new AdditionExpression(new DoubleExpression(2),
                                                                                   new DoubleExpression(3)));
            var sb = new StringBuilder();

            additionExpression.Print(sb);
            Console.WriteLine(sb);
        }
Exemple #9
0
        public void Visit(AdditionExpression additionExpression)
        {
            additionExpression.Left.Accept(this);
            var left = Result;

            additionExpression.Right.Accept(this);
            var right = Result;

            Result = left + right;
        }
        static void Main(string[] args)
        {
            var e = new AdditionExpression(new AdditionExpression(new Value(2), new Value(3)),
                                           new MultiplicationExpression(new Value(4), new Value(5)));
            var ep = new ExpressionPrinter();

            ep.Visit(e);

            WriteLine(ep);
        }
Exemple #11
0
        public void Visit(AdditionExpression ae)
        {
            ae.Left.Accept(this);
            var a = Result;

            ae.Right.Accept(this);
            var b = Result;

            Result = a + b;
        }
Exemple #12
0
        private static void AcyclicVisitor()
        {
            AdditionExpression e = new AdditionExpression(new DoubleExpression(1.0),
                                                          new AdditionExpression(new DoubleExpression(2.0), new DoubleExpression(3.0)));

            var ep = new ExpressionPrinter();

            ep.Visit(e);
            Console.WriteLine(ep);
        }
Exemple #13
0
        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();
            var sb = new StringBuilder();

            ep.Print(e, sb);
            Console.WriteLine(sb);
        }
Exemple #14
0
        static void Main(string[] args)
        {
            var sb = new StringBuilder();
            var e  = new AdditionExpression(
                new DoubleExpression(2),
                new AdditionExpression(
                    new DoubleExpression(3),
                    new DoubleExpression(1)
                    ));

            ExpressionPrinter.Print(e, sb);
            //e.Print(sb);
            Console.WriteLine(sb.ToString());

            Console.ReadLine();
        }
Exemple #15
0
        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());

            var calc = new ExpressionCalculator();

            calc.Visit(e);
            Console.WriteLine($"{ep} = {calc.Result}");
        }
Exemple #16
0
        static void Main(string[] args)
        {
            var expression = new AdditionExpression(
                new DoubleExpression(1),
                new AdditionExpression(new DoubleExpression(2), new DoubleExpression(3))
                );

            var expressionPrinter = new ExpressionPrinter();

            expressionPrinter.Visit(expression);

            Console.WriteLine(expressionPrinter);

            var calculator = new ExpressionCalculator();

            calculator.Visit(expression);
            Console.WriteLine($"{expressionPrinter} = {calculator.Result}");
        }
        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();

            // same as ep.Visit(e); can be used:
            e.Accept(ep);
            var ec = new ExpressionCalculator();

            e.Accept(ec);
            Console.WriteLine($"{ep} = {ec}");
        }
 public void Visit(AdditionExpression ae)
 {
     ae.Left.Accept(this);
     ae.Right.Accept(this);
 }
 public abstract void Visit(AdditionExpression ae);
Exemple #20
0
 public abstract void Accept(AdditionExpression ae);