public double Visit(MinusOpNode caller) { double left = caller.LeftSon.Accept(this); double right = caller.RightSon.Accept(this); return(left - right); }
public int Visit(MinusOpNode caller) { int left = caller.LeftSon.Accept(this); int right = caller.RightSon.Accept(this); return(checked (left - right)); }
public string Visit(MinusOpNode visited) { var sb = new StringBuilder(); sb.Append("("); sb.Append(visited.LeftSon.Accept(this)); sb.Append("-"); sb.Append(visited.RightSon.Accept(this)); sb.Append(")"); return(sb.ToString()); }
public string Visit(MinusOpNode visited) { var sb = new StringBuilder(); // - has lowest priority - no need for parentheses around left child sb.Append(visited.LeftSon.Accept(this)); sb.Append("-"); // - is not associative - parentheses needed if right child has same priority int thisPriority = visited.Accept(priorityGetter); int rightSonPriority = visited.RightSon.Accept(priorityGetter); if (rightSonPriority <= thisPriority) { sb.Append("("); } sb.Append(visited.RightSon.Accept(this)); if (rightSonPriority <= thisPriority) { sb.Append(")"); } return(sb.ToString()); }
public int Visit(MinusOpNode visited) { return(0); }