In other words, you want to write something that will lex, parse, and analyze C and PHP. Those are three separate (though somewhat related) problems. So, first lex and parse the C (or PHP) into a data structure. Then, you analyze that data structure for anything you consider to be a flaw. Take a look at
PPI for how to lex and parse a language (in this case, Perl). Alternately, you'll want to use something like flex and yacc (
Parse::Flex and
Parse::Eyapp are good modules to start with).
My criteria for good software:
- Does it work?
- Can someone else come in, make a change, and be reasonably certain no bugs were introduced?