-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathREADME.txt
More file actions
39 lines (24 loc) · 1.51 KB
/
README.txt
File metadata and controls
39 lines (24 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
July 2024
University of Wyoming, College of Engineering
Lars Kotthoff
Grace Abawe
Python scripts for extracting graph characteristics from Abstract Syntax Trees
For C code:
First, generate the AST using Clang by running the following command in your terminal:
clang -Xclang -ast-dump=json -fsyntax-only <sourcefile.c> > ast.txt
Ensure that the imported modules are installed and that the python virtual environment is activated.
Then, execute the python script to parse and extract characteristics from the AST and visualize it by running the following:
python3 ast_analysis.py
--------------------------------------------------------------------------------------------------------------------
For python code:
To build the ASTs, extract characteristics, and visualize, run the following:
python3 python_ast_analysis.py <sourcefiles.py>
Multiple file paths can be specificied, it will prompt you for wether you would like to visualize graphs, and the output will be saved in 'results.csv'.
---------------------------------------------------------------------------------------------------------------------
Example code files have been included in the ast_analysis folder, such as simple.c, matrix.c, and simple.py
Common issues:
If experiencing issues with uninstalled modules, try running:
pip install networkx matplotlib
sudo apt-get install graphviz
Tutorial for creating and activating a virtual environment:
https://python.land/virtual-environments/virtualenv