tree-sitter/src/rules/symbol.cpp

23 lines
714 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) {};
Symbol::Symbol(const char *name) : name(name) {};
2013-11-07 13:24:01 -08:00
TransitionMap<Rule> Symbol::transitions() const {
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);
return (other != NULL) && (other->name == name);
2013-11-07 13:24:01 -08:00
}
std::string Symbol::to_string() const {
return name;
}
2013-11-07 13:24:01 -08:00
}
}