Add ability to edit multiple times between parses

This commit is contained in:
Max Brunsfeld 2015-09-18 23:20:06 -07:00
parent 6254f45c1b
commit f37f73f92f
13 changed files with 135 additions and 119 deletions

View file

@ -1,6 +1,6 @@
#include "runtime/helpers/tree_helpers.h"
const char *symbol_names[24] = {
static const char *symbol_names[24] = {
"ERROR", "END", "two", "three", "four", "five", "six", "seven", "eight",
"nine", "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen",
"sixteen", "seventeen", "eighteen", "nineteen", "twenty", "twenty-one",
@ -14,18 +14,6 @@ TSTree ** tree_array(std::vector<TSTree *> trees) {
return result;
}
EqualsTree::EqualsTree(const TSTree *expected, const char **symbol_names)
: expected(expected), symbol_names(symbol_names) {}
bool EqualsTree::Matches(const TSTree *actual) const {
return ts_tree_eq(actual, expected);
}
std::ostream &operator<<(std::ostream &stream, const EqualsTree &matcher) {
stream << std::string("equals tree: ") << std::string(ts_tree_string(matcher.expected, matcher.symbol_names));
return stream;
}
std::ostream &operator<<(std::ostream &stream, const TSTree *tree) {
return stream << std::string(ts_tree_string(tree, symbol_names));;
}
@ -34,3 +22,7 @@ std::ostream &operator<<(std::ostream &stream, const TSNode node) {
return stream << std::string("{") << (const TSTree *)node.data <<
std::string(", ") << std::to_string(ts_node_pos(node).chars) << std::string("}");
}
bool operator==(const TSNode &left, const TSNode &right) {
return ts_node_eq(left, right);
}