Store edits in trees, not by splitting stack
This allows for multiple edits per parse, though it is not exposed through the API yet
This commit is contained in:
parent
0467d190fe
commit
b3d883e128
11 changed files with 169 additions and 333 deletions
|
|
@ -34,10 +34,16 @@ struct TSTree {
|
|||
unsigned short int ref_count;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
TSTree *tree;
|
||||
TSLength offset;
|
||||
} TSTreeChild;
|
||||
TSTree *ts_tree_make_leaf(TSSymbol, TSLength, TSLength, TSNodeType);
|
||||
TSTree *ts_tree_make_node(TSSymbol, size_t, TSTree **, TSNodeType);
|
||||
TSTree *ts_tree_make_error(TSLength size, TSLength padding, char lookahead_char);
|
||||
void ts_tree_retain(TSTree *tree);
|
||||
void ts_tree_release(TSTree *tree);
|
||||
bool ts_tree_eq(const TSTree *tree1, const TSTree *tree2);
|
||||
char *ts_tree_string(const TSTree *tree, const char **names);
|
||||
TSLength ts_tree_total_size(const TSTree *tree);
|
||||
void ts_tree_prepend_children(TSTree *, size_t, TSTree **);
|
||||
void ts_tree_edit(TSTree *, TSInputEdit);
|
||||
|
||||
static inline bool ts_tree_is_extra(const TSTree *tree) {
|
||||
return tree->options.extra;
|
||||
|
|
@ -59,28 +65,29 @@ static inline void ts_tree_set_fragile_right(TSTree *tree) {
|
|||
tree->options.fragile_right = true;
|
||||
}
|
||||
|
||||
static inline bool ts_tree_is_fragile_left(TSTree *tree) {
|
||||
static inline bool ts_tree_is_fragile_left(const TSTree *tree) {
|
||||
return tree->options.fragile_left;
|
||||
}
|
||||
|
||||
static inline bool ts_tree_is_fragile_right(TSTree *tree) {
|
||||
static inline bool ts_tree_is_fragile_right(const TSTree *tree) {
|
||||
return tree->options.fragile_right;
|
||||
}
|
||||
|
||||
TSTree *ts_tree_make_leaf(TSSymbol, TSLength, TSLength, TSNodeType);
|
||||
TSTree *ts_tree_make_node(TSSymbol, size_t, TSTree **, TSNodeType);
|
||||
TSTree *ts_tree_make_error(TSLength size, TSLength padding, char lookahead_char);
|
||||
void ts_tree_retain(TSTree *tree);
|
||||
void ts_tree_release(TSTree *tree);
|
||||
bool ts_tree_eq(const TSTree *tree1, const TSTree *tree2);
|
||||
char *ts_tree_string(const TSTree *tree, const char **names);
|
||||
char *ts_tree_error_string(const TSTree *tree, const char **names);
|
||||
TSLength ts_tree_total_size(const TSTree *tree);
|
||||
void ts_tree_prepend_children(TSTree *, size_t, TSTree **);
|
||||
void ts_tree_edit(TSTree *, TSInputEdit);
|
||||
static inline bool ts_tree_is_terminal(const TSTree *tree) {
|
||||
return tree->child_count == 0;
|
||||
}
|
||||
|
||||
static inline bool ts_tree_is_empty(TSTree *tree) {
|
||||
return ts_tree_total_size(tree).bytes == 0;
|
||||
static inline bool ts_tree_has_changes(const TSTree *tree) {
|
||||
return tree->options.has_changes;
|
||||
}
|
||||
|
||||
static inline bool ts_tree_is_empty(const TSTree *tree) {
|
||||
return ts_tree_total_size(tree).chars == 0;
|
||||
}
|
||||
|
||||
static inline bool ts_tree_is_fragile(const TSTree *tree) {
|
||||
return ts_tree_is_empty(tree) || tree->options.fragile_left ||
|
||||
tree->options.fragile_right;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue