public void Visit(AdditionExpression obj) { sb.Append("("); obj.Left.Accept(this); sb.Append("+"); obj.Right.Accept(this); sb.Append(")"); }
public void BasicTest() { 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); Assert.AreEqual("(1+(2+3))", ep.ToString()); }
//static void Main(string[] args) //{ // main(); // ReadLine(); //} static void main() { 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); WriteLine(ep); }