Each recursive call to parse() was subtracting one from sub_remaining,
causing it to get out of sync with the actual statement hierarchy.
{
const StatementKey *key;
if(cur_info)
+ {
key = &cur_info->key;
+ cur_info = 0;
+ }
else
{
int id = parse_int();
}
}
- if(!sub_remaining.empty())
- --sub_remaining.back();
+ unsigned upper_nsub = (sub_remaining.empty() ? 0 : sub_remaining.back());
unsigned nsub = parse_int();
for(unsigned j = 0; j<nsub; ++j)
result.sub.push_back(parse());
+ if(upper_nsub>0)
+ sub_remaining.back() = upper_nsub-1;
+
result.valid = true;
- cur_info = 0;
return result;
}