context analysis: rework the read_clause logic

This simplifies the read_clause implementation to make it easier
to split out into a separate function.