Package com.odiago.flumebase.exec

Examples of com.odiago.flumebase.exec.SymbolTable


  }

  @Override
  protected void visit(DropStmt s) throws VisitException {
    // Check that the DROP ____ type matches the type of the object to be dropped.
    SymbolTable symtab = mSymTableContext.top();
    String name = s.getName();
    Symbol sym = symtab.resolve(name);
    if (null == sym) {
      throw new TypeCheckException("No such object at top level: " + name);
    }
    EntityTarget targetType = s.getType();
    Type.TypeName symType = sym.getType().getTypeName();
View Full Code Here


    // Nothing to do.
  }

  @Override
  protected void visit(LiteralSource s) throws VisitException {
    SymbolTable symtab = mSymTableContext.top();

    String name = s.getName();
    LOG.debug("Visiting literalsrc " + name);
    Symbol symbol = symtab.resolve(name);
    if (null == symbol) {
      throw new TypeCheckException("No such identifier: " + name);
    } else if (symbol.getType().getTypeName() != Type.TypeName.STREAM) {
      throw new TypeCheckException("Identifier " + name + " is not a stream (type="
          + symbol.getType());
    }

    // Add a new symbol table layer containing the named stream's symbols.
    SymbolTable sourceTable = s.getFieldsSymbolTable(symtab, mNextFieldId);

    // Push it on top of the stack.
    mSymTableContext.push(sourceTable);
  }
View Full Code Here

    }
  }

  @Override
  protected void visit(SelectStmt s) throws VisitException {
    SymbolTable outTable = null;

    mSelectNestingDepth++;

    // Visiting a source pushes one or more symbol tables on the stack,
    // declaring the fields of this source. While visiting our clauses, we
    // also push a symbol table declaring the names of any windows defined
    // with WINDOW .. AS clauses.  Make sure we pop them on our way out by
    // resetting the stack to its current height.
    int symbolStackHeight = mSymTableContext.size();
    SymbolTable originalSymtab = mSymTableContext.top();

    try {
      // Visit the window clauses first; if their types are okay, create a new
      // symbol table to use when visiting our sources, that contains the
      // window names.

      SymbolTable symbolsForSources = new HashSymbolTable(originalSymtab);
      List<WindowDef> windowDefs = s.getWindowDefs();
      for (WindowDef def : windowDefs) {
        def.accept(this);
        symbolsForSources.addSymbol(new WindowSymbol(def.getName(), def.getWindowSpec()));
      }
      mSymTableContext.push(symbolsForSources);
     
      // Now visit the sources, with the symbols for any windows pushed.
      SQLStatement source = s.getSource();
      visitValidSource(source);

      SymbolTable exprTable = mSymTableContext.top();
      outTable = new HashSymbolTable(originalSymtab);

      // The "stream name" representing this SELECT stmt in the parent
      // statement.
      String stmtAlias = s.getAlias();
      // Nested SELECT statements require an alias.
      if (mSelectNestingDepth > 1 && null == stmtAlias) {
        throw new TypeCheckException("Each derived stream must have its own alias.");
      }

      // Type check all the selected expressions using the symbols from our source.
      for (AliasedExpr aliasedExpr : s.getSelectExprs()) {
        aliasedExpr.accept(this);
        // Add our output symbols to the output symbol table.
        if (aliasedExpr.getExpr() instanceof AllFieldsExpr) {
          // Add all symbols in the source's table into this one,
          // to add fields pulled in by the "*" operator.
          // Resolve away all aliased symbols to their final version, and rename
          // any "qualifier.field" -> "field".
          Iterator<Symbol> sourceSymbols = exprTable.levelIterator();
          while (sourceSymbols.hasNext()) {
            Symbol srcSym = sourceSymbols.next().resolveAliases();
            String symName = StringUtils.dequalify(srcSym.getName());

            if (null != stmtAlias) {
View Full Code Here

    assert(mSymTableContext.size() == symtabHeight + 2);

    // Each of these sources has pushed one symbol table on the stack.
    // Merge them together, removing duplicate symbols. These must be
    // referred to by "qualified.alias" only.
    SymbolTable rightSymTab = mSymTableContext.pop();
    SymbolTable leftSymTab = mSymTableContext.pop();

    SymbolTable symTab = SymbolTable.mergeSymbols(leftSymTab, rightSymTab,
        mSymTableContext.top());
    s.setJoinedSymbols(symTab);
    mSymTableContext.push(symTab);

    // Verify that the join expression is BOOLEAN.
View Full Code Here

  @Override
  protected void visit(DescribeStmt s) throws VisitException {
    // Check the symbol table that the identifier exists.
    String id = s.getIdentifier();
    SymbolTable symtab = mSymTableContext.top();

    Symbol symbol = symtab.resolve(id);
    if (null == symbol) {
      throw new TypeCheckException("No such identifier: " + id);
    }
  }
View Full Code Here

  protected void visit(BinExpr e) throws VisitException {
    // Type-check sub-expressions.
    e.getLeftExpr().accept(this);
    e.getRightExpr().accept(this);

    SymbolTable symTab = mSymTableContext.top();

    // Get the type from the expression; this handles promotion of
    // lhs to rhs or vice versa.
    Type expType = e.getType(symTab);
    if (null == expType) {
View Full Code Here

    outSym.item = (AssignedSymbol) fieldSym;
  }

  protected void visit(IdentifierExpr e) throws VisitException {
    SymbolTable fieldsSymTab = mSymTableContext.top();
    String fieldName = e.getIdentifier();

    Ref<AssignedSymbol> symRef = new Ref<AssignedSymbol>();
    Ref<Type> typeRef = new Ref<Type>();
    resolveIdentifier(fieldsSymTab, fieldName, symRef, typeRef);
View Full Code Here

    // and that the subexpr type is appropriate for the operator.

    // Start by type-checking the subexpression.
    e.getSubExpr().accept(this);

    SymbolTable symTab = mSymTableContext.top();
    Type expType = e.getType(symTab);
    if (null == expType) {
      throw new TypeCheckException("Cannot resolve type for expression: " + e.toStringOneLine());
    }
View Full Code Here

    Expr prev = spec.getPrevSize();
    after.accept(this);
    prev.accept(this);


    SymbolTable symTab = mSymTableContext.top();
   
    Type prevType = prev.getType(symTab);
    Type afterType = after.getType(symTab);
    if (null == prevType) {
      throw new TypeCheckException("Cannot resolve type for expression: "
View Full Code Here

      throw new TypeCheckException("Expression " + after.toStringOneLine() + " is not constant");
    }
  }

  protected void visit(GroupBy g) throws VisitException {
    SymbolTable fieldsSymTab = mSymTableContext.top();

    // Check that the fields are real fields; resolve them to TypedField instances,
    // like we do for an IdentifierExpr.
    List<TypedField> typedFields = new ArrayList<TypedField>();
    Ref<AssignedSymbol> symRef = new Ref<AssignedSymbol>();
View Full Code Here

TOP

Related Classes of com.odiago.flumebase.exec.SymbolTable

Copyright © 2018 www.massapicom. 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.