use of org.apache.asterix.external.classad.StringLexerSource in project asterixdb by apache.
the class FunctionalTester method get_expr.
/*********************************************************************
* Function: get_expr
* Purpose:
*
* @throws IOException
*********************************************************************/
public static ExprTree get_expr(AMutableString line, State state, Parameters parameters, ClassAdObjectPool objectPool) throws IOException {
int offset;
ExprTree tree;
ClassAdParser parser = new ClassAdParser(objectPool);
StringLexerSource lexer_source = new StringLexerSource(line.getStringValue());
tree = parser.parseExpression(lexer_source, false);
offset = lexer_source.getCurrentLocation();
shorten_line(line, offset);
if (tree == null) {
print_error_message("Missing expression", state);
}
return tree;
}
use of org.apache.asterix.external.classad.StringLexerSource in project asterixdb by apache.
the class ClassAdParser method parseClassAd.
public boolean parseClassAd(String buffer, ClassAd classad, AMutableInt32 offset) throws IOException {
boolean success = false;
StringLexerSource stringLexerSource = new StringLexerSource(buffer, offset.getIntegerValue());
success = parseClassAd(stringLexerSource, classad);
offset.setValue(stringLexerSource.getCurrentLocation());
return success;
}
use of org.apache.asterix.external.classad.StringLexerSource in project asterixdb by apache.
the class ClassAdParser method parseClassAd.
public ClassAd parseClassAd(String buffer, AMutableInt32 offset) throws IOException {
currentSource = new StringLexerSource(buffer);
ClassAd ad = parseClassAd((StringLexerSource) currentSource);
offset.setValue(((StringLexerSource) currentSource).getCurrentLocation());
return ad;
}
use of org.apache.asterix.external.classad.StringLexerSource in project asterixdb by apache.
the class FunctionalTester method get_two_exprs.
/*********************************************************************
* Function: get_two_exprs
* Purpose:
*
* @throws IOException
*********************************************************************/
public static void get_two_exprs(AMutableString line, ExprTreeHolder tree1, ExprTreeHolder tree2, State state, Parameters parameters, ClassAdObjectPool objectPool) throws IOException {
int offset;
ClassAdParser parser = new ClassAdParser(objectPool);
StringLexerSource lexer_source = new StringLexerSource(line.getStringValue());
tree1.setInnerTree(parser.parseExpression(lexer_source, false));
if (tree1.getInnerTree() == null) {
print_error_message("Couldn't parse first expression.", state);
tree2.setInnerTree(null);
throw new IOException();
} else {
if (parameters.debug) {
System.out.print("# Tree1: ");
print_expr(tree1, state, parameters, objectPool);
}
if (parser.peekToken() != TokenType.LEX_COMMA) {
print_error_message("Missing comma.\n", state);
tree1.setInnerTree(null);
tree2.setInnerTree(null);
;
} else {
parser.consumeToken();
tree2.setInnerTree(parser.parseNextExpression());
offset = lexer_source.getCurrentLocation();
shorten_line(line, offset);
if (tree2.getInnerTree() == null) {
print_error_message("Couldn't parse second expression.", state);
tree1.setInnerTree(null);
throw new IOException();
} else if (parameters.debug) {
System.out.print("# Tree2: ");
print_expr(tree2, state, parameters, objectPool);
System.out.print("# Tree1: ");
print_expr(tree1, state, parameters, objectPool);
System.out.println();
}
}
}
return;
}
use of org.apache.asterix.external.classad.StringLexerSource in project asterixdb by apache.
the class ClassAdParser method parseExpression.
public boolean parseExpression(String buf, ExprTreeHolder tree, boolean full) throws IOException {
boolean success;
StringLexerSource lexer_source = new StringLexerSource(buf);
success = false;
if (lexer.initialize(lexer_source)) {
success = parseExpression(tree, full);
}
return success;
}
Aggregations