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"
|
2013-12-19 23:05:54 -08:00
|
|
|
|
2014-07-20 21:43:27 -07:00
|
|
|
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
|
|
|
}
|
2014-07-20 21:43:27 -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
|