Organize source into compiler and runtime dirs

This commit is contained in:
Max Brunsfeld 2013-12-15 23:57:30 -08:00
parent e480cf538d
commit 9618efd12a
46 changed files with 169 additions and 38 deletions

View file

@ -0,0 +1,31 @@
#include "string.h"
#include "transition_map.h"
#include "char.h"
#include "seq.h"
namespace tree_sitter {
namespace rules {
String::String(std::string value) : value(value) {};
string_ptr str(const std::string &value) {
return std::make_shared<String>(value);
}
TransitionMap<Rule> String::transitions() const {
rule_ptr result = character(value[0]);
for (int i = 1; i < value.length(); i++)
result = seq({ result, character(value[i]) });
return result->transitions();
}
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 + "')";
}
}
}