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 −
In postfix notation, the operator comes after an operand, i.e., the operator follows an operand.
Postfix Notation for the expression (a+b) * (c+d) is ab + cd +*
Postfix Notation for the expression (a*b) - (c+d) is ab* + cd + - .
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.
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|