Skip to content

An interpreter for the Monkey programming language, written in Java.

Notifications You must be signed in to change notification settings

IcePanorama/JavaMonkeyInterpreter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 

Repository files navigation

Java Monkey Interpreter

A tree-walking interpreter for the Monkey programming language, written in Java.

As of July 3rd, 2024, the interpreter is fully functional, supporting "mathematical expressions, variable bindings, functions and the application of those functions, conditionals, [both explicit and implicit] return statements, and advanced concepts like higher-order functions and closures" (Ball 197) as well as 5 data types: integers, booleans, strings, arrays, and hashes.

Features

  • Read-Eval-Print-Loop (REPL) environment for typing in code
  • Lexer for tokenization
  • Pratt/Recursive descent parser for syntactic analysis.
  • Abstract syntax tree (AST) for code representation and evaluation.

All of the interpreter's features were created from scratch, without the use of any outside libraries or frameworks.

Installation & Usage

First, verify that you have both java and maven installed on your machine.

java --version
mvn --version

After that, installation can be completed by simply cloning the repository on to your local machine:

git clone https://github.com/IcePanorama/JavaMonkeyInterpreter

You can then run the interpreter using the following commands:

cd JavaMonkeyInterpreter/
mvn package
java -cp target/classes com.monkeyinterpreter.Main

To quit the interpreter, type .quit.

To do

  • Refactor entire codebase.
  • Create better documentation for codebase.
  • Implement float datatype.
  • Implement quality-of-life improvements for REPL.

Acknowledgements

This project was developed using the book, "Writing An Interpreter In Go" by Thorsten Ball. As the name implies, Ball's original project was written entirely in Go and I converted everything to Java.

As of July 3rd, 2024, I'm finished with the book, although I still plan on cleaning the project up some before I'll truly consider it "complete". After that, I'll likely add some more features to the language on my own before moving onto the Thorsten Ball's next book, "Writing An Interpreter In Go: The Lost Chapter - A Macro System For Monkey".

About

An interpreter for the Monkey programming language, written in Java.

Topics

Resources

Stars

Watchers

Forks

Languages