Skip to content
/ lox Public

A Python implementation of the Lox language, from the book Crafting Interpreters by Bob Nystrom

License

Notifications You must be signed in to change notification settings

ehomrich/lox

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Lox language in Python

A Python (3.6+) implementation of the Lox language, from the in-progress book Crafting Interpreters by Bob Nystrom.

This project is a port of jlox, the Java-based implementation presented throughout part of the book.

What is Lox?

Lox is a full-featured, object-oriented scripting language with dynamic typing, garbage collection, lexical scope, first-class functions, closures, classes and inheritance, and more.

Under development

This implementation is still ongoing, and there is a desire to extend the project later for educational purposes.

At the moment, the implementation follows almost every step and decision in the book, however:

  • Not all challenges have been implemented yet.
  • I'll be using null instead of nil.
  • I will try to handle both int and float numbers.
  • The TokenType enum has many more tokens and keywords than those described by the book. I recorded all the ideas that came to mind while reading the language planning section.

Requirements

The only requirement to run this project is Python 3.6+, due to the type hints used almost everywhere.

This project was developed on OS X, but it should work on any OS without any problems.

Usage

REPL

python -m lox

Enter exit or press Ctrl+D to leave.

Running a file:

python -m lox path/to/file

License

MIT License

About

A Python implementation of the Lox language, from the book Crafting Interpreters by Bob Nystrom

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages