Define expression data type

This commit is contained in:
2025-08-09 17:00:10 +01:00
parent 00d1961d36
commit 23bbbea755

View File

@@ -3,11 +3,41 @@
#define MAX_SYMBOL_LEN 32U
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
typedef struct {
char buf[MAX_SYMBOL_LEN];
size_t len;
} symbol_t;
typedef enum {
ATOM_TYPE_EMPTY_LIST,
ATOM_TYPE_INTEGER,
ATOM_TYPE_SYMBOL,
} atom_type_t;
typedef struct {
atom_type_t type;
union {
int64_t integer;
symbol_t symbol;
};
} atom_t;
struct expr;
typedef struct {
struct expr *car, *cdr;
} pair_t;
typedef struct expr {
bool is_atom;
union {
atom_t atom;
pair_t pair;
};
} expr_t;
#endif