starting lisp core

This commit is contained in:
2023-10-01 16:36:22 -07:00
parent 25c76c67ce
commit 21ac50c94a
7 changed files with 147 additions and 52 deletions

39
stage2/include/lisp.h Normal file
View File

@@ -0,0 +1,39 @@
#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;

10
stage2/include/memory.h Normal file
View File

@@ -0,0 +1,10 @@
#pragma once
#include <cstddef>
// memory.h contains the memory management code for the system.
// right now, it uses the stdlib malloc/free directly.
//
// TODO(kyle): switch to arena memory.
void *sys_malloc(size_t);
void sys_free(void *);

View File

@@ -0,0 +1,8 @@
#pragma once
namespace neopxl {
void start();
bool blink(bool);
} // namespace neopxl