Add primitive procedures to expression type

This commit is contained in:
2025-08-10 14:37:40 +01:00
parent 3f871d2b43
commit 472a682757
5 changed files with 55 additions and 2 deletions

View File

@@ -7,15 +7,21 @@
#include <stddef.h>
#include <stdint.h>
struct am;
struct store;
typedef struct {
char buf[MAX_SYMBOL_LEN];
size_t len;
} symbol_t;
typedef void (*prim_proc_t)(struct am *am, struct store *store);
typedef enum {
ATOM_TYPE_EMPTY_LIST,
ATOM_TYPE_INTEGER,
ATOM_TYPE_SYMBOL,
ATOM_TYPE_PRIM_PROC,
} atom_type_t;
typedef struct {
@@ -23,6 +29,7 @@ typedef struct {
union {
int64_t integer;
symbol_t symbol;
prim_proc_t prim_proc;
};
} atom_t;
@@ -40,12 +47,11 @@ typedef struct expr {
};
} expr_t;
struct store;
expr_t *expr_integer(struct store *store, int64_t value);
expr_t *expr_symbol(struct store *store, const symbol_t *symbol);
expr_t *expr_str_symbol(struct store *store, const char *str);
expr_t *expr_empty_list(struct store *store);
expr_t *expr_pair(struct store *store, expr_t *car, expr_t *cdr);
expr_t *expr_prim_proc(struct store *store, prim_proc_t prim_proc);
#endif