Skip to content

Small Lisp interpreter, written as a first project in OCaml

Notifications You must be signed in to change notification settings

qmaurmann/Ocamalambda

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

Ocamalambda

Interpreter (with parser) for toy language "Little Lambda" defined in blog post "What is a programming language?", written as a first exercise in OCaml.

Little Lambda is a small Lisp-like language; a program consists of a single expression, i.e. one of the forms

<expression> ::= <integer>
               | <symbol>
               | (+ <expression> <expression>)
               | ( * <expression> <expression>)
               | (if0 <expression> <expression> <expression>)
               | (lambda (<symbol>) <expression>)
               | (<expression> <expression>)

Evaluate an expression by applying the function run to it (as a string).

The corresponding Lisp code weighs in under 20 lines, but the comparison isn't totally fair because parsing is totally free in Lisp (via the builtin quote), whereas parsing is actually the trickiest step in any other language.

TODO:

  • Switch to bignums to prevent silent integer overflow

  • Expand to the larger, impure language of the Proglang repository

  • Add a REPL?

About

Small Lisp interpreter, written as a first project in OCaml

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages