Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated README, mostly to more accurately describe the compiler pipeline #31

Merged
merged 1 commit into from Mar 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 5 additions & 5 deletions README.md
Expand Up @@ -4,7 +4,7 @@ I've had the book, "Crafting Interpreters", for a while and went through the fir

# Quick start

Checkout the project using git. Then open it up using Xcode and run the project. That should start up a REPL within Xcode itself in the bottom right of the IDE. You should be able to enter in expressions and see their effects/results in the REPL.
Checkout the project using git. Then open it up using Xcode and run the project by hitting ⌘-R. That should start up a REPL within Xcode itself, in the bottom right of the IDE. You should be able to enter expressions and see their effects/results in the REPL.

<img src="./images/repl.png" />

Expand All @@ -20,7 +20,7 @@ So far, the following have been implemented in `slox`:
- Function declaration and invocation
- Lambda expressions
- Class declaration and instantiation
- Instance properties and methods
- Instance-level properties and methods
- Referencing the scoped instance via `this`
- Class-level properties and methods
- Single inheritance
Expand All @@ -31,16 +31,16 @@ So far, the following have been implemented in `slox`:

# Design

Most of the design of `slox` is very similar to the one in the book. There are four phases involved in the execution of code in `slox`:
Most of the design of `slox` is fairly similar to the one in the book. There are four phases involved in the execution of code in `slox`:

- scanning for tokens
- parsing of tokens into statements and expressions
- resolving of variables from parsed code
- interpreting of resolved statements

Both the REPL and file runner instantiate the scanner, parser, resolver, and interpreter in succession, each feeding their results to the next, and eventually printing the output of the interpreter.
However, unlike how they are implemented in the book, the REPL and file runner instantiate just the interpreter, passing in code to be executed; it is the interpreter that instantiates and runs each of the scanner, parser, resolver in succession, each feeding their results to the next. The interpreter also reads in a small standard library defined in a string; at this point, only a class declaration for a `List` class and some associated methods are defined in it.

Nonetheless, there are a few differences between this implementation and that in the book.
There are a few other differences between this implementation and that in the book which are described below.

### Enums instead of class hierarchies

Expand Down