crafting-interpreters/README.md

41 lines
1.3 KiB
Markdown
Raw Normal View History

2025-02-06 11:00:57 +01:00
# Crafting Interpreters
Using rust to implement the first part of
[Crafting interpreters](https://craftinginterpreters.com) for the
2025-02-06 11:00:57 +01:00
[FHNW](https://www.fhnw.ch) [PL-Circle](https://github.com/fhnw-pl-circle).
2025-02-06 11:34:46 +01:00
All dependencies for running the respective implementations are specified in the
2025-06-06 09:39:19 +02:00
[flake.nix](./flake.nix) file within the project folder (look for the key
`buildInputs`, though [rustup](https://rustup.rs/) might just work with the
provided toolchain file). My recommendation is to use the provided
[nix flake](https://nixos.wiki/wiki/Flakes) directly, as it sets up everything
automatically.
2025-02-06 11:34:46 +01:00
Use `cargo run -- <ARGS>` to run the interpreter directly from the source code.
Specify needed arguments in place of `<ARGS>`.
```
Usage: rox <COMMAND>
Commands:
run Run a Lox source file
2025-02-06 11:34:46 +01:00
repl Run a Lox REPL
help Print this message or the help of the given subcommand(s)
Options:
-h, --help Print help
-V, --version Print version
```
2025-05-26 10:31:51 +02:00
2025-05-28 22:01:40 +02:00
For example running the
[Game of Life](https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life)
implemented in [brainfuck](https://en.wikipedia.org/wiki/Brainfuck) (read the
2025-05-28 22:02:52 +02:00
[source file](bf/game_of_life.bf) to figure out how to use it):
2025-05-28 22:01:40 +02:00
```
RUST_LOG=info cargo run --release -- run -s ./lox/bf.lox -- bf/game_of_life.bf
```
2025-05-26 10:31:51 +02:00
Please note that some parts of the implementation have not been given enough
thought.