]> git.lizzy.rs Git - uwu-lang.git/commitdiff
Add :nil:nil
authorElias Fleckenstein <eliasfleckenstein@web.de>
Thu, 30 Dec 2021 14:22:29 +0000 (15:22 +0100)
committerElias Fleckenstein <eliasfleckenstein@web.de>
Thu, 30 Dec 2021 14:22:29 +0000 (15:22 +0100)
Makefile
doc/std.md
example/test.uwu
std/bool.c
std/int.c
std/nil.c [new file with mode: 0644]
uwu [new file with mode: 0755]

index f218bdb926324cead2ded36d259cc770d0b2a646..8dbf5d8a38b5817bc1ddd537a1dfa830e7c7566a 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -5,7 +5,7 @@ uwu: src/*.c src/*.h
 
 .PHONY: std api
 
-std: std/bool.so std/int.so std/str.so
+std: std/bool.so std/int.so std/str.so std/nil.so
 api: api/api.so
 
 std/%.so: std/%.c
index 1ebd6db85f1b07a223f91e06768413fa35663f2f..debf46055e83d72d9b14cc7280c08f6d3d83f433 100644 (file)
@@ -1,5 +1,9 @@
 # Standard library
 
+## The `:nil` module
+
+- `:nil:nil`: The nil constant
+
 ## The `:bool` module
 
 - `:bool:if`: Requires exactly 3 arguments of arbitrary type. If $0 is a truthy value, evaluate and return $1. If $0 is a falsy value, evaluate and return $2. Values considered as falsy are: `:bool:false` and `:nil:nil`. Everything else is considered truey.
index 375a03f1cfec4b9871bbae1eff005abe228845e9..081eb69f9ba971adbf0d500b7f92b2577b14f176 100644 (file)
@@ -3,5 +3,6 @@ hello_world "hello world
 
 main :str:cat(
        hello_world,
-       fibo:print(10)
+       fibo:print(10),
+       :nil:nil
 )
index 80aade57218093906e535189bcb6c8b70171d24b..76772bf1c44593bff5234928eaa7f67dbe1489d7 100644 (file)
@@ -9,7 +9,6 @@ static inline bool get_bool_arg(UwUVMArgs *args, size_t i)
        return uwubool_get(uwuvm_get_arg(args, i));
 }
 
-#include "../api/str.h"
 UwUVMValue uwu_if(UwUVMArgs *args)
 {
        if (args->num != 3)
index 48c808b18fcec473d78b7b16608ddc6cb40ad6c3..dfc436cfdf126fb6a5af22c7b68f46c918bbadf7 100644 (file)
--- a/std/int.c
+++ b/std/int.c
@@ -80,7 +80,7 @@ static int reduce(const char *fnname, UwUVMArgs *args, ReduceOP op, int result)
 
 UwUVMValue uwu_add(UwUVMArgs *args)
 {
-       return uwuint_create(reduce(":int:mul", args, ROP_ADD, 0));
+       return uwuint_create(reduce(":int:add", args, ROP_ADD, 0));
 }
 
 UwUVMValue uwu_sub(UwUVMArgs *args)
diff --git a/std/nil.c b/std/nil.c
new file mode 100644 (file)
index 0000000..33230fb
--- /dev/null
+++ b/std/nil.c
@@ -0,0 +1,10 @@
+#include "../src/err.h"
+#include "../api/nil.h"
+
+UwUVMValue uwu_nil(UwUVMArgs *args)
+{
+       if (args->num != 0)
+               error(":nil:nil does not accept any arguments\n");
+
+       return uwunil_create();
+}
diff --git a/uwu b/uwu
new file mode 100755 (executable)
index 0000000..d092964
Binary files /dev/null and b/uwu differ