Professional Documents
Culture Documents
Compiler Design Theory 1
Compiler Design Theory 1
Introduction to Compiling
Compilers
A compiler translates (or compiles) a program written in a high
level programming language that is suitable for human
programmers into an equivalent program in target (sometimes
machine) language that is required by computers
During this process, the compiler will also attempt to spot and
report obvious programmer mistakes
Source
Compiler Target
program
program
Error Warnings
messages
A Language Processing System
Advantage of using HLL
Role of recursion
The phases of the compiler
Source program
Lexical Analyzer
Syntax Analyzer
Code Optimizer
Code Generator
Target program
The phases of the compiler
Lexical Analyzer
:=
id1 +
id1:=id2+id3*60 id2 *
Syntax Analyzer
id3
inttoreal
Intermediate Code Generator
:= temp1:=inttoreal(60)
id1 + temp2:=id3*temp1
temp3:=id2+temp2
id2 * id1=temp3
id3 60
Code Optimizer
temp1:=id3*60.0
id1:=id2+temp1
Code Generator
MOVF id3,R2
MULF #60.0,R2
MOVF id2,R1
ADDF R2,R1
MOVF R1,id1
Why learn about compilers?
Preprocessors-Macro processor
File Inclusion
Rational Preprocessor
Language Extensions- Equel
Assemblers- Pass, Two pass assemblers..
Loaders- loading and link editing
Compiler Construction Tools
Literal
Value
Length
Relative/ Absolute
Terminal Table and Tokens