A simple implementation of Lox interpreter from the CraftingInterpreter book.
This is an exercise repo, meant to implement what's in the book with some addition:
- All challenges completed
- Better repl with syntax highlighting, etc
- Language Server to integrate with editors / IDE
- Static analysis tool
After cloning the repo, execute:
$ mvn package
to generate an executable jar in the target
directory.
You can then run the file:
$ java -jar target/lox-0.0.1-SNAPSHOT.jar
to see the REPL.
File and build system is not really supported for now, but the foundation to do so is there.
Right now the interpreter can:
- parse and execute basic statements (arithmetic, logical operation)
- assign global variable
- assign variable in block scope
- execute ternary operator
- flow control via if statement
- looping via for and while statements
More will come:
-
Update REPL to support statement. Rule is: execute statement, print result of expression.
-
Throws a runtime error on uninitialized variable
-
Create an exact rule for global / local scoping, i.e.:
var a = 1; { var a = a + 2; print a; }
in C# this will give an error. C will prints 2 because that inside
a
counts as uninitialized and uninitialized is treated asnull
, andint
+null
isint
. -
Integrate build and packaging system (maven? gradle?)
-
Implement control flow (if, while, for)
-
Implement break statement for looping
-
Implement function and make sure it's first-class value
-
Upgrade variable / function binding and resolving
-
Implement Basic Class (OOP)
-
Implement Inheritance
-
Implmenet ADT
-
Learn about VM and implement VM (likely in C or Rust)