aboutsummaryrefslogtreecommitdiff
path: root/c
diff options
context:
space:
mode:
authorJoel Martin <github@martintribe.org>2014-04-23 21:59:50 -0500
committerJoel Martin <github@martintribe.org>2014-04-23 21:59:50 -0500
commit6301e0b6374cecc5599665be14d6ddc6a31ce1e8 (patch)
treedbf1dc2ff6c682fd87c72a7907e7f6e59c8d4c03 /c
parent89bd4de1e2704c1bc562788b2c5e4fc08b71a538 (diff)
downloadmal-6301e0b6374cecc5599665be14d6ddc6a31ce1e8.tar.gz
mal-6301e0b6374cecc5599665be14d6ddc6a31ce1e8.zip
All: TCO let* and quasiquote.
Diffstat (limited to 'c')
-rw-r--r--c/step5_tco.c4
-rw-r--r--c/step6_file.c4
-rw-r--r--c/step7_quote.c7
-rw-r--r--c/step8_macros.c7
-rw-r--r--c/step9_interop.c7
-rw-r--r--c/stepA_more.c7
6 files changed, 26 insertions, 10 deletions
diff --git a/c/step5_tco.c b/c/step5_tco.c
index 3a46bd2..edca21b 100644
--- a/c/step5_tco.c
+++ b/c/step5_tco.c
@@ -101,7 +101,9 @@ MalVal *EVAL(MalVal *ast, Env *env) {
assert_type(key, MAL_SYMBOL, "let* bind to non-symbol");
env_set(let_env, key->val.string, EVAL(val, let_env));
}
- return EVAL(a2, let_env);
+ ast = a2;
+ env = let_env;
+ // Continue loop
} else if ((a0->type & MAL_SYMBOL) &&
strcmp("do", a0->val.string) == 0) {
//g_print("eval apply do\n");
diff --git a/c/step6_file.c b/c/step6_file.c
index d73acfe..9ff62a9 100644
--- a/c/step6_file.c
+++ b/c/step6_file.c
@@ -101,7 +101,9 @@ MalVal *EVAL(MalVal *ast, Env *env) {
assert_type(key, MAL_SYMBOL, "let* bind to non-symbol");
env_set(let_env, key->val.string, EVAL(val, let_env));
}
- return EVAL(a2, let_env);
+ ast = a2;
+ env = let_env;
+ // Continue loop
} else if ((a0->type & MAL_SYMBOL) &&
strcmp("do", a0->val.string) == 0) {
//g_print("eval apply do\n");
diff --git a/c/step7_quote.c b/c/step7_quote.c
index b66bde6..d0d1d3d 100644
--- a/c/step7_quote.c
+++ b/c/step7_quote.c
@@ -128,7 +128,9 @@ MalVal *EVAL(MalVal *ast, Env *env) {
assert_type(key, MAL_SYMBOL, "let* bind to non-symbol");
env_set(let_env, key->val.string, EVAL(val, let_env));
}
- return EVAL(a2, let_env);
+ ast = a2;
+ env = let_env;
+ // Continue loop
} else if ((a0->type & MAL_SYMBOL) &&
strcmp("quote", a0->val.string) == 0) {
//g_print("eval apply quote\n");
@@ -137,7 +139,8 @@ MalVal *EVAL(MalVal *ast, Env *env) {
strcmp("quasiquote", a0->val.string) == 0) {
//g_print("eval apply quasiquote\n");
MalVal *a1 = _nth(ast, 1);
- return EVAL(quasiquote(a1), env);
+ ast = quasiquote(a1);
+ // Continue loop
} else if ((a0->type & MAL_SYMBOL) &&
strcmp("do", a0->val.string) == 0) {
//g_print("eval apply do\n");
diff --git a/c/step8_macros.c b/c/step8_macros.c
index e7aebf2..3558caf 100644
--- a/c/step8_macros.c
+++ b/c/step8_macros.c
@@ -152,7 +152,9 @@ MalVal *EVAL(MalVal *ast, Env *env) {
assert_type(key, MAL_SYMBOL, "let* bind to non-symbol");
env_set(let_env, key->val.string, EVAL(val, let_env));
}
- return EVAL(a2, let_env);
+ ast = a2;
+ env = let_env;
+ // Continue loop
} else if ((a0->type & MAL_SYMBOL) &&
strcmp("quote", a0->val.string) == 0) {
//g_print("eval apply quote\n");
@@ -161,7 +163,8 @@ MalVal *EVAL(MalVal *ast, Env *env) {
strcmp("quasiquote", a0->val.string) == 0) {
//g_print("eval apply quasiquote\n");
MalVal *a1 = _nth(ast, 1);
- return EVAL(quasiquote(a1), env);
+ ast = quasiquote(a1);
+ // Continue loop
} else if ((a0->type & MAL_SYMBOL) &&
strcmp("defmacro!", a0->val.string) == 0) {
//g_print("eval apply defmacro!\n");
diff --git a/c/step9_interop.c b/c/step9_interop.c
index f248c55..6ba594e 100644
--- a/c/step9_interop.c
+++ b/c/step9_interop.c
@@ -153,7 +153,9 @@ MalVal *EVAL(MalVal *ast, Env *env) {
assert_type(key, MAL_SYMBOL, "let* bind to non-symbol");
env_set(let_env, key->val.string, EVAL(val, let_env));
}
- return EVAL(a2, let_env);
+ ast = a2;
+ env = let_env;
+ // Continue loop
} else if ((a0->type & MAL_SYMBOL) &&
strcmp("quote", a0->val.string) == 0) {
//g_print("eval apply quote\n");
@@ -162,7 +164,8 @@ MalVal *EVAL(MalVal *ast, Env *env) {
strcmp("quasiquote", a0->val.string) == 0) {
//g_print("eval apply quasiquote\n");
MalVal *a1 = _nth(ast, 1);
- return EVAL(quasiquote(a1), env);
+ ast = quasiquote(a1);
+ // Continue loop
} else if ((a0->type & MAL_SYMBOL) &&
strcmp("defmacro!", a0->val.string) == 0) {
//g_print("eval apply defmacro!\n");
diff --git a/c/stepA_more.c b/c/stepA_more.c
index de49568..b4b7431 100644
--- a/c/stepA_more.c
+++ b/c/stepA_more.c
@@ -153,7 +153,9 @@ MalVal *EVAL(MalVal *ast, Env *env) {
assert_type(key, MAL_SYMBOL, "let* bind to non-symbol");
env_set(let_env, key->val.string, EVAL(val, let_env));
}
- return EVAL(a2, let_env);
+ ast = a2;
+ env = let_env;
+ // Continue loop
} else if ((a0->type & MAL_SYMBOL) &&
strcmp("quote", a0->val.string) == 0) {
//g_print("eval apply quote\n");
@@ -162,7 +164,8 @@ MalVal *EVAL(MalVal *ast, Env *env) {
strcmp("quasiquote", a0->val.string) == 0) {
//g_print("eval apply quasiquote\n");
MalVal *a1 = _nth(ast, 1);
- return EVAL(quasiquote(a1), env);
+ ast = quasiquote(a1);
+ // Continue loop
} else if ((a0->type & MAL_SYMBOL) &&
strcmp("defmacro!", a0->val.string) == 0) {
//g_print("eval apply defmacro!\n");