Search in sources :

Example 1 with StringLexerSource

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;
}
Also used : ClassAdParser(org.apache.asterix.external.library.ClassAdParser) StringLexerSource(org.apache.asterix.external.classad.StringLexerSource) ExprTree(org.apache.asterix.external.classad.ExprTree) PrettyPrint(org.apache.asterix.external.classad.PrettyPrint)

Example 2 with StringLexerSource

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;
}
Also used : StringLexerSource(org.apache.asterix.external.classad.StringLexerSource)

Example 3 with StringLexerSource

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;
}
Also used : StringLexerSource(org.apache.asterix.external.classad.StringLexerSource) ClassAd(org.apache.asterix.external.classad.ClassAd)

Example 4 with StringLexerSource

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;
}
Also used : ClassAdParser(org.apache.asterix.external.library.ClassAdParser) StringLexerSource(org.apache.asterix.external.classad.StringLexerSource) IOException(java.io.IOException) PrettyPrint(org.apache.asterix.external.classad.PrettyPrint)

Example 5 with StringLexerSource

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;
}
Also used : StringLexerSource(org.apache.asterix.external.classad.StringLexerSource)

Aggregations

StringLexerSource (org.apache.asterix.external.classad.StringLexerSource)5 PrettyPrint (org.apache.asterix.external.classad.PrettyPrint)2 ClassAdParser (org.apache.asterix.external.library.ClassAdParser)2 IOException (java.io.IOException)1 ClassAd (org.apache.asterix.external.classad.ClassAd)1 ExprTree (org.apache.asterix.external.classad.ExprTree)1