Introduction Supplement Cross compiler History Chapter 1 2301373

  • Slides: 11
Download presentation
Introduction Supplement: Cross compiler, History Chapter 1 2301373: Introduction 1

Introduction Supplement: Cross compiler, History Chapter 1 2301373: Introduction 1

Cross Compiler • a compiler which generates target code for a different machine from

Cross Compiler • 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 S T H • Cross compilers are used very often in practice. Chapter 1 2301373: Introduction 2

Cross Compilers (cont’d( • If we want a compiler from language A to language

Cross Compilers (cont’d( • If we want a compiler from language A to language B on a machine with language E, – write one with E – write one with D if you have a compiler from D to E on some machine A E A Chapter 1 2301373: Introduction B D D E ? • It is better than the former approach if D is a high-level language but E is a machine language – write one from G to B with E if we A have a compiler from A to G written in E B G G E B E 3

Porting • Porting: construct a compiler between a source and a target language using

Porting • Porting: construct a compiler between a source and a target language using one host language from another host language A K A A A H K A A H A K H A H Chapter 1 K K K 2301373: Introduction 4

Bootstrapping • If we have to implement, from scratch, a compiler from a highlevel

Bootstrapping • If we have to implement, from scratch, a compiler from a highlevel language A to a machine, which is also a host, language, – direct method – bootstrapping A A H H H A 1 H A 2 H A 3 H H Chapter 1 2301373: Introduction 5

Cousins of Compilers • • Linkers Loaders Interpreters Assemblers Chapter 1 2301373: Introduction 6

Cousins of Compilers • • Linkers Loaders Interpreters Assemblers Chapter 1 2301373: Introduction 6

History (1930’s -40’s( • 1930’s – John von Neumann invented the concept of stored-program

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 • Z 1 -4 (by Zuse) in Germany • ENIAC (programmed by a plug board) Chapter 1 2301373: Introduction 7

History : 1950 • Many electronic, stored-program computers were designed. 0 A 1 F

History : 1950 • Many electronic, stored-program computers were designed. 0 A 1 F 83 90 4 B – EDVAC (by von Neumann) op code, address, . . – ACE (by Turing) • Programs were written in machine languages. • Later, programs are written in assembly languages LDI B, 4 instead. C, 3 code and memory – Assemblers translate. LDI symbolic address to machine LDI code. A, 0 • • ST: ADI A, C John Backus developed (no recursive DEC FORTRAN B call) and FORTRANJNZ compiler. B, ST STO structure 0 XF 0, A of languages Noam Chomsky studied and classified them into classes called Chomsky hierarchy. Grammar Chapter 1 2301373: Introduction 8

History (1960’s( • Recursive-descent parsing was introduced. • Nuar designed Algol 60, Pascal’s ancestor,

History (1960’s( • Recursive-descent parsing was introduced. • Nuar designed Algol 60, Pascal’s ancestor, which allows recursive call. • Backus-Nuar form (BNF) was used to described Algol 60. • LL(1) parsing was proposed by Lewis and Stearns. • General LR parsing was invented by Knuth. • SLR parsing was developed by De. Remer. Chapter 1 2301373: Introduction 9

History (1970’s( • LALR was develpoed by De. Remer. • Aho and Ullman founded

History (1970’s( • LALR was develpoed by De. Remer. • Aho and Ullman founded theory of LR parsing techniques. • Yacc (Yet Another Compiler) was developed by Johnson. • Type inference was studied by Milner. Chapter 1 2301373: Introduction 10

Reading Assignment • Louden, K. C. , Compiler Construction: Principles and Practice, PWS Publishing,

Reading Assignment • Louden, K. C. , Compiler Construction: Principles and Practice, PWS Publishing, 1997. ->Chapter 1 2301373: Introduction 11