Skip to content

A Python3 implementation of the Lox language tree-walk interpreter from Crafting Interpreters

License

Notifications You must be signed in to change notification settings

Soup-5/Python-Lox

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Python Lox Interpreter

GitHub Repo stars GitHub forks GitHub Downloads (all assets, all releases) GitHub

Description

An (incredibly bare bones) Python 3.9.2 interpreter implementation of the lox programming language, adapted from the jlox tree-walk interpeter in the book "Crafting Interpreters" by Robert Nystrom.

I put "bare bones" because currently the interpreter only supports a few of lox's basic features so far:

  • Literals (strings, floats)
  • Basic Arithmetic (+, -, *, /)
  • Boolean Arithmetic & Equality
  • Expressions
  • Statements (only print & var)
  • Variable Declaration
  • Variable Assignment
  • Comments (single & multi-line)
  • Block Statements & Scope
  • If/Else Statements
  • While Loops
    I plan on adding more as I progress through the book

Installation

Windows:

  • This project assumes you have already installed python 3.9.2, if not you can download it here for Windows (64-bit) or grab other builds here
  • Download this project's latest release here
  • Unzip and extract Downloads/Python-Lox-1.0.0.zip
  • Open the Windows PowerShell app using the Start menu
  • Run the script by typing in the following format: python3 src/main.py *.lox

For example, if you want to run the fizzbuzz.lox script you can type in the following command:

python3 src/main.py examples/fizzbuzz.lox

Macbook:

  • This project assumes you have already installed python 3.9.2, if not you can download it here for MacOS or grab other builds here
  • Download this project's latest release here
  • Unzip and extract Downloads/Python-Lox-1.0.0.zip
  • Open the Terminal app through Launchpad
  • Use cd to change to the project's directory
  • Run the script by typing in the following format: python3 src/main.py *.lox

For example, if you want to run the fizzbuzz.lox script you can type in the following command:

python3 src/main.py examples/fizzbuzz.lox

Debian/Ubuntu:

  • This project assumes you have already installed python 3.9.2, if not you can run sudo apt install python3.9
  • Download this project's latest release here
  • Run unzip Downloads/Python-Lox-1.0.0.zip
  • Use cd to change to the project's directory
  • Run the script by typing in the following format: python3 src/main.py *.lox

For example, if you want to run the fizzbuzz.lox script you can type in the following command:

python3 src/main.py examples/fizzbuzz.lox

License & Attributions

This Project is licensed under the MIT License

Huge thank you to Bob Nystrom for letting me dive into the monstrosity that is compiler/interpreter programming with Crafting Interpreters

About

A Python3 implementation of the Lox language tree-walk interpreter from Crafting Interpreters

Topics

Resources

License

Stars

Watchers

Forks

Languages