







Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!








BBy :
OO utlinetli
4.4. ConclusionConclusion
The Translation Process/
Phases of a Compiler
Program writtenwritten Assembly in a Programming
Assembly Language Translation
Compiler g g Languages
15 15--OctOct--10 10 Sufi Tabassum GulSufi Tabassum Gul 33
PhPh ases of a Compilerf C il
Program (character stream) Lexical Analyzer (Scanner) Token Stream
Lexical Analyzer (Scanner) Token Stream
g ( )
SS yntax Analyzer (Parser)t A l (P )
15 15--OctOct--10 10 Sufi Tabassum GulSufi Tabassum Gul 77
SS yntax Analyzer (Parser)t A l (P )
int * foo(i, j, k)) int i; int j; (^) Extra parentheses { for(i=0; i j) {
Extra parentheses
fi(i>j) return j;
Missing Not an expressionincrement }
Not an expressionincrement Not a keyword
PhPh ases of a Compilerf C il
Program (character stream) Lexical Analyzer (Scanner) Token Stream
Program (character stream)
Syntax Analyzer (Parser)
Token Stream
Parse TreeParse Tree Semantic Analyzer
Parse Tree Semantic Analyzer
Parse Tree
Intermediate Representation/te ed ate ep ese tat o / Annotated Tree
15 15--OctOct--10 10 Sufi Tabassum GulSufi Tabassum Gul 99
SS emantic Analyzerti A l
intint ** foo(ifoo(i , j, k)j k) int i; int j;int j; Type not declared { int
Type not declared
int x; x = x + j + N; t j
Mismatched return type
return j; U i iti li d i bl }
Uninitialized variable used Undeclared variable
Lexical Analyzer (Scanner)
Program (character stream) Lexical Analyzer (Scanner)
Syntax Analyzer (Parser)
Token Stream
Semantic Analyzer
Syntax Analyzer (Parser) Parse Tree
Code Optimizer
Semantic Analyzer Intermediate Representation Code Optimizer Optimized Intermediate Representation Code Generator Assembly codeAssembly code Target Code Optimizer
Code Generator
15 15--OctOct--10 10 Sufi Tabassum GulSufi Tabassum Gul 1313
Target Code Optimizer
CC ousins of Compileri f C il
15 15--OctOct--10 10 Sufi Tabassum GulSufi Tabassum Gul 1515
II nterpreterst t
An interpreter is a language translator like a compiler.compiler.
It differs from the compiler in that it executes the source program immediately rather than generatingsource program immediately rather than generating object code that is executed after translation is complete.complete.
BASIC is a language that is more usually interpreted than compiled.interpreted than compiled.
If speed of execution is of primary concern then compiler is to be preferred compiler is to be preferred.
LL oadersd
Most often a compiler, assembler or linker will
produce code that is
The purpose of loader is to resolve all
relocatable addresses relative to the given basel l l or starting address.g
The use of the loader makes executable code more
15 15--OctOct--10 10 Sufi Tabassum GulSufi Tabassum Gul 1919
flexible.
PPreprocessors
A preprocessor is a separate program that is called
by the compiler before actual translation begins.
SuchSuch preprocessorspreprocessors cancan deletedelete
EditEditors
Compiler usually accept source programs written
using any editors that will produce a standard file, such as an ASCII filesuch as an ASCII file.
Today's compilers come with editors and other
programs as IDE
Structure based editorsStructure based editors
15 15--OctOct--10 10 SufiSufi TabassumTabassum GulGul 2121
D bDebuggers
A debugger is a program that can be used to
determine execution errors in a compiled program
Bundled with IDEBundled with IDE
Step by Step execution
Can halt execution at prescribed locations called
bbreakpoints k i t
CC onclusionl i