Search in sources :

Example 6 with PrefixOperator

use of org.matheclipse.parser.client.operator.PrefixOperator in project symja_android_library by axkr.

the class DoubleFormFactory method convertOperator.

protected boolean convertOperator(final Operator operator, final IAST list, final StringBuilder buf, final int precedence, ISymbol head) {
    if ((operator instanceof PrefixOperator) && (list.isAST1())) {
        convertPrefixOperator(buf, list, (PrefixOperator) operator, precedence);
        return true;
    }
    if ((operator instanceof InfixOperator) && (list.size() > 2)) {
        InfixOperator infixOperator = (InfixOperator) operator;
        if (head.equals(S.Plus)) {
            if (fPlusReversed) {
                convertPlusOperatorReversed(buf, list, infixOperator, precedence);
            } else {
                convertPlusOperator(buf, list, infixOperator, precedence);
            }
            return true;
        } else if (head.equals(S.Times)) {
            convertTimesFraction(buf, list, infixOperator, precedence, NO_PLUS_CALL);
            return true;
        } else if (list.isPower()) {
            convertPowerOperator(buf, list, infixOperator, precedence);
            return true;
        } else if (list.isAST(S.Apply)) {
            if (list.size() == 3) {
                convertInfixOperator(head, buf, list, ASTNodeFactory.APPLY_OPERATOR, precedence);
                return true;
            }
            if (list.size() == 4 && list.arg2().equals(F.CListC1)) {
                convertInfixOperator(head, buf, list, ASTNodeFactory.APPLY_LEVEL_OPERATOR, precedence);
                return true;
            }
            return false;
        } else if (list.size() != 3 && infixOperator.getGrouping() != InfixOperator.NONE) {
            return false;
        }
        convertInfixOperator(head, buf, list, (InfixOperator) operator, precedence);
        return true;
    }
    if ((operator instanceof PostfixOperator) && (list.isAST1())) {
        convertPostfixOperator(buf, list, (PostfixOperator) operator, precedence);
        return true;
    }
    return false;
}
Also used : PrefixOperator(org.matheclipse.parser.client.operator.PrefixOperator) PostfixOperator(org.matheclipse.parser.client.operator.PostfixOperator) InfixOperator(org.matheclipse.parser.client.operator.InfixOperator)

Aggregations

PrefixOperator (org.matheclipse.parser.client.operator.PrefixOperator)6 InfixOperator (org.matheclipse.parser.client.operator.InfixOperator)4 PostfixOperator (org.matheclipse.parser.client.operator.PostfixOperator)4 ASTNode (org.matheclipse.parser.client.ast.ASTNode)1 FunctionNode (org.matheclipse.parser.client.ast.FunctionNode)1 NumberNode (org.matheclipse.parser.client.ast.NumberNode)1