예제 #1
0
 public override void Visit(AdditionExpression ae)
 {
     _stringBuilder.Append("(");
     VisitForExpression(ae.LHS);
     _stringBuilder.Append("+");
     VisitForExpression(ae.RHS);
     _stringBuilder.Append(")");
 }
예제 #2
0
 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(")");
 }
예제 #4
0
 public void Visit(AdditionExpression ae)
 {
     sb.Append("(");
     ae.Left.Accept(this);
     sb.Append("+");
     ae.Right.Accept(this);
     sb.Append(")");
 }
예제 #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(")");
 }
예제 #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());
        }
예제 #7
0
 public override void Accept(AdditionExpression ae)
 {
     sb.Append("(");
     ae.LHS.Visit(this);
     sb.Append("+");
     ae.RHS.Visit(this);
     sb.Append(")");
 }
예제 #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);
        }
예제 #9
0
        public void Visit(AdditionExpression additionExpression)
        {
            additionExpression.Left.Accept(this);
            var left = Result;

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

            Result = left + right;
        }
예제 #10
0
        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);
        }
예제 #11
0
        public void Visit(AdditionExpression ae)
        {
            ae.Left.Accept(this);
            var a = Result;

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

            Result = a + b;
        }
예제 #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);
        }
예제 #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);
        }
예제 #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();
        }
예제 #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}");
        }
예제 #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}");
        }
예제 #17
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();

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

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