JLox* is a tree walk interpreter for Lox written in Java. Lox is a full-featured, efficient scripting language from Robert Nystrom's book, Crafting Interpreters.
This project was done as part of my CS375 independent study for FA 2024.
The documentation for the Lox programming language itself can be found here.
- Java
While most of my implementation follows the guidelines for the Lox language, there are a few things(features) not part of the actual Lox language that Jlox* supports:
- Native functions:
input
,clock
andnumber
.
input
: Calling this native function will read a string from standard input.
clock
: Calling this native function will return the current time in seconds.
number
: Calling this native function will convert the argument provided to number, if possible. - String and number concatenation
- Static methods for classes
Check sampleFiles/staticMethods.lox file to check out how static methods work in Jlox*.
- Download the latest version
Lox.jar
file from the releases section here: https://github.com/paudsu01/Lox/releases
- Open up your terminal.
cd path/to/directory/of/Lox.jar
- To run the interpreter, run:
java -jar Lox.jar
- To run a .lox file, run:
java -jar Lox.jar file.lox
You can also download some sample
.lox
files from the sampleFiles/ directory and run them.
-
I would suggest adding an alias from the terminal to run the
Lox.jar
file such asalias jlox="java -jar path/to/Lox.jar"
You can now just type use
jlox
to use the interpreter for the remaining terminal session. -
If you want to add a permanent alias, you can add the command to your shell config file such as
~/.bashrc
file.