Skip to content

Commit

Permalink
A REPL (#138)
Browse files Browse the repository at this point in the history
* A REPL based on dynamic linking and type-indexed pretty printing of natively represented values.
* Support for commands in the REPL including support for setting flags with and without arguments.
* Menu and search feature support.
* Support for loading (and compiling) mlb-files through `:load` commands.
* Automatic testing of the REPL (preliminary simple testing).
* Proper position-independent code generation on Linux (e.g., add types to global labels to avoid linker warnings).
* Set rpath at compile time instead of enforcing use of LD_LIBRARY_PATH on Linux (linking issue).
* Fix pretty-printing of negative nans on Linux.
* Support for control of printing depth and string printing cutoff (throug flags `pretty_depth` and `pretty_string_size`.
* support for multiple concurrent REPL sessions.
  • Loading branch information
melsman committed Nov 2, 2023
1 parent 4ec4dca commit 685fe42
Show file tree
Hide file tree
Showing 92 changed files with 4,496 additions and 1,775 deletions.
1 change: 1 addition & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ jobs:
make -C test test_mlkit
make -C test test_mlkit_no_gc
make -C test/explicit_regions all
make -C test/repl all
make -C test/parallelism all
- name: Configure SmlToJs
Expand Down
14 changes: 11 additions & 3 deletions basis/Real.sml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,17 @@ structure Real : REAL =

fun (x:real) / (y:real) : real = prim ("divFloat", (x, y))
fun rem (x:real, y:real) : real = prim ("remFloat", (x, y))
fun to_string_gen (s : string) (x : real) : string =
prim ("generalStringOfFloat", (s,x))
fun toString (x:real) : string = prim ("stringOfFloat", x)

local
fun repair_negnan (s:string) : string =
if s = "~nan" then "nan" else s
in
fun to_string_gen (s : string) (x : real) : string =
repair_negnan (prim ("generalStringOfFloat", (s,x)))
fun toString (x:real) : string =
repair_negnan (prim ("stringOfFloat", x))
end

fun sub_unsafe (s:string, i:int) : char = prim ("__bytetable_sub", (s,i))
fun isNan (x:real) : bool = prim ("isnanFloat", x)

Expand Down
2 changes: 1 addition & 1 deletion basis/basis.mlb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ local

basis Word =
let open General String IntInfRep
basis W = bas WORD.sig Word.sml Word64.sml Word63.sml Word32.sml Word31.sml Word8.sml
basis W = bas WORD.sig Word.sml Word64.sml (*Word63.sml*) Word32.sml Word31.sml Word8.sml
ann safeLinkTimeElimination
in local WordN.sml
in Word16.sml
Expand Down
14 changes: 9 additions & 5 deletions basis/io/text-io.sig
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,15 @@ necessary until one of these conditions holds. (This is the behaviour
of the `input' function prescribed in the 1990 Definition of Standard
ML).
[inputLine istr] returns one line of text, including the terminating
newline character. If end of stream is reached before a newline
character, then the remaining part of the stream is returned, with a
newline character added. If istr is at end of stream or is closed,
then the empty string "" is returned.
[inputLine istr] returns SOME(ln), where ln is the next line of input
in the stream strm. Specifically, ln returns all characters from the
current position up to and including the next newline (#"\n")
character. If it detects an end-of-stream before the next newline, it
returns the characters read appended with a newline. Thus, ln is
guaranteed to always be new-line terminated (and thus nonempty). If
the current stream position is the end-of-stream, then it returns
NONE. It raises Size if the length of the line exceeds the length of
the longest string.
[endOfStream istr] returns false if any elements are available in
istr; returns true if istr is at end of stream or closed; blocks if
Expand Down
2 changes: 2 additions & 0 deletions basis/repl.mlb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
basis.mlb
repl.sml
Loading

0 comments on commit 685fe42

Please sign in to comment.