Help coding a pascal source code analyzer in TP 7.0

I'm trying to write a program in TP 7.0 that will read in TurboPascal
source code (in straight text format) that will maintain a list of the
procedures including parameters, local variables, and the procedure or
functions McCabe Complexity Metric (which I really don't know too much
about, but I've been told its a good way to analyze efficiency)
I then want the program to display a structure chart that will allow
you to click on each function/procedure and get a pop-up window  that
will contain all of the relevant info for that function.

        The areas I need help in are: how to write the code that
analyzes in source-code input.  I'm sure I could muddle through it
on my own, but I feel that it would make more sense (and make for a more
efficient program) if I just learned how to do it properly.  Also, any
info on the McCabe Complexity Metric, and how to write code to calculate
it would be GREATLY appreciated.

                                                Brian J. Leonard
|  There's no sensation to compare with this,           |
|  Suspended animation, a state of bliss                | SunDragon Software
|  Can't keep my mind from the circling sky,            | 409 Main Street
|  Tongue-tied & twisted just an earth-bound misfit, I      | Cotuit, MA 02635-3115