bslox
This project follows Bob Nystrom's excellent book, Crafting Interpreters which takes you through the process of writing an interpreter for a language called Lox.
The book describes two implementations. The first in Java and is a tree-walking interpreter. I have already ported that version to Swift in my other project, slox. The final part of the book describes a bytecode interpreter in C. This is my Swift port of the bytecode interpreter.
The book is being released as chapters are completed, one chapter at a time.
Progress
As of Aug 18th, 2018, bslox is up to date with the released chapters of Part III, implementing the following chapters:
- Chunks of Bytecode.
- A Virtual Machine.
- Scanning on Demand.
- Compiling Expressions.
- Types of Values.
Goals & Design
As with my other port, I will sometimes deviate from the C implementation to take advantage of Swift's features and idioms. For example, instead of storing a constant's index inline with the bytecode, it's stored as an associated value. This may lead to less compact bytecode array. I will revisit this decision as we progress through other chapters.
License
MIT