Explicitly inform stack pop callback when the stack is exhausted

Also, pass non-extra tree count as a single value, rather than keeping
track of the extra count and the total separately.
This commit is contained in:
Max Brunsfeld 2016-03-10 11:51:38 -08:00
parent 288a164823
commit e7d3d40a59
4 changed files with 25 additions and 24 deletions

View file

@ -71,9 +71,9 @@ vector<StackEntry> get_stack_entries(Stack *stack, int head_index) {
ts_stack_pop_until(
stack,
head_index,
[](void *payload, TSStateId state, size_t depth, size_t extra_count) {
[](void *payload, TSStateId state, size_t tree_count, bool is_done) {
auto entries = static_cast<vector<StackEntry> *>(payload);
StackEntry entry = {state, depth};
StackEntry entry = {state, tree_count};
if (find(entries->begin(), entries->end(), entry) == entries->end())
entries->push_back(entry);
return StackIterateContinue;