Clarify distinction btwn tree padding, tree offset, node position
- Node position is public. It represents the node's first character index in the document. - Tree offset is private. It represents the distance between the tree's first character index and it's parent's first character index. - Tree padding is private. It represents the amount of whitespace (or other separator characters) immediately preceding the tree.
This commit is contained in:
parent
226ffd6b5b
commit
3430a5edcc
6 changed files with 126 additions and 78 deletions
|
|
@ -17,7 +17,7 @@ struct TSTree {
|
|||
TSSymbol symbol;
|
||||
TSTreeOptions options;
|
||||
size_t ref_count;
|
||||
size_t offset;
|
||||
size_t padding;
|
||||
size_t size;
|
||||
union {
|
||||
struct {
|
||||
|
|
@ -35,8 +35,8 @@ struct TSTree {
|
|||
|
||||
typedef struct {
|
||||
TSTree *tree;
|
||||
size_t position;
|
||||
} TSChildWithPosition;
|
||||
size_t offset;
|
||||
} TSTreeChild;
|
||||
|
||||
static inline int ts_tree_is_extra(const TSTree *tree) {
|
||||
return (tree->options & TSTreeOptionsExtra);
|
||||
|
|
@ -61,8 +61,8 @@ static inline size_t ts_tree_visible_child_count(const TSTree *tree) {
|
|||
return tree->visible_child_count;
|
||||
}
|
||||
|
||||
static inline TSChildWithPosition *ts_tree_visible_children(const TSTree *tree,
|
||||
size_t *count) {
|
||||
static inline TSTreeChild *ts_tree_visible_children(const TSTree *tree,
|
||||
size_t *count) {
|
||||
if (tree->symbol == ts_builtin_sym_error || tree->visible_child_count == 0) {
|
||||
if (count)
|
||||
*count = 0;
|
||||
|
|
@ -70,17 +70,17 @@ static inline TSChildWithPosition *ts_tree_visible_children(const TSTree *tree,
|
|||
} else {
|
||||
if (count)
|
||||
*count = tree->visible_child_count;
|
||||
return (TSChildWithPosition *)(tree + 1);
|
||||
return (TSTreeChild *)(tree + 1);
|
||||
}
|
||||
}
|
||||
|
||||
TSTree *ts_tree_make_leaf(TSSymbol symbol, size_t size, size_t offset,
|
||||
TSTree *ts_tree_make_leaf(TSSymbol symbol, size_t size, size_t padding,
|
||||
int is_hidden);
|
||||
TSTree *ts_tree_make_node(TSSymbol symbol, size_t child_count,
|
||||
TSTree **children, int is_hidden);
|
||||
TSTree *ts_tree_make_error(char lookahead_char, size_t expected_input_count,
|
||||
const TSSymbol *expected_inputs, size_t size,
|
||||
size_t offset);
|
||||
size_t padding);
|
||||
void ts_tree_retain(TSTree *tree);
|
||||
void ts_tree_release(TSTree *tree);
|
||||
int ts_tree_equals(const TSTree *tree1, const TSTree *tree2);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue