|Do you know where your variables are?|
Re: Parsing a PHP web applicationby andreychek (Parson)
|on Aug 20, 2002 at 22:57 UTC||Need Help??|
talexb and I briefly discussed in the chatterbox that this might be possible by using Vim syntax files. If one were to write a Perl parser for the syntax files, you could obtain a lot of information about the php scripts you are interested in.
The syntax files contain lines that look like the following:
The above are just a few snippets from the php.vim file I received with vim 6.1. With this, it doesn't seem like it would be too difficult to write a script to parse this syntax file, then pull out interesting information from the actual php scripts.
Using the above snippets, perhaps we could create 4 arrays: phpEnvVar, phpIntVar, phpFunctions, and phpComment. Then, just use split or the like to put each variable, function name, and comment from the syntax file onto their respective array. Once you have all the information you care about parsed out of the syntax file, you could use any number of means to extract useful info out of the PHP scripts. As talexb mentioned, Parse::RecDescent seems like a good candidate for this. However, the adventurous may even be able to get it to work with a combination of Tie::File and Quantum::Superpositions.
Lucy: "What happens if you practice the piano for 20 years and then end up not being rich and famous?"
Schroeder: "The joy is in the playing."