Understanding Compiler _

Views:
 
Category: Education
     
 

Presentation Description

Understanding Compiler

Comments

Presentation Transcript

Understanding Compiler.:

Understanding Compiler.

Structure of a Compiler Compiler Stages:

Structure of a Compiler Compiler Stages Source Language ? Target Language

PowerPoint Presentation:

Source Language Target Language Front End Back End Intermediate Code Structure of a Compiler Compiler Stages

PowerPoint Presentation:

Source Language Target Language Semantic Analyzer Syntax Analyzer Lexical Analyzer Front End Back End Int. Code Generator Intermediate Code Structure of a Compiler Compiler Stages

PowerPoint Presentation:

Source Language Target Language Semantic Analyzer Syntax Analyzer Lexical Analyzer Front End Code Optimizer Target Code Generator Back End Int. Code Generator Intermediate Code Structure of a Compiler Compiler Stages

PowerPoint Presentation:

Source Language Target Language Semantic Analyzer Syntax Analyzer Lexical Analyzer Code Optimizer Target Code Generator Int. Code Generator Intermediate Code Source Code: cur_time = start_time + cycles * 60 Example Compilation

PowerPoint Presentation:

Source Language Target Language Semantic Analyzer Syntax Analyzer Lexical Analyzer Code Optimizer Target Code Generator Int. Code Generator Intermediate Code Source Code: cur_time = start_time + cycles * 60 Lexical Analysis: ID(1) ASSIGN ID(2) ADD ID(3) MULT INT(60) Example Compilation

PowerPoint Presentation:

Source Language Target Language Semantic Analyzer Syntax Analyzer Lexical Analyzer Code Optimizer Target Code Generator Int. Code Generator Intermediate Code Source Code: cur_time = start_time + cycles * 60 Lexical Analysis: ID(1) ASSIGN ID(2) ADD ID(3) MULT INT(60) Syntax Analysis: ASSIGN ID(1) ADD ID(2) MULT ID(3) INT(60) Example Compilation

PowerPoint Presentation:

Source Language Target Language Semantic Analyzer Syntax Analyzer Lexical Analyzer Code Optimizer Target Code Generator Int. Code Generator Intermediate Code Syntax Analysis: ASSIGN ID(1) ADD ID(2) MULT ID(3) INT(60) Sematic Analysis: ASSIGN ID(1) ADD ID(2) MULT ID(3) int2real INT(60) Example Compilation

PowerPoint Presentation:

Source Language Target Language Semantic Analyzer Syntax Analyzer Lexical Analyzer Code Optimizer Target Code Generator Int. Code Generator Intermediate Code Sematic Analysis: ASSIGN ID(1) ADD ID(2) MULT ID(3) int2real INT(60) Intermediate Code: temp1 = int2real(60) temp2 = id3 * temp1 temp3 = id2 + temp2 id1 = temp3 Example Compilation

PowerPoint Presentation:

Source Language Target Language Semantic Analyzer Syntax Analyzer Lexical Analyzer Code Optimizer Target Code Generator Int. Code Generator Intermediate Code Intermediate Code: temp1 = int2real(60) temp2 = id3 * temp1 temp3 = id2 + temp2 id1 = temp3 Optimized Code ( step 0 ): temp1 = int2real(60) temp2 = id3 * temp1 temp3 = id2 + temp2 id1 = temp3 Example Compilation

PowerPoint Presentation:

Source Language Target Language Semantic Analyzer Syntax Analyzer Lexical Analyzer Code Optimizer Target Code Generator Int. Code Generator Intermediate Code Intermediate Code: temp1 = int2real(60) temp2 = id3 * temp1 temp3 = id2 + temp2 id1 = temp3 Optimized Code ( step 1 ): temp1 = 60.0 temp2 = id3 * temp1 temp3 = id2 + temp2 id1 = temp3 Example Compilation

PowerPoint Presentation:

Source Language Target Language Semantic Analyzer Syntax Analyzer Lexical Analyzer Code Optimizer Target Code Generator Int. Code Generator Intermediate Code Intermediate Code: temp1 = int2real(60) temp2 = id3 * temp1 temp3 = id2 + temp2 id1 = temp3 Optimized Code ( step 2 ): temp2 = id3 * 60.0 temp3 = id2 + temp2 id1 = temp3 Example Compilation

PowerPoint Presentation:

Source Language Target Language Semantic Analyzer Syntax Analyzer Lexical Analyzer Code Optimizer Target Code Generator Int. Code Generator Intermediate Code Intermediate Code: temp1 = int2real(60) temp2 = id3 * temp1 temp3 = id2 + temp2 id1 = temp3 Optimized Code ( step 3 ): temp2 = id3 * 60.0 id1 = id2 + temp2 Example Compilation

PowerPoint Presentation:

Source Language Target Language Semantic Analyzer Syntax Analyzer Lexical Analyzer Code Optimizer Target Code Generator Int. Code Generator Intermediate Code Intermediate Code: temp1 = int2real(60) temp2 = id3 * temp1 temp3 = id2 + temp2 id1 = temp3 Optimized Code: temp1 = id3 * 60.0 id1 = id2 + temp1 Example Compilation

PowerPoint Presentation:

Source Language Target Language Semantic Analyzer Syntax Analyzer Lexical Analyzer Code Optimizer Target Code Generator Int. Code Generator Intermediate Code Intermediate Code: temp1 = int2real(60) temp2 = id3 * temp1 temp3 = id2 + temp2 id1 = temp3 Optimized Code: temp1 = id3 * 60.0 id1 = id2 + temp1 Target Code: MOVF id3, R2 MULF #60.0, R2 MOVF id2, R1 ADDF R2, R1 MOVF R1, id1 Example Compilation

authorStream Live Help