aboutsummaryrefslogtreecommitdiff
path: root/neb
diff options
context:
space:
mode:
Diffstat (limited to 'neb')
-rw-r--r--neb/std/strings.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/neb/std/strings.py b/neb/std/strings.py
index 4a7166e..00d1fc3 100644
--- a/neb/std/strings.py
+++ b/neb/std/strings.py
@@ -57,3 +57,10 @@ def interpretRaw(symbol, args, env, ns):
return String(str(args[0]))
STRINGS.register("raw", Builtin("raw", interpretRaw, [Arg("string", TypeEnum.STRING)], return_type=Type(":string")))
+
+def interpretOrd(symbol, args, env, ns):
+ if len(args[0].value) != 1:
+ raise InterpretPanic(symbol, "requires a :string of length 1", args[0])
+ return Int(ord(args[0].value))
+
+STRINGS.register("ord", Builtin("ord", interpretOrd, [Arg("char", TypeEnum.STRING)], return_type=Type(":int")))