tree-sitter/src/compiler/rules/string.cc

28 lines
721 B
C++
Raw Normal View History

2014-03-09 21:37:21 -07:00
#include "compiler/rules/string.h"
2014-03-09 22:45:33 -07:00
#include <string>
2014-03-09 21:37:21 -07:00
#include "compiler/rules/visitor.h"
namespace tree_sitter {
namespace rules {
using std::string;
using std::hash;
String::String(string value) : value(value) {}
bool String::operator==(const Rule &rule) const {
const String *other = dynamic_cast<const String *>(&rule);
return other && (other->value == value);
2014-03-09 21:37:21 -07:00
}
size_t String::hash_code() const { return hash<string>()(value); }
rule_ptr String::copy() const { return std::make_shared<String>(*this); }
string String::to_string() const { return string("#<string '") + value + "'>"; }
void String::accept(Visitor *visitor) const { visitor->visit(this); }
} // namespace rules
} // namespace tree_sitter