Lox Tree-Walk Interpreter in C++

Intro

The Lox Language

Lox is a language designed by Bob Nystrom for his book Crafting Interpreters. It is a dynamically-typed language that has many features of high-level languages, such as classes, inheritance, and automatic memory management. The Tree-Walk Interpreter was originally written in java (nicknamed jlox) in Nystrom's book.

Tree-Walk Interpreters

Tree-Walk interpreters execute instructions by directly walking the Abstract Syntax Tree (AST). While this approach works and simple to implement and understand, it tends to get painfully slow for larger, real-world programs. This is due to the overhead of tree traversal.

Goal

The goal was to get a better understanding of how code was actually run on a machine. To learn how we specifically go from a high-level language like C++ that is human-readable to machine code. I also wanted to learn the basics of Compiler/Interpreter implementation.

Credit

The largest, and only, credit is due to Bob Nystrom for writing his book.

Future Work



Source Code

Source code may be found here.