-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProduction.cpp
51 lines (41 loc) · 1.16 KB
/
Production.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
#include "Production.hpp"
/********************----- CLASS: Production -----********************/
Production::Production(SymbolList &&i_left, SymbolList &&i_right)
:m_left(std::forward<SymbolList>(i_left)), m_right(std::forward<SymbolList>(i_right))
{
}
Production::Production(SymbolList const &i_left, SymbolList const &i_right)
:m_left(i_left), m_right(i_right)
{
}
SymbolList const &Production::left() const
{
return m_left;
}
SymbolList const &Production::right() const
{
return m_right;
}
std::string Production::toString() const
{
std::string returnString;
for(size_t i=0; i<m_left.count(); ++i)
{
returnString += m_left[i].toString();
returnString += " ";
}
returnString += "=>";
for(size_t i=0; i<m_right.count(); ++i)
{
returnString += " ";
returnString += m_right[i].toString();
}
return returnString;
}
/**************************************************/
/********************----- Operators -----********************/
Production operator>>=(SymbolList &&i_left, SymbolList &&i_right)
{
return Production(std::forward<SymbolList>(i_left), std::forward<SymbolList>(i_right));
}
/**************************************************/