by neng-fa zhou compiler construction cis 707 prof. neng-fa zhou [email protected] zhou
Post on 19-Dec-2015
241 views
TRANSCRIPT
by Neng-Fa Zhou
Compiler Construction
CIS 707
Prof. Neng-Fa Zhou
http://www.sci.brooklyn.cuny.edu/~zhou/
by Neng-Fa Zhou
What is a Compiler?
Gccgcc –S myprog.c
Javapjavap –c MyClass
compilersource
program
targetprogram
errormessages
by Neng-Fa Zhou
Why Do We Learn Compilers?
Design and implement languages Use languages more effectively 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 foundin this book will be used many times in the career of a computer scientist.
by Neng-Fa Zhou
Analysis of Source Programs
lexical analyzer
syntax analyzer
semantic analyzer
source program
tokens
parse trees
parse trees
by Neng-Fa Zhou
Symbol Table
There is a record for each identifier The attributes include name, type, location, etc.
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