tree-sitter/src/compiler/rules/symbol.cpp

25 lines
700 B
C++
Raw Normal View History

2013-12-18 20:58:05 -08:00
#include "rules.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
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-12-18 20:58:05 -08:00
void Symbol::accept(RuleVisitor &visitor) const {
visitor.visit(this);
}
2013-11-07 13:24:01 -08:00
}
}