Principles of Compiler Design Unit – I ➢ Analysis of the Source Program, Phases of a Compiler, ➢ Compiler Construction Tools, Lexical Analysis Unit – II ➢ Parser, Grammar, Context-Free Grammar, Top-Down Parsing, Bottom-Up Parsing Unit – III ➢ Intermediate Languages Unit – IV ➢ Code Generation Unit – V ➢ Code Optimization and Run-Time Environments Reference Book: ➢ Alfred Aho, Ravi Sethi, Jeffrey D Ullman, “Compilers Principles, Techniques and Tools”, Pearson Education, India, 2/e.
Unit – I ➢Compilers ▪ Analysis of the Source Program ▪ Phases of a Compiler ▪ Cousins of the Compiler ▪ Grouping of Phases ▪ Compiler Construction Tools ➢Lexical Analysis ▪ Role of Lexical Analyzer ▪ Input Buffering ▪ Specification of Tokens
Introduction ▪ Why we need to learn it? ➢ May never write a full compiler ➢ But the techniques we learn is useful in many tasks ✓ Write interpreters for a scripting language ✓ Validating forms and so on… ▪ Compiler ➢ A program that translates source code into object code ➢ The total programming code is compiled at once and all the errors are displayed. ▪ Interpreter ➢ It goes on compiling only one line every time. ➢ If any error is encountered in any line, the control stops and displays the error. ➢ Once the error is rectified and compiled again, it moves to the next line and so on.
Introduction ▪ Disciplines involved ➢ ➢ ➢ ➢ Algorithms (Design and Analysis of Algorithms) Languages and Machines (Automata Theory). Operating Systems Computer Architecture and Organization ▪ Abstract View of Compiler Source code Compiler Machine code errors ➢ ➢ ➢ ➢ Recognizes legal (and illegal) programs statements Generate correct code Manage storage of all variables and code Agreement on format for object (or assembly) code