当前位置: 首页>>代码示例>>C++>>正文


C++ Statement::aggregate方法代码示例

本文整理汇总了C++中Statement::aggregate方法的典型用法代码示例。如果您正苦于以下问题:C++ Statement::aggregate方法的具体用法?C++ Statement::aggregate怎么用?C++ Statement::aggregate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Statement的用法示例。


在下文中一共展示了Statement::aggregate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: aggregate

    void BlockStatement::aggregate()
    {
        // Create scope.
        scope = new SymbolTable(SymbolTable::getActiveScope());

        // If this scope has a name, register that as
        // a member of the containing scope.
        if(name)
        {
            // Assumes this code will never get executed by the outermost block (before there is an active scope).
            SymbolTable* outer = SymbolTable::getActiveScope();

            PackageDefinition* package = new PackageDefinition(name->getValue(), scope);

            // Shove the this package into the containing outer scope.
            outer->put(package, getSourcePosition());
            // Create a back-reference, so the scope knows it defines a new package,
            // rather than just sharing a private subset of the outer scope's package.
            scope->setPackage(package);
        }

        // Enter the created scope.
        SymbolTable::enterScope(scope);
        
        ListNode<Statement*>::ListType& list = statements->getList();
        // First gather all constant definitions in this scope.
        for(size_t i = 0; i < list.size(); i++)
        {
            Statement* statement = list[i];
            if(statement->getStatementType() == Statement::CONSTANT_DECLARATION)
            {
                statement->aggregate();
            }
        }
        
        // Next, if this is the main block, calculate the header.
        if(handleHeader(list))
        {
            // Now, check out all the other statements.
            for(size_t i = 0; i < list.size(); i++)
            {
                Statement* statement = list[i];
                switch(statement->getStatementType())
                {
                    // Skip already handled cases.
                    case Statement::CONSTANT_DECLARATION:
                    case Statement::HEADER:
                        break;
                    // Aggregate the rest.
                    default:
                        statement->aggregate();
                        break;
                }
            }
        }
        
        SymbolTable::exitScope();
    }
开发者ID:Bananattack,项目名称:nel-bison,代码行数:58,代码来源:block_statement.cpp

示例2: handleHeader

 // Find and handle the header for the main block.
 bool BlockStatement::handleHeader(ListNode<Statement*>::ListType& list)
 {
     Statement* header = 0;
     for(size_t i = 0; i < list.size(); i++)
     {
         Statement* statement = list[i];
         if(statement->getStatementType() == Statement::HEADER)
         {
             if(blockType == MAIN)
             {
                 if(!header)
                 {
                     header = list[i];
                 }
                 else
                 {
                     std::ostringstream os;
                     os << "multiple ines headers found. (previous header at ";
                     header->getSourcePosition()->print(os);
                     os << ").";
                     error(os.str(), statement->getSourcePosition(), true);
                     return false;
                 }
             }
             else
             {
                 std::ostringstream os;
                 os << "ines header cannot appear inside a begin/end block.";
                 error(os.str(), statement->getSourcePosition(), true);
                 return false;       
             }
         }
         else if(blockType == MAIN && !header)
         {
             if(statement->getStatementType() != Statement::CONSTANT_DECLARATION)
             {
                 error("statement that is not a constant declaration found before the ines header.", statement->getSourcePosition(), true);
                 return false;
             }
         }
     }
     
     if(blockType == MAIN)
     {
         if(!header)
         {
             error("no ines header found.", getSourcePosition(), true);
             return false;
         }
         
         header->aggregate();
     }
     return true;
 }
开发者ID:Bananattack,项目名称:nel-bison,代码行数:55,代码来源:block_statement.cpp


注:本文中的Statement::aggregate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。