Welcome to CS251 Interpreter and Translators Theory of Programming - - PowerPoint PPT Presentation

welcome to cs251 interpreter and translators
SMART_READER_LITE
LIVE PREVIEW

Welcome to CS251 Interpreter and Translators Theory of Programming - - PowerPoint PPT Presentation

Introduction Interpretation and Translation Interpretation versus Translation Boot Strapping Welcome to CS251 Interpreter and Translators Theory of Programming Languages Computer Science Department Wellesley College Introduction


slide-1
SLIDE 1

Introduction Interpretation and Translation Interpretation versus Translation Boot Strapping

Welcome to CS251 Interpreter and Translators

Theory of Programming Languages Computer Science Department Wellesley College

slide-2
SLIDE 2

Introduction Interpretation and Translation Interpretation versus Translation Boot Strapping

Table of contents

Introduction Interpretation and Translation Interpretation versus Translation Boot Strapping

slide-3
SLIDE 3

Introduction Interpretation and Translation Interpretation versus Translation Boot Strapping

Analyzing programming languages

slide-4
SLIDE 4

Introduction Interpretation and Translation Interpretation versus Translation Boot Strapping

You control the horizontal

Life stages:

  • Applications user;
  • programmer;
  • language designer.
slide-5
SLIDE 5

Introduction Interpretation and Translation Interpretation versus Translation Boot Strapping

Under the hood

There are two fundamental approaches to programming language implementation:

  • 1. Interpreting one language (the source language) on top of

another (the implementation language);

  • 2. translating a program in one language (the source language)

into another programming language (the target language) via a translation program written in an implementation language.

slide-6
SLIDE 6

Introduction Interpretation and Translation Interpretation versus Translation Boot Strapping

Interpreters and compilers

There are two basic reasoning rules involving interpreters and translators (a.k.a. compilers):

  • 1. The Interpreter Rule (I)

P-in-L program; L interpreter machine (I) P machine

  • 2. The Translator Rule (T)

P-in-S program; S-to-T translator machine (T) P-in-T program

slide-7
SLIDE 7

Introduction Interpretation and Translation Interpretation versus Translation Boot Strapping

Displaying a web page

You are given:

  • 251 webpage in HTML (HTML program);
  • HTML-in-C web browser (HTML-to-display translator

machine);

  • C-to-Pentium translator (gcc);
  • Pentium-based computer (Pentium interpreter machine).

Using the rules given above, give a “proof” of how to display the 251 webpage

slide-8
SLIDE 8

Introduction Interpretation and Translation Interpretation versus Translation Boot Strapping

Displaying a webpage

251 webpage in HTML; HTML-in-C browser; C-to-Pentium translator (T) HTML-in-Pentium browser ; Pentium computer (I) HTML-browser machine (T) Display of 251 webpage

slide-9
SLIDE 9

Introduction Interpretation and Translation Interpretation versus Translation Boot Strapping

Translators can compose

introduction.tex

❄ L

AT

EX

introduction.dvi

❄ dvips

introduction.ps ; Postscript printer

(T)

print document

slide-10
SLIDE 10

Introduction Interpretation and Translation Interpretation versus Translation Boot Strapping

Alternatively

introduction.tex

❄ L

AT

EX

introduction.dvi

❄ dvips

introduction.ps

✲ ps2pdf

introduction.pdf ; Acrobat reader

(T)

display document

slide-11
SLIDE 11

Introduction Interpretation and Translation Interpretation versus Translation Boot Strapping

Pluses and minuses

INTERPRETATION:

  • On the fly;
  • incremental;
  • can be

inefficient.

slide-12
SLIDE 12

Introduction Interpretation and Translation Interpretation versus Translation Boot Strapping

Pluses and minuses

INTERPRETATION:

  • On the fly;
  • incremental;
  • can be

inefficient. TRANSLATION:

  • Entire

program seen in advance;

  • analysis →

efficient;

slide-13
SLIDE 13

Introduction Interpretation and Translation Interpretation versus Translation Boot Strapping

Pluses and minuses

INTERPRETATION:

  • On the fly;
  • incremental;
  • can be

inefficient. BYTE-CODE:

  • Combines

translation & interpreta- tion;

  • portable;
  • less efficient

than native code. TRANSLATION:

  • Entire

program seen in advance;

  • analysis →

efficient;

slide-14
SLIDE 14

Introduction Interpretation and Translation Interpretation versus Translation Boot Strapping

Metacircular Interpreters

Scheme-interpreter-in-Scheme; Scheme interpreter machine 1 (I) Scheme interpreter machine 2

slide-15
SLIDE 15

Introduction Interpretation and Translation Interpretation versus Translation Boot Strapping

Watch closely

C-to-Pentium-translator-in-C; C-to-Pentium-translator-in-Pentium-1; Pentium machine (I) C-to-Pentium-translator-1 (T) C-to-Pentium-translator-in-Pentium-2

slide-16
SLIDE 16

Introduction Interpretation and Translation Interpretation versus Translation Boot Strapping

Nothing up my sleeve

C-to-Pentium-translator-in-C; C-to-Pentium-translator-in-Pentium-1; Pentium machine (I) C-to-Pentium-translator-1 (T) C-to-Pentium-translator-in-Pentium-2 ; Pentium machine (I) C-to-Pentium-translator-2

slide-17
SLIDE 17

Introduction Interpretation and Translation Interpretation versus Translation Boot Strapping

Hocus Pocus

C-to-Pentium-trans-in-C; C-to-Pentium-trans-in-C; C-to-Pentium-trans-in-Pentium-1; Pentium machine (I) C-to-Pentium trans-1 (T) C-to-Pentium-translator-in-Pentium-2 ; Pentium machine (I) C-to-Pentium translator-2 (T) C-to-Pentium-in-Pentium translator-3