|
1 | | -[](https://app.codecrafters.io/users/codecrafters-bot?r=2qF) |
2 | | - |
3 | | -This is a starting point for Rust solutions to the |
4 | | -["Build your own Interpreter" Challenge](https://app.codecrafters.io/courses/interpreter/overview). |
5 | | - |
6 | | -This challenge follows the book |
7 | | -[Crafting Interpreters](https://craftinginterpreters.com/) by Robert Nystrom. |
8 | | - |
9 | | -In this challenge you'll build an interpreter for |
10 | | -[Lox](https://craftinginterpreters.com/the-lox-language.html), a simple |
11 | | -scripting language. Along the way, you'll learn about tokenization, ASTs, |
12 | | -tree-walk interpreters and more. |
13 | | - |
14 | | -Before starting this challenge, make sure you've read the "Welcome" part of the |
15 | | -book that contains these chapters: |
16 | | - |
17 | | -- [Introduction](https://craftinginterpreters.com/introduction.html) (chapter 1) |
18 | | -- [A Map of the Territory](https://craftinginterpreters.com/a-map-of-the-territory.html) |
19 | | - (chapter 2) |
20 | | -- [The Lox Language](https://craftinginterpreters.com/the-lox-language.html) |
21 | | - (chapter 3) |
22 | | - |
23 | | -These chapters don't involve writing code, so they won't be covered in this |
24 | | -challenge. This challenge will start from chapter 4, |
25 | | -[Scanning](https://craftinginterpreters.com/scanning.html). |
26 | | - |
27 | | -**Note**: If you're viewing this repo on GitHub, head over to |
28 | | -[codecrafters.io](https://codecrafters.io) to try the challenge. |
29 | | - |
30 | | -# Passing the first stage |
31 | | - |
32 | | -The entry point for your program is in `src/main.rs`. Study and uncomment the |
33 | | -relevant code, and push your changes to pass the first stage: |
34 | | - |
35 | | -```sh |
36 | | -git commit -am "pass 1st stage" # any msg |
37 | | -git push origin master |
38 | | -``` |
39 | | - |
40 | | -Time to move on to the next stage! |
41 | | - |
42 | | -# Stage 2 & beyond |
43 | | - |
44 | | -Note: This section is for stages 2 and beyond. |
45 | | - |
46 | | -1. Ensure you have `cargo (1.86)` installed locally |
47 | | -2. Run `./your_program.sh` to run your program, which is implemented in |
48 | | - `src/main.rs`. This command compiles your Rust project, so it might be slow |
49 | | - the first time you run it. Subsequent runs will be fast. |
50 | | -3. Commit your changes and run `git push origin master` to submit your solution |
51 | | - to CodeCrafters. Test output will be streamed to your terminal. |
| 1 | +<div align="center"> |
| 2 | + <img src="https://github.com/user-attachments/assets/c897b8e9-a218-47a9-a25e-d19add09c36e" alt="Fox" width="100%" /> |
| 3 | + |
| 4 | +  |
| 5 | +</div> |
| 6 | + |
| 7 | +## Overview |
| 8 | +`Fox` is a fast Lox interpreter written in rust based from the specifications in the [Lox](https://craftinginterpreters.com/the-lox-language.html) programming language by Robert Nystrom. Lox is known as a dynamic scripting language but with some OOP aspects like classes and inheritance. Imports are **not** included in this interpreter, however it's easy to add given the structure of the code. |
| 9 | + |
| 10 | +## Features |
| 11 | +- [x] High Performance Lexer and Parser |
| 12 | +- [x] Evaluating Expressions with Order (using Recursive Descent Parsing Algorithm) |
| 13 | +- [x] Useful Error Messages |
| 14 | +- [ ] Variable declaration |
| 15 | +- [ ] Scoping |
| 16 | +- [ ] Functions |
| 17 | +- [ ] Classes & OOP |
| 18 | +- [ ] REPL |
| 19 | + |
| 20 | +## Setup |
| 21 | +1. Clone this repository. |
| 22 | +2. Install [the rust toolchain](https://www.rust-lang.org/tools/install) version `1.86.0`. |
| 23 | +3. Build the projcet with `cargo build` or if you are in release mode, `cargo build --release`. |
| 24 | +4. Run the interpreter with either the following subcommands depending on the output that you want: `tokenize` (lexer), `parse` (parser), or `evaluate` (evaluator). `cargo run <subcommand> <file_name>`. |
| 25 | + |
| 26 | +## WIP |
| 27 | +While this is a working interpreter at the moment, I wanted to finish it as a usable complete day-to-day interpreter that you would actually use. Providing a good developer experience is key to a good interpreter. Some features that I will definitely implement are pretty error messages, interactive REPL, and maybe in the future an LSP server with treesitter. |
0 commit comments