Compiler tutorial on Swish

At https://swish.swi-prolog.org/p/Compiler1.swinb I’ve put up an implementation of the compiler example in Chapter 24 of The Art of Prolog

It’s the same code I previously posted on the thread https://swi-prolog.discourse.group/t/a-tokeniser-ive-written-any-suggestions-on-how-to-improve-it/367, but thought it best to save it on Swish before I lose it, and is also handier for anyone who wants to play with it.

I’m thinking of working through a Lisp textbook on compilers which is freely online at http://cs.brown.edu/courses/cs173/2012/book/, doing a Prolog version along with the Lisp covered in the book.

Does anyone know if that book is any good, or if there are better suggestions?

1 Like

That depends upon what your goal is?

If you define a compiler as a program to converts syntax into executable code then the dragon book is the standard. “Compilers: Principles, Techniques, and Tools” (WorldCat)

If you goal is to understand programming language design, then I don’t know any one book, but for learning about functional languages and types it is hard to beat the Brick book. “Types and programming languages” (WorldCat) This will touch on Hindley–Milner type system which uses inferencing to decide types; wonder where I heard the word inferencing before? (That’s a rhetorical question).

Another classic book is “Structure and Interpretation of Computer Programs

1 Like

Shriram Krishnamurthi is a well-known researcher in programming languages and also very interested in teaching pedagogy. See also: https://www.pyret.org/
If you contact him (Twitter, Facebook, email), there’s a good chance he’d give you his opinion of your project.

This might also interest you: https://medium.com/@gvanrossum_83706/peg-parsers-7ed72462f97c

1 Like

The more I look at some of the code examples in the book you noted, the more I think you might want to switch to using LogTalk (I have never used LogTalk but keep it in mind often). Paulo hangs out here.

Many thanks to and peter.ludemann for the interesting pointers. Enough reading to keep me busy for quiet a while.