diff options
-rw-r--r-- | .gitignore | 3 | ||||
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | doc/std.md | 4 | ||||
-rw-r--r-- | example/test.uwu | 3 | ||||
-rw-r--r-- | std/bool.c | 1 | ||||
-rw-r--r-- | std/int.c | 2 | ||||
-rw-r--r-- | std/nil.c | 10 |
7 files changed, 21 insertions, 4 deletions
@@ -50,3 +50,6 @@ modules.order Module.symvers Mkfile.old dkms.conf + +# Executable +uwu @@ -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 @@ -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. diff --git a/example/test.uwu b/example/test.uwu index 375a03f..081eb69 100644 --- a/example/test.uwu +++ b/example/test.uwu @@ -3,5 +3,6 @@ hello_world "hello world main :str:cat( hello_world, - fibo:print(10) + fibo:print(10), + :nil:nil ) @@ -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) @@ -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 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(); +} |