Tombstone Diagrams

8
1 Tombstone Diagrams M chine implemented in hardware S --> T L Translator implemented in L M L Language interpreter in L Program P implemented in L L P เเเเเเเเเเเเเเเเเเเเเเเเเเเเเ เเเเเเเเเเเเเเเเเเเเเเเเเเเ

description

Program P implemented in L. Translator implemented in L. S --> T. L. P. Machine implemented in hardware. Language interpreter in L. L. M. M L. Tombstone Diagrams. เอาไว้ใช้ในการอธิบายกระบวนการแปลภาษาให้เข้าใจได้ง่ายขึ้น. OK!. M. OK!. OK!. M. OK!. P. T. S --> T. S --> T. M. - PowerPoint PPT Presentation

Transcript of Tombstone Diagrams

Page 1: Tombstone Diagrams

1

Tombstone Diagrams

M

Machine implemented in hardware

S --> T

L

Translator implemented in L

ML

Language interpreter in L

Program P implemented in L

LP

เอาไว้�ใช้�ในการอธิ บายกระบว้นการแปลภาษาให้�เข้�าใจได้�ง่�ายข้��น

Page 2: Tombstone Diagrams

2

Tombstone diagrams: Combination rules

SP P

TS --> T

M

M

LP

S --> T

MWRONG!

OK!OK!

OK!MMP

OK!

M

LP

WRONG!

Page 3: Tombstone Diagrams

3

Tetrisx86C

Tetris

Compilation

x86

ตั�วอย่�าง คอมไพล!โปรแกรมภาษาซี$เพ%&อให้�ร'นบน CPU ตระก)ล X86 ได้�

C --> x86

x86x86

Tetris

x86

Page 4: Tombstone Diagrams

4

TetrisPPCC

Tetris

Cross compilation

x86

C --> PPC

x86

Cross compiler เป+นคอมไพเลอร!ที่$&ผล ต machine code ข้อง่ CPU ที่$&ไม�ใช้� ข้อง่เคร%&อง่ที่$&เป+น host

Host ≠ Target

PPCTetris

PPC

download

Page 5: Tombstone Diagrams

5

x86

Java-->x86

Compiling a Compiler

ตั�วอย่�าง: เข้$ยนคอมไพเลอร!เพ%&อแปลง่จาก Java ให้�เป+น X86 machine code โด้ยใช้�ภาษา C++

Java-->x86

C++

x86

C++-->x86

x86

Page 6: Tombstone Diagrams

6

Interpreters

Interpreter เป+นโปรแกรมที่$&ประมว้ลผลช้.ด้ค/าสั่'&ง่ จ/าลอง่การที่/าง่านข้อง่การ ประมว้ลช้.ด้ค/าสั่'&ง่โด้ย CPU ต'ว้อย�าง่ข้อง่ interpreter เช้�น Java Virtual

Machine (JVM)

JVMx86

x86

JVMTetris

Page 7: Tombstone Diagrams

7

Full Bootstrap

•เร &มต�นสั่ร�าง่คอมไพเลอร!อย�าง่ไร• สั่มม.ต ว้�าเราต�อง่การสั่ร�าง่ Ada compiler สั่/าห้ร'บ CPU M

• ใช้�กระบว้นการที่$&เร$ยกก'นว้�า bootstrapping

• เร &มสั่ร�าง่ compiler Ada แบบพ%�นฐานที่$&สั่.ด้โด้ยใช้� machine code M

• เข้$ยน optimized Ada compiler โด้ยใช้� Ada

• ใช้�คอมไพเลอร!พ%�นฐานที่$&อย)�ในร)ป machine code M คอมไพล!optimized Ada compiler

Page 8: Tombstone Diagrams

8

Bootstrapping

เร &มต�นจาก: Ada-->Mslow

Mslow

ต�อง่การเข้$ยนoptimized Ada compiler โด้ยใช้�Ada

Ada-->Mfast

Ada

Ada-->Mfast

Ada

M

Ada-->Mfast

Mslow

Step 1

Ada-->Mslow

Mslow

Step 2 Ada-->Mfast

Ada

M

Ada-->Mfast

MfastAda-->Mfast

Mslow

ได้�คอมไพเลอร!ที่$&คอมไพล!ได้�เร2ว้และ

ผล ด้ machine code ที่$&ร 'นได้�เร2ว้!