<p>For the "intermediate code" version of an interpreter there is no finer example in a small book than <a href="https://www.abebooks.com/book-search/isbn/0130830984/" rel="nofollow noreferrer">On Pascal Compilers</a> by Per Branch Hansen. You need to be able (or a least willing) to read Pascal of course. </p>

<p>This book is a rare instance of CS Literature. Hansen is one of the masters. </p>

<p>The way the code in the book is developed you actually see the difference between compiling and interpreting as he does "code generation" to an intermediate language and then provides a separate interpreter for that language. So you see what you need to do to get to the point at which interpretation is efficient and then see how the interpreter part actually works. </p>

<hr>

<p>The book is out of print. Check around for a used copy. <a href="https://rads.stackoverflow.com/amzn/click/0130830984" rel="nofollow noreferrer">Amazon</a> currently has it a bit cheaper than Abe Books. If you have a good University Library nearby they may have it. You might also be able to get a copy from interlibrary loan that is supported by most libraries. </p>

CC BY-SA 3.0
2017-09-21T21:18:11.670Z
2017-09-22T12:15:35.237Z
2017-09-22T12:15:35.237Z
Buffy
<p>Can anyone recommend a good textbook for writing interpreters (not compilers) that <strong>don't</strong> use languages like Scheme or Haskell? </p>

CC BY-SA 3.0
2017-09-21T20:52:34.120Z
Since the difference between a compiler and an interpreter is actually very small, most good compiler books will give you the basis. The difference is only in the back end where an execution engine replaces the code generator. The front and middle sections are the same: scanning, parsing, semantic analysis, maybe some optimization. It may even create intermediate code and work from that. Otherwise from the parse tree usually.
Buffy
CC BY-SA 3.0
2017-09-21T21:21:20.023Z
And welcome to CSEducators.
Buffy
CC BY-SA 3.0
2017-09-21T21:56:13.993Z
Can you give some more context about the age of the students, the previous experience, the environment, etc? Also, welcome!
thesecretmaster
<resource-request><textbook>
Is there a good textbook for writing an interpreter in an imperative language?
# Is there a good textbook for writing an interpreter in an imperative language?

(Asked by: username_0 on 2017-09-21)

Can anyone recommend a good textbook for writing interpreters (not compilers) that **don't** use languages like Scheme or Haskell?

**Tags:** resource-request, textbook

> **Comments:**
> **username_1**: Since the difference between a compiler and an interpreter is actually very small, most good compiler books will give you the basis. The difference is only in the back end where an execution engine replaces the code generator. The front and middle sections are the same: scanning, parsing, semantic analysis, maybe some optimization. It may even create intermediate code and work from that. Otherwise from the parse tree usually.  
> **username_1**: And welcome to CSEducators.  
> **username_2**: Can you give some more context about the age of the students, the previous experience, the environment, etc? Also, welcome!  

---

## 1 answers

### Answer by username_1 on 2017-09-21. Score: 0

For the "intermediate code" version of an interpreter there is no finer example in a small book than [On Pascal Compilers](https://www.abebooks.com/book-search/isbn/0130830984/) by Per Branch Hansen. You need to be able (or a least willing) to read Pascal of course.

This book is a rare instance of CS Literature. Hansen is one of the masters.

The way the code in the book is developed you actually see the difference between compiling and interpreting as he does "code generation" to an intermediate language and then provides a separate interpreter for that language. So you see what you need to do to get to the point at which interpretation is efficient and then see how the interpreter part actually works.

---

The book is out of print. Check around for a used copy. [Amazon](https://rads.stackoverflow.com/amzn/click/0130830984) currently has it a bit cheaper than Abe Books. If you have a good University Library nearby they may have it. You might also be able to get a copy from interlibrary loan that is supported by most libraries.


---

