Skip to content

Commit 8a158eb

Browse files
authored
Update 2025-01-11-ImplementingaJITCompiledLanguagewit
small REPL
1 parent 334f4c8 commit 8a158eb

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

_posts/2025-01-11-ImplementingaJITCompiledLanguagewithOCamlandLLVM.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,5 +110,26 @@ type parsed_text = (int, string ) result
110110

111111
{% endhighlight %}
112112

113+
# The REPL
114+
The driver is intended to invoke the expressions in a loop to create the small REPL. The loop is now commented temporarily.
115+
116+
{% highlight ocaml %}
117+
118+
type parsed_text = (int, string ) result
119+
[@@deriving show]
120+
121+
let cli ~stdin ~stdout =
122+
let buf = Eio.Buf_read.of_flow stdin ~initial_size:100 ~max_size:1_000_000 in
123+
(* while true do *)
124+
125+
let line = Eio.Buf_read.line buf in
126+
traceln "> %s" line;
127+
match line with
128+
|line -> let parsed_text = main line in
129+
Eio.Flow.copy_string (Fmt.str " %S\n" (show_parsed_text parsed_text)) stdout
130+
;
131+
(* done *)
132+
133+
{% endhighlight %}
113134

114135
> TODO

0 commit comments

Comments
 (0)