aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOskari Timperi <oskari.timperi@iki.fi>2014-05-15 22:52:43 +0300
committerOskari Timperi <oskari.timperi@iki.fi>2014-05-15 22:52:43 +0300
commit06b32874034251d808394b66bcbdf12afe0f41b4 (patch)
tree62711f5e76bbe4d0c311f3c329ca755bc3ed67fd
parent043cddd93a65930c534f4170ed517bb1f76fd3ae (diff)
downloadlispish-06b32874034251d808394b66bcbdf12afe0f41b4.tar.gz
lispish-06b32874034251d808394b66bcbdf12afe0f41b4.zip
add eval functions that take env as argument (no env support yet)
-rw-r--r--eval.c20
-rw-r--r--eval.h9
2 files changed, 22 insertions, 7 deletions
diff --git a/eval.c b/eval.c
index 5c8d314..1fd6a6a 100644
--- a/eval.c
+++ b/eval.c
@@ -73,10 +73,20 @@ static int atom_cmp(struct list *a, struct list *b)
struct list *eval(struct list *list)
{
- if (!IS_LIST(list))
- return list;
+ return eval_env(list, NULL);
+}
+
+struct list *eval_str(const char *str)
+{
+ return eval_str_env(str, NULL);
+}
+
+struct list *eval_env(struct list *expr, struct list *env)
+{
+ if (!IS_LIST(expr))
+ return expr;
- struct list *l = LIST_GET_ATOM(list)->list;
+ struct list *l = LIST_GET_ATOM(expr)->list;
if (IS_SYM(l))
{
@@ -227,12 +237,12 @@ struct list *eval(struct list *list)
return list_append(NULL, &nil_atom);
}
-struct list *eval_str(const char *str)
+struct list *eval_str_env(const char *expr, struct list *env)
{
struct list *result;
int pos = 0;
- result = eval(parse(str, &pos));
+ result = eval_env(parse(expr, &pos), env);
return result;
}
diff --git a/eval.h b/eval.h
index d22355b..eab225d 100644
--- a/eval.h
+++ b/eval.h
@@ -1,7 +1,12 @@
#ifndef EVAL_H
#define EVAL_H
-struct list *eval(struct list *list);
-struct list *eval_str(const char *str);
+struct list;
+
+struct list *eval(struct list *expr);
+struct list *eval_str(const char *expr);
+
+struct list *eval_env(struct list *expr, struct list *env);
+struct list *eval_str_env(const char *expr, struct list *env);
#endif