A gentle introduction to search-based software refactoring

Posted on Thu 05 May 2022 in blog • Tagged with blog, ANTLR, compiler, tutorial

Finding the best sequence of the refactoring operation to ab applied to a software system is an optimization problem. It can be solved by search techniques in the field known as search-based software engineering (SBSE). In this approach, refactorings are applied stochastically to the original software solution, and then the software is measured using a fitness function consisting of one or more software quality measures. Unfortunately, there is no technical document describing an implementation of decent search-based refactoring. In this tutorial, I am going to explain the implementation of search-based refactoring at the source code level from scratch.


Continue reading

Automated refactoring of the Java code using ANTLR in Python

Posted on Mon 02 May 2022 in blog • Tagged with blog, ANTLR, compiler, tutorial

Refactoring is a type of program transformation that preserves the program’s behavior. The goal of refactoring is to improve the program’s internal structure without changing its external behavior. In this way, the program quality, defined and measured in terms of quality attributes, is improved. The refactoring process could be automated to reduce the required time and cost and increase the reliability of applied transformation. In this tutorial, I give a short description of how we can automate the refactoring process with ANTLR in Python.


Continue reading

Program dynamic analysis with ANTLR

Posted on Tue 30 March 2021 in blog • Tagged with blog, ANTLR, compiler, tutorial

Dynamic analysis refers to extracting specific information from the program related to the program’s execution. Therefore, it requires to execute the program under analysis. Often the source code must be augmented in a way that executing the program outputs the additional information required for dynamic analysis. A well-known technique for this aim is program instrumentation. The ANTLR tool can be used to instrument the source code effectively. In this tutorial, I explain how we can use the ANTLR tool to instrument the C++ program in the Python programming language.


Continue reading

Program static analysis with ANTLR

Posted on Mon 29 March 2021 in blog • Tagged with blog, ANTLR, compiler, tutorial

Static analysis means extracting specific information from the program artifacts, e.g., source code, without any execution of the program. The ANTLR tool can be used to perform all types of static analysis at the source-code level. In this tutorial, I explain how we can use the ANTLR tool to perform some basic kinds of static analysis of the C++ programs in the Python programming language. The task I chose to explain is extracting the class diagram and computing the relevant design metrics.


Continue reading

An introduction to ANTLR in Python

Posted on Mon 22 March 2021 in blog • Tagged with blog, ANTLR, compiler, tutorial

ANTLR is a parser generator that can generate the parser program from context-free grammar descriptions specified in the ANTLR grammar format. In this tutorial, I explain how we can generate and use the Java parser with ANTLR in the Python programming language.


Continue reading