https://github.com/harrydrippin/dismantler-python
This module dismantles python code to parse tree, token, symbols and reproduces it to dictionary and string.
https://github.com/harrydrippin/dismantler-python
dismantler parse-trees python3
Last synced: 5 months ago
JSON representation
This module dismantles python code to parse tree, token, symbols and reproduces it to dictionary and string.
- Host: GitHub
- URL: https://github.com/harrydrippin/dismantler-python
- Owner: harrydrippin
- License: other
- Created: 2018-07-16T07:43:35.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-07-16T08:24:35.000Z (almost 8 years ago)
- Last Synced: 2025-11-27T17:48:37.213Z (7 months ago)
- Topics: dismantler, parse-trees, python3
- Language: Python
- Size: 9.77 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Dismantler
[](https://badge.fury.io/py/dismantler-python)
[]()

[](https://saythanks.io/to/harrydrippin)
```
██████╗ ██╗███████╗███╗ ███╗ █████╗ ███╗ ██╗████████╗██╗ ███████╗██████╗
██╔══██╗██║██╔════╝████╗ ████║██╔══██╗████╗ ██║╚══██╔══╝██║ ██╔════╝██╔══██╗
██║ ██║██║███████╗██╔████╔██║███████║██╔██╗ ██║ ██║ ██║ █████╗ ██████╔╝
██║ ██║██║╚════██║██║╚██╔╝██║██╔══██║██║╚██╗██║ ██║ ██║ ██╔══╝ ██╔══██╗
██████╔╝██║███████║██║ ╚═╝ ██║██║ ██║██║ ╚████║ ██║ ███████╗███████╗██║ ██║
╚═════╝ ╚═╝╚══════╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═══╝ ╚═╝ ╚══════╝╚══════╝╚═╝ ╚═╝
```
This module dismantles python code to parse tree, token, symbols and reproduces it to dictionary and json.
[한국어 README는 여기를 참조하십시오: README.ko.md](https://github.com/harrydrippin/dismantler-python/blob/master/docs/README.ko.md)
## What is this?
Dismantler takes a Python code as input and creates a parse tree in a short time. It also export the parse tree to a dictionary or json. You can get list of tokens or symbols separately if you want. This project can be used for research purpose, such as teaching the source code to deep learning model as tokenized sequential data or interpreting the Python code on token level and using it for educational programs (like tutoring).
## Basic Usage
```python
>>> import dismantler
>>> d = dismantler.run_from_string('a + 5').dictionary()
>>> print(d)
{
"type": "symbol",
"name": "stmt",
"value": [
// Nodes...
]
}
>>> d = dismantler.run_from_file('file.py').json(indent=4)
>>> print(d)
"{
"type": "symbol",
"name": "stmt",
"value": [
// Nodes...
]
}"
```
## Installation
### Via pip
```bash
pip3 install dismantler-python
```
### Via source
```bash
git clone http://github.com/harrydrippin/dismantler-python
cd dismantler-python
python3 setup.py install
```
## Contribution
This project is very small now, so contribution to this project is very welcome. Feel free to submit some issues or PRs to this project.