Professional Documents
Culture Documents
1.1 Introduction
1.1 Introduction
Outline
• Syllabus & Text books
• History of compilers
• Interpreters
• What are compilers?
• Types of compilers
• Properties of the compiler
• Parts of compilation
• Analysis of the source program
Syllabus
PRINCIPLES OF COMPILER DESIGN LTPMC
3 1 0 100 4
UNIT I INTRODUCTION TO COMPILERS 9+3
Compilers, Analysis of the Source Program, The Phases of a Compiler,
Cousins of the Compiler, The Grouping of Phases, Compiler-Construction
Tools, Translators-Compilation and Interpretation, A simple one-pass
compiler
John Backus,
team lead on
FORTRAN.
History of Compilers
• First complete compiler (1957) for
FORTRAN – John Backus
• Early compilers – Assembly language
• Self Hosting compiler
– LISP (1962)
– PASCAL / C
– Bootstrapping
Interpreter
• An interpreter reads the source code one instruction or
line at a time, converts this line into machine code and
executes it.
Disadvantages
• Examples of interpreters are BASIC, script interpreters
such as JavaScript, and languages such as Lisp.
Interpreter
Intermediate
code
Source Target
Compiler Program
Program
Error
Messages
Types of Compilers
• One pass
– Quick ; PASCAL
• Multi-pass
– Step by step
– High performance; slower; lesser memory
• Source to Source Compiler
Types of Compilers
• Stage Compiler
– Byte code compiler
• JIT Compiler
– Byte code is compiled to native machine code
prior to execution
• Decompiler
Types of Compilers
• Transcompilers / Cascaders
• Cross Compilers
– Embedded Systems
• Narrow Vs Broad Compilers
Properties of a good compiler
• Reliability
• Faithfulness
• Compilation Speed
• Diagnostics
• Error handling
• Implementation and Maintenance
• Good human interface
Properties of generated code
• Reliable
• Secure
• Faithful
• Small
• Fast
Parts of the compilation
• Analysis
• Synthesis
Lexical Analysis
Source Code
Syntax Analysis
Semantic Analysis
IR Generation
IR Optimization
Code Generation