pcm4/stage2/include/lisp.h

40 lines
902 B
C++

#pragma once
#include <cstdint>
#define SYMBOL_TABLE_SIZE 2048
typedef char * symbol_t;
#define TYPE_SYMBOL 1
#define TYPE_NUMBER 2
#define TYPE_STRING 3
#define TYPE_FLOAT 4
#define TYPE_LIST 5
#define symbolp(x) (x->type == TYPE_SYMBOL)
#define numberp(x) (x->type == TYPE_NUMBER)
#define stringp(x) (x->type == TYPE_STRING)
#define floatp(x) (x->type == TYPE_FLOAT)
#define listp(x) (x->type == TYPE_LIST)
typedef struct cell {
uint8_t type;
union {
struct {
cell *head;
cell *tail;
};
struct {
union {
symbol_t sym;
int num;
char *str;
float fnum;
};
};
};
} cell_t;