2014-03-09 21:37:21 -07:00
|
|
|
#include "compiler/rules/string.h"
|
|
|
|
|
#include "compiler/rules/visitor.h"
|
2013-12-19 23:05:54 -08:00
|
|
|
|
2013-11-07 18:30:00 -08:00
|
|
|
namespace tree_sitter {
|
2014-03-09 21:37:21 -07:00
|
|
|
using std::string;
|
|
|
|
|
using std::hash;
|
|
|
|
|
|
2013-11-07 18:30:00 -08:00
|
|
|
namespace rules {
|
2013-12-19 23:05:54 -08:00
|
|
|
String::String(string value) : value(value) {};
|
2014-03-09 19:49:35 -07:00
|
|
|
|
2013-11-07 18:30:00 -08:00
|
|
|
bool String::operator==(const Rule &rule) const {
|
|
|
|
|
const String *other = dynamic_cast<const String *>(&rule);
|
2014-02-15 16:14:52 -08:00
|
|
|
return other && (other->value == value);
|
2013-11-07 18:30:00 -08:00
|
|
|
}
|
2014-03-09 19:49:35 -07:00
|
|
|
|
2013-12-30 23:52:38 -08:00
|
|
|
size_t String::hash_code() const {
|
2014-02-15 16:12:16 -08:00
|
|
|
return hash<string>()(value);
|
2013-12-30 23:52:38 -08:00
|
|
|
}
|
2014-03-09 19:49:35 -07:00
|
|
|
|
2014-01-02 13:04:41 -08:00
|
|
|
rule_ptr String::copy() const {
|
|
|
|
|
return std::make_shared<String>(*this);
|
|
|
|
|
}
|
2014-03-09 19:49:35 -07:00
|
|
|
|
2013-12-19 23:05:54 -08:00
|
|
|
string String::to_string() const {
|
2013-12-30 23:12:19 -08:00
|
|
|
return string("#<string '") + value + "'>";
|
2014-03-09 19:49:35 -07:00
|
|
|
}
|
|
|
|
|
|
2014-03-09 22:21:58 -07:00
|
|
|
void String::accept(Visitor *visitor) const {
|
|
|
|
|
visitor->visit(this);
|
2013-12-18 20:58:05 -08:00
|
|
|
}
|
2013-11-07 18:30:00 -08:00
|
|
|
}
|
2014-03-09 21:37:21 -07:00
|
|
|
}
|