aboutsummaryrefslogtreecommitdiff
path: root/neb/std/repl.py
diff options
context:
space:
mode:
Diffstat (limited to 'neb/std/repl.py')
-rw-r--r--neb/std/repl.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/neb/std/repl.py b/neb/std/repl.py
new file mode 100644
index 0000000..48a7811
--- /dev/null
+++ b/neb/std/repl.py
@@ -0,0 +1,24 @@
+from .. import TypeEnum, Environment, Arg, Builtin, UserFunction, evaluate
+from ..structs import *
+
+REPL = Environment()
+
+def interpretHowTo(symbol, args, env, ns):
+ if not isinstance(args[0], Function):
+ raise InterpretPanic(symbol, "expects a :func", args[0])
+ print(args[0].describe())
+ return List([])
+
+REPL.register("howto", Builtin(interpretHowTo, [Arg("symbol", TypeEnum.ANY)]))
+
+def interpretSymbols(symbol, args, env, ns):
+ keys = [Symbol(k, -1) for k,v in env.environment.items()]
+ return List(keys)
+
+REPL.register("symbols", Builtin(interpretSymbols, []))
+
+def interpretUserSymbols(symbol, args, env, ns):
+ keys = [Symbol(k, -1) for k,v in env.environment.items() if isinstance(v, UserFunction) or isinstance(v, Literal)]
+ return List(keys)
+
+REPL.register("user-symbols", Builtin(interpretUserSymbols, []))