/** * Get the variable names from the given expression. * * @param expression * @param result * a set which contains the variable names */ public static void getVariables(String expression, Set<String> result) { getVariables(expression, result, true); }
/** * Get the variable names from the given expression. * * @param expression * @param result * a set which contains the variable names */ public static void getVariables(String expression, Set<String> result) { Parser p = new Parser(); ASTNode node = p.parse(expression); getVariables(node, result); }
/** * Get the variable names from the given expression. * * @param expression the expression * @param result a set which contains the variable names */ public static void getVariables( String expression, Set<String> result ) { Parser p = new Parser(); ASTNode node = p.parse( expression ); getVariables( node, result ); }
/** * Get the variable names from the given expression. * * @param expression * @param result * a set which contains the variable names * @param relaxedSyntax * if <code>true</code> us e function syntax like <code>sin(x)</code> otherwise use <code>Sin[x]</code>. */ public static void getVariables(String expression, Set<String> result, boolean relaxedSyntax) { Parser p = new Parser(relaxedSyntax ? ASTNodeFactory.RELAXED_STYLE_FACTORY : ASTNodeFactory.MMA_STYLE_FACTORY, relaxedSyntax); ASTNode node = p.parse(expression); getVariables(node, result); }
/** * Get the variable names from the given AST node. * * @param node an already parsed AST node * @param result a set which contains the variable names */ public static void getVariables( final ASTNode node, Set<String> result ) { if ( node instanceof FunctionNode ) { FunctionNode functionNode = (FunctionNode) node; if ( functionNode.size() > 0 && functionNode.getNode( 0 ) instanceof SymbolNode ) { for ( int i = 1; i < functionNode.size(); i++ ) { getVariables( functionNode.getNode( i ), result ); } } } if ( node instanceof SymbolNode ) { Object obj = SYMBOL_DOUBLE_MAP.get( node.toString() ); if ( obj == null ) { obj = SYMBOL_BOOLEAN_MAP.get( node.toString() ); if ( obj == null ) { result.add( node.toString() ); } } } } }
/** * Get the variable names from the given AST node. * * @param node * an already parsed AST node * @param result * a set which contains the variable names */ public static void getVariables(final ASTNode node, Set<String> result) { if (node instanceof FunctionNode) { FunctionNode functionNode = (FunctionNode) node; if (functionNode.size() > 0 && functionNode.getNode(0) instanceof SymbolNode) { for (int i = 1; i < functionNode.size(); i++) { getVariables(functionNode.getNode(i), result); } } } if (node instanceof SymbolNode) { Object obj = SYMBOL_DOUBLE_MAP.get(node.toString()); if (obj == null) { obj = SYMBOL_BOOLEAN_MAP.get(node.toString()); if (obj == null) { result.add(node.toString()); } } } }
/** * Get the variable names from the given AST node. * * @param node * an already parsed AST node * @param result * a set which contains the variable names */ public static void getVariables(final ASTNode node, Set<String> result) { if (node instanceof FunctionNode) { FunctionNode functionNode = (FunctionNode) node; if (functionNode.size() > 0 && functionNode.getNode(0) instanceof SymbolNode) { for (int i = 1; i < functionNode.size(); i++) { getVariables(functionNode.getNode(i), result); } } } if (node instanceof SymbolNode) { Object obj = SYMBOL_DOUBLE_MAP.get(node.toString()); if (obj == null) { obj = SYMBOL_BOOLEAN_MAP.get(node.toString()); if (obj == null) { result.add(node.toString()); } } } } }