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 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 HTML-in-C browser ; C-to-Pentium translator ( T ) HTML-in-Pentium browser ; Pentium computer ( I ) 251 webpage in HTML ; HTML-browser machine ( T ) Display of 251 webpage
Introduction Interpretation and Translation Interpretation versus Translation Boot Strapping Translators can compose introduction.tex ❄ L A T EX introduction.dvi ❄ dvips introduction.ps ; Postscript printer (T) print document
Introduction Interpretation and Translation Interpretation versus Translation Boot Strapping Alternatively introduction.tex ❄ L A T EX introduction.dvi ❄ dvips ps2pdf introduction.ps 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: TRANSLATION: • Entire • On the fly; program seen in advance; • incremental; • analysis → • can be efficient; inefficient.
Introduction Interpretation and Translation Interpretation versus Translation Boot Strapping Pluses and minuses INTERPRETATION: BYTE-CODE: TRANSLATION: • Combines • Entire • On the fly; translation & program seen interpreta- in advance; • incremental; tion; • analysis → • can be • portable; efficient; inefficient. • less efficient than native code.
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-Pentium-1 ; Pentium machine ( I ) C-to-Pentium-translator-in-C ; 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-Pentium-1 ; Pentium machine ( I ) C-to-Pentium-translator-in-C ; 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-Pentium-1 ; Pentium machine ( I ) C-to-Pentium-trans-in-C ; C-to-Pentium trans-1 ( T ) C-to-Pentium-translator-in-Pentium-2 ; Pentium machine ( I ) C-to-Pentium-trans-in-C ; C-to-Pentium translator-2 ( T ) C-to-Pentium-in-Pentium translator-3
Recommend
More recommend