Static analysis library.
Project description
Features
What to expect from bonsai:
classes for the different entities of a program (e.g. variables, functions, etc.);
extended classes for specific programming languages (only C++ for now);
parser implementations, able to take a file and produce a model (e.g. clang for C++);
extensible interface to manipulate and query the resulting model (e.g. find calls for a function);
a console script to use as a standalone application.
Installation
Method 1: Running Without Installation
git clone https://github.com/git-afsantos/bonsai.git
cd bonsai
python bonsai-runner.py <args>
You can also run it with the executable package syntax.
python -m bonsai <args>
Method 2: Installing Bonsai on Your Machine
[sudo] pip install bonsai-code
python setup.py install
Examples
parser = CppAstParser(workspace = "examples/cpp")
parser.global_scope.pretty_str()
CodeQuery(parser.global_scope).all_references.where_name("a").get()
class C:
C():
[declaration]
void m(int a):
[declaration]
int x_ = None
C():
x_ = 0
void m(int a):
a = (a + 2) * 3
this.x_ = a
int main(int argc, char ** argv):
C c = new C()
c.m(42)
C * c1 = new C()
C * c2 = new C()
new C()
delete(c1)
delete(c2)
return 0
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bonsai-code-0.6.8.tar.gz.
File metadata
- Download URL: bonsai-code-0.6.8.tar.gz
- Upload date:
- Size: 43.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.8.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6ef835e605bd8ac6cba9df68d0c9f176297027ccb277469ffb4baeea837a3602
|
|
| MD5 |
31de73d3ac6989802624632ffabc2e9b
|
|
| BLAKE2b-256 |
cc3c95755937d4dbb6d493408e939445b86b675b623bc87cc4e72d67950523f3
|
File details
Details for the file bonsai_code-0.6.8-py3-none-any.whl.
File metadata
- Download URL: bonsai_code-0.6.8-py3-none-any.whl
- Upload date:
- Size: 52.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.8.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ca880e515a52ff823f5f7e79452867078270c81f18bc7616f4d038941a166d7b
|
|
| MD5 |
b7251e9e52a5cce6a2635a823cf2598d
|
|
| BLAKE2b-256 |
8730265c6fc841513cf36d17eaaf22cc149286c1901fb036dd381e021041602d
|