Skip to content
/ jlox Public

Writing JLOX while following 'Crafting Interpreters'

Notifications You must be signed in to change notification settings

Sarakuzoi/jlox

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

62 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Jlox ⚙️

An abstract syntax tree walk interpreter written in Java for a modified version of lox with support for better control flow (e.g. continue, break statements), improved error messages and many other fun features!

Run guide 📝

First, clone the repository locally:

git clone https://github.com/Sarakuzoi/jlox.git

Then in your IDE of choice run the Lox.java class. You can run the interpreter with or without a CLI argument specifying an input file for the program.

If you choose to run the program without an input file, you will be promped with a REPL environment in your console:

> var a = 4;
> var b = 2;
> a + b == 6;
true

Example code 🎮

Here is a simple program showcasing some of JLox's syntax with an (inefficient) implementation of a program printing out the first 20 Fibonacci numbers:

fun fib(n) {
    if (n <= 1) return n;
    return fib(n - 2) + fib(n - 1);
}

for (var i = 0; i < 20; i = i + 1) {
    print fib(i);
}

License ⚖️

This project is released under MIT license. Check out the LICENSE file for more information.

About

Writing JLOX while following 'Crafting Interpreters'

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages