refactor: spread across files
This commit is contained in:
+22
@@ -0,0 +1,22 @@
|
||||
#include "lisp.h"
|
||||
|
||||
Node *lisp_function_addition(Nodes *args) {
|
||||
if (args->count != 2) {
|
||||
printf("'+' expects two arguments!\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (args->items[0].kind != NODE_KIND_NUMBER ||
|
||||
args->items[1].kind != NODE_KIND_NUMBER) {
|
||||
printf("'+' can only add numbers, you specified something else!\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Node *node = malloc(sizeof(Node));
|
||||
node->kind = NODE_KIND_NUMBER;
|
||||
|
||||
intptr_t a = args->items[0].as_number;
|
||||
intptr_t b = args->items[1].as_number;
|
||||
node->as_number = a + b;
|
||||
return node;
|
||||
}
|
||||
Reference in New Issue
Block a user