Example #1
0
 public void Print(AdditionExpression ae, StringBuilder sb)
 {
     sb.Append("(");
     Print((dynamic)ae.Left, sb);
     sb.Append(" + ");
     Print((dynamic)ae.Right, sb);
     sb.Append(")");
 }
Example #2
0
        public void Test_using_the_print_visitor()
        {
            Expression exp = new AdditionExpression(
                new DoubleExpression(1.0),
                new AdditionExpression(
                    new DoubleExpression(2.0),
                    new DoubleExpression(3.0))
                );

            var sb      = new StringBuilder();
            var printer = new ExpressionPrinter();

            printer.Print((dynamic)exp, sb);

            string result = sb.ToString();

            Assert.False(string.IsNullOrEmpty(result));
        }