本文整理汇总了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;
}
示例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;
}
示例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();
}
示例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);
}
}