Thursday, March 24, 2016

Define different types of translation with example


A translation is an input/output mapping. Generally three types of translation scheme are used -

  • Three Address Statements
  • Quadruples &
  • Triples

Three Address Statements : Three address statements are a sequence of statements.
Typically, the general form A : B op C, where A, & C are either programmer defined names. Constants or compiler - generated temporary names. Op stands for any operator, such as a fixed or floating -point arithmatic operator or a logical operator on Boolean -valued data. Three address statements usually contain  three addresses, two for the operands & one for the result.

Example : Let us consider the expression A : = -B*(C+D).

We get the following three-address code from the expression : 

T1 : = -B
T2 : = C+D
T3 : = T1+T2
A : = T3

Quardruples : Quadruples representation the three - address code by using four fields
These are -
                    OP, ARG1, ARG2 & RESULT.
Implementation of quadruples : Let us consider the following three - address code : 
T1 : = -B
T2 : = C+D
T3 : = T1+T2
A : = T3
These statement are represented by quadruples as shown in fig . (a) 

SL NO OP ARG1 ARG2 RESULT
(0) Uminus B - T1
(1) + C D T2
(2) * T1 T2 T3
(3) := T3 - A

Fig. (a) quadruple representation of three -address statements.


Triple : Triple representation the three address code by using three fields. 
These are -
                    OP, ARG1, ARG2.
So, we use parenthesized number to represent pointer into the triple structure.while symbol-table pointers are represented by names themselves.
Implementation of quadruples : Let us consider the following three - address code : 
T1 : = -B
T2 : = C+D
T3 : = T1+T2
A : = T3
 These statement are represented by quadruples as shown in fig . (a) 


SL NO OP ARG1 ARG2
(0) Uminus B -
(1) + C D
(2) * (0) (1)
(3) := A (2)

Fig. (b) triple representation of three -address statements.


                                       
 
If You want to learn about the technology, computer science & engineering, web programming, freelancing, earning please click here :CSE SOLVE

Related Posts:

  • Define different types of translation with example  Different types of translation with example :  A translation is an input/output mapping. Generally three types of translation scheme are used - Three Address Statements Quadruples & Triples Three Ad… Read More
  • What is String(Word)? String(Word) : A string (word) is a finite sequence of symbols of that string . Example : abc, 01110 are the examples of string If You want to learn about the technology, computer science & engineering, web programmi… Read More
  • What is Symbol? Symbol : A symbol is an abstract entity set we shall not define formally; just an point & line are not defined in geometry. Example :  Letter & digits are examples of symbol. If You want to learn about the t… Read More
  • What is Lexema?  Lexema : A lexema is a sequence of characters in the source program that is matched by the pattern for a token. Example : For Pascal statement -  Cons pi = 3.1416; Here, the sub-string pi is a lexema for the… Read More
  • What is Token? Token : The string representing a program can be partitioned at the lowest level into a sequence of sub-string called tokens. Each token is a sequence of characters whose significant is possessed collectively rather than in… Read More

0 comments:

Post a Comment