Skip to content
/ JLox Public

Jlox: An immitation of craftinginterpreters Lox language in Java with a little bit of my own flavor.

Notifications You must be signed in to change notification settings

RougherO/JLox

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JLox

Welcome to JLox, a language crafted for learning and educational exploration. This is an attempt at implementing Robert Nystrom's Lox in Java, how its done in the first part of the book craftinginterpreters by Robert Nystrom, combined with some of my own features.

Overview

JLox is a passionate project created primarily for educational purposes, designed primarily for my own sake of learning more about interpreters and compilers. It's important to note:

  1. Designed for Learning: This language is intentionally built for learning and educational purposes. So it's not optimized for performance given that the implementation relies on JVM's own GC and also moderate usage of instanceof which is not cheap, it serves as a valuable tool for understanding language concepts. It can be used as a reference while going through the book.

  2. Early Stage Prototype: Currently, JLox exists in its early prototype stage. It's a work in progress and I am investing almost 14 - 16 hours weekly on it since the last month. Judging by the current pace, it would take another month to complete the java version of this language.

  3. Inspired by "Crafting Interpreters": The language is heavily influenced by Robert Nystrom's book "Crafting Interpreters". While following the book's guidance, it incorporates original elements and some of my own adaptations to add a unique flavor to the language.

  4. Future Development Roadmap: The language is undergoing active development. The immediate roadmap involves completing the initial implementation in Java, based on the book's first part. Following this phase, I plan to reimplement the language in C, based on the book's second part but that's another beast which would probably take another 4 - 5 months to tame. This reimplementation aims to enhance performance, making the language more suitable for real-world applications.

Features

  • Jlox is dynamically typed language, no type definition is required. New variables are declared using the let keyword.
let myVar = 2;
  • C-like syntax: Here's an example for loop
for (let i = 0; i < 10; i++) {
    print("Programming languages are cool!" + "Programmers are even cooler!");
}
  • Garbage collected (JVM)
  • Need semi-colon to end statements. (Yes I am that guy who favours semi-colons)
  • ...more on the way.(from Chapter 10 functions)

Installation

For now, until a docker image or a CLI app is made available, to test and poke around the language run it by downloading the jar file and running it using JVM.

$ java -jar JLox-0.0.1.jar [filename]

The filename is any text file which contains valid JLox code that can be interpreted.

If no filename is provided then a standard REPL interface opens up which accepts any valid jlox statements.

Documentation

Docs are available here and are currently incomplete and undergoing development. Feel free to contribute towards improving the documentation.

Upcoming

  • Functions
  • Closures
  • Classes
  • Inheritance
  • Multi-line comments
  • break and continue statements with loop labels
  • Testing / unit-tests
  • feel free to suggest

Contributing

At the moment contributions are not accepted, since I feel the source code documentation could still use some work, although I have tried to provide as much relavant comments as possible to make the source code more readable. However once the language is completely implemented with better code documentation it will be open for all kinds of feedbacks, contributions, suggestions etc.

Reporting of issues is always open.

Once testing is implemented PR's for additional test cases are also welcome.

Acknowledgements

  1. craftinginterpreters book
  2. Robert Nystrom -
  3. Answers to the book's challenges
  4. @OpenAI - Documentation and README has been generated with the help of ChatGPT.

To stay tuned for further updates and progress consider following the project and might as well star it too :D.

About

Jlox: An immitation of craftinginterpreters Lox language in Java with a little bit of my own flavor.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages