refactor: special forms

This commit is contained in:
2026-07-25 00:25:21 +02:00
parent 729f07655a
commit 0e134957af
4 changed files with 263 additions and 227 deletions
+17 -17
View File
@@ -26,17 +26,17 @@
#define func_arithmetic(name, operator) \
func_arithmetic_ex(name, operator, #operator)
func_arithmetic(lisp_function_add, +);
func_arithmetic(lisp_function_sub, -);
func_arithmetic(lisp_function_div, /);
func_arithmetic(lisp_function_mul, *);
func_arithmetic_ex(lisp_function_eq, ==, "=");
func_arithmetic(lisp_function_lt, <);
func_arithmetic(lisp_function_gt, >);
func_arithmetic(lisp_function_lt_eq, <=);
func_arithmetic(lisp_function_gt_eq, >=);
func_arithmetic(builtin_add, +);
func_arithmetic(builtin_sub, -);
func_arithmetic(builtin_div, /);
func_arithmetic(builtin_mul, *);
func_arithmetic_ex(builtin_eq, ==, "=");
func_arithmetic(builtin_lt, <);
func_arithmetic(builtin_gt, >);
func_arithmetic(builtin_lt_eq, <=);
func_arithmetic(builtin_gt_eq, >=);
int lisp_function_println(Nodes args, Scopes *scopes, Node *result) {
int builtin_println(Nodes args, Scopes *scopes, Node *result) {
if (args.count != 1) {
printf("'println' expects one argument!\n");
return 1;
@@ -52,7 +52,7 @@ int lisp_function_println(Nodes args, Scopes *scopes, Node *result) {
return 0;
}
int lisp_function_list(Nodes args, Scopes *scopes, Node *result) {
int builtin_list(Nodes args, Scopes *scopes, Node *result) {
UNUSED(scopes);
Nodes *nodes = malloc(sizeof(Nodes));
@@ -68,7 +68,7 @@ int lisp_function_list(Nodes args, Scopes *scopes, Node *result) {
return 0;
}
int lisp_function_append(Nodes args, Scopes *scopes, Node *result) {
int builtin_append(Nodes args, Scopes *scopes, Node *result) {
UNUSED(scopes);
if (args.count != 2) {
@@ -100,7 +100,7 @@ int lisp_function_append(Nodes args, Scopes *scopes, Node *result) {
return 0;
}
int lisp_function_length(Nodes args, Scopes *scopes, Node *result) {
int builtin_length(Nodes args, Scopes *scopes, Node *result) {
UNUSED(scopes);
if (args.count != 1) {
@@ -118,7 +118,7 @@ int lisp_function_length(Nodes args, Scopes *scopes, Node *result) {
return 0;
}
int lisp_function_isnull(Nodes args, Scopes *scopes, Node *result) {
int builtin_isnull(Nodes args, Scopes *scopes, Node *result) {
UNUSED(scopes);
if (args.count != 1) {
@@ -136,7 +136,7 @@ int lisp_function_isnull(Nodes args, Scopes *scopes, Node *result) {
return 0;
}
int lisp_function_builtins(Nodes args, Scopes *scopes, Node *result) {
int builtin_builtins(Nodes args, Scopes *scopes, Node *result) {
if (args.count != 0) {
printf("'builtins' expects no arguments!\n");
return 1;
@@ -158,7 +158,7 @@ int lisp_function_builtins(Nodes args, Scopes *scopes, Node *result) {
return 0;
}
int lisp_function_floor(Nodes args, Scopes *scopes, Node *result) {
int builtin_floor(Nodes args, Scopes *scopes, Node *result) {
UNUSED(scopes);
if (args.count != 1) {
@@ -176,7 +176,7 @@ int lisp_function_floor(Nodes args, Scopes *scopes, Node *result) {
return 0;
}
int lisp_function_ceil(Nodes args, Scopes *scopes, Node *result) {
int builtin_ceil(Nodes args, Scopes *scopes, Node *result) {
UNUSED(scopes);
if (args.count != 1) {