What is Source Code Transformation in Software Engineering

Source Code Transformation

One method used in this area of software renovation is source code transformation. Source code transformations, which are applied at the program’s syntax level, are typically carried out using string replacement technology.

Source code transformation includes 5 steps from “Source Code” to “Final Code”.

Step: 01 

The first step is the conversion of source code to tokenized code with the help of “Lexical Analyzer”.

Lexical Analyzer:

Another name for it is a scanner. It accepts the preprocessor’s output, which is in a pure high-level language and handles file inclusion and macro expansion, as input.

In order to create lexemes—sequences of characters that “go together”—it reads the characters from the source program.

A token is assigned to each lexeme. The lexical analyzer can comprehend regular expressions used to define tokens. It also eliminates comments, white space, and lexical mistakes (such as incorrect letters).

The input for the first step will be the source code and the output will be the tokenized code.

Step: 02

The second step includes the conversion of Tokenized Code to Parsed Code with the help of Syntactic Analyzer.

Syntactic Analyzer:

It is also referred to as a parser. The parse tree is created. Context-Free Grammar is used to build the parse tree after taking each token one at a time.

After this step, we will have a “Parsed Code”.

Step: 03

In the third step, we will convert Parsed code to Qualified code with Semantic Analyzer.

Semantic Analyzer:

It checks to see if the parse tree is meaningful. Additionally, a confirmed parse tree is produced. Additionally, it performs type, label, and flow control checks.

Semantic Analyzer will give us Qualified code, which will be able to use in the next step.

Step: 04

In the fourth step of the process, we have the conversion of Qualified code to Object code. We will complete this process with the help of the Code Generator.

Code Generator:

It produces intermediate code, which is a format that a machine can easily execute. We offer a lot of well-liked intermediate codes. Three address codes, for instance.

Step: 05

This is the last and final step of the process. In this step, we convert Object code to Final code with Optimizer. 

Code Optimizer:

It modifies the code to make it use fewer resources and run more quickly. The changed code retains its original meaning.

The two types of optimization are machine-dependent and machine-independent.

After this final step, we will get Final Code.

Leave a Reply