2013-11-07 13:24:01 -08:00
|
|
|
#include "symbol.h"
|
2013-11-10 14:24:25 -08:00
|
|
|
#include "blank.h"
|
2013-11-07 13:24:01 -08:00
|
|
|
#include "transition_map.h"
|
|
|
|
|
|
|
|
|
|
namespace tree_sitter {
|
|
|
|
|
namespace rules {
|
2013-11-10 14:24:25 -08:00
|
|
|
Symbol::Symbol(const std::string &name) : name(name) {};
|
2013-11-14 12:55:02 -08:00
|
|
|
|
|
|
|
|
sym_ptr sym(const std::string &name) {
|
|
|
|
|
return std::make_shared<Symbol>(name);
|
|
|
|
|
}
|
2013-11-07 13:24:01 -08:00
|
|
|
|
|
|
|
|
TransitionMap<Rule> Symbol::transitions() const {
|
2013-11-14 12:55:02 -08:00
|
|
|
return TransitionMap<Rule>({ sym(name) }, { blank() });
|
2013-11-07 13:24:01 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Symbol::operator==(const Rule &rule) const {
|
|
|
|
|
const Symbol *other = dynamic_cast<const Symbol *>(&rule);
|
2013-11-14 21:25:58 -08:00
|
|
|
return other && (other->name == name);
|
2013-11-07 13:24:01 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::string Symbol::to_string() const {
|
2013-11-12 18:37:02 -08:00
|
|
|
return std::string("(sym '") + name + "')";
|
2013-11-10 14:24:25 -08:00
|
|
|
}
|
2013-11-07 13:24:01 -08:00
|
|
|
}
|
|
|
|
|
}
|