What is compiler ? Technology Gyan

 what is compiler

By the way, if I say a compiler in easy language, then it is such a program that converts a source language into a target language as per the requirement. In a computer, it converts high level language into machine language. That's why today I thought that why should I provide complete information to you people about what is the work of the compiler, so that in the coming time, you should already be aware of this basic technology. So without delay, let's start and know what the compiler is called and how it works.



what is compiler

A compiler is a software program that transforms high-level source code written by a developer into a high-level programming language, into a low-level object code (binary code) machine language, and which Key can be easily shared by the processor. This process in which high-level programming is converted into machine language is called Compilation.

Compiler is a computer program that converts a program written in a high level language (C/C++/java etc.) into a low level language (object/target/machine). That is, the compiler acts as an interface between the user / programmer and the computer. When programmer writes program in any high language like C/C++/Java etc. and executes it, first of all it goes to the compiler. After that the compiler converts that source code into object code and gives it to the computer. If there is an error in the source code, it displays it. The compiler translates the entire program at once. Whereas interpreter and assembler translates line by line.

who is the compiler

As I have already introduced you to the technical definition of Compiler, as everyone often does, but now I am going to explain to you the definition of Compiler in very easy language so that even a non-technical person can understand.

Forget about the compiler for some time and imagine that you have gone to a beautiful country to spend your vacation. There is a very basic problem in this that you can speak, write and understand only in your regional language which is Hindi. But there the citizens of that country know nothing but English only. Then how will you communicate with others there?

In such a situation, there is only one solution for this that you will need a language translator which can be a human or a book or even an App. This language translator will translate your Hindi into English so that the other person can understand your words. Together he will convert English into Hindi as well till you can understand his language.

The same thing happens with computers. Computers also understand only binary language (language which contains 0s and 1s), whereas users who understand computer understand English or any language. In such a situation, how will the computer understand the commands given by you? Also, you will not understand any process calculation performed by the computer. In such a situation, a language translator is needed here so that he can have a good balance between the two.

When we give some command to the computer to process, then we write some set of instructions-program in English language like c, c++, java etc. which is in English only and a language translator is needed. To convert into binary language so that a computer can understand it easily. In such a situation, Complier is used in this place, which converts high level language into machine language.

What are the Major Parts of Compliers

By the way, there are mainly two major parts of the compiler:

Analysis Phase

The first part is the analysis phase, in which an intermediate representation is created from a given source program. The main parts of this phase are – Lexical Analyzer, Syntax Analyzer and Semantic Analyze.

Synthesis Phase

Whereas the second part is the synthesis phase, in which the equivalent target program is created from the intermediate representation. The main parts of this phase are – Intermediate Code Generator, Code Generator, and Code Optimizer.

what is decompiler

A compiler that converts machine language into high-level natural language is called a decompiler.

What is a Cross-Compiler?

Compilers which produce object code which is made to run only in the system are called Cross-Compilers.

What is Programming Language?

Such a compiler that converts one programming language to another is called a language translator.

what is the use of compiler

Compilers are most commonly used to perform four major steps.

1. Scanning: This scanner reads one character at a time from the source code and keeps track of all the characters so that it knows which character is present in which line.

2. Lexical Analysis: Compiler converts the sequence of characters that appear in the source code into a series of strings of characters (called key tokens), which are associated with a specific rule of a program. through a lexical analyzer. A symbol table is used to store words in the lexical analyzer in the source code, which corresponds with the token generated.

3. Syntactic Analysis: In this step, syntax analysis is done, which involves preprocessing which determines whether the tokens that are created during lexical analysis are in proper order or not according to usage. The correct order of the set of keywords which finally yields a desired result is called Syntax. In this the compiler has to check this check source code so that syntactic accuracy can be ensured.

4. Semantic Analysis: There are many intermediate steps in this step. First, in this the structure of tokens is checked, along with their order is also checked whether it is according to the grammar of the given language or not. The meaning of the token structure is interpreted by the parser and analyzer so that finally an intermediate code can be generated which is called Object code. These object codes contain instructions that represent the processor action for a corresponding token when it is encountered in the program. Finally, the entire code is parsed and interpreted to check whether any optimizations are possible or not. Once the optimizations are performed, then appropriate modified tokens are inserted in the object code to generate the final object code, which is saved within a file.

Main features of the compiler

  1. Compiler converts the program code written in high level language into machine language, then that program is run in the computer.
  2. Compiler scans the entire program before translating the program into machine code and converts that program into machine language only if there is no error.
  3. Compiler takes the entire source code as input.
  4. In the case of compiler, object code is generated.
  5. The compiler takes much less time in execution than the interpreter.
  6. Through the compiler, the code written in the following programming language is converted into machine language -: C, COBOL, C#, C++, etc.
  7.  Compiler requires much more memory than Interpreter.
  8. If there is any modification in the program then the entire program has to be recompile.
  9.  Compiler is much faster than Interpreter.
  10. After compiling the program, there is no need to compile it again and again.
  11. If an error occurs in the program, then the compiler provides a list of errors after compiling the program.
  12. Compiler converts that program into machine code only after removing the error found in the program.
  13. Debugging in the compiler is a bit slow because the compiler first compiles the entire program and then displays it when there is an error.

Comments