Skip to content
Tools for code analysis, visualizations, or style-preserving source transformation.
OCaml Java PHP Makefile TeX Prolog Other
Find file
Latest commit bde9692 Mar 23, 2016 @phooji phooji [pfff] unbreak parsing `$$variable` with a quick lexer hack
Summary:
Managed to break this in D3005435. The fix is to explicitly
look for `$$name` cases in the lexer, and push the dollar
token separate from the `VARIABLE`. This way, the parser
gets the tokens it would see prior to D3005435.

Test Plan:
  ~/pfff $ make test
  ~/pfff $ ./pfff -dump_php ./tests/php/parsing/dynamic_var.php

**Output**

  [StmtList(
   [ExprStmt(
         Assign(IdVar(DName(("o", i_1)), Ref(NoScope)), i_2,
                 Sc(C(String(("foo", i_3))))), i_4);
                     ExprStmt(
                           Assign(IdVar(DName(("foo", i_5)), Ref(NoScope)), i_6,
                                   Sc(C(Int(("42", i_7))))), i_8);
                                       Echo(i_9, [Left(Deref(i_10, IdVar(DName(("o", i_11)), Ref(NoScope))))],
                                             i_12)]); FinalDef(i_13)]

(Previous output after D3005435 was to barf :()

Reviewers: logozzo, dreeves

Differential Revision: https://phabricator.fb.com/D3089181
Failed to load latest commit information.
.arc * .arc/default-relative-commit: Apr 12, 2012
code_graph cm/cg: fix Gtk warning Critical bla bla Remove xxx Apr 17, 2015
code_map * code_map/Visual.tex.nw: misc Sep 12, 2015
commons * commons/common.ml: misc Jul 3, 2015
data [pfff] remove `rm` for nonexistant files Nov 18, 2014
demos CEs on commons/lib-json/ -> external/jsonwheel and also removed Feb 28, 2014
docs * data/cpp_stdlib/macros.h: cleanup, and introduced pfff_macros.h loc… Sep 9, 2014
editors/emacs * editors/emacs/sgrep.el: Aug 14, 2013
external [pfff] add json_out to exported symbols for jsonwheel Dec 22, 2014
globals many more META files for findlib Apr 13, 2015
graph_code Merge branch 'master' of github.com:facebook/pfff Mar 20, 2015
h_files-format many more META files for findlib Apr 14, 2015
h_program-lang * lang_nw/parsing/lexer_nw.mll: highlight special \t footnote (pad sp… Sep 12, 2015
h_program-visual * commons/file_type.ml: handling .coffee Feb 3, 2015
h_version-control [pfff] export findlib target for h_version-control Dec 22, 2014
h_visualization * h_visualization/META: export, for efuns Apr 24, 2015
lang_bytecode * h_program-lang/prolog_code.ml: new, extracted from graph_code_pro.og Aug 26, 2014
lang_c * lang_c/parsing/ast_c.ml: typo Aug 5, 2015
lang_clang * lang_clang/analyze/compile_commands_clang.ml: link Jan 21, 2016
lang_cmt * Makefile: remove CLANG_HACK Oct 8, 2014
lang_cpp CEs on Typedef constructor removal Aug 31, 2015
lang_csharp CEs on highlight_code and entity_code factorization Aug 27, 2014
lang_css * lang_css/parsing/ast_css.ml: remove dead type Aug 20, 2014
lang_erlang * lang_erlang/parsing/parse_erlang.ml: cleanup, remove program2 Aug 5, 2015
lang_haskell CEs on Typedef constructor removal Aug 31, 2015
lang_html * lang_html/parsing/parse_html.ml: cleanup, remove program2 Aug 5, 2015
lang_java CEs on highlight_code and entity_code factorization Aug 27, 2014
lang_js * lang_js/analyze/module_js.ml: Fix invalid documentation comments. Aug 24, 2015
lang_lisp * h_program-lang/parse_info.ml: factorize lexbuf_to_strpos Aug 5, 2015
lang_ml * lang_ml/analyze/visual/highlight_ml.ml: CE Aug 31, 2015
lang_nw * lang_nw/parsing/lexer_nw.mll: highlight special \t footnote (pad sp… Sep 12, 2015
lang_opa CEs on Typedef constructor removal Aug 31, 2015
lang_php [pfff] unbreak parsing `$$variable` with a quick lexer hack Mar 23, 2016
lang_python * lang_python/parsing/parse_python.ml: cleanup Aug 5, 2015
lang_rust CEs on Typedef constructor removal Aug 31, 2015
lang_sql/parsing * h_program-lang/parse_info.ml: factorize lexbuf_to_strpos Aug 5, 2015
lang_text CEs on commons/lib-json/ -> external/jsonwheel and also removed Feb 28, 2014
lang_web CEs on commons/lib-json/ -> external/jsonwheel and also removed Feb 28, 2014
matcher * matcher/fuzzy_vs_fuzzy.ml: fix test regressions Aug 27, 2014
mini * mini/readme.txt: Aug 23, 2014
opa * opa/pfff_logger.opa: Apr 5, 2012
scripts clean lang_js/ remove avik's code, remove NotParsedCorrectly, FinalDef Mar 7, 2014
tests Merge pull request #118 from mutantzombie/multiple_patterns May 4, 2015
web [pfff] move commons_graph to a separate directory Dec 23, 2014
.arcconfig * .arcconfig: new file May 5, 2011
.gitignore * .gitignore: Apr 17, 2015
.travis.yml * .travis.yml: send email to gmail too Aug 4, 2014
META * META: Nov 13, 2013
Makefile * Makefile: mv in Makefile.config the Wno-invalid-token hack for clang Aug 5, 2015
Makefile.common Remove `-warn-error +a` in released builds. Mar 2, 2016
README.md [pfff] add travis CI badge to readme Feb 26, 2015
architecture.txt * architecture.txt: Sep 18, 2014
authors.txt * authors.txt: update Aug 9, 2013
bugs.txt * bugs.txt: changed email Jul 3, 2015
changes.txt * changes.txt: misc Jan 21, 2016
configure Build systems very often (usually?) don't check the make version. Nov 4, 2015
copyright.txt * configure: new option --nocmt Mar 4, 2014
credits.txt * credits.txt: adding john whaley Aug 29, 2014
env.csh initial import into fresh git repo. Sep 22, 2010
env.sh [pfff] switch to 4.01 Jun 23, 2014
find_source.ml * lang_lisp/analyze/graph_code_lisp.ml: first version, module only deps Aug 18, 2014
find_source.mli factorize more skip_code stuff Jan 29, 2014
gtkrc-2.0 * gtkrc-2.0: example of config Jul 9, 2014
install.txt port to 4.02 (disabled lang_cmt/ for now in configure), fixed Sep 26, 2014
install_linux.txt * install_linux.txt: Feb 18, 2014
install_macos.txt Fix MacOSX install instructions Jan 21, 2015
license.txt initial import into fresh git repo. Sep 23, 2010
main.ml * main_codeslicer.ml: new file! moved lpizer here too Sep 16, 2014
main_codegraph.ml Improve codegraph path handling Jan 9, 2016
main_codemap.ml * main_codemap.ml: -test_loc support for multiple dir (so can use ski… Sep 12, 2015
main_codequery.ml * main_codequery.ml: todo Feb 1, 2015
main_codeslicer.ml * main_codeslicer.ml: misc Aug 5, 2015
main_db.ml * main_db.ml: handle -o for -db_of_graph_code and generate json by de… Jul 16, 2014
main_scheck.ml * main_scheck.ml: todo Apr 16, 2015
main_sgrep.ml Reuse the AST so multiple pattern matching is more efficient. Apr 3, 2015
main_spatch.ml * main_spatch.ml: related work Aug 22, 2014
main_stags.ml * main_stags.ml: related work Nov 16, 2014
main_test.ml * main_test.ml: -luisa Feb 1, 2015
project.el * project.el: update Sep 3, 2014
skip_list.txt * skip_list.txt: Aug 27, 2014
syncweb.txt * syncweb.txt: Oct 10, 2013
travis-ci.sh * travis-ci.sh: yes Aug 20, 2015

README.md

                          pfff

Build Status

pfff is a set of tools and APIs to perform static analysis, code visualizations, code navigations, or style-preserving source-to-source transformations such as refactorings on source code. There is good support for C, Java, Javascript and PHP. There is also preliminary support for other languages such as C++, Rust, C#, Html, CSS, Erlang, Lisp, Haskell, Python, OPA and SQL. There is also very good 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
  • scheck, a bug finder
  • stags, an Emacs tag generator
  • sgrep, a syntactical grep
  • spatch, a syntactical patch
  • codemap, which is a gtk and cairo based source code visualizer/navigator/searcher leveraging the information computed previously by pfff_db and codegraph.
  • codegraph, a source code indexer and package/module/class dependency visualizer
  • codequery, an interactive tool a la SQL to query information about the structure of a codebase using Prolog as the query engine
  • pfff_db, 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/db.json)

For more information, look at the pfff wiki here: http://github.com/facebook/pfff/wiki/Main as well as the docs/manual/ directory.

Usage for pfff:

$ ./pfff -parse_php demos/foo.php

or

$ ./pfff -dump_php demos/foo.php

You can also look at ./pfff --help

Usage for pfff_db:

$ ./pfff_db -lang ml -o /tmp/pfff.json ~/pfff

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

Usage for codemap:

$ ./codemap ~/pfff

This should launch a gtk-based GUI that allows you to visualize source code and perform some code search.

Usage for codegraph:

$ ./codegraph -lang cmt -build ~/pfff

to generate a graph_code.marshall file in ~/pfff containing all dependency information about the pfff codebase using the typed bytecode .cmt files generated during the compilation of pfff.

$ ./codegraph ~/pfff

This should launch a gtk-based GUI that allows you to visualize source code dependencies.

More information

Look at the pfff wiki here: http://github.com/facebook/pfff/wiki/Main

Something went wrong with that request. Please try again.