Clox
An interpreter of the Lox scripting language, implemented in C
Install / Use
/learn @zlliang/CloxREADME
CLox
An interpreter of the Lox scripting language, implemented in C.
Lox is a tiny scripting language described in Bob Nystrom's book Crafting Interpreters. I've already written an tree-walk interpreter using TypeScript, called TSLox. This C version is a bytecode virtual machine, developed along with reading Part III of the book.
Usage
First build this project. Here we use CMake:
$ mkdir build && cd build # Create a CMake workspace
$ cmake .. && make
$ ./clox # Start CLox
Invoking clox without parameter starts the REPL. To run Lox source files, please specify the file path. Feel free to run examples in the examples directory:
$ ./clox ../examples/hello-world.lox
Hello, world!
What's Next
By the end of 2021, I complete reading Crafting Interpreters and implement two interpreters of the Lox scripting language, in TypeScript and C respectively. I get some knowledge about creating programming languages, and it feels great! Next I may play with some toy languages, learn more optimization tricks and investigate different language features. Hope I can make some "real" production one day. ;)
Resources
- Book: Crafting Interpreters
- Blog post: Crafting "Crafting Interpreters"
- Wiki: Lox implementations
Related Skills
node-connect
339.5kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
83.9kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
339.5kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
commit-push-pr
83.9kCommit, push, and open a PR
