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) {};
|
|
|
|
|
Symbol::Symbol(const char *name) : name(name) {};
|
2013-11-07 13:24:01 -08:00
|
|
|
|
|
|
|
|
TransitionMap<Rule> Symbol::transitions() const {
|
2013-11-10 14:24:25 -08:00
|
|
|
return TransitionMap<Rule>({ rule_ptr(new Symbol(name)) }, { rule_ptr(new 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-10 14:24:25 -08:00
|
|
|
return (other != NULL) && (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
|
|
|
}
|
|
|
|
|
}
|