Add ts_node_edit API

This commit is contained in:
Max Brunsfeld 2018-07-11 16:17:46 -07:00
parent 308016b776
commit 9e8bec458d
6 changed files with 132 additions and 2 deletions

View file

@ -7,6 +7,16 @@
#include "compiler/lexical_grammar.h"
#include "compiler/build_tables/parse_item.h"
#include "compiler/build_tables/lex_item.h"
#include "helpers/point_helpers.h"
ostream &operator<<(ostream &stream, const TSInputEdit &edit) {
return stream << "{TSInputEdit start_byte: " << edit.start_byte <<
", old_end_byte: " << edit.old_end_byte <<
", new_end_byte: " << edit.new_end_byte <<
", start_point: " << edit.start_point <<
", old_end_point: " << edit.old_end_point <<
", new_end_point: " << edit.new_end_point << "}";
}
namespace tree_sitter {

View file

@ -7,6 +7,7 @@
#include <map>
#include <unordered_set>
#include <vector>
#include "tree_sitter/runtime.h"
#include "compiler/grammar.h"
#include "compiler/prepare_grammar/interned_grammar.h"
#include "compiler/prepare_grammar/initial_syntax_grammar.h"
@ -91,6 +92,8 @@ inline std::ostream& operator<<(std::ostream &stream, const std::pair<T1, T2> &p
} // namespace std
std::ostream &operator<<(std::ostream &, const TSInputEdit &);
namespace tree_sitter {
using std::ostream;

View file

@ -46,7 +46,10 @@ ostream &operator<<(ostream &stream, const TSNode &node) {
}
bool operator==(const TSNode &left, const TSNode &right) {
return ts_node_eq(left, right);
return
left.id == right.id &&
ts_node_start_byte(left) == ts_node_start_byte(right) &&
ts_node_start_point(left) == ts_node_start_point(right);
}
bool operator==(const std::vector<const Subtree *> &vec, const SubtreeArray &array) {