diff options
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | README.md | 31 | ||||
-rw-r--r-- | compile.c | 6 | ||||
-rw-r--r-- | iclean.icl | 9 |
4 files changed, 40 insertions, 8 deletions
@@ -10,5 +10,5 @@ iclean: compile.o iclean.icl clm -l compile.o iclean -o iclean run: iclean - ./iclean + ./iclean -nr -nt @@ -1,2 +1,33 @@ # iClean Interactive Clean + +This module allows you to execute Clean commands interactively, similar to GHCi or the Python shell. Functionality is very limited. In particular there is **no memory**, so you're restricted to one-liners. + +## Example session + + $ ./iclean + > [1,2,3,4] + [1,2,3,4] + > map toString [1..10] + ["1","2","3","4","5","6","7","8","9","10"] + > [Ctrl-D] + $ + +## Installation + + make iclean + +## Running +Either + + ./iclean + +or + + make run + +## Todo + + * Implement memory (e.g. to first declare a function / constant and then use it) + * Commands memory (scroll through previous commands with arrow keys) + * Imports @@ -42,7 +42,7 @@ * * @return void */ -void compile(CleanString path, CleanString module) { +int64_t compile(CleanString path, CleanString module) { char* pathchars, * modulechars; int pathlength, modulelength; @@ -71,13 +71,13 @@ void compile(CleanString path, CleanString module) { // Build command: // clm -ms <module> -o <module> - char cmd[64] = "clm -ms "; + char cmd[64] = "clm -ms -nw "; strcat(cmd, modulechars); strcat(cmd, " -o "); strcat(cmd, modulechars); // Call clm - system(cmd); + return system(cmd); } /** @@ -43,11 +43,12 @@ Start w where loop :: *World -> *World loop w - #! w = print "> " w + #! w = print "λ. " w #! (s,w) = readline w | s == "" = w #! w = writemodule s w - #! w = compile temp_path temp_module w + #! (r,w) = compile temp_path temp_module w + | r <> 0 = loop w #! w = run (temp_path +++ temp_module) w = loop w @@ -81,9 +82,9 @@ writemodule s w | not ok = abort ("Couldn't close " +++ temp_file +++ "\n") | otherwise = w -compile :: !String !String *World -> *World +compile :: !String !String !*World -> !*(!Int,!*World) compile _ _ _ = code { - ccall compile "SS:V:p" + ccall compile "SS:p:p" } run :: !String *World -> *World |