Consolidate logic for making shared pointers to rules

This commit is contained in:
Max Brunsfeld 2013-12-19 23:05:54 -08:00
parent 9f78d72a7c
commit 6f444fcc79
22 changed files with 113 additions and 94 deletions

View file

@ -1,21 +1,19 @@
#include "rules.h"
#include "transition_map.h"
using std::string;
namespace tree_sitter {
namespace rules {
String::String(std::string value) : value(value) {};
String::String(string value) : value(value) {};
rule_ptr str(const std::string &value) {
return std::make_shared<String>(value);
}
bool String::operator==(const Rule &rule) const {
const String *other = dynamic_cast<const String *>(&rule);
return (other != NULL) && (other->value == value);
}
std::string String::to_string() const {
return std::string("(string '") + value + "')";
string String::to_string() const {
return string("(string '") + value + "')";
}
void String::accept(RuleVisitor &visitor) const {