Janet implementation of Lox from the book Crafting Interpreters
Janet 90.0%
Nix 9.1%
Other 0.8%
20 1 0

Clone this repository

https://tangled.org/pvsr.dev/janet-lox
git@tangled.org:pvsr.dev/janet-lox

For self-hosted knots, clone URLs may differ based on your setup.

readme.md

This is a Janet implementation of the Lox programming language, from Crafting Interpreters by Robert Nystrom. It's loosely based on jlox, the Java tree-walking interpreter from the book, but takes advantage of Janet features to simplify the code when possible.

Notably:

  • The scanner is a parsing expression grammar
  • Scoping is built on top of dynamic bindings
  • The repl uses Janet's getline, which wraps linenoise
  • While Janet has support for object-oriented programming, most of the code is written in a more functional style. For instance the visitor pattern is replaced by pattern matching

Progress#

  • Scanning
  • Representing Code
  • Parsing Expressions
  • Evaluating Expressions
  • Statements and State
  • Control Flow
  • Functions
  • Resolving and Binding
    • Lexical scope
    • Prevent self-referential initializer
    • Prevent variable name reuse in same scope
    • Prevent top-level return
  • Classes
  • Inheritance