pebblisp/src/pebblisp.h

67 lines
1.8 KiB
C

#ifndef PEBBLISP_H
#define PEBBLISP_H
#include <stdio.h>
#include "env.h"
#include "object.h"
#define static_assert _Static_assert
#define array_length(_array) (sizeof(_array) / sizeof((_array)[0]))
#define fn(_name, _docs, ...) static const char * const _name ## Doc = _docs; \
static const char * const _name ## Tests[] = {__VA_ARGS__}; \
static_assert(array_length(_name ## Tests) % 2 == 0, "Array of test strings must have exactly one expected result for each test."); \
Object _name
#define fnn(_name, _symbol, _docs, ...)\
static const char * const _name ## Doc = _docs;\
static const char * const _name ## Symbol = _symbol;\
static const char * const _name ## Tests[] = {__VA_ARGS__}; \
static_assert(array_length(_name ## Tests) % 2 == 0, "Array of test strings must have exactly one expected result for each test."); \
Object _name
struct Slice {
const char* text;
unsigned char length;
int lineNumber;
};
typedef struct Result {
Object obj;
struct Slice* slices;
} Result;
Object eval(const Object* obj, struct Environment* env);
Result parse(struct Slice* slices);
Result readSeq(struct Slice* slices);
Result parseAtom(struct Slice* slice);
Object parseEval(const char* input, struct Environment* env);
void evalForms(Object* destList, const Object* src, struct Environment* env);
void copySlice(char* dest, struct Slice* src);
Object evalLambdaArgs(const Object* arg_forms, struct Environment* env);
Object listEvalLambda(Object* lambda, const Object* remaining,
struct Environment* env);
void debugSlice(struct Slice* s);
Object simpleFuncEval(Object func, Object arg1, Object arg2, struct Environment* env);
#ifdef STANDALONE
int _readFile(FILE* input, struct Environment* env);
int readFile(const char* filename, struct Environment* env);
#endif /* STANDALONE */
#endif