What is Compilation Process in PPL

 Compilation :- It is a process to convert a high level Programming Language into a Machine  Language  that the computer can understand.

·       Why do we need a compilation process?

अगर हम C Language की बात करे तो ये एक High Level Programming Language है जिसकी वजह से C  Language में  लिखे गए Code को मशीन Language(Binary Language यानि 0  और 1) में convert  किया  जाता है इसके लिए हमें Compilation Process की जरुरत होती है |

·  Compilation Process का ये काम compiler के जरिये किया जाता है | Compiler C Language में लिखे गए code को Machine Code में convert कर देता है जिससे Machine उस Code को आसानी से समझने में 

Capable (सक्षम) हो जाता है |

· Phases of Compilation Process :-

1.   Lexical Analyzer

2.   Syntax Analyzer

3.   Semantic Analyzer

4.   Intermediate Code Generator

5.   Code Optimization

 


                 Fig:- Compilation Process 


1. Lexical Analyzer :- यह Phase प्रोग्राम को character by 

character स्कैन करता है और इन characters को meaningful

 words (Lexemes ) में grouping करता है जैसे Identifier,

 Special words ,Operators और punctuation Symbols

·     Lexical Analyzer ये Source Program के comments 

को Ignores करता है क्योकि compiler का उनके लिए कोई 

इस्तेमाल नहीं है |

2 . Syntax Analyzer :- यह Phase Lexical Analyzer

 के output को Input के शकल में लेता    है  और Program

 के Grammar को check करने के लिए  Syntax tree 

(Parse Tree ) को Generate  करता है ताकि  इसके 

syntax को check कर सके |

3. Semantic Analyzer :- यह phase check करता है

 की Syntax Analyzer phase में जिस  syntax  tree 

 का  construction किया गया है  वो language के 

rules को follow कर रहा है |

Eg :- अगर हमने int x  को define किया है तो वह 

सिर्फ Integer value को ही store  करना  चाहिए |

4. Intermediate code generator:-  इस phase में 

source code का Intermediate code  generate होता है

  और इस Intermediate code को Machine Language

 में translate  किया जाता है | 

5.Code Optimization :- इस phase में जो भी intermediate

 code के जरिये से unnecessary code lines generate हुआ है 

उसको remove कर दिया जाता है |

    What is a Symbol Table?

The symbol table is mainly known as the data 

structure of the compiler. It helps in storing the

 identifiers with their name and types. It makes

 it very easy to operate the searching and 

fetching process.

The symbol table connects or interacts with all

 phases of the compiler and error handler for updates.

 It is also accountable for scope management.

Why do we use parsing in compilers?

  The parser in the compilation process is utilised  
  to split the data into smaller components 
  reaching from the lexical analysis phase
  (first phase). It takes input in the form of 
  a series of tokens and creates output as the
   parse tree.

Difference between a Compiler

and an Interpreter?

         Compiler

    Interpreter

1 . A compiler translates the complete source program in a single run.

1.   An interpreter translates the source program line by line.

2.   It consumes less time.

2 It consumes more time than compiler.

3.     It is faster.

3.   It is slower.

4.   It is more efficient.

4.   It is less efficient.

5. It is not flexible.

5.   It is flexible.

6.  Compilers are larger in size.

6.   Interpreter are often smaller than compilers.

7.   The error localization is difficult.

7.   The error localization is easier than the compiler.

8. CPU utilization is more.

8.   CPU utilization is less as compared to compilers.

9.    Both syntactic and semantic errors can be checked at the same time.

9.   Only syntactic error can be checked at a time.

10. A presence of an error may cause whole program to be recognized.

10.  A presence of an error causes only a part of the program to be recognized.

11.  A compiler does not provide an improved debugging environment.

11.  An interpreter provides an improved debugging environment.

12 Compiler is used by languages such as C, C++ etc

12.  An interpreter is used by languages such as Java.

Tausif

Hi! My name is TAUSIF AHMAD I have completed B.Tech in Computer Science from Maulana Azad National Urdu University Hyderabad. I am always ready to have new experiences meet new people and learn new things. 1. I am very interested in Frontend Development. 2. I love video editing and graphics designing. 3. I enjoy challenges that enables to grow. 4. I am part time Blogger.

Post a Comment (0)
Previous Post Next Post