Compiler Construction CIS 707 Prof NengFa Zhou zhousci

  • Slides: 14
Download presentation
Compiler Construction CIS 707 Prof. Neng-Fa Zhou zhou@sci. brooklyn. cuny. edu http: //www. sci.

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

What is a Compiler? source program compiler error messages 4 Gcc gcc –S myprog.

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

Why Do We Learn Compilers? The principles and techniques of compiler writing are so

Why Do We Learn Compilers? 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 Design and implement languages 4 Use languages more effectively 4 Many other application areas – Data (text, image, audio, video) processing – Information retrieval – Bio-informatics by Neng-Fa Zhou

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

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

Analysis of Source Programs source program lexical analyzer tokens syntax analyzer parse trees semantic

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

Lexical Analysis tokens by Neng-Fa Zhou

Lexical Analysis tokens by Neng-Fa Zhou

Syntax Analysis parse tree by Neng-Fa Zhou

Syntax Analysis parse tree by Neng-Fa Zhou

Semantic Analysis type checking type conversion by Neng-Fa Zhou

Semantic Analysis type checking type conversion by Neng-Fa Zhou

Symbol Table 4 There is a record for each identifier 4 The attributes include

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

Synthesis of Object Code parse tree & symbol table intermediate code generator intermediate code

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

Intermediate Code Generation by Neng-Fa Zhou

Intermediate Code Generation by Neng-Fa Zhou

Code Optimization by Neng-Fa Zhou

Code Optimization by Neng-Fa Zhou

Code Generation by Neng-Fa Zhou

Code Generation by Neng-Fa Zhou

Interpreters and Compilers 4 The boundary between interpreters and compilers is becoming vague –

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 by Neng-Fa Zhou