A Python-based tool for visualizing and exploring the Abstract Syntax Tree (AST) of C source files using Clang and Tkinter for a graphical user interface (GUI):
- Displays the source code and its corresponding AST side by side.
- Search functionality to quickly locate symbols and their AST representations.
- Fully interactive GUI with expandable and collapsible AST nodes.
- Non-editable code view for clarity.
- Python 3.6 or higher
- Clang Python Bindings (
libclang
) - Tkinter (comes pre-installed with Python)
Install Clang bindings:
pip install libclang
Run the script:
python clang_ast_dumper.py
- Load a file:
- Insert the full path to a given input C file.
- The source code will be read and parsed into an AST.
- Search for a Symbol:
- Type a symbol name in the search bar and press the Search button or hit Enter.
- The AST and corresponding source code will update to reflect the selected symbol.
- Leave the search bar empty and press Search to reset to the entire AST of the translation unit.
- AST Interaction:
- The AST tree is expandable and collapsible. Click on nodes to view child nodes.
- View Code:
- The code view updates automatically when a symbol is selected, displaying its declaration and/or definition.