This is a minimal Lisp interpreter/compiler written in Zig.
It supports basic arithmetic expressions and demonstrates the core steps of interpreting a Lisp-like language: tokenization, parsing, and evaluation.
- Fully working tokenizer, parser, and evaluator
- Supports:
- Nested expressions
- Arithmetic operations:
+
,-
,*
,/
,%
- Basic error handling:
- Unbalanced parentheses
- Extra tokens
- Division/modulo by zero
- Invalid operators or operands
.
├── main.zig # Entry point with REPL-style loop
├── tokeniser.zig # Tokenizes raw Lisp code into token list
├── parser.zig # Parses token list into AST
├── evaluator.zig # Evaluates AST and computes result
├── ast.zig # AST type definitions
├── .gitignore
└── README.md
Prerequisites :
-
Make sure you have Zig installed. Tested with
0.11.0+
-
If not get it from Zig
-
Clone or Download the Project
git clone https://github.com/shreyas-omkar/Lisp-Compiler cd Lisp-Compiler
-
Run the Interpreter
zig run main.zig
-
Try Lisp Expressions
list> ( + 1 2 ) 3 list> ( * 2 ( + 3 4 ) ) 14
-
To Exit
list> exit
- Core interpreter with basic math
- Tokenizer, Parser, AST Builder, Evaluator
- Interactive REPL
define
(variables)lambda
functionsif
conditionals- Scoping & environments
- Low-level control + high performance
- Simple, C-like syntax
- Excellent for learning how compilers/interpreters work
- Fast, safe, and minimal — perfect for building from scratch
Shreyas Hegde (aka Shaggy)
Built for fun, learning, and eventual world domination.
Feel free to fork, star, or contribute!