예제 #1
0
 // [Lhs / Rhs] / number
 public override ASTNode TryDivide(ASTNode number)
 {
     if (Lhs.IsNumeric)
     {
         // [Lhs / Rhs] / number --> [Lhs / number] / Rhs
         return(new ASTQuotient(new ASTQuotient(Lhs, number), Rhs));
     }
     if (Rhs.IsNumeric)
     {
         // [Lhs / Rhs] / number --> Lhs / [Rhs * number]
         ASTNode product    = new ASTParenthesized(new ASTProduct(Rhs, number));
         ASTNode normalized = Lhs.TryDivide(product);
         return((normalized != null) ? normalized : new ASTQuotient(Lhs, product));
     }
     return(null);
 }
        public void Encode(ASTParenthesized node)
        {
            SenseExpr nested = m_stack.Pop();

            m_stack.Push(new SenseExpr(nested.Value, String.Format("({0})", nested.Code)));
        }
        public void Encode(ASTParenthesized node)
        {
            NumExpr expr = m_stack.Pop();

            m_stack.Push(new NumExpr(expr.IsTrueValue, expr.Value, String.Format("({0})", expr.Code)));
        }