1 Introduction Supplement Cross compiler History Chapter 1 2301373 Introduction 2 a compiler which generates target code for a different machine from one on which the compiler runs A host language is a language in which the compiler is written ID: 794462
Download The PPT/PDF document "Chapter 1 2301373: Introduction" is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.
Slide1
Chapter 1
2301373: Introduction
1
Introduction
Supplement: Cross compiler, History
Slide2Chapter 1
2301373: Introduction
2
a compiler which generates target code for a different machine from one on which the compiler runs. A host language is a language in which the compiler is written.
T-diagram
Cross compilers are used very often in practice.
Cross Compiler
S
H
T
Slide3Chapter 1
2301373: Introduction
3
Cross Compilers (cont’d)
If we want a compiler from language
A
to language
B
on a machine with language
E,
write one with Ewrite one with
D if you have a compiler from D to E on some machineIt is better than the former approach if D is a high-level language but E is a machine languagewrite one from G to B with E if we have a compiler from A to G written in E
A
E
B
D
?
E
A
D
B
G
E
B
A
E
G
Slide4Chapter 1
2301373: Introduction
4
Porting
Porting: construct a compiler between a source and a target language using one host language from another host language
A
A
K
A
H
H
A
H
K
A
A
K
A
H
K
A
K
K
Slide5Chapter 1
2301373: Introduction
5
Bootstrapping
If we have to implement, from scratch, a compiler from a high-level language A to a machine, which is also a host, language,
direct method
bootstrapping
A
H
H
A
A
1
H
A
1
A
2
H
A
2
A
3
H
A
3
H
H
Slide6Chapter 1
2301373: Introduction
6
Cousins of Compilers
Linkers
Loaders
Interpreters
Assemblers
Slide7Chapter 1
2301373: Introduction
7
History (1930’s -40’s)
1930’s
John von Neumann invented the concept of stored-program computer.
Alan Turing defined Turing machine and computability.
1940’s
Many electro-mechanic, stored-program computers were constructed.
ABC (Atanasoff Berry Computer) at Iowa
Z1-4 (by Zuse) in Germany ENIAC (programmed by a plug board)
Slide8Chapter 1
2301373: Introduction
8
History : 1950
Many electronic, stored-program computers were designed.
EDVAC (by von Neumann)
ACE (by Turing)
Programs were written in machine languages.
Later, programs are written in assembly languages instead.
Assemblers translate symbolic code and memory address to machine code.
John Backus developed FORTRAN (no recursive call) and FORTRAN compiler.
Noam Chomsky studied structure of languages and classified them into classes called Chomsky hierarchy.
0A 1F 83 90 4Bop code, address,..
LDI B, 4 LDI C, 3 LDI A, 0ST: ADI A, C DEC B JNZ B, ST STO 0XF0, A
Grammar
Slide9Chapter 1
2301373: Introduction
9
History (1960’s)
Recursive-descent parsing was introduced.
Nuar designed Algol60, Pascal’s ancestor, which allows recursive call.
Backus-Nuar form (BNF) was used to described Algol60.
LL(1) parsing was proposed by Lewis and Stearns.
General LR parsing was invented by Knuth.
SLR parsing was developed by DeRemer.
Slide10Chapter 1
2301373: Introduction
10
History (1970’s)
LALR was develpoed by DeRemer.
Aho and Ullman founded the theory of LR parsing techniques.
Yacc (Yet Another Compiler Compiler) was developed by Johnson.
Type inference was studied by Milner.
Slide11Chapter 1
2301373: Introduction
11
Reading Assignment
Louden, K.C., Compiler Construction: Principles and Practice, PWS Publishing, 1997. ->Chapter 1