Rework tree generation mode and API
Store tree nodes in congruent, compact arena array. Define handle types to refer to tree nodes rather than pointers to structure instances. Free tree with context.
This commit is contained in:
1 parent
dddb1b5089
commit
5fc712c6ee
39 files changed
+1349
-811
No files matched your search
@@ -9,31 +9,28 @@ int main()
|
||||
p_context_t * context;
|
||||
context = p_context_new((uint8_t const *)input, strlen(input));
|
||||
assert(p_parse(context) == P_SUCCESS);
|
||||
Start * start = p_result(context);
|
||||
assert_not_null(start->bs);
|
||||
assert_not_null(start->bs->b);
|
||||
assert_not_null(start->bs->bs->b);
|
||||
assert_not_null(start->bs->bs->bs->b);
|
||||
assert_not_null(start->bs->bs->bs->bs->b);
|
||||
p_tree_delete(start);
|
||||
Start start = p_result(context);
|
||||
assert(p_node_valid(p_Start_bs(start)));
|
||||
assert(p_node_valid(p_tree_walk_Start(start, bs, b)));
|
||||
assert(p_node_valid(p_tree_walk_Start(start, bs, bs, b)));
|
||||
assert(p_node_valid(p_tree_walk_Start(start, bs, bs, bs, b)));
|
||||
assert(p_node_valid(p_tree_walk_Start(start, bs, bs, bs, bs, b)));
|
||||
p_context_delete(context);
|
||||
|
||||
context = p_context_new((uint8_t const *)input, strlen(input));
|
||||
assert(p_parse_Bs(context) == P_SUCCESS);
|
||||
Bs * bs = p_result_Bs(context);
|
||||
assert_not_null(bs->b);
|
||||
assert_not_null(bs->bs->b);
|
||||
assert_not_null(bs->bs->bs->b);
|
||||
assert_not_null(bs->bs->bs->bs->b);
|
||||
p_tree_delete_Bs(bs);
|
||||
Bs bs = p_result_Bs(context);
|
||||
assert(p_node_valid(p_Bs_b(bs)));
|
||||
assert(p_node_valid(p_tree_walk_Bs(bs, bs, b)));
|
||||
assert(p_node_valid(p_tree_walk_Bs(bs, bs, bs, b)));
|
||||
assert(p_node_valid(p_tree_walk_Bs(bs, bs, bs, bs, b)));
|
||||
p_context_delete(context);
|
||||
|
||||
input = "c";
|
||||
context = p_context_new((uint8_t const *)input, strlen(input));
|
||||
assert(p_parse_R(context) == P_SUCCESS);
|
||||
R * r = p_result_R(context);
|
||||
assert_not_null(r->c);
|
||||
p_tree_delete_R(r);
|
||||
R r = p_result_R(context);
|
||||
assert(p_node_valid(p_R_c(r)));
|
||||
p_context_delete(context);
|
||||
|
||||
return 0;
|
||||
|
||||
Reference in new issue
Block a user