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


C++ SymbolTable::Insert方法代码示例

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


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

示例1: subprogram_head

//---------------------------------------------------------------------
//subprogram_head->PROCEDURE ID subprogram_parameters SEMICOLON
//1.  Traverse the list of variable symbols to create list of parameters
//2.  Create a procedure symbol using the list of parameters created in step 1.
//3.  Insert the procedure symbol into the symbol table.
//4.  Create a new locality.
//5.  Insert the variable symbols into the symbol table.
//---------------------------------------------------------------------
SubprogramSymbol* subprogram_head(string id,List<VariableSymbol*>* VL)
{  Subprogram* PL=ParameterList(VL,ST.TVoid());
   ProcedureSymbol* P=new ProcedureSymbol(id,PL,ST.LexicalLevel());
   ST.Insert(P);
   ST.NewLocality();
   InsertVariables(VL);
   return P;
}
开发者ID:drenfro87,项目名称:TD,代码行数:16,代码来源:subprogram_head.cpp

示例2: program_head

//---------------------------------------------------------------------
//---------------------------------------------------------------------
SubprogramSymbol* program_head(string id)
{  List<VariableSymbol*>* VL=new List<VariableSymbol*>;
   Subprogram* PL=ParameterList(VL,ST.TVoid());
   ProcedureSymbol* P=new ProcedureSymbol(id,PL,0);

   ST.Insert(P);
   ST.NewLocality();
   return P;
}
开发者ID:drenfro87,项目名称:TD,代码行数:11,代码来源:program_head.cpp

示例3: TestLogic


//.........这里部分代码省略.........

				ASTTreeCtrlVisitor						ctrlvis(ctrltxt);
				ASTTreeVisualisationVisitor				visitor(fouttxt);
				//ASTTreeVisualisationVisitor				metaVisualVisitor(metatxt);
				//ASTMITTreeVisualizerXMLProducerVisitor	mitvis(foutxml);
				//ASTCloneVisitor							cloneVisitor;
				//ASTUnparseTreeVisitor					uparseVisitor;
				//
				root->Accept(&visitor);
				root->Accept(&ctrlvis);
				//root->Accept(&mitvis);
				//root->Accept(&uparseVisitor);
				//root->Accept(&cloneVisitor);

				//String unpasedString1 = uparseVisitor.UnparsedString();
				//uparseVisitor.CleanUnparsedString();

				//cloneVisitor.Root()->Accept(&uparseVisitor);
				//String unpasedString2 = uparseVisitor.UnparsedString();
				//
				//SINASSERT(unpasedString1 == unpasedString2);

				//

				//static_cast<OutputStream&>(STDOUT) << "\n\n" << unpasedString2 << "\n\n\n";

				foutxml.flush();
				fouttxt.flush();
				ctrltxt.flush();


				//ASTNode & lastKid = static_cast<ASTNode &>(*root->rbegin());
				//cloneVisitor.Resset();
				//lastKid.Accept(&cloneVisitor);
				//uparseVisitor.CleanUnparsedString();
				//ASTNode * cloneRoot = cloneVisitor.Root();
				//cloneRoot->Accept(&uparseVisitor);
				//static_cast<OutputStream&>(STDOUT) << "\n\n" << uparseVisitor.UnparsedString() << "\n\n\n";
				//cloneVisitor.DeleteListAndAST();


				VM::VirtualState vs;
				vs.SetPrintHandler(&__print_handler);

				Library::Library lib;

				Library::Functions::print			print;
				Library::Functions::println			println;
				Library::Functions::arguments		arguments;
				Library::Functions::totalarguments	totalarguments;
				Library::Functions::tostring		tostring;
				Library::Functions::strtonum		strtonum;
				Library::Functions::typeof			typeof;
				Library::Functions::fileopen        fileopen;
				Library::Functions::fileread        fileread;
				
				lib.InstallFunction(&print			);
				lib.InstallFunction(&println		);
				lib.InstallFunction(&arguments		);
				lib.InstallFunction(&totalarguments	);
				lib.InstallFunction(&tostring		);
				lib.InstallFunction(&strtonum		);
				lib.InstallFunction(&typeof			);
				lib.InstallFunction(&fileopen       );
				lib.InstallFunction(&fileread       );

				// TODO remove the reference here and watch it burn 
				SymbolTable *globalSymTable = &vs.CurrentStable();
				globalSymTable->Insert("print",          SINEWCLASS(MemoryCellLibFunction, (&print)));
				globalSymTable->Insert("println",        SINEWCLASS(MemoryCellLibFunction, (&println)));
				globalSymTable->Insert("arguments",      SINEWCLASS(MemoryCellLibFunction, (&arguments)));
				globalSymTable->Insert("totalarguments", SINEWCLASS(MemoryCellLibFunction, (&totalarguments)));
				globalSymTable->Insert("tostring",       SINEWCLASS(MemoryCellLibFunction, (&tostring)));
				globalSymTable->Insert("strtonum",       SINEWCLASS(MemoryCellLibFunction, (&strtonum)));
				globalSymTable->Insert("typeof",         SINEWCLASS(MemoryCellLibFunction, (&typeof)));
				globalSymTable->Insert("fileopen",       SINEWCLASS(MemoryCellLibFunction, (&fileopen)));
				globalSymTable->Insert("fileread",       SINEWCLASS(MemoryCellLibFunction, (&fileread)));

				
				TreeEvaluationVisitor eval(&lib, &vs);
				
				try {
					root->Accept(&eval);
				} catch(SIN::RunTimeError rte) {
					static_cast<OutputStream&>(STDOUT) << rte.CompleteMessage() << "\n";
					exit(-1);
				} catch(...) {
					static_cast<OutputStream&>(STDOUT) << "Unexpected exception" << "\n";
					exit(-1);
				}
				//ShiftToMetaEvaluatorASTVisitor shifter(eval);
				//root->Accept(&shifter);
				//shifter.Root()->Accept(&metaVisualVisitor);
				
				

				metatxt.flush();
				test.DeleteListAndAST();
//				shifter.DeleteListAndAST();
			}
开发者ID:HistoricalValue,项目名称:sin,代码行数:101,代码来源:SINRunTester.cpp

示例4: InsertVariables

//---------------------------------------------------------------------
//Function InsertVariables inserts variables into the symbol table
//---------------------------------------------------------------------
static void InsertVariables(List<VariableSymbol*>* VL)
{   for (VL->First();!VL->IsEol();VL->Next()) {
        VariableSymbol* S=VL->Member();
        ST.Insert(S);
    }
}
开发者ID:drenfro87,项目名称:TD,代码行数:9,代码来源:subprogram_head.cpp


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