aboutsummaryrefslogtreecommitdiff
path: root/iclean.icl
diff options
context:
space:
mode:
authorCamil Staps2016-10-18 23:38:01 +0200
committerCamil Staps2016-10-18 23:38:01 +0200
commita3c32c724d37996ac7e1b8f1557b6fb55963328d (patch)
treefbafbbd74a97357a1f2e26814f55a1bb1a5ffb98 /iclean.icl
parentDocker (diff)
Add :undef
Diffstat (limited to 'iclean.icl')
-rw-r--r--iclean.icl21
1 files changed, 15 insertions, 6 deletions
diff --git a/iclean.icl b/iclean.icl
index 4daba82..dce11f3 100644
--- a/iclean.icl
+++ b/iclean.icl
@@ -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