Beispiel #1
0
        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;
                }
            }
        }
Beispiel #2
0
 public void Visit(DivideOperator @operator)
 {
     ParenthesizedExpression.Append("(");
     @operator.LeftNode.Accept(this);
     ParenthesizedExpression.Append("/");
     @operator.RightNode.Accept(this);
     ParenthesizedExpression.Append(")");
 }
Beispiel #3
0
        public void Visit(DivideOperator @operator)
        {
            @operator.LeftNode.Accept(this);
            var leftValue = this.Result;

            @operator.RightNode.Accept(this);
            var rightValue = this.Result;

            Result = leftValue / rightValue;
        }
Beispiel #4
0
 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(")");
     }
 }