sLox
A Lox interpreter written in Scala, exploring how source code becomes a running program.
- Scala
- sbt
From source text to execution
The interpreter follows the Java implementation in Crafting Interpreters through chapter 10.2, translating the approach into Scala. A scanner produces tokens, a parser builds statements and expressions, and a tree-walk interpreter evaluates them. It accepts a script file or individual lines through an interactive prompt.
Put the language to work
The repository includes examples for loops, variable environments, and function calls. Its Fibonacci example combines a recursive function with this loop to print the first twenty values:
for (var i = 0; i < 20; i = i + 1) {
print fib(i);
}Explore language implementation
Separate scanner, parser, environment, and interpreter modules make each stage visible. Expression and statement visitors handle evaluation, and runtime errors carry the source token so a failure can report its line. The project offers a compact view of the machinery behind everyday programming constructs.