tree-sitter/src/rules/symbol.cpp

26 lines
755 B
C++
Raw Normal View History

2013-11-07 13:24:01 -08:00
#include "symbol.h"
#include "blank.h"
2013-11-07 13:24:01 -08:00
#include "transition_map.h"
namespace tree_sitter {
namespace rules {
Symbol::Symbol(const std::string &name) : name(name) {};
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 {
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);
return other && (other->name == name);
2013-11-07 13:24:01 -08:00
}
std::string Symbol::to_string() const {
return std::string("(sym '") + name + "')";
}
2013-11-07 13:24:01 -08:00
}
}