32 lines
628 B
C++
32 lines
628 B
C++
#include "orga-comp.h"
|
|
#include <cstddef>
|
|
#include <string>
|
|
|
|
scope::scope(){
|
|
head = nullptr;
|
|
}
|
|
|
|
void
|
|
scope::add(std::string key, symbol_type type, size_t pos){
|
|
if (head == nullptr){
|
|
head = new node;
|
|
head->key = key;
|
|
head->type = type;
|
|
}else{
|
|
struct node *tmp = head;
|
|
head = new node;
|
|
head->key = key;
|
|
head->type = type;
|
|
head->next = tmp;
|
|
}
|
|
}
|
|
|
|
scope::symbol_type
|
|
scope::look(std::string key){
|
|
struct node *tmp = head;
|
|
while(tmp != nullptr){
|
|
if(tmp->key == key) return tmp->type;
|
|
tmp = tmp->next;
|
|
}
|
|
return NOT_FOUND;
|
|
} |