Yumasi / pylox

Python implementation of the Lox programming language from the Crafting Interpreters book.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Pylox

Running Pylox

Prerequisites

  • Poetry
  • Python >= 3.10

Running with Poetry

poetry run pylox        # To run in REPL mode
poetry run pylox <script> # To execute a script

Challenges left

  • [ ] Interpret and print expression in the REPL (Chapter 8)

Development

Run poetry shell

poetry shell

Install pre-commit hooks

pre-commit install

Guix

Poetry

Poetry does not create a virtualenv, so we need to create one ourselves and ask Poetry to install the dependencies in it:

python3 -m venv .venv
. .venv/bin/activate
poetry install

Ruff

Ruff is not (yet) packaged in GNU Guix, so we need to build it ourselves. That’s what the dependencies in manifest.scm are for. To build Ruff run the following:

# Activate the Guix shell and source the venv
guix shell
. .venv/bin/activate
# If Ruff has been installed by Poetry
pip uninstall ruff
# Install Ruff
CC=gcc pip install --no-binary :all: ruff

Once installed in the virtualenv, you don’t need to use guix shell to do your development.

Pre-commit

Pre-commit tries to install Ruff from pip. Since this does not work in Guix, load you virtualenv, run pre-commit, find the path to its ruff installation and replace it with a symlink to your newly built Ruff

About

Python implementation of the Lox programming language from the Crafting Interpreters book.


Languages

Language:Python 98.5%Language:Scheme 0.9%Language:Emacs Lisp 0.6%Language:Shell 0.1%