Repository navigation
Main
Contents
pfff is mainly an OCaml API to write static analysis, dynamic analysis, code visualizations, code navigations, or style-preserving source-to-source transformations such as refactorings on source code. For now the effort is focused on PHP but there is preliminary support for Javascript, C, C++, Java, Sql, and even TeX. There is also preliminary support for OCaml code so that pfff can be used on the code of pfff itself.
pfff is also made of few tools:
- pfff, which allows to test the different parsers on a single file
- pfff_db_light, which does some global analysis on a set of source files and store the data in a marshalled form in a file somewhere (e.g. /tmp/light_db.db)
- pfff_db, which does language specific global analysis on a set of source files and store the data in a database somewhere (e.g. /tmp/pfff_db)
- pfff_visual, which is a gtk and cairo based source code visualizer/navigator/searcher leveraging the information computed previously by pfff_db_light and pfff_db. See Examples for screenshots of the tool applied to lots of different open source projects.
- sgrep, a syntactical grep, to make it easy to find precise code patterns
-
- spatch, a syntactical patch, to make it easy to refactor
- code
- scheck, a lint-like bug finder
- pfff_tags, a more precise Emacs tag generator
- other command line tools leveraging the information computed by
pfff_db such as a deadcode reaper, a test coverage generator, etc.
Click on the "Download Source" button in the top right of this window.
If you have git installed on your machine you can also do:
$ git clone git://github.com/facebook/pfff.git
Email to pad at facebook dot com or click on "Issues" in the github project bar above.
- TODO Pfff manual
- Vision
- Features
- work in progress: Visualizer manual
-
- good support:
-
- Pfff:PHP: parsing, xhp parsing builtin support, global callgraph analysis, global class/define use/def analysis, bug finder (unused variable, use of undefined variable, etc), sgrep, deadcode analysis, code coverage (using phpunit and xdebug), control flow, experimental data flow, emacs TAGS, highlighter, semantic visual feedback in pfff_visual (important functions/classes/methods, bad smells (specific to facebook for now))
-
- preliminary support:
-
- Pfff:OCaml: parsing, hacky global analysis for callgraphs, emacs TAGS, highlighter, experimental semantic visual feedback in pfff_visual (important functions, bad smells (use of globals))
- Pfff:Javascript: parsing, hacky global analysis for callgraphs, highlighter, hack class analysis, semantic visual feedback in pfff_visual (important function/classes/methods)
-
- todo:
- work in progress: Commons library
- work in progress: Treemap library
- work in progress: OCaml
See Examples.






part1: http://www.youtube.com/watch?v=HRZjBGD3osw
part2: http://www.youtube.com/watch?v=993pmNLY_VU
OCaml may seem to be a weird choice. It's not a very popular language. But actually in the static analysis world, it is one of the most popular langage. Researchers in Berkeley and Stanford are using OCaml for performing analysis of C code (e.g. Necula with CIL at Berkeley, Aiken with Saturn at Stanford), some type inferers for Ruby are written in OCaml (DRuby), the Windows Device verifiers (based on work from Microsoft Research by Thomas Ball on SLAM) is written in OCaml, people in the Linux kernel are using the Coccinelle tool to perform some complex refactoring and to find bugs, also written in OCaml. In fact one of the latest programming language of Microsoft, F#, is directly inspired (one could say copy) from OCaml.
OCaml is good for code analysis. Trust me.