Package com.odiago.flumebase.parser

Examples of com.odiago.flumebase.parser.Expr.accept()


    // Test that INT can promote to BIGINT on the lhs.
    Expr binopExpr = new BinExpr(
      new ConstExpr(Type.getPrimitive(Type.TypeName.BIGINT), Integer.valueOf(2)),
      BinOp.Add, new ConstExpr(Type.getPrimitive(Type.TypeName.INT), Integer.valueOf(3)));
    TypeChecker tc = new TypeChecker(new HashSymbolTable());
    binopExpr.accept(tc);
  }

  @Test
  public void testIdentifier() throws VisitException {
    // Test that we can look up an identifier in the symbol table.
View Full Code Here


    Expr binopExpr = new BinExpr(
      new ConstExpr(Type.getPrimitive(Type.TypeName.INT), Integer.valueOf(2)),
      BinOp.Add, new IdentifierExpr("x"));
    TypeChecker tc = new TypeChecker(symbols);
    binopExpr.accept(tc);
  }

  @Test
  public void testIdentifierPromotion() throws VisitException {
    // Test that an identifier's type can promote to a constant.
View Full Code Here

    Expr binopExpr = new BinExpr(
      new ConstExpr(Type.getPrimitive(Type.TypeName.BIGINT), Integer.valueOf(2)),
      BinOp.Add, new IdentifierExpr("x"));
    TypeChecker tc = new TypeChecker(symbols);
    binopExpr.accept(tc);
  }

  @Test
  public void testIdentifierPromotion2() throws VisitException {
    // Test that a const's type can promote to an identifier's.
View Full Code Here

    Expr binopExpr = new BinExpr(
      new ConstExpr(Type.getPrimitive(Type.TypeName.INT), Integer.valueOf(2)),
      BinOp.Add, new IdentifierExpr("x"));
    TypeChecker tc = new TypeChecker(symbols);
    binopExpr.accept(tc);
  }

  // TODO:
  // Test unary expressions
  // Test restrictions on aliasedexpr with AllFieldsExpr
View Full Code Here

      }

      // Check the where clause for validity if it's non-null.
      Expr where = s.getWhereConditions();
      if (null != where) {
        where.accept(this);
        // The where clause must evaluate to a boolean value.
        Type whereType = where.getType(exprTable);
        if (!whereType.promotesTo(Type.getNullable(Type.TypeName.BOOLEAN))) {
          throw new TypeCheckException("Expected where clause with boolean type, not "
              + whereType);
View Full Code Here

      // Check the OVER clause for validity if it's non-null.
      // This must evaluate to a value of type WINDOW.
      Expr windowOver = s.getWindowOver();
      if (null != windowOver) {
        windowOver.accept(this);
        Type winType = windowOver.getType(exprTable);
        if (!winType.equals(Type.getPrimitive(Type.TypeName.WINDOW))) {
          throw new TypeCheckException("SELECT ... OVER clause requires a window, not an "
              + "identifier of type " + winType);
        }
View Full Code Here

    // HAVING clause uses the output symbol names. It can only operate on
    // fields already explicitly selected by the user -- if these are not
    // already present, this will fail.
    Expr having = s.getHaving();
    if (null != having) {
      having.accept(this);
      // The having clause must evaluate to a boolean value.
      Type havingType = having.getType(outTable);
      if (!havingType.promotesTo(Type.getNullable(Type.TypeName.BOOLEAN))) {
        throw new TypeCheckException("Expected having clause with boolean type, not "
            + havingType);
View Full Code Here

    s.setJoinedSymbols(symTab);
    mSymTableContext.push(symTab);

    // Verify that the join expression is BOOLEAN.
    Expr joinExpr = s.getJoinExpr();
    joinExpr.accept(this);
    Type joinType = joinExpr.getType(symTab);
    if (!joinType.promotesTo(Type.getNullable(Type.TypeName.BOOLEAN))) {
      throw new TypeCheckException("JOIN ... ON clause requires boolean test expression, not "
          + joinExpr.toStringOneLine());
    }
View Full Code Here

          + joinExpr.toStringOneLine());
    }

    // Make sure the "OVER" clause joins over a Window.
    Expr windowExpr = s.getWindowExpr();
    windowExpr.accept(this);
    Type winType = windowExpr.getType(symTab);
    if (!winType.equals(Type.getPrimitive(Type.TypeName.WINDOW))) {
      throw new TypeCheckException("JOIN ... OVER clause requires a window, not an "
          + "identifier of type " + winType);
    }
View Full Code Here

      throw new TypeCheckException("Cannot use the '.' character in a field alias ("
          + userAlias + ")");
    }

    // Typecheck the sub-expression.
    subExpr.accept(this);
  }

  protected void visit(ConstExpr e) throws VisitException {
    // Nothing to do.
  }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.