- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is types of Intermediate Code Representation?
The translation of the source code into the object code for the target machine, a compiler can produce a middle-level language code, which is referred to as intermediate code or intermediate text. There are three types of intermediate code representation are as follows −
Postfix Notation
In postfix notation, the operator comes after an operand, i.e., the operator follows an operand.
Example
Postfix Notation for the expression (a+b) * (c+d) is ab + cd +*
Postfix Notation for the expression (a*b) - (c+d) is ab* + cd + - .
Syntax Tree
A tree in which each leaf node describes an operand & each interior node an operator. The syntax tree is shortened form of the Parse Tree.
Example − Draw Syntax Tree for the string a + b ∗ c − d.
Three-Address Code
The three-address code is a sequence of statements of the form A−=B op C, where A, B, C are either programmer-defined names, constants, or compiler-generated temporary names, the op represents for an operator that can be fixed or floatingpoint arithmetic operators or a Boolean valued data or a logical operator. The reason for the name “three address code” is that each statement generally includes three addresses, two for the operands, and one for the result.
There are three types of three address code statements which are as follows −
Quadruples representation − Records with fields for the operators and operands can be define three address statements. It is possible to use a record structure with fields, first hold the operator ‘op’, next two hold operands 1 and 2 respectively, and the last one holds the result. This representation of three addresses is called a quadruple representation.
Triples representation − The contents of operand 1, operand 2, and result fields are generally pointer to symbol records for the names described by these fields. Therefore, it is important to introduce temporary names into the symbol table as they are generated.
This can be prevented by using the position of statement defines temporary values. If this is completed then, a record structure with three fields is enough to define the three address statements− The first holds the operator and the next two holds the values of operand 1 and operand 2 respectively. Such representation is known as triple representation.
Indirect Triples Representation − The indirect triple representation uses an extra array to list the pointer to the triples in the desired sequence. This is known as indirect triple representation.
The triple representation for the statement x− = (a + b)*-c is as follows −
Statement | Statement | Location | Operator | Operand 1 | Operand 2 |
---|---|---|---|---|---|
(0) | (1) | (1) | + | a | B |
(1) | (2) | (2) | - | c | |
(2) | (3) | (3) | * | (0) | (1) |
(3) | (4) | (4) | / | (2) | d |
(4) | (5) | (5) | :=) | (3) |
- Related Articles
- What is Intermediate Code Generation?
- Intermediate Goods
- What is Instance-based representation?
- Resistor Types and Color Code
- What is representation of fixed-length and variablelength array representation in the symbol table?
- What is the Representation of DFA in compiler design?
- What is Decibel Representation for Wireless Communications?
- What is Polynomial Code?
- What is the general name of the elements whose properties are intermediate between those of metals and nonmetals?
- What are some good Python projects for an intermediate programmer?
- What is Fixed Point Representation in Computer Architecture?
- What is Floating-Point Representation in Computer Architecture?
- What is Array Name Representation in Symbol Table?
- What is Gray code?\n
- What is Code Division Multiplexing?
