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;
}
}
}
Aggregations