-*~
\ No newline at end of file
+*~
+/src/linenoise.c
+/src/linenoise.h
#include <stdio.h>
+#include <histedit.h>
+
+#include "linenoise.h"
#include "types.h"
#include "eval.h"
#include "dict.h"
#include "parser.h"
#include "builtins.h"
+#include "sexpr.h"
-Sexpr* stepl(char* str, Sexpr* env) {
- Sexpr* toeval = parse(str);
-
-}
-
int main(int argc, char** argv) {
printf("makefile functional lol\n");
load_env(env);
// now do the loop, right?
char* input = NULL;
-
-
+ while(1) {
+ input = linenoise("> ");
+ if(input == NULL)
+ return 0;
+ linenoiseHistoryAdd(input);
+ Sexpr* in = parse(input);
+ Sexpr* out = eval(in, env);
+ printf(" - %s\n", sprint_sexpr(out));
+ linenoiseFree(input);
+ }
return 0;
}
strcpy(out, s->value.s);
return out;
}
+ /*
else if(s->type == FUN) {
out = malloc(6*sizeof(char));
strcpy(out, "<fun>");
strcpy(out, "<fexp>");
return out;
}
+ */
else if(s->type == UINT) {
nbytes = snprintf(NULL, 0, "%" PRIu64 "", s->value.u) + 1;
out = malloc(nbytes*sizeof(char));
typedef char* Symbol_t;
typedef void* Nil_t;
typedef void* Truth_t;
-//typedef uint64_t Builtin_t;
typedef enum Sexpr_Type {
- UINT, SYM, BUILTIN, NIL, T, CONS, FEXP, FUN
-} Sexpr_Type; // to be used rarely, mainly only in eval i think
+ UINT, SYM, BUILTIN, NIL, T, CONS
+} Sexpr_Type;
typedef struct Cons {
struct Sexpr* car;
uint64_t opcode;
} Builtin_t;
-typedef struct Closure {
- uint64_t opcode;
- uint64_t num_args;
- uint64_t len_args;
- struct Sexpr* arglist;
-} Closure_t;
-typedef Closure_t Fexpr_t;
-typedef Closure_t Fun_t;
typedef struct Sexpr {
Sexpr_Type type;
union {
- Fexpr_t x;
- Fun_t f;
uint64_t u;
Builtin_t b;
Symbol_t s;