This repository has been archived by the owner on Jun 4, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 204
CodeQuery
pad edited this page Apr 2, 2014
·
12 revisions
Contents
codequery
is an interactive tool a la SQL to query information
about the structure of the code (the inheritance tree, the call graph,
the data graph, etc). The data is the code. The query language is
Prolog (http://en.wikipedia.org/wiki/Prolog), a logic-based
programming language used mainly in AI but also popular in database
(http://en.wikipedia.org/wiki/Datalog). The particular Prolog
implementation we use is SWI-prolog
(http://www.swi-prolog.org/pldoc/refman/).
By default when you give just a directory to codequery
it builds the Prolog database and then enters Prolog's
read-eval-print loop. After the ?- prompt, you can enter a query
followed by a dot. For instance:
$ cd /tmp/test/ $ cat foo.php <?php class A { } class B extends A { } class C extends B { } $ codequery . generating prolog facts in /tmp/test/facts.pl compiling prolog facts with swipl in /tmp/test/prolog_compiled_db % /tmp/test/facts.pl compiled 0.00 sec, 13,984 bytes % /home/pad/pfff/h_program-lang/database_code.pl compiled 0.00 sec, 19,072 bytes ... Welcome to SWI-Prolog (Multi-threaded, 64 bits, Version 5.11.29-39-g35fdbf2) Copyright (c) 1990-2011 University of Amsterdam, VU Amsterdam SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to redistribute it under certain conditions. Please visit http://www.swi-prolog.org for details. For help, use ?- help(Topic). or ?- apropos(Word). ?- children(X, 'A').
See https://github.com/facebook/pfff/blob/master/main_codequery.ml