bun run repl #2

Merged
probablycorey merged 6 commits from repl into main 2025-10-26 00:24:45 +00:00
Owner

Mostly AI generated, but I helped.

Try it out:

bun run repl

This changes the way the compiler works slightly (and also required some changes to Reef):

  • Making a REPL for a regular interpreter is easy because you just keep evaluating each new line in the context of the previous lines
  • However, our interpreter is actually a compiler. So we needed a way to incrementally add new instructions to our program on the fly.
  • Reef was designed to run entire, frozen programs.
  • Specifically, Reef expects the program to end with HALT and then define functions after that, using labels.
  • However, this makes building a REPL difficult.
  • As of this PR, we define the function body inline with the program (using a label) and just JUMP over it.
  • This makes the REPL happy.
Mostly AI generated, but I helped. Try it out: bun run repl This changes the way the compiler works slightly (and also required some changes to Reef): - Making a REPL for a regular interpreter is easy because you just keep evaluating each new line in the context of the previous lines - However, our interpreter is actually a compiler. So we needed a way to incrementally add new instructions to our program on the fly. - Reef was designed to run entire, frozen programs. - Specifically, Reef expects the program to end with `HALT` and then define functions after that, using labels. - However, this makes building a REPL difficult. - As of this PR, we define the function body inline with the program (using a label) and just `JUMP` over it. - This makes the REPL happy.
defunkt added 1 commit 2025-10-25 17:18:13 +00:00
defunkt force-pushed repl from 7d044b28a4 to 831966323a 2025-10-25 17:20:56 +00:00 Compare
defunkt force-pushed repl from 831966323a to 5988e75939 2025-10-25 17:21:03 +00:00 Compare
defunkt added 1 commit 2025-10-25 17:26:24 +00:00
defunkt added 1 commit 2025-10-25 17:32:46 +00:00
defunkt added 2 commits 2025-10-25 17:43:05 +00:00
defunkt added 1 commit 2025-10-25 22:52:15 +00:00
probablycorey merged commit e3b941d5f2 into main 2025-10-26 00:24:45 +00:00
Sign in to join this conversation.
No reviewers
No Label
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: probablycorey/shrimp#2
No description provided.