diff options
-rw-r--r-- | awk/scheme/scheme/diagram.md | 43 |
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 |