Skip to content

0xcacti/shrew

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Shrew

A very mini lisp interpreter in C.

I'm learning C, and a friend told me it's always good to build a lisp in a new language you are learning, so I took that advice to heart.
I wanted to build it entirely without the help of internet or AI, but it turns out I don't know how to build a lisp interpreter as well as I thought I did in the beginning, so I needed to do a fair bit of research. Nonetheless, it was an extremely useful project for me to learn about good ways to manually manage memory.

All that said, it's done. The language is fully implemented with a lexer, parser, and evaluator. It supports closures, macros, a boatload of builtins, several special forms, and garbage collection.

Below is my list of todos. Maybe it will give a sense of everything involved in building the project.

TODO

  • Implement token
  • Implement lexer
  • Implement parser
    • Implement parsing of atoms
    • Implement parsing of lists
  • Implement hashtable
  • Implement evaluator
    • Implement symbol interning
    • Implement lvals
    • Implement env
    • Implement atom evaluation
    • Implement list evaluation
    • Implement user defined functions
    • Implement closures
    • Implement evaluate multiple expressions
    • Implement special forms
      • define
      • set
      • lambda
      • quote family
        • quote
        • quasiquote
        • unquote
        • unquote-splicing
      • if
      • cond
      • begin
      • defmacro
    • Implement builtins
      • Arithmetic
        • +
        • -
        • *
        • /
        • mod
        • abs
        • min
        • max
        • floor
        • ceil
        • round
        • trunc
        • sqrt
        • exp
        • log
      • Comparison and equality
        • =
        • <
        • <=
        • >
        • >=
        • eq? (identity)
        • equal? (deep)
      • Booleans
        • not
        • and
        • or
      • Lists / pairs
        • cons
        • car
        • cdr
        • list
        • length
        • append
        • reverse
      • Type predicates
        • atom?
        • list?
        • null?
        • number?
        • symbol?
        • string?
        • list?
        • pair?
        • function?
      • Strings utils
        • string-length
        • string-append
      • Casting
        • number->string
        • string->number
        • number->string
        • symbol->string
        • string->symbol
      • Functional
        • apply
        • map
        • reduce
        • foldl
        • foldr
        • filter
        • gensym
        • error
        • eval
        • load
      • I/O
        • print
        • newline
  • Implement garbage collector
  • Implement CLI tool
    • Repl
    • File execution

About

Building a Lisp Interpreter in C

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published