-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsymbolArray.cpp
57 lines (49 loc) · 1.18 KB
/
symbolArray.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
#include "stdafx.h"
#include "symbolArray.h"
typedef size_t refId;
symbolArray::symbolArray()
{
push_back(std::make_tuple(TYPES::MOCK, -1));
}
symbolArray::~symbolArray()
{
while (!empty())
{
auto t = back();
switch (std::get<0>(t))
{
case TYPES::COMMENT: delete std::get<1>(t).string; break;
case TYPES::ERROR: delete std::get<1>(t).errorMsg; break;
case TYPES::LABEL: delete std::get<1>(t).string; break;
}
pop_back();
}
}
#define Gen(ARG, CLASS, VAL) case ARG: out << "<span class=\"" #CLASS "\">" << VAL << "</span>"; break;
std::ostream &operator<<(std::ostream &out, const entry &entry)
{
auto &val = std::get<1>(entry);
switch (std::get<0>(entry))
{
case TYPES::ERROR:
{
auto a = std::get<1>(*val.errorMsg);
encode(a);
out << "<abbr title=\"" << std::get<0>(*val.errorMsg) << "\">" << a << "</abbr>"; break;
}
case TYPES::COMMENT:
{
std::string a = *val.string;
encode(a);
if (val.string->size())
out << R"(<span class="comment">)" << a << "</span>";
out << std::endl;
break;
}
Gen(TYPES::NUMBER, number, val.number);
Gen(TYPES::LABEL, label, *val.string);
default:
out << "Implement me for " << (int) std::get<0>(entry);
}
return out;
}