DESKTOP

# Algorithms for Compiler Design: INTERMEDIATE CODE GENERATION

7/24/2010 8:02:39 PM
##### 6.5 INTERMEDIATE CODE GENERATION While translating a source program into a functionally equivalent object code representation, a parser may first generate an intermediate representation. This makes retargeting of the code possible and allows some optimizations to be carried out that would otherwise not be possible. The following are commonly used intermediate representations: Postfix notation Syntax tree Three-address code #### Postfix Notation In postfix notation, the operator follows the operand. For example, in the expression (a − b) * (c + d) + (a − b), the postfix representation is: #### Syntax Tree The syntax tree is nothing more than a condensed form of the parse tree. The operator and keyword nodes of the parse tree (Figure 1) are moved to their parent, and a chain of single productions is replaced by single link (Figure ). #### Three-Address Code Three address code is a sequence of statements of the form x = y op z. Since a statement involves no more than three references, it is called a "three-address statement," and a sequence of such statements is referred to as three-address code. For example, the three-address code for the expression a + b * c + d is: Sometimes a statement might contain less than three references; but it is still called a three-address statement. The following are the three-address statements used to represent various programming language constructs: Used for representing arithmetic expressions: Used for representing Boolean expressions: Used for representing array references and dereferencing operations: Used for representing a procedure call: var sc_project=11388663; var sc_invisible=1; var sc_security="7db37af3"; var scJsHost = (("https:" == document.location.protocol) ? "https://secure." : "http://www."); document.write("<sc"+"ript type='text/javascript' src='" + scJsHost+ "statcounter.com/counter/counter.js'></"+"script>");
 Other

 Top 10
 REVIEW
- First look: Apple Watch

- 3 Tips for Maintaining Your Cell Phone Battery (part 1)

- 3 Tips for Maintaining Your Cell Phone Battery (part 2)