Final Compiler
Final Compiler
compiler
interpreter
preprocessor
Assembler
Linker
puts together all executable object files into memory for execution
loader
• we've thought of a compiler as a single box that maps a
source program into a semantically equivalent target program.
• If we open this box, we can see that this mapping is divided
into two parts: analysis and synthesis.
Analysis part
Analysis part
synthesis part
symbol table
reads the stream of characters making up the source program and
groups the characters into meaningful sequences called lexemes
lexical analyzer
token-name
attribute-value
syntax tree
uses the syntax tree and the symbol table to check the source
program for semantic consistency with the language definition.
semantic analyzer
semantic analyzer
machine-independent code-optimization
code optimizer
code generator
• crucial aspect of code generation is the judicious assignment of
registers to hold variables.
symbol table
Parser generators
Scanner generators
Syntax-directed
produce a code generator from a collection of rules for translating
each operation of the intermediate language into the machine
language for a target machine.
Code-generator generators
Data-flow analysis
Compiler-construction
• macro instructions were added to assembly languages so that a
programmer could define parameterized shorthands for
frequently used sequences of machine instructions.
First-generation
assembly languages.
Second-generation
Third-generation
Fourth-generation
Fifth-generation
imperative
Declarative
Languages such as C, C++, C#, and Java are.
imperative languages.
declarative languages
object-oriented language
Scripting languages
Awk, JavaScript, Perl, PHP, Python, Ruby, and Tel are popular
examples of
scripting languages
.
• Compiler writing is challenging.
o A compiler by itself is a large program.
o Moreover, many modern language-processing systems
handle several source languages and target machines
within the same framework; that is, they serve as
collections of compilers, possibly consisting of millions
of lines of code.
o Consequently, good software-engineering techniques
are essential for creating and evolving modern
language processors.
context-free grammars
trees
optimization
• the optimization of code that a compiler performs has become
both more important and more complex.
• It is more complex because processor architectures have
become more complex, yielding more opportunities to improve
the way code executes.
• It is more important because massively parallel computers
require substantial optimization, or their performance suffers
by orders of magnitude.
• Compiler optimizations must meet the following design
objectives:
o must be correct
o improve the performance
o compilation time must be kept reasonable
o engineering effort required must be manageable.
• we must keep the system simple to assure that the engineering
and maintenance costs of the compiler are manageable.
• Applications of Compiler : Implementation, Optimizations for
Computer Architectures, Design of New Computer
Architectures, Program Translations, Code optimization,
Debugging
Implementation
provide efficient and accurate translations of high-level code into
machine code.
Implementation
Program Translations
Program Translations
Debugging
Code optimization