Keep track of AST node sizes and positions

This commit is contained in:
Max Brunsfeld 2014-03-01 15:44:25 -08:00
parent 5045d5cccc
commit 72a0c0e09c
5 changed files with 51 additions and 8 deletions

View file

@ -14,6 +14,8 @@ static const ts_symbol ts_builtin_sym_end = -2;
typedef struct ts_tree {
ts_symbol symbol;
size_t ref_count;
size_t offset;
size_t size;
union {
struct {
size_t count;
@ -28,7 +30,7 @@ typedef struct ts_tree {
} ts_tree;
ts_tree * ts_tree_make_leaf(ts_symbol symbol, size_t size, size_t offset);
ts_tree * ts_tree_make_node(ts_symbol symbol, size_t child_count, ts_tree **children);
ts_tree * ts_tree_make_node(ts_symbol symbol, size_t child_count, ts_tree **children, size_t size, size_t offset);
ts_tree * ts_tree_make_error(char lookahead_char, size_t expected_input_count, const ts_symbol *expected_inputs, size_t size, size_t offset);
void ts_tree_retain(ts_tree *tree);
void ts_tree_release(ts_tree *tree);