2013-05-20 19:34:15 -04:00
|
|
|
#include "Symbol.h"
|
|
|
|
|
|
2013-10-02 03:15:20 -04:00
|
|
|
Symbol::Symbol() {
|
|
|
|
|
this->name = "UninitlizedSymbol";
|
|
|
|
|
this->terminal = false;
|
|
|
|
|
value = "NoValue";
|
|
|
|
|
}
|
|
|
|
|
|
2013-05-20 19:34:15 -04:00
|
|
|
Symbol::Symbol(std::string name, bool isTerminal) {
|
|
|
|
|
this->name = name;
|
2013-05-30 19:49:19 -04:00
|
|
|
this->terminal = isTerminal;
|
2013-07-02 01:47:42 -04:00
|
|
|
value = "NoValue";
|
2013-05-30 19:49:19 -04:00
|
|
|
}
|
|
|
|
|
|
2013-07-01 22:45:33 -04:00
|
|
|
Symbol::Symbol(std::string name, bool isTerminal, std::string value) {
|
|
|
|
|
this->name = name;
|
|
|
|
|
this->terminal = isTerminal;
|
|
|
|
|
this->value = value;
|
|
|
|
|
}
|
|
|
|
|
|
2013-05-20 19:34:15 -04:00
|
|
|
Symbol::~Symbol() {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-02 03:15:20 -04:00
|
|
|
const bool Symbol::operator==(const Symbol &other) const {
|
2013-05-30 19:49:19 -04:00
|
|
|
return( name == other.name && terminal == other.terminal);
|
2013-05-23 01:35:54 -04:00
|
|
|
}
|
|
|
|
|
|
2013-10-02 03:15:20 -04:00
|
|
|
const bool Symbol::operator!=(const Symbol &other) const {
|
2013-07-31 23:51:05 -04:00
|
|
|
return(!this->operator==(other));
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-02 03:15:20 -04:00
|
|
|
const bool Symbol::operator<(const Symbol &other) const {
|
|
|
|
|
return name < other.getName();
|
2013-06-27 23:45:38 -04:00
|
|
|
}
|
|
|
|
|
|
2013-10-02 03:15:20 -04:00
|
|
|
std::string Symbol::getName() const {
|
|
|
|
|
return(name);
|
2013-05-30 19:49:19 -04:00
|
|
|
}
|
|
|
|
|
|
2013-10-16 01:43:18 -04:00
|
|
|
std::string Symbol::getValue() const {
|
|
|
|
|
return(value);
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-02 03:15:20 -04:00
|
|
|
std::string Symbol::toString() const {
|
|
|
|
|
return(name + (terminal ? " " + value : ""));
|
2013-05-30 19:49:19 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Symbol::isTerminal() {
|
|
|
|
|
return terminal;
|
2013-05-20 19:34:15 -04:00
|
|
|
}
|
|
|
|
|
|