-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathenvironment.hpp
59 lines (43 loc) · 1.49 KB
/
environment.hpp
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// File: environment.hpp
// Author: Samuel McFalls
#ifndef ENVIRONMENT_H
#define ENVIRONMENT_H
#include <unordered_map>
#include <string>
#include <math.h>
#include "proc.hpp"
#include "interpreter_semantic_error.hpp"
#include "env_entry.hpp"
class Environment {
public:
// Default constructor
// Pre-loads the environment with the required symbols and procedures
Environment();
// Defines a symbol in the environment
// @param symbol The key associated with the value to store
// @param entry The value to store
// @throw InterpreterSemanticError if the symbol is already defined
void define(std::string symbol, EnvEntry entry);
// Gets the value associated with a symbol
// @param symbol The key associated with the desired value
// @return The value associated with the given key
// @throw InterpreterSemanticError if the symbol is not found
EnvEntry fetch(std::string symbol);
// Checks if a symbol is defined
// @param symbol The key to check
// return True if the key is defined, false otherwise
bool exists(std::string symbol);
// Clears the vector of graphical items to be drawn
void clearToDraw();
// Adds an item to the vector of items to be drawn
// @param item The item to add
// @throw logic_error if item is not graphical type
void addDraw(Atom item);
// Gets the vector of graphical items to be drawn
// @return The vector of items to be drawn
std::vector<Atom> toBeDrawn();
private:
std::unordered_map<std::string, EnvEntry> env;
std::vector<Atom> toDraw;
};
#endif