forked from mashiox/idaho_sicxe_assembler
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsymtab.cc
39 lines (33 loc) · 853 Bytes
/
symtab.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/* Phillip Domann, Shad Aziz, Melanie Reed, Matt Walther
masc0832
Team Idaho
prog3
CS530, Spring 2016
*/
#include <map>
#include <string>
#include <sstream>
#include "symtab.h"
#include "symtab_exception.h"
using namespace std;
symtab::symtab(){}
void symtab::add(string label, string value){
symbol_iter = symbol_table.find(label);
if( symbol_iter != symbol_table.end() ) {
throw symtab_exception("Symbol " + label + " already declared");
}
symbol_table[label] = value;
}
string symtab::get(string label){
symbol_iter = symbol_table.find(label);
if( symbol_iter == symbol_table.end() ) {
throw symtab_exception("Label " + label + " does not exist");
}
return symbol_iter->second;
}
bool symtab::exists(string label){
if ( symbol_table.find(label) == symbol_table.end() )
return false;
else
return true;
}