Make it clear which field of TSNode can be used as a unique id
This commit is contained in:
parent
e3670be42f
commit
95be6e3bee
2 changed files with 14 additions and 11 deletions
|
|
@ -66,12 +66,14 @@ typedef struct {
|
|||
|
||||
typedef struct {
|
||||
uint32_t context[4];
|
||||
const void *ref[2];
|
||||
const void *id;
|
||||
const void *tree;
|
||||
} TSNode;
|
||||
|
||||
typedef struct {
|
||||
uint32_t context[2];
|
||||
void *ref[2];
|
||||
const void *id;
|
||||
const void *tree;
|
||||
} TSTreeCursor;
|
||||
|
||||
TSParser *ts_parser_new();
|
||||
|
|
|
|||
|
|
@ -17,7 +17,8 @@ typedef struct {
|
|||
TSNode ts_node_new(const TSTree *tree, const Subtree *subtree, Length position, TSSymbol alias) {
|
||||
return (TSNode) {
|
||||
{position.bytes, position.extent.row, position.extent.column, alias},
|
||||
{tree, subtree},
|
||||
subtree,
|
||||
tree,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -27,14 +28,6 @@ static inline TSNode ts_node__null() {
|
|||
|
||||
// TSNode - accessors
|
||||
|
||||
static inline const TSTree *ts_node__tree(const TSNode *self) {
|
||||
return self->ref[0];
|
||||
}
|
||||
|
||||
static inline const Subtree *ts_node__subtree(TSNode self) {
|
||||
return self.ref[1];
|
||||
}
|
||||
|
||||
static inline uint32_t ts_node__byte(const TSNode *self) {
|
||||
return self->context[0];
|
||||
}
|
||||
|
|
@ -47,6 +40,14 @@ static inline uint32_t ts_node__alias(const TSNode *self) {
|
|||
return self->context[3];
|
||||
}
|
||||
|
||||
static inline const Subtree *ts_node__subtree(TSNode self) {
|
||||
return self.id;
|
||||
}
|
||||
|
||||
static inline const TSTree *ts_node__tree(const TSNode *self) {
|
||||
return self->tree;
|
||||
}
|
||||
|
||||
// NodeChildIterator
|
||||
|
||||
static inline NodeChildIterator ts_node_child_iterator_begin(const TSNode *node) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue