Presentation is loading. Please wait.

Presentation is loading. Please wait.

By Neng-Fa Zhou Compiler Construction CIS 707 Prof. Neng-Fa Zhou

Similar presentations


Presentation on theme: "By Neng-Fa Zhou Compiler Construction CIS 707 Prof. Neng-Fa Zhou"— Presentation transcript:

1 by Neng-Fa Zhou Compiler Construction CIS 707 Prof. Neng-Fa Zhou zhou@sci.brooklyn.cuny.edu http://www.sci.brooklyn.cuny.edu/~zhou/

2 by Neng-Fa Zhou What is a Compiler?  Gcc gcc –S myprog.c  Javap javap –c MyClass compiler source program target program error messages

3 by Neng-Fa Zhou Why Do We Learn Compilers? 4 Design and implement languages 4 Use languages more effectively 4 Many other application areas –Data (text, image, audio, video) processing –Information retrieval –Bio-informatics The principles and techniques of compiler writing are so pervasive that the ideas found in this book will be used many times in the career of a computer scientist.

4 by Neng-Fa Zhou The Context of a Compiler analysis synthesis

5 by Neng-Fa Zhou Analysis of Source Programs lexical analyzer syntax analyzer semantic analyzer source program tokens parse trees

6 by Neng-Fa Zhou Lexical Analysis tokens

7 by Neng-Fa Zhou Syntax Analysis parse tree

8 by Neng-Fa Zhou Semantic Analysis type checking type conversion

9 by Neng-Fa Zhou Symbol Table 4 There is a record for each identifier 4 The attributes include name, type, location, etc.

10 by Neng-Fa Zhou Synthesis of Object Code intermediate code generator code optimizer code generator parse tree & symbol table intermediate code optimized intermediate code target program

11 by Neng-Fa Zhou Intermediate Code Generation

12 by Neng-Fa Zhou Code Optimization

13 by Neng-Fa Zhou Code Generation

14 by Neng-Fa Zhou Interpreters and Compilers 4 The boundary between interpreters and compilers is becoming vague –Interpreters interpret intermediate forms of programs Parse trees (Basic, Tcl, and Pearl) Virtual machine code (Java, Lisp, and Prolog) 4 Native code compiler


Download ppt "By Neng-Fa Zhou Compiler Construction CIS 707 Prof. Neng-Fa Zhou"

Similar presentations


Ads by Google