Skip to content
This repository
tag: RELEASE-0.13
Fetching contributors…

Cannot retrieve contributors at this time

file 72 lines (53 sloc) 2.511 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
                              pfff

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, Sql, and C++ code. There is also preliminary
support for OCaml code so that the framework can be used on the code
of pfff itself.

For each languages there are mainly 2 libraries, for instance
parsing_php.cma and analysis_php.cma, that you can
embed in your own application if you need to process PHP code. See the
demos/ directory for example of use of the pfff API. See also
docs/manual/Parsing_xxx.pdf and docs/manual/Analyzis_xxx.pdf for
more documentation on how to use or extend pfff.

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)
 - 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
 - sgrep, a syntactical grep
 - spatch, a syntacitcal patch
 - scheck, a bug finder
 - pfff_tags, an Emacs tag generator

Usage for pfff:
-----------------

   $ ./pfff -parse_php demos/foo.php

or

   $ ./pfff -dump_ast demos/foo.php

You can also look at ./pfff --help

Usage for pfff_db_light:
-------------------

   $ ./pfff_db_light -lang ml ~/pfff

to analyze all the .ml and .mli files under ~/pfff and store metadata
information (the database) in /tmp/light_db.db

Usage for pfff_db:
-------------------

   $ ./pfff_db -lang php -metapath /tmp/pfff_db ~/www/

to analyze all the .php and .phpt files under ~/www and store metadata
information (the database) in /tmp/pfff_db. It may takes some time,
for instance 20 minutes for a really big PHP codebase.

Once this is done you can use some of the flags of pfff_db to
do some analysis as in:

  $ ./pfff_db -deadcode_analysis /tmp/pfff_db

Usage for pfff_visual:
------------------------

  $ ./pfff_visual -with_info /tmp/light_db.db ~/pfff

This should launch a gtk-based GUI that allows you to visualize
source code and perform some code search.
Something went wrong with that request. Please try again.