コード例 #1
0
  private PExp parse(String exp) throws AnalysisException {
    if (exp == null || exp.isEmpty()) {
      throw new AnalysisException("No expression to generate from");
    }

    ParserResult<PExp> parseResult = null;

    try {
      parseResult = ParserUtil.parseExpression(exp);
    } catch (Exception e) {
      throw new AnalysisException(
          "Unable to parse expression: " + exp + ". Message: " + e.getMessage());
    }

    if (parseResult.errors.size() > 0) {
      throw new AnalysisException("Unable to parse expression: " + exp);
    }

    TypeCheckResult<PExp> typeCheckResult = null;
    try {
      typeCheckResult = TypeCheckerUtil.typeCheckExpression(exp);
    } catch (Exception e) {
      throw new AnalysisException(
          "Unable to type check expression: " + exp + ". Message: " + e.getMessage());
    }

    if (typeCheckResult.errors.size() > 0) {
      // throw new AnalysisException("Unable to type check expression: "
      // + exp);
    }

    return typeCheckResult.result;
  }