If I had such a task to do, I would use Parse::RecDescent or Parse::Yapp and a little grammar (Pascal is known to have a small and a regular grammatic structure -- you may even look for FreePascal, which may provide you one quasi-suitable), in order to analyze and translate on the fly the source code.
You may refer to this code example where I use Parse::RD to build SQL queries from LDAP filters.
____
HTH, Dominique
My two favorites:
If the only tool you have is a hammer, you will see every problem as a nail. --Abraham Maslow
Bien faire, et le faire savoir...