Rework AST access API: reduce heap allocation
This commit is contained in:
parent
feb46302f3
commit
54e40b8146
16 changed files with 288 additions and 273 deletions
|
|
@ -112,9 +112,11 @@ struct TSLanguage {
|
|||
* Parse Table Macros
|
||||
*/
|
||||
|
||||
#define ACTIONS(...) \
|
||||
(TSParseAction[]) { \
|
||||
__VA_ARGS__, { .type = 0 } \
|
||||
#define ACTIONS(...) \
|
||||
(TSParseAction[]) { \
|
||||
__VA_ARGS__, { \
|
||||
.type = 0 \
|
||||
} \
|
||||
}
|
||||
|
||||
#define SHIFT(to_state_value) \
|
||||
|
|
@ -155,7 +157,9 @@ struct TSLanguage {
|
|||
.lex_fn = ts_lex, \
|
||||
}; \
|
||||
\
|
||||
const TSLanguage *language_name() { return &language; }
|
||||
const TSLanguage *language_name() { \
|
||||
return &language; \
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,27 +37,29 @@ typedef struct {
|
|||
size_t chars_removed;
|
||||
} TSInputEdit;
|
||||
|
||||
typedef struct {
|
||||
const void *data;
|
||||
TSLength position;
|
||||
} TSNode;
|
||||
|
||||
typedef unsigned short TSSymbol;
|
||||
typedef struct TSLanguage TSLanguage;
|
||||
|
||||
typedef struct TSNode TSNode;
|
||||
TSLength ts_node_pos(const TSNode *);
|
||||
TSLength ts_node_size(const TSNode *);
|
||||
TSSymbol ts_node_sym(const TSNode *);
|
||||
TSNode *ts_node_child(TSNode *, size_t);
|
||||
size_t ts_node_child_count(const TSNode *);
|
||||
TSNode *ts_node_find_for_pos(TSNode *, size_t);
|
||||
TSNode *ts_node_find_for_range(TSNode *, size_t, size_t);
|
||||
TSNode *ts_node_parent(TSNode *node);
|
||||
TSNode *ts_node_next_sibling(TSNode *node);
|
||||
TSNode *ts_node_prev_sibling(TSNode *node);
|
||||
const char *ts_node_name(const TSNode *);
|
||||
const char *ts_node_string(const TSNode *);
|
||||
void ts_node_retain(TSNode *node);
|
||||
void ts_node_release(TSNode *node);
|
||||
bool ts_node_eq(const TSNode *, const TSNode *);
|
||||
|
||||
typedef struct TSDocument TSDocument;
|
||||
|
||||
TSLength ts_node_pos(TSNode);
|
||||
TSLength ts_node_size(TSNode);
|
||||
TSSymbol ts_node_sym(TSNode);
|
||||
TSNode ts_node_child(TSNode, size_t);
|
||||
size_t ts_node_child_count(TSNode);
|
||||
TSNode ts_node_find_for_pos(TSNode, size_t);
|
||||
TSNode ts_node_find_for_range(TSNode, size_t, size_t);
|
||||
TSNode ts_node_parent(TSNode);
|
||||
TSNode ts_node_next_sibling(TSNode);
|
||||
TSNode ts_node_prev_sibling(TSNode);
|
||||
const char *ts_node_name(TSNode, const TSDocument *);
|
||||
const char *ts_node_string(TSNode, const TSDocument *);
|
||||
bool ts_node_eq(TSNode, TSNode);
|
||||
|
||||
TSDocument *ts_document_make();
|
||||
void ts_document_free(TSDocument *);
|
||||
void ts_document_set_language(TSDocument *, const TSLanguage *);
|
||||
|
|
@ -66,7 +68,7 @@ void ts_document_set_input_string(TSDocument *, const char *);
|
|||
void ts_document_edit(TSDocument *, TSInputEdit);
|
||||
TSDebugger ts_document_get_debugger(const TSDocument *);
|
||||
void ts_document_set_debugger(TSDocument *, TSDebugger);
|
||||
TSNode *ts_document_root_node(const TSDocument *);
|
||||
TSNode ts_document_root_node(const TSDocument *);
|
||||
|
||||
#define ts_builtin_sym_error 0
|
||||
#define ts_builtin_sym_end 1
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue