pebblisp/src/pebblisp.h

66 lines
1.9 KiB
C
Raw Normal View History

2016-04-18 04:25:36 -04:00
#ifndef PEBBLISP_H
#define PEBBLISP_H
2020-05-04 18:14:41 -04:00
#include "object.h"
#include "env.h"
2016-04-18 04:25:36 -04:00
#ifndef STANDALONE
#include <pebble.h>
#define printd(...) copySlice(NULL, NULL)
#endif
#ifdef DEBUG
#define printd(...) printf(__VA_ARGS__)
#else
#define printd(...) copySlice(NULL, NULL)
#endif
2016-04-18 04:25:36 -04:00
struct Slice {
const char *text;
2020-05-04 18:14:41 -04:00
char length;
2016-04-18 04:25:36 -04:00
};
typedef struct Result {
Object obj;
struct Slice *slices;
} Result;
2020-05-04 10:03:35 -04:00
Object eval(const Object *obj, struct Environment *env);
2016-04-18 04:25:36 -04:00
Result parse(struct Slice *slices);
Result readSeq(struct Slice *slices);
Object 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);
2020-05-05 13:42:28 -04:00
2020-05-05 19:21:54 -04:00
Object evalLambdaArgs(const Object *arg_forms);
2020-05-04 18:14:41 -04:00
// Slices
void copySlice(char * dest, struct Slice *src);
void debugSlice(struct Slice *s);
#define BASIC_OP(_name) \
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);
#undef BASIC_OP
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);
2020-10-29 11:23:35 -04:00
Object prepend(Object list, Object newElement, struct Environment *env);
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);
2020-10-28 18:08:03 -04:00
Object isNum(Object test, Object ignore, struct Environment *ignore2);
Object isString(Object test, Object ignore, struct Environment *ignore2);
2020-10-28 18:08:03 -04:00
2020-10-30 14:36:44 -04:00
Object print(Object p, Object ignore, struct Environment *ignore2);
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
2016-04-18 04:25:36 -04:00
#endif