Search in sources :

Example 1 with BinOpNode

use of org.cytoscape.equations.internal.parse_tree.BinOpNode in project cytoscape-impl by cytoscape.

the class EquationParserImpl method parseExpr.

// 
// The actual parsing takes place here.
// 
/**
 *   Implements expr --> term | term {+ term } | term {- term} | term {& term} | term compOp term.
 */
private AbstractNode parseExpr() {
    AbstractNode exprNode = parseTerm();
    for (; ; ) {
        final Token token = tokeniser.getToken();
        final int sourceLocation = tokeniser.getStartPos();
        if (token == Token.PLUS || token == Token.MINUS || token == Token.AMPERSAND) {
            final TreeNode term = parseTerm();
            if (token == Token.PLUS || token == Token.MINUS)
                exprNode = handleBinaryArithmeticOp(token, sourceLocation, exprNode, term);
            else
                // String concatenation.
                exprNode = new BinOpNode(sourceLocation, Token.AMPERSAND, exprNode, term);
        } else if (token.isComparisonOperator()) {
            final TreeNode term = parseTerm();
            // No chaining for comparison operators!
            return handleComparisonOp(token, sourceLocation, exprNode, term);
        } else {
            tokeniser.ungetToken(token);
            return exprNode;
        }
    }
}
Also used : BinOpNode(org.cytoscape.equations.internal.parse_tree.BinOpNode) AbstractNode(org.cytoscape.equations.AbstractNode) TreeNode(org.cytoscape.equations.TreeNode)

Aggregations

AbstractNode (org.cytoscape.equations.AbstractNode)1 TreeNode (org.cytoscape.equations.TreeNode)1 BinOpNode (org.cytoscape.equations.internal.parse_tree.BinOpNode)1