diff options
Diffstat (limited to 'iclean.icl')
-rw-r--r-- | iclean.icl | 21 |
1 files changed, 15 insertions, 6 deletions
@@ -35,16 +35,20 @@ import ExtraString temp_path :== "/tmp/" temp_module :== "iclean" readline_history :== "/home/.iclean_history" -template :== map ((+++) "import ") - [ "StdEnv" - , "StdMaybe" - , "StdDynamic" - , "genLibTest" - ] +template :== map ((+++) "import ") ["StdEnv", "StdDynamic", "genLibTest"] // END SETTINGS temp_file :== temp_path +++ temp_module +++ ".icl" +help :== + "\tInteractive Clean - known commands:\n\n" +++ + "\t:quit\t\t\tExit iClean\n" +++ + "\t:mem\t\t\tDisplay current memory\n" +++ + "\t:help\t\t\tDisplay this message\n\n" +++ + "\t:import MODULE\t\tAdd an import to the memory\n" +++ + "\t:def F X1 .. X2 = RHS\tAdd a rewrite rule to the memory\n" +++ + "\t:undef F\t\tRemove all rewrite rules starting with 'F ' from the memory\n" + Start :: *World -> *World Start w # w = setReadLineName "iClean" w @@ -66,6 +70,8 @@ where | s == ":mem" = loop mem True (print (join "\n" mem) w) | matches ":import " s = loop (mem ++ [skip 1 s]) True w | matches ":def " s = loop (mem ++ [skip 5 s]) True w + | matches ":undef " s = loop (filter (undef (skip 7 s)) mem) True w + | s == ":help" = loop mem True (print help w) | matches ":" s = loop mem False (print ("Unknown command\n") w) # w = writemodule mem s w # (r,w) = compile temp_path temp_module w @@ -74,6 +80,9 @@ where | r <> 0 = loop mem False w = loop mem True w + undef :: !String !String -> Bool + undef n h = not (matches (n +++ " ") h) + // iClean functions checkedWorldFunc :: (a *World -> (Bool, *World)) !String !a !*World -> *World checkedWorldFunc f err s w |