rework things a bit so cfg is called exactly once at the end of the parse.