This project is experimental in nature and aims to explore various concepts and techniques to apply renaissance pattern matching in a generic way using multiple abstract syntax trees.
sudo apt-get install -y build-essential clangThe code for the experiments is located in the src folder.
This project is a generic approach to refactor code bases with a generic AST structure.
It uses TNO Renaissance pattern matching.
Currently, clang native and clang python bindings are supported.
You'll need to implement a concrete class for syntax_tree.ASTNode.
Follow the implementations of ClangASTNode and ClangJsonASTNode as an example.
If the concrete AST has a different language then also a PatternFactory must be added. See CPatternFactory for inspiration.
To install the necessary dependencies, follow these steps:
- Run the Installation Script
- Navigate to the project directory.
- Execute the
install.batscript by double-clicking it or running the following command in the terminal:./install.bat
-
Configure the Environment
- Open Visual Studio Code (VSCode).
- Ensure that the Python extension is installed.
- Open the project folder in VSCode.
- alternatively in shell goto /python folder and
code .
-
Verify the Installation
- Open the integrated terminal in VSCode.
- Run the following command to execute the tests:
python -m unittest discover
- Check the output to ensure all tests pass successfully.
By following these steps, you will have installed and verified the setup for the project.
An incomplete list of todo's:
- The get_properties methods of both
ClangASTNodeandClangJsonASTNodeare not complete yet. This might cause mismatches in theMatch_Finder - C++ constructs have not been tested yet
- An example of how to use includes in a
Patternmust be added - Tests need to be added for macro handling
- The methods
get_referencesandreferred_bymust be added toASTNodeand implemented in the concrete classes - Test cases for multiple match patterns need to be added. Currently, there is only one working case in the examples
- Comments in Clang appear incorrectly in the
ASTShower. This seems to be a Clang issue, which is surprising
cli
Inspect the AST of a source file.
cli inspect features/targets/demo.py passit will show ast of demo.py and focus on 'pass' statements