2016-04-18 04:25:36 -04:00
|
|
|
#ifndef PEBBLISP_H
|
|
|
|
#define PEBBLISP_H
|
|
|
|
|
2020-05-10 13:51:33 -04:00
|
|
|
#include "env.h"
|
2022-01-07 16:55:03 -05:00
|
|
|
#include "object.h"
|
2020-05-06 00:47:14 -04:00
|
|
|
|
2016-04-18 04:25:36 -04:00
|
|
|
struct Slice {
|
2022-01-07 16:55:03 -05:00
|
|
|
const char* text;
|
2022-03-15 21:43:53 -04:00
|
|
|
unsigned char length;
|
2016-04-18 04:25:36 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct Result {
|
|
|
|
Object obj;
|
2022-01-07 16:55:03 -05:00
|
|
|
struct Slice* slices;
|
2016-04-18 04:25:36 -04:00
|
|
|
} Result;
|
|
|
|
|
2022-01-07 16:55:03 -05:00
|
|
|
Object eval(const Object* obj, struct Environment* env);
|
|
|
|
|
|
|
|
Result parse(struct Slice* slices);
|
|
|
|
|
|
|
|
Result readSeq(struct Slice* slices);
|
|
|
|
|
2022-03-15 15:26:01 -04:00
|
|
|
Result parseAtom(struct Slice* slice);
|
2022-01-07 16:55:03 -05:00
|
|
|
|
|
|
|
Object parseEval(const char* input, struct Environment* env);
|
2020-05-05 13:42:28 -04:00
|
|
|
|
2022-01-07 16:55:03 -05:00
|
|
|
void evalForms(Object* destList, const Object* src, struct Environment* env);
|
|
|
|
|
|
|
|
void copySlice(char* dest, struct Slice* src);
|
|
|
|
|
2022-03-16 16:36:04 -04:00
|
|
|
Object evalLambdaArgs(const Object* arg_forms, struct Environment* env);
|
2022-03-14 23:46:20 -04:00
|
|
|
Object listEvalLambda(Object* lambda, const Object* remaining,
|
|
|
|
struct Environment* env);
|
2020-05-05 19:21:54 -04:00
|
|
|
|
2020-05-04 18:14:41 -04:00
|
|
|
// Slices
|
2022-01-07 16:55:03 -05:00
|
|
|
void copySlice(char* dest, struct Slice* src);
|
|
|
|
|
|
|
|
void debugSlice(struct Slice* s);
|
2020-05-04 18:14:41 -04:00
|
|
|
|
2020-05-14 23:51:59 -04:00
|
|
|
#define BASIC_OP(_name) \
|
2022-01-07 16:55:03 -05:00
|
|
|
Object _name(Object obj1, Object obj2, struct Environment *env);
|
|
|
|
|
|
|
|
BASIC_OP(add);
|
|
|
|
|
|
|
|
BASIC_OP(sub);
|
|
|
|
|
|
|
|
BASIC_OP(mul);
|
|
|
|
|
|
|
|
BASIC_OP(dvi);
|
|
|
|
|
|
|
|
BASIC_OP(mod);
|
|
|
|
|
|
|
|
BASIC_OP(equ);
|
|
|
|
|
|
|
|
BASIC_OP(gth);
|
|
|
|
|
|
|
|
BASIC_OP(lth);
|
|
|
|
|
|
|
|
BASIC_OP(and);
|
|
|
|
|
|
|
|
BASIC_OP(or);
|
2020-05-14 23:51:59 -04:00
|
|
|
#undef BASIC_OP
|
2020-08-02 16:16:26 -04:00
|
|
|
|
2022-01-07 16:55:03 -05:00
|
|
|
Object catObjects(const Object obj1, const Object obj2,
|
|
|
|
struct Environment* env);
|
|
|
|
|
|
|
|
Object filter(Object obj1, Object obj2, struct Environment* env);
|
|
|
|
|
|
|
|
Object append(Object list, Object newElement, struct Environment* env);
|
|
|
|
|
|
|
|
Object prepend(Object list, Object newElement, struct Environment* env);
|
|
|
|
|
2022-03-16 16:36:04 -04:00
|
|
|
Object reduce(Object listInitial, Object func, struct Environment* env);
|
|
|
|
|
2022-01-07 16:55:03 -05:00
|
|
|
Object at(Object index, Object list, struct Environment* env);
|
|
|
|
|
|
|
|
Object rest(Object list, Object ignore, struct Environment* env);
|
|
|
|
|
|
|
|
Object reverse(Object _list, Object ignore, struct Environment* ignore2);
|
|
|
|
|
|
|
|
Object isNum(Object test, Object ignore, struct Environment* ignore2);
|
2020-05-10 13:51:33 -04:00
|
|
|
|
2022-03-16 16:36:04 -04:00
|
|
|
Object isList(Object test, Object ignore, struct Environment* ignore2);
|
|
|
|
|
2022-01-07 16:55:03 -05:00
|
|
|
Object isString(Object test, Object ignore, struct Environment* ignore2);
|
2020-10-28 18:08:03 -04:00
|
|
|
|
2022-01-07 16:55:03 -05:00
|
|
|
Object isErr(Object test, Object ignore, struct Environment* ignore2);
|
2021-12-10 16:33:59 -05:00
|
|
|
|
2022-01-07 16:55:03 -05:00
|
|
|
Object charAt(Object string, Object at, struct Environment* ignore);
|
|
|
|
|
|
|
|
Object charVal(Object test, Object ignore, struct Environment* ignore2);
|
|
|
|
|
|
|
|
Object print(Object p, Object ignore, struct Environment* ignore2);
|
|
|
|
|
|
|
|
Object pChar(Object c, Object i1, struct Environment* i2);
|
|
|
|
|
|
|
|
Object printEnvO(Object i1, Object i2, struct Environment* env);
|
|
|
|
|
|
|
|
Object parseEvalO(Object text, Object ignore, struct Environment* env);
|
2020-10-30 14:36:44 -04:00
|
|
|
|
2022-03-15 15:26:01 -04:00
|
|
|
Object possessive(Object structo, Object field, struct Environment* env);
|
|
|
|
|
2020-11-02 16:30:21 -05:00
|
|
|
#ifdef STANDALONE
|
2022-01-07 16:55:03 -05:00
|
|
|
|
|
|
|
Object takeInput(Object i1, Object i2, struct Environment* i3);
|
|
|
|
|
|
|
|
Object systemCall(Object call, Object _, struct Environment* i3);
|
|
|
|
|
|
|
|
Object loadFile(Object filename, Object _, struct Environment* env);
|
|
|
|
|
2022-03-14 23:46:20 -04:00
|
|
|
Object startServer(Object path, Object textFunc, struct Environment* env);
|
2022-03-15 23:22:28 -04:00
|
|
|
Object addGetRoute(Object path, Object textFunc, struct Environment* env);
|
|
|
|
Object addPostRoute(Object path, Object textFunc, struct Environment* env);
|
2022-03-14 23:46:20 -04:00
|
|
|
|
2020-11-02 16:30:21 -05:00
|
|
|
#endif
|
|
|
|
|
2016-04-18 04:25:36 -04:00
|
|
|
#endif
|