use of org.matheclipse.parser.client.operator.PrefixOperator in project symja_android_library by axkr.
the class Parser method parsePrimary.
private ASTNode parsePrimary() {
if (fToken == TT_OPERATOR) {
if (";;".equals(fOperatorString)) {
FunctionNode function = fFactory.createFunction(fFactory.createSymbol(IConstantOperators.Span));
function.add(fFactory.createInteger(1));
getNextToken();
if (fToken == TT_COMMA || fToken == TT_ARGUMENTS_CLOSE || fToken == TT_PRECEDENCE_CLOSE) {
function.add(fFactory.createSymbol(IConstantOperators.All));
return function;
}
function.add(parsePrimary());
if (fToken == TT_OPERATOR && ";;".equals(fOperatorString)) {
function.add(fFactory.createSymbol(IConstantOperators.All));
getNextToken();
}
return function;
}
if (".".equals(fOperatorString)) {
fCurrentChar = '.';
return getNumber(false);
}
final PrefixOperator prefixOperator = determinePrefixOperator();
if (prefixOperator != null) {
getNextToken();
final ASTNode temp = parseLookaheadOperator(prefixOperator.getPrecedence());
if ("PreMinus".equals(prefixOperator.getFunctionName()) && temp instanceof NumberNode) {
// special cases for negative numbers
((NumberNode) temp).toggleSign();
return temp;
}
return prefixOperator.createFunction(fFactory, temp);
}
throwSyntaxError("Operator: " + fOperatorString + " is no prefix operator.");
}
return getPart();
}
use of org.matheclipse.parser.client.operator.PrefixOperator in project symja_android_library by axkr.
the class OutputFormFactory method convertOperator.
private boolean convertOperator(final Operator operator, final IAST list, final Appendable buf, final int precedence, ISymbol head) throws IOException {
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(buf, list, ASTNodeFactory.APPLY_OPERATOR, precedence);
return true;
}
if (list.size() == 4 && list.arg2().equals(F.CListC1)) {
convertInfixOperator(buf, list, ASTNodeFactory.APPLY_LEVEL_OPERATOR, precedence);
return true;
}
return false;
} else if (list.size() != 3 && infixOperator.getGrouping() != InfixOperator.NONE) {
return false;
}
convertInfixOperator(buf, list, (InfixOperator) operator, precedence);
return true;
}
if ((operator instanceof PostfixOperator) && (list.isAST1())) {
convertPostfixOperator(buf, list, (PostfixOperator) operator, precedence);
return true;
}
return false;
}
use of org.matheclipse.parser.client.operator.PrefixOperator in project symja_android_library by axkr.
the class Parser method parsePrimary.
private ASTNode parsePrimary(final int min_precedence) {
if (fToken == TT_OPERATOR) {
if (".".equals(fOperatorString)) {
fCurrentChar = '.';
return getNumber(false);
}
final PrefixOperator prefixOperator = determinePrefixOperator();
if (prefixOperator != null) {
return parsePrefixOperator(prefixOperator);
}
throwSyntaxError("Operator: " + fOperatorString + " is no prefix operator.");
}
return getPart(min_precedence);
}
use of org.matheclipse.parser.client.operator.PrefixOperator in project symja_android_library by axkr.
the class MathMLFormFactory method convertOperator.
private boolean convertOperator(final org.matheclipse.parser.client.operator.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;
// } else
if (list.isAST(S.Apply)) {
if (list.size() == 3) {
convertInfixOperator(buf, list, ASTNodeFactory.APPLY_OPERATOR, precedence);
return true;
}
if (list.size() == 4 && list.arg2().equals(F.CListC1)) {
convertInfixOperator(buf, list, ASTNodeFactory.APPLY_LEVEL_OPERATOR, precedence);
return true;
}
return false;
} else if (list.size() != 3 && infixOperator.getGrouping() != InfixOperator.NONE) {
return false;
}
convertInfixOperator(buf, list, (InfixOperator) operator, precedence);
return true;
}
if ((operator instanceof PostfixOperator) && (list.isAST1())) {
convertPostfixOperator(buf, list, (PostfixOperator) operator, precedence);
return true;
}
return false;
}
use of org.matheclipse.parser.client.operator.PrefixOperator in project symja_android_library by axkr.
the class ComplexFormFactory 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) {
convertInfixOperatorReversed(buf, list, "add");
} else {
convertInfixOperator(buf, list, "add");
}
return true;
} else if (head.equals(S.Times)) {
convertInfixOperator(buf, list, "multiply");
return true;
} else if (list.isPower()) {
convertInfixOperator(buf, list, "pow");
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;
}
Aggregations