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.
42 lines
902 B
D
42 lines
902 B
D
import testparser;
|
|
import std.stdio;
|
|
import testutils;
|
|
|
|
int main()
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
unittest
|
|
{
|
|
string input = "bbbb";
|
|
p_context_t * context = p_context_new(input);
|
|
assert(p_parse(context) == P_SUCCESS);
|
|
Start start = p_result(context);
|
|
assert(start.bs.valid);
|
|
assert(start.bs.b.valid);
|
|
assert(start.bs.bs.b.valid);
|
|
assert(start.bs.bs.bs.b.valid);
|
|
assert(start.bs.bs.bs.bs.b.valid);
|
|
|
|
p_context_delete(context);
|
|
|
|
context = p_context_new(input);
|
|
assert(p_parse_Bs(context) == P_SUCCESS);
|
|
Bs bs = p_result_Bs(context);
|
|
assert(bs.b.valid);
|
|
assert(bs.bs.b.valid);
|
|
assert(bs.bs.bs.b.valid);
|
|
assert(bs.bs.bs.bs.b.valid);
|
|
|
|
p_context_delete(context);
|
|
|
|
input = "c";
|
|
context = p_context_new(input);
|
|
assert(p_parse_R(context) == P_SUCCESS);
|
|
R r = p_result_R(context);
|
|
assert(r.c.valid);
|
|
|
|
p_context_delete(context);
|
|
}
|