Introduction Interpretation and Translation Interpretation versus Translation Boot Strapping
Welcome to CS251 Interpreter and Translators Theory of Programming - - PowerPoint PPT Presentation
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
Introduction Interpretation and Translation Interpretation versus Translation Boot Strapping
Table of contents
Introduction Interpretation and Translation Interpretation versus Translation Boot Strapping
Introduction Interpretation and Translation Interpretation versus Translation Boot Strapping
Analyzing programming languages
Introduction Interpretation and Translation Interpretation versus Translation Boot Strapping
You control the horizontal
Life stages:
- Applications user;
- programmer;
- language designer.
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.
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
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
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
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
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
Introduction Interpretation and Translation Interpretation versus Translation Boot Strapping
Pluses and minuses
INTERPRETATION:
- On the fly;
- incremental;
- can be
inefficient.
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;
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;
Introduction Interpretation and Translation Interpretation versus Translation Boot Strapping
Metacircular Interpreters
Scheme-interpreter-in-Scheme; Scheme interpreter machine 1 (I) Scheme interpreter machine 2
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
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
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