use of org.apache.asterix.external.classad.ExprTreeHolder in project asterixdb by apache.
the class ClassAdParser method parseRelationalExpression.
// RelationalExpression .= ShiftExpression
// | RelationalExpression '<' ShiftExpression
// | RelationalExpression '>' ShiftExpression
// | RelationalExpression '<=' ShiftExpression
// | RelationalExpression '>=' ShiftExpression
private boolean parseRelationalExpression(ExprTreeHolder tree) throws IOException {
TokenType tt;
if (!parseShiftExpression(tree)) {
return false;
}
tt = lexer.peekToken();
while (tt == TokenType.LEX_LESS_THAN || tt == TokenType.LEX_GREATER_THAN || tt == TokenType.LEX_LESS_OR_EQUAL || tt == TokenType.LEX_GREATER_OR_EQUAL) {
int op = Operation.OpKind_NO_OP;
ExprTreeHolder treeL = tree;
ExprTreeHolder treeR = objectPool.mutableExprPool.get();
lexer.consumeToken();
parseShiftExpression(treeR);
switch(tt) {
case LEX_LESS_THAN:
op = Operation.OpKind_LESS_THAN_OP;
break;
case LEX_LESS_OR_EQUAL:
op = Operation.OpKind_LESS_OR_EQUAL_OP;
break;
case LEX_GREATER_THAN:
op = Operation.OpKind_GREATER_THAN_OP;
break;
case LEX_GREATER_OR_EQUAL:
op = Operation.OpKind_GREATER_OR_EQUAL_OP;
break;
default:
throw new HyracksDataException("ClassAd: Should not reach here");
}
if (treeL.getInnerTree() != null && treeR.getInnerTree() != null) {
Operation newTree = objectPool.operationPool.get();
Operation.createOperation(op, treeL, treeR, null, newTree);
tree.setInnerTree(newTree);
} else {
tree.setInnerTree(null);
return false;
}
tt = lexer.peekToken();
}
return true;
}
use of org.apache.asterix.external.classad.ExprTreeHolder in project asterixdb by apache.
the class ClassAdParser method parseLogicalANDExpression.
// LogicalANDExpression .= InclusiveORExpression
// | LogicalANDExpression '&&' InclusiveORExpression
private boolean parseLogicalANDExpression(ExprTreeHolder tree) throws IOException {
if (!parseInclusiveORExpression(tree)) {
return false;
}
while ((lexer.peekToken()) == TokenType.LEX_LOGICAL_AND) {
ExprTreeHolder treeL = tree;
ExprTreeHolder treeR = objectPool.mutableExprPool.get();
lexer.consumeToken();
parseInclusiveORExpression(treeR);
if (treeL.getInnerTree() != null && treeR.getInnerTree() != null) {
Operation newTree = objectPool.operationPool.get();
Operation.createOperation(Operation.OpKind_LOGICAL_AND_OP, treeL, treeR, null, newTree);
tree.setInnerTree(newTree);
} else {
tree.setInnerTree(null);
return false;
}
}
return true;
}
use of org.apache.asterix.external.classad.ExprTreeHolder in project asterixdb by apache.
the class ClassAdParser method parseExclusiveORExpression.
// ExclusiveORExpression .= ANDExpression
// | ExclusiveORExpression '^' ANDExpression
private boolean parseExclusiveORExpression(ExprTreeHolder tree) throws IOException {
if (!parseANDExpression(tree)) {
return false;
}
while ((lexer.peekToken()) == TokenType.LEX_BITWISE_XOR) {
lexer.consumeToken();
ExprTreeHolder treeL = tree;
ExprTreeHolder treeR = objectPool.mutableExprPool.get();
parseANDExpression(treeR);
if (treeL.getInnerTree() != null && treeR.getInnerTree() != null) {
Operation newTree = objectPool.operationPool.get();
Operation.createOperation(Operation.OpKind_BITWISE_XOR_OP, treeL, treeR, null, newTree);
tree.setInnerTree(newTree);
} else {
tree.setInnerTree(null);
return false;
}
}
return true;
}
use of org.apache.asterix.external.classad.ExprTreeHolder in project asterixdb by apache.
the class ClassAdParser method parseExprList.
public boolean parseExprList(ExprList list, boolean full) throws IOException {
TokenType tt;
ExprTreeHolder tree = objectPool.mutableExprPool.get();
ExprList loe = objectPool.exprListPool.get();
if ((tt = lexer.consumeToken()) != TokenType.LEX_OPEN_BRACE) {
throw new HyracksDataException("while parsing expression list: expected LEX_OPEN_BRACE" + " but got " + Lexer.strLexToken(tt));
// return false;
}
tt = lexer.peekToken();
while (tt != TokenType.LEX_CLOSE_BRACE) {
// parse the expression
parseExpression(tree);
if (tree.getInnerTree() == null) {
throw new HyracksDataException("while parsing expression list: expected " + "LEX_CLOSE_BRACE or LEX_COMMA but got " + Lexer.strLexToken(tt));
}
// insert the expression into the list
loe.add(tree);
// the next token must be a ',' or a '}'
tt = lexer.peekToken();
if (tt == TokenType.LEX_COMMA) {
lexer.consumeToken();
} else if (tt != TokenType.LEX_CLOSE_BRACE) {
throw new HyracksDataException("while parsing expression list: expected " + "LEX_CLOSE_BRACE or LEX_COMMA but got " + Lexer.strLexToken(tt));
}
}
lexer.consumeToken();
list.setValue(ExprList.createExprList(loe, objectPool));
// if a full parse was requested, ensure that input is exhausted
if (full && (lexer.consumeToken() != TokenType.LEX_END_OF_INPUT)) {
list.clear();
throw new HyracksDataException("while parsing expression list: expected " + "LEX_END_OF_INPUT for full parse but got " + Lexer.strLexToken(tt));
}
return true;
}
use of org.apache.asterix.external.classad.ExprTreeHolder in project asterixdb by apache.
the class FunctionalTester method handle_sameq.
/*********************************************************************
* Function: handle_sameq
* Purpose:
* @param objectPool
*
* @throws IOException
*********************************************************************/
public static void handle_sameq(AMutableString line, State state, Parameters parameters, ClassAdObjectPool objectPool) throws IOException {
ExprTreeHolder tree = new ExprTreeHolder(objectPool);
ExprTreeHolder tree2 = new ExprTreeHolder(objectPool);
get_two_exprs(line, tree, tree2, state, parameters, objectPool);
if (tree.getInnerTree() != null || tree2.getInnerTree() != null) {
if (!tree.sameAs(tree2)) {
print_error_message("the expressions are different.", state);
}
}
return;
}
Aggregations