180 likes | 443 Views
Lecture # 1. Compiler Design CSE344. Introduction to Compiler Design. Instructor: Asma Sanam Larik Text Book: Compilers: Principles, Techniques and Tools by Aho, Sethi and Ullman (2 nd Edition) Course Website: http://cse344compilerdesign.wikispaces.com/. Course Syllabus: An overview
E N D
Lecture # 1 Compiler Design CSE344
Introduction to Compiler Design • Instructor: Asma Sanam Larik • Text Book: Compilers: Principles, Techniques and Tools by Aho, Sethi and Ullman (2nd Edition) • Course Website: http://cse344compilerdesign.wikispaces.com/
Course Syllabus: An overview • Grading Policy Midterm Exams 30% Assignments 10% Quizzes 5% (best 5) Project 15% (3 phases) Final 40%
Class Taking Techniques • I will use projected material extensively • I welcome questions • PowerPoint materials available on web page • Read the book- Not all material will be covered in class • The midterms will cover both lecture and reading • I take surprise quiz • Submit the assignments within due date
What is a Compiler? • A compiler is a program that reads a program written in one language called the source language into an equivalent program in another language called the target language. The target program is then provided the input to produce output. C, Java, Pascal all are compiled
What is an Interpreter? • An interpreter requires no pre-computation it directly takes the source program and runs the input on it producing the desired output. Ada is interpreted.
Positive/Negative of Interpretation • Positive: • No pre-computation on the program text • Short startup time faster for smaller programs • Negative: • Program parts are repeatedly analyzed during execution • less efficient access to program variables • Slower execution speed
Essence of Compilation • Compile Time and Run time are two different phases • Static Information available at Compile Time including • Declared variables • Size and dimension of arrays incase of C, Pascal • Space for declared variable • Addresses for declared variable • Dynamic Information would be available at runtime including • value of expressions • value of pointer • virtual function information etc
Trade-off: Compilation Time vs Runtime • Pre-processing of source program provides for efficient access to the values of program variable at runtime however compilation takes time • When program execution is sped up compilation pays off in long run
Why study Compilation? • Compilers are important • Responsible for many aspects of system performance • Attaining performance has become more difficult over time • Compilers are interesting • Compilers include many applications of theory to practice • Writing a compiler exposes algorithmic & engineering issues • Compilers are everywhere • Many practical applications have embedded languages Commands, macros, formatting tags
Why study Compilation? • Computer Science is the art of creating virtual objects and making them useful. • We invent abstractions and uses for them • We invent ways to make them efficient • Programming is the way we realize these inventions • Well written compilers make abstraction affordable
Challenges of Compiler Construction Compiler construction poses challenging and interesting problems: • Compilers must process large inputs, perform complex algorithms, but also run quickly • Compilers have primary responsibility for run-time performance • Compilers are responsible for making it acceptable to use the full power of the programming language • Computer architects perpetually create new challenges for the compiler by building more complex machine • Compilers must hide that complexity from the programmer A successful compiler requires mastery of the many complex interactions between its constituent parts
Compiler and other areas • Compiler construction involves ideas from many different parts of computer science • Artificial intelligence: Greedy algorithms, Heuristic search techniques • Algorithms: Graph algorithms, Dynamic programming • Theory of Automata: DFAs & PDAs, pattern matching, regular expressions • Architecture: Pipelining and Instruction set use
Lets start the course…… Highly Motivated
Analysis-Synthesis Model of Compilation • There are two parts to compilation: • Analysis determines the operations implied by the source program which are recorded in a tree structure • Synthesis takes the tree structure and translates the operations therein into the target program
Phases of Compiler • Lexical Analysis • Syntax Analysis • Semantic Analysis • Intermediate code generation • Code Optimization • Code Generator