Ticker

6/recent/ticker-posts

Program Compilation Process


Program Compilation Process :-

Compilation दूसरा चरण है। यह प्रीप्रोसेसर और सोर्स कोड का आउटपुट लेता है, और assembler source code जेनरेट करता है। इस चरण में, प्रीप्रोसेड कोड असेंबली इंस्ट्रक्शन से टारगेट प्रोसेसर आर्किटेक्चर के लिए ट्रांसलेट होता है।

compilaton की प्रक्रिया को छह phases में विभाजित किया गया है, जिनमें से प्रत्येक एक symbol table manager और एक error handler के साथ intract करता है। इस compilation को विश्लेषण / संश्लेषण (analysis/synthesis)  model कहा जाता है।

Phases of compilation process

Lexical Analysis :   In a compiler, linnar analysis is called lexical analysis or scanning .It combines characters in the source file, to form a "TOKEN" .A token is a set of characters that does not have 'space', 'tab' and 'new line'. यह comments, generates symbol table and relocation table entries को भी हटाता है.

Syntax Analysis:   Hierarchical analysis is called parsing or syntax analysis. The syntax analysis checks for syntax of our statements. It will then generate a parse tree for our statement.

For example : 

x=3 + 7

    =
  /    \
x      +
       /   \
      3       7

syntax में किसी भी त्रुटि के मामले में जैसे x = x +;  it misses one identifier/constant after '+' operator. तो, यह एक त्रुटि उत्पन्न करेगा।


Semantic Analysis : Semantic analysis कभी-कभी presented as performed after syntactic analysis. यह चरण बाद के कोड जनरेशन चरण के लिए सिमेंटिक त्रुटियों के लिए स्रोत प्रोग्राम की जाँच करता है। सिमेंटिक विश्लेषण का एक महत्वपूर्ण component टाइप चेकिंग है। यहां, compiler जांचता है कि operator has operands . जो source language specification द्वारा permitted हैं।
हमने कुछ Semantic errors का उल्लेख किया है जो semantic analyzer को पहचानने की उम्मीद है
  • Type mismatch
  • Undeclared variable
  • Reserved identifier misuse
  • Multiple declaration of variable in a scope
  • Accessing an out of scope variable
  • Actual and formal parameter mismatch

intermediate code generation : एक compiler के analysis-synthesis model में, पहले एक compiler के सामने का अंत एक स्रोत प्रोग्राम का एक स्वतंत्र intermediate code में अनुवाद करता है, फिर compiler के पीछे का अंत target code उत्पन्न करने के लिए इस मध्यवर्ती कोड का उपयोग करता है ( जिसे समझा जा सकता है मशीन द्वारा)। compiler प्रक्रिया को अधिक कुशल बनाने के लिए और कई प्लेटफार्मों के लिए कई स्रोत भाषा में Program से compile के लिए we need to have less number of backend and frontend operations form compiling की आवश्यकता है। तो इस उद्देश्य के लिए हम intermediate code generation. के इस चरण का वर्णन करते हैं।

Code Optimization: In a general way, to make the execution of programs efficient, like usage of fewer resources and time efficient, the compiler will optimize our code up to some extent. We should write the codes by following some code tuning techniques.

Common optimizations include :

  • removing redundant identifiers
  • removing unreachable sections of code identifying common sub expressions
  • unfolding loops
  • eliminating procedures
Code Generation: यह प्रोग्राम Compilation प्रक्रिया का अंतिम चरण है CPU और  other devices के architecture पर निर्भर करता है। कंपाइलर का अंतिम चरण एक विशिष्ट मशीन के लिए कोड उत्पन्न करना है 

इस चरण में हम consider करते हैं।
  • memory management
  • register assignment
  • machine-specific optimization
इस चरण से आउटपुट आमतौर पर assembly language या reloadable करने योग्य machine code होता है.

error Handling:  compiler के छह चरणों (मुख्य रूप से विश्लेषण चरण) में से प्रत्येक में त्रुटियां हो सकती हैं।
Errors या तो वाक्यात्मक या शब्दार्थ हैं.

एक error  compiler must :

  • report the error in a helpful way.
  • correct the error if possible.
  • continue processing (if possible) after the error to look for further errors.
Symbol Table Management :     एक Symbol table एक डेटा संरचना है जिसमें प्रत्येक identifier की सभी विशेषताओं के साथ एक source program के सभी identifiers(procedure, name of variables) शामिल हैं। symbol table का उद्देश्य compilation प्रक्रिया के दौरान quick and uniform access to identifier attributes प्रदान करना है।

Post a Comment

0 Comments