This is a framework for statically analyzing source code using Datalog queries.
For the set of supported source languages, see the list of parsers in the grammars-v4 repository. The following languages are included out of the box: C, C++, COBOL85, Go, JavaScript, Kotlin, Lua, PHP, Prolog, Python3, Rust, and Solidity. Support for more languages can be easily added, read on below for how to enable support for other languages.
This framework works by transforming ANTLR parsers to Datalog front-ends. An ANTLR parser API is translated into a Datalog schema and the parser is then invoked on the source code to populate a "facts" directory according to the schema. Finally, the analysis logic runs on the facts and computes the analysis results. For more information, see ARCHITECTURE.md.
- Install the parsers used:
./install-parsers.sh
-
Install Souffle.
-
Build and install the distribution:
./gradlew installDist
Python3 example:
build/install/antlr2datalog/bin/antlr2datalog -l python3 -i grammars-v4/python/python3/examples/coroutines.py
Kotlin example:
build/install/antlr2datalog/bin/antlr2datalog -l kotlin -i grammars-v4/kotlin/kotlin-formal/examples/Test.kt
- Put your ANTLR parser in the local Maven repository. For example, to pick from the "grammars-v4" parsers, install them as follows:
git clone https://github.com/antlr/grammars-v4.git
cd grammars-v4
mvn install
-
Edit class ParserConfiguration to add a case for the parser.
-
Add
logic/LANGUAGE-logic.dl
with the Datalog rules for the new language.
For the license of this project, see LICENSE. Note that ANTLR parsers may be covered by different licenses.