doesn't solve the OP's problem
I think it does. He wants to syntax-check code before examining it for security issues. He'd do that for each phase. It's not an all-at-once syntax check, but it does allow syntax-check-before-running.
The reason I don't know the order of processing of special blocks other than BEGIN is that I have no reason to know. I don't use them. Someone who thinks I should look up something I don't use has a serious proctological issue.
Caution: Contents may have been coded under pressure.