Search in sources :

Example 1 with SyntaxException

use of com.cinchapi.ccl.SyntaxException in project concourse by cinchapi.

the class Criteria method parse.

/**
 * Return a {@link Criteria} object that expresses the same as the
 * {@code ccl} statement.
 *
 * @param ccl the CCL statement to parse
 * @return an equivalent {@link Criteria} object
 */
public static Criteria parse(String ccl) {
    try {
        AbstractSyntaxTree ast = ConcourseCompiler.get().parse(ccl);
        BuiltCriteria criteria = new BuiltCriteria();
        criteria.symbols = Lists.newArrayList(ConcourseCompiler.get().tokenize(ast));
        return criteria;
    } catch (Exception e) {
        if (e instanceof SyntaxException || e instanceof IllegalStateException || e.getCause() != null && e.getCause() instanceof com.cinchapi.ccl.generated.ParseException) {
            throw new ParseException(new com.cinchapi.concourse.thrift.ParseException(e.getMessage()));
        } else {
            throw CheckedExceptions.throwAsRuntimeException(e);
        }
    }
}
Also used : AbstractSyntaxTree(com.cinchapi.ccl.syntax.AbstractSyntaxTree) SyntaxException(com.cinchapi.ccl.SyntaxException) ParseException(com.cinchapi.concourse.ParseException) SyntaxException(com.cinchapi.ccl.SyntaxException) ParseException(com.cinchapi.concourse.ParseException)

Aggregations

SyntaxException (com.cinchapi.ccl.SyntaxException)1 AbstractSyntaxTree (com.cinchapi.ccl.syntax.AbstractSyntaxTree)1 ParseException (com.cinchapi.concourse.ParseException)1