-
Notifications
You must be signed in to change notification settings - Fork 0
/
Symbol.cpp
65 lines (55 loc) · 1.19 KB
/
Symbol.cpp
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
60
61
62
63
64
65
//
// Created by vedam on 4/20/22.
//
#include "Symbol.hpp"
Symbol::Symbol(std::string name, std::string module, SymbolType type, bool variable, bool exported) :
m_name(name),
m_module(module),
m_exported(exported),
m_variable(variable),
m_type(type)
{
}
Symbol::~Symbol() noexcept {}
std::string Symbol::name() const { return m_name; }
std::ostream &operator<<(std::ostream &os, const Symbol &symbol)
{
os << "Symbol<";
os << "name: " << symbol.m_name;
os << ", type: " << typeid(symbol).name();
os << ", exported: " << symbol.m_exported;
os << ">";
return os;
}
std::string toString(SymbolType type) {
switch (type) {
case SymbolType::INTEGER:
return "INTEGER";
case SymbolType::REAL:
return "REAL";
case SymbolType::ARRAY_TYPE:
return "ARRAY OF";
case SymbolType::POINTER_TYPE:
return "POINTER TO ";
case SymbolType::RECORD_TYPE:
return "RECORD WITH ";
default:
return "UNKNOWN TYPE";
}
}
bool Symbol::exported() const
{
return false;
}
bool Symbol::variable() const
{
return false;
}
SymbolType Symbol::type() const
{
return m_type;
}
std::string Symbol::module() const
{
return m_module;
}