Skip to content
/ JLox Public

My implementation for the Lox tree walk interpreter written in Java

Notifications You must be signed in to change notification settings

paudsu01/JLox

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

96 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Jlox*

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.

Requirements

  • Java

Why Jlox* and not Jlox ?

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 and number.

    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*.

Installation guide:

Running the interpreter

  • 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.

Running the interpreter from anywhere in the terminal

  • I would suggest adding an alias from the terminal to run the Lox.jar file such as

    alias 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.

About

My implementation for the Lox tree walk interpreter written in Java

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages