A Lisp interpreter in 170 lines of Perl code

A few years ago, I was on a train from Eindhoven to Utrecht; this should have been a ride of less than an hour, but thanks to various mishaps (”ladies and gentlemen, it turns out that the replacement engine is also broken, so we’ll be here a little longer”), it took me almost five hours to get home that day.

Fortunately I had my laptop with me, so to while away the time I wrote a very simple Lisp interpreter in Perl. Recently, while looking through some old back-ups, I came across it again.

Here it is: the interpreter and a test file. To run the test program, execute:
perl minilisp.pl test.l

Needless to say, this is a toy. If, for any reason, you need a real Lisp interpreter in Perl, check out perl-lisp on CPAN, by Gisle Aas.

One Response to “A Lisp interpreter in 170 lines of Perl code”

  1. Frank de Groot Says:

    Hmm, sounds familiar. I remember you sending me the interpreter after I told you I wrote a LISP-like language interpreter in VBScript (yes, a man does desperate things when bored!).

    Worst thing was, after I finished the atom tokenizer I read about VBScript’s Regex. Hmm, that would have made it easier :-(.

Leave a Reply