Code Monkey home page Code Monkey logo

nmote / pfff Goto Github PK

View Code? Open in Web Editor NEW

This project forked from semgrep/pfff

0.0 0.0 0.0 47.64 MB

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.

Home Page: https://semgrep.dev

License: Other

C++ 0.83% Python 0.35% Shell 0.40% PHP 4.96% Emacs Lisp 0.52% C 0.29% OCaml 78.22% Makefile 2.34% Standard ML 1.41% TeX 0.83% Java 0.45% Prolog 0.40% C# 0.01% CSS 0.08% Erlang 0.01% Haskell 0.01% HTML 0.17% JavaScript 8.61% Common Lisp 0.01% Hack 0.11%

pfff's Introduction

pfff

CircleCI

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 Javascript, Python, C, Java, Go, and PHP. There is also preliminary support for other languages such as C++, Ruby, Rust, C#, Html, CSS, Erlang, Lisp, Haskell, Skip, 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
  • 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)

A few pfff-related tools are now in their own repositories:

  • sgrep and spatch, a bug-finder and refactoring tool
  • codemap, which is a gtk and cairo based source code visualizer/navigator/searcher leveraging the information computed by pfff_db and codegraph_build
  • codegraph_build, a source code indexer
  • codegraph, a package/module/class dependency visualizer leveraging the information computed previously by codegraph_build

For more information, look at the pfff wiki here: http://github.com/returntocorp/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

Adding a Language

  1. In commons/file_type.ml, add your language under the appropriate programming language type in type file_type and add in matching to the file extension of your language in file_type_of_file2
  2. In commons/file_type.mli, add you language under the appropriate programming language type in type file_type
  3. In lang_GENERIC/parsing/Lang.ml, add your language and necessary code in
    • type t
    • list_of_lang
    • langs_of_filename
    • string_of_lang
    • ext_of_lang
  4. In lang_GENERIC/parsing/Lang.mli, add your language in type t.
  5. In lang_GENERIC/parsing/Parse_generic.ml, add you language and necessary code into:
    • parse_pattern
    • parse_with_lang

More information

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

pfff's People

Contributors

akuhn avatar aryx avatar avikchaudhuri avatar brendongo avatar colleend avatar damiendoligez avatar drewdennison avatar emjin avatar gabelevi avatar gabrielemaurina avatar hansonw avatar iagoabal avatar ievans avatar jeffmo avatar jl3931 avatar jwatzman avatar mjambon avatar mmcqd avatar msullivan avatar nbrahms avatar nox avatar paroski avatar phooji avatar ruin0x11 avatar s-santillan avatar sharontlin avatar sjord avatar soutaro avatar underyx avatar yasoob avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.