示例#1
0
 public void Visit(AdditionExpression obj)
 {
     _sb.Append("(");
     obj.Left.Accept(this);
     _sb.Append(" + ");
     obj.Right.Accept(this);
     _sb.Append(")");
 }
示例#2
0
        public void Test_using_the_print_visitor()
        {
            var exp = new AdditionExpression(
                left: new DoubleExpression(1.0),
                right: new AdditionExpression(
                    left: new DoubleExpression(2.0),
                    right: new DoubleExpression(3.0))
                );

            var printer = new ExpressionPrinter();

            printer.Visit(exp);

            string result = printer.ToString();

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