Put rule classes in their own files

This commit is contained in:
Max Brunsfeld 2013-11-07 13:24:01 -08:00
parent 849f2ee195
commit d830c7c255
17 changed files with 326 additions and 215 deletions

25
src/rules/symbol.cpp Normal file
View file

@ -0,0 +1,25 @@
#include "symbol.h"
#include "transition_map.h"
namespace tree_sitter {
namespace rules {
Symbol::Symbol(int id) : id(id) {};
TransitionMap<Rule> Symbol::transitions() const {
return TransitionMap<Rule>({ copy() }, { new Blank() });
}
bool Symbol::operator==(const Rule &rule) const {
const Symbol *other = dynamic_cast<const Symbol *>(&rule);
return (other != NULL) && (other->id == id);
}
Symbol * Symbol::copy() const {
return new Symbol(id);
}
std::string Symbol::to_string() const {
return std::to_string(id);
}
}
}