public ASTNode createFunction(final INodeParserFactory factory, final ASTNode lhs, final ASTNode rhs) { if (fOperatorString.equals("//")) { // lhs // rhs ==> rhs[lhs] FunctionNode function =factory.createAST(rhs); function.add(lhs); return function; } return factory.createFunction(factory.createSymbol(getFunctionName()), lhs, rhs); } }
@Override public ASTNode createFunction(final INodeParserFactory factory, final ASTNode lhs, final ASTNode rhs) { if (fOperatorString.equals("@")) { FunctionNode fn = factory.createAST(lhs); fn.add(rhs); return fn; } FunctionNode fn = factory.createFunction(factory.createSymbol("Apply"), lhs, rhs); if (fOperatorString.equals("@@")) { return fn; } // case "@@@" fn.add(factory.createFunction(factory.createSymbol("List"), factory.createInteger(1))); return fn; } }
private ASTNode parseDerivative(ASTNode expr) { int derivativeCounter = 1; getNextToken(); while (fToken == TT_DERIVATIVE) { derivativeCounter++; getNextToken(); } FunctionNode head = fFactory.createFunction(DERIVATIVE, new IntegerNode(derivativeCounter)); FunctionNode deriv = fFactory.createAST(head); deriv.add(expr); expr = parseArguments(deriv); return expr; }
private ASTNode getTimes(ASTNode temp) throws SyntaxError { FunctionNode func = fFactory.createAST(new SymbolNode("Times")); func.add(temp); do { getNextToken(); temp = parseExpression(); func.add(temp); if (fToken != TT_PRECEDENCE_CLOSE) { throwSyntaxError("\')\' expected."); } getNextToken(); } while (fToken == TT_PRECEDENCE_OPEN); return func; }
/** * Get a function f[...][...] * */ FunctionNode getFunctionArguments(final ASTNode head) throws SyntaxError { final FunctionNode function = fFactory.createAST(head); fRecursionDepth++; getNextToken(); if (fToken == TT_ARGUMENTS_CLOSE) { fRecursionDepth--; getNextToken(); if (fToken == TT_ARGUMENTS_OPEN) { return getFunctionArguments(function); } return function; } getArguments(function); fRecursionDepth--; if (fToken == TT_ARGUMENTS_CLOSE) { getNextToken(); if (fToken == TT_ARGUMENTS_OPEN) { return getFunctionArguments(function); } return function; } throwSyntaxError("']' expected."); return null; }
final FunctionNode function = fFactory.createAST(head);
final FunctionNode function = fFactory.createAST(fFactory.createSymbol("Optional")); function.add(fFactory.createPattern(symbol, null, false)); function.add(defaultValue); final FunctionNode function = fFactory.createAST(fFactory.createSymbol("Optional")); function.add(fFactory.createPattern(null, null, false)); function.add(defaultValue);