Phases Of Compiler In System Programming!!!!
Phases Of Compiler In System Programming !!!
Phases of compiler :
- Lexical analysis
- Syntax analysis
- Semantic analysis
- Intermediate code generation
- Code optimization
- Code generation
Phases Of Compiler In System Programming!!!! |
Lexical Analysis
Lexical analysis is the first phase of compiler which is also termed as scanning.
Source program is scanned to read the stream of characters and those characters are grouped to form a sequence called lexemes which produces token as output.
Token: Token is a sequence of characters that represent lexical unit, which matches with the pattern, such as keywords, operators, identifiers etc.
Lexeme: Lexeme is instance of a token i.e., group of characters forming a token. ,
Pattern: Pattern describes the rule that the lexemes of a token takes. It is the structure that must be matched by strings.
Once a token is generated the corresponding entry is made in the symbol table.
Recommend Articles For More Information :
What Is Operating System? Knowledge Of OS!!
Operating System As A User Interface And As A Resource Manager - Technopedia!
Services Of Operating System -
Technopedia!!!
Basic Concepts Of OOPC!!
CONCEPT OF DBMS!!
Types Of Operating System - Technopedia!!!
Input: stream of characters
Output: Token
Token Template: <token-name, attribute-value>
Example: c=a+b*e;
c : operand
= : operator
a : operand
+ : operator
b : operand
* : operator
e : operand
Syntax Analysis
Syntax analysis is the second phase of compiler which is also called as parsing.
Parser converts the tokens produced by lexical analyzer into a tree like representation called parse tree.
A parse tree describes the syntactic structure of the input.
Syntax tree is a compressed representation of the parse tree in which the operators appear as interior nodes and the operands of the operator are the children of the node for that operator.
Input: Tokens
Output: Syntax tree
Semantic Analysis
Semantic analysis is the third phase of compiler.
It checks for the semantic consistency.
Type information is gathered and stored in symbol table or in syntax tree.
Performs type checking.
Intermediate Code Generation
Intermediate code generation produces intermediate representations for the source program which are of the following forms:
- Postfix notation
- Three address code
- Syntax tree
Most commonly used form is the three address code.
It should be easy to produce.
It should be easy to translate into target program.
May You Like To Read This Related Articles:
Introduction Of C++!!.
Operators In C++
Function Overloading In C++
Data Types in C++
Types Of Constructor In C++
Classes and Objects In C++
What Is Inheritance In C++?
Types Of Inheritance?
Basic Concepts Of OOPC!!
CONCEPT OF DBMS!!
Basic Program Of C Language For Print Hello!!
Code Optimization
Code optimization phase gets the intermediate code as input and produces optimized intermediate code as output.
It results in faster running machine code.
It can be done by reducing the number of lines of code for a program.
This phase reduces the redundant code and attempts to improve the intermediate code so that faster-running machine code will result.
During the code optimization, the result of the program is not affect.
To improve the code generation, the optimization involves
- Deduction and removal of dead code (unreachable code).
- Calculation of constants in expressions and terms.
- Collapsing of repeated expression into temporary string.
- Loop unrolling.
- Moving code outside the loop.
- Removal of unwanted temporar
Code Generation
Code generation is the final phase of a compiler.
It gets input from code optimization phase and produces the target code or object code as result.
It gets input from code optimization phase and produces the target code or object code as result.
Intermediate instructions are translate into a sequence of machine instructions that perform the same task.
The code generation involves
- Allocation of register and memory.
- Generation of correct references.
- Generation of correct data types.
- Generate the missing code.
LDF R2, id3
MULF R2, # 5.0
LDF R1, id2
ADDF R1, R2
For More Knowledge Check This Articles For Better Understanding :
Machine Learning Technology in Software Engineering
Trending Pieces Of Technology You Should Know About!!!
CONCEPT OF DBMS!!
Phases Of Compiler In System Programming!!!!
C Program For Addition, Subtraction, Multiplication, Division Of Two Numbers!!
Difference between a monolithic and micro kernel?
Difference Between The Procedure Oriented Language and Object Oriented Language.
What Is Inheritance In C++? Types Of Inheritance?
Comments
Post a Comment