Add helper functions for making shared pointers to rules
- start work on item set class
This commit is contained in:
parent
ec8b7ccf20
commit
11e3980319
33 changed files with 486 additions and 150 deletions
|
|
@ -1,25 +1,23 @@
|
|||
#include "symbol.h"
|
||||
#include "blank.h"
|
||||
#include "transition_map.h"
|
||||
|
||||
namespace tree_sitter {
|
||||
namespace rules {
|
||||
Symbol::Symbol(int id) : id(id) {};
|
||||
Symbol::Symbol(const std::string &name) : name(name) {};
|
||||
Symbol::Symbol(const char *name) : name(name) {};
|
||||
|
||||
TransitionMap<Rule> Symbol::transitions() const {
|
||||
return TransitionMap<Rule>({ copy() }, { new Blank() });
|
||||
return TransitionMap<Rule>({ rule_ptr(new Symbol(name)) }, { rule_ptr(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);
|
||||
return (other != NULL) && (other->name == name);
|
||||
}
|
||||
|
||||
std::string Symbol::to_string() const {
|
||||
return std::to_string(id);
|
||||
}
|
||||
return name;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue