public string Visit(NegateOpNode visited) { var sb = new StringBuilder(); sb.Append("("); sb.Append("-"); sb.Append(visited.Son.Accept(this)); sb.Append(")"); return(sb.ToString()); }
public string Visit(NegateOpNode visited) { var sb = new StringBuilder(); sb.Append("-"); int thisPriority = visited.Accept(priorityGetter); int sonPriority = visited.Son.Accept(priorityGetter); //everything except value nodes needs parentheses if (sonPriority < thisPriority) { sb.Append("("); } sb.Append(visited.Son.Accept(this)); if (sonPriority < thisPriority) { sb.Append(")"); } return(sb.ToString()); }
public int Visit(NegateOpNode visited) { return(10); }
public double Visit(NegateOpNode caller) { double son = caller.Son.Accept(this); return(-son); }
public int Visit(NegateOpNode caller) { int son = caller.Son.Accept(this); return(checked (-son)); }