public void Visit(DivideOperator @operator) { @operator.LeftNode.Accept(this); var leftValue = this.Result; @operator.RightNode.Accept(this); var rightValue = this.Result; if (leftValue == null || rightValue == null) { Result = null; } else { try { if (rightValue == 0) { ErrorHandler.PrintError(Errors.Divide); Result = null; } else { Result = leftValue / rightValue; } } catch { ErrorHandler.PrintError(Errors.Overflow); Result = null; } } }
public void Visit(DivideOperator @operator) { ParenthesizedExpression.Append("("); @operator.LeftNode.Accept(this); ParenthesizedExpression.Append("/"); @operator.RightNode.Accept(this); ParenthesizedExpression.Append(")"); }
public void Visit(DivideOperator @operator) { @operator.LeftNode.Accept(this); var leftValue = this.Result; @operator.RightNode.Accept(this); var rightValue = this.Result; Result = leftValue / rightValue; }
public void Visit(DivideOperator @operator) { if (!(@operator.LeftNode is DivideOperator || @operator.LeftNode is Operand)) { ParenthesizedExpression.Append("("); } @operator.LeftNode.Accept(this); if (!(@operator.LeftNode is DivideOperator || @operator.LeftNode is Operand)) { ParenthesizedExpression.Append(")"); } ParenthesizedExpression.Append("/"); if (!(@operator.RightNode is DivideOperator || @operator.RightNode is Operand)) { ParenthesizedExpression.Append("("); } @operator.RightNode.Accept(this); if (!(@operator.RightNode is DivideOperator || @operator.RightNode is Operand)) { ParenthesizedExpression.Append(")"); } }