There are several rules that apply to subprogram_body which are common to both procedure and function. Consider splitting those out.