Beispiel #1
0
int main() {

	node root;
	Bst *t = new Bst(&root, 10);
	t->insert(&root, 5);
	t->printTree(&root);

	return 0;
}
Beispiel #2
0
/*
Function: insertNewSymbol(std::string name, int line)

Description: This function will add a new entry to the current scope level
on the stack. 

Parameters:
std::string name: The name of the identifier to be added to the current scope 
level. 
int line: The line number that the associated identifier is located at in the
source program. 
*/
symbolTableEntry* symbolTable::insertNewSymbol(std::string name, int line) {
	symbolTableEntry* newEntry = new symbolTableEntry(name, line);
	Bst* currentVars = table[table.size() - 1].getBst();
	currentVars->insert(entry(name, *newEntry));
	bstItr bitr = currentVars->find(name);
	if(bitr != currentVars->end()){
		return &bitr->second; 
	}
	else{
		return NULL;
	}
}
Beispiel #3
0
/*
Function: insertNewSymbol(std::string name, int line)

Description: This function will add a new entry to the current scope level
on the stack. 

Parameters:
std::string name: The name of the identifier to be added to the current scope 
level. 
int line: The line number that the associated identifier is located at in the
source program. 
*/
symbolTableEntry* symbolTable::insertNewSymbol(std::string name, int line) {
	// allocate a new symbol table entry object and add it to the BST at
	// the current scope 
	symbolTableEntry* newEntry = new symbolTableEntry(name, line);
	Bst* currentVars = table[table.size() - 1].getBst();
	currentVars->insert(entry(name, *newEntry));
	
	// search for and declare a pointer to the symbol table entry object in the
	// BST and NOT the one we just created in this function 
	bstItr bItr = currentVars->find(name);
	if(bItr != currentVars->end()) {
		return &bItr->second; 
	}
	else return NULL; 
}