aboutsummaryrefslogtreecommitdiffstats
path: root/awk/scheme
diff options
context:
space:
mode:
authorelioat <elioat@tilde.institute>2025-01-19 15:17:01 -0500
committerelioat <elioat@tilde.institute>2025-01-19 15:17:01 -0500
commitc9ef8456e8fa12f1cf7a95fda586bf8afd95897b (patch)
tree841eea1badbf8491cddb77deca90042057bc23e0 /awk/scheme
parentc33abea4005922736c1d9a8b4891b3acc79288b3 (diff)
downloadtour-c9ef8456e8fa12f1cf7a95fda586bf8afd95897b.tar.gz
*
Diffstat (limited to 'awk/scheme')
-rw-r--r--awk/scheme/scheme/diagram.md43
1 files changed, 43 insertions, 0 deletions
diff --git a/awk/scheme/scheme/diagram.md b/awk/scheme/scheme/diagram.md
new file mode 100644
index 0000000..74a9811
--- /dev/null
+++ b/awk/scheme/scheme/diagram.md
@@ -0,0 +1,43 @@
+# Awk-Scheme Diagram
+
+How this is all orchestrated.
+
+```
++----------------+ Scheme Code +----------------+ Assembly +----------------+
+| | -----------------> | | -------------> | |
+| REPL | "(+ 1 2)" | Compiler | "PUSH_CONST | VM |
+| (bin/repl) | | compiler.awk | N:1 | vm.awk |
+| | | | PUSH_CONST | |
+| User Input | | Translates | N:2 | Stack-based |
+| Interface | | Scheme to | ADD | Interpreter |
+| | | VM Assembly | HALT" | |
+| | <------------------ | | <------------- | |
+| | Output: "N:3" | | Result | |
++----------------+ +----------------+ +----------------+
+ ^ |
+ | |
+ | Data Flow |
+ | v
++------+-------------------------------------------------------------------------+
+| |
+| 1. REPL (bin/repl) reads Scheme expression from user |
+| 2. Expression sent to compiler (compiler.awk) |
+| 3. Compiler generates VM assembly instructions |
+| 4. VM (vm.awk) executes assembly and maintains: |
+| - Stack: For operation values |
+| - Heap: For storing pairs/lists |
+| - Type tags: N:(number), B:(boolean), P:(pair), NIL: |
+| 5. Result returned through REPL to user |
+| |
++--------------------------------------------------------------------------------+
+
+Example Flow:
+┌─────────────┐ ┌─────────────┐ ┌─────────────┐
+│ Input: │ │ Compiler │ │ VM │
+│ (+ 1 2) │ → │ PUSH_CONST │ → │ Stack: │
+│ │ │ N:1 │ │ [N:1] │
+│ │ │ PUSH_CONST │ │ [N:1,N:2] │
+│ │ │ N:2 │ │ [N:3] │
+│ │ │ ADD │ │ │
+└─────────────┘ └─────────────┘ └─────────────┘
+``` \ No newline at end of file