Lox_Learning is a project inspired by the book Crafting Interpreters by Robert Nystrom. This project focuses on creating an interpreter for the Lox programming language, a language designed to showcase both object-oriented and functional programming paradigms. The interpreter is implemented in Java.
-
Object-Oriented Programming (OOP):
- Classes and instances.
- Inheritance for code reuse and extensibility.
- Encapsulation and method invocation.
-
Functional Programming (FP):
- First-class functions.
- Lexical scoping.
- Support for higher-order functions.
-
Interpreter Design:
- Lexical analysis (tokenization).
- Syntax parsing (AST generation).
- Semantic analysis and runtime evaluation.
You can use the Lox interpreter in two ways:
-
Interactive Mode (REPL): Run the interpreter without arguments to enter the interactive shell:
java -cp bin com.lox.Lox
You can then type Lox code directly and see the results.
-
Script Mode: Provide a
.loxfile as an argument to execute a script:java -cp bin com.example.lox path/to/script.lox
class Greeter {
greet(name) {
print "Hello, " + name + "!";
}
}
var greeter = Greeter();
greeter.greet("World");
Hello, World!
- Robert Nystrom for the Crafting Interpreters book, which inspired this project.