Skip to content
/ zisp Public

Toy Lisp Interpreter in ~700 Lines of Zig implemented in a single file.

Notifications You must be signed in to change notification settings

wagiejack/zisp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 

Repository files navigation

🚨Disclamer

This is a toy version of the lisp interpreter implemented by "fuck around and find out" with claude,

discussing the approach and implementing it,

I don't expect all the complex features to work nor the code to be optimal like a actual interpreter built by someone who knows this stuff,

this was made for fun as a side project but I'll try to rewrite it when I am more knowledgable about this.

Zisp - A Toy Lisp Interpreter in Zig

Zisp is a minimalistic Lisp interpreter crafted with Zig.

This project was started because after reaching 58/109 exercises in ziglings, I got overwhelmed with the theory part,

too.much.theowy.hurts.my.brain.and.gets.me.tweaking.mp4

But after beginning to lose interest I remembered that i was the top guy and cannot give up like this,

I.m.the.top.guy.mp4

Having a low attention span and not having read ~10 pages of something in one sitting in past 8 years, im as good as a illiterate,

educational videos too bore me.

So I decided to rawdog Claude with a series of "fuck around and find out" and started to build this,

Since I'm getting results so I'll keep cooking

cooking

Project Pipeline

Tokenizer -> Abstract Syntax Tree -> Parser -> Evaluator -> REPL Environment
   ✔️               ✔️                   ✔️           ✔️               ✔️ 

🚨Zisp Highlights

zesty-sonic-zesty

  • AST: Hierarchical structure for Lisp expressions, with support for special forms.
  • Evaluator: Implements key Lisp functions (define, lambda, if, etc.) with arithmetic and comparison operations.
  • Environment: Manages variable scope with nested support.
  • REPL: Interactive, multi-line capable, with immediate result display and simple exit commands.

🤫 POF(Proof of functionality)

image

zisp>(+ (* 2 3) (- 10 5))  
Result: -9

zisp>(define x 5)    
Result: 5

zisp>(define square (lambda (n) (* n n)))
Result: <lambda with 1 params>

zisp>(if (> 10 5) (* 2 3) (+ 1 1))
Result: 6

zisp>(begin (define y 10) (* y 2))  
Result: 20

🚧 Pending Features

image
Feature Description Status Implementation Details
Strings Support for string literals in the Lisp code, allowing text manipulation Not yet implemented
Comments Support for semicolon-style comments, essential for code documentation Not yet implemented
Float Numbers Support for decimal point numbers to enable non-integer arithmetic Not yet implemented
Scientific Notation Support for exponential format numbers (e.g., 1e10) for very large or small values Not yet implemented
Error Reporting Line and column tracking for precise error location identification Not yet implemented
Symbol Validation Enforcing symbol naming conventions in the Lisp code ✔️ Implemented through tokenizer logic and AST node typing
Reserved Keywords Special handling of Lisp-specific keywords like define, lambda, if ✔️ Fully implemented with special form handling in AST construction
Character Literals Support for single character values Not yet implemented
Escape Sequences Support for special characters in strings and other literals Not yet implemented
Alternative Bases Support for binary, octal, and hexadecimal number representations Not yet implemented
Buffer Management Dynamic sizing of input buffers for handling varying input lengths Not yet implemented
Error Recovery Graceful handling and recovery from malformed input Not yet implemented

🏗️ Build and Run

image

To run Zisp, simply use:

zig run main.zig

About

Toy Lisp Interpreter in ~700 Lines of Zig implemented in a single file.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages