Renaissance.Py is a library and tool for software analysis and transformation. Renaissance.Py provides AST matching for multiple programming languages. Renaissance.Py combines the insights obtain with Renaissance and Renaissance-Ada.
This repository is licensed under the Eclipse Public License 2.0 (EPL-2.0) as described in LICENSE.
The copyright holder may also offer this software under separate license terms. Such alternative licenses are only granted on request and only through a separate written agreement and are not available through this GitHub repository. For licensing inquiries please contact: Jos Hegge
To ensure that the project can continue to be distributed under non-restrictive OS licenses and for certain applications closed source licenses, all contributions must be submitted under the MIT License or BSD 3-Clause License and must comply with the contribution policy described in CONTRIBUTING.md.
Contributions that are subject to additional restrictions or incompatible license terms will not be accepted.
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