aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAleksey Veresov <aleksey@veresov.pro>2021-01-02 19:39:59 +0300
committerAleksey Veresov <aleksey@veresov.pro>2021-01-02 19:39:59 +0300
commitcff0c84f6b14f37497ff22c54948380af64e8106 (patch)
tree2acf23d98b0f9681d5f42346230538aa684a527b /src
parent0c32a26c9a43b2d45968b9ac59b8916c1d4092d1 (diff)
downloadcsx-cff0c84f6b14f37497ff22c54948380af64e8106.tar
csx-cff0c84f6b14f37497ff22c54948380af64e8106.tar.xz
csx-cff0c84f6b14f37497ff22c54948380af64e8106.zip
It's alive.
Diffstat (limited to 'src')
-rw-r--r--src/csx.c24
1 files changed, 7 insertions, 17 deletions
diff --git a/src/csx.c b/src/csx.c
index abf94aa..7225792 100644
--- a/src/csx.c
+++ b/src/csx.c
@@ -24,7 +24,7 @@ typedef struct pair_data {
/* typedef char name_data; */
-typedef csx_base_data base_data;
+/* typedef csx_base_data base_data; */
/* typedef int num_data; */
@@ -70,9 +70,9 @@ static char *new_name(const char *name)
return res;
}
-static base_data *new_base(base_data base)
+static csx_base_data *new_base(csx_base_data base)
{
- base_data *res = new(type_base, sizeof(base_data));
+ csx_base_data *res = new(type_base, sizeof(csx_base_data));
*res = base;
return res;
}
@@ -133,7 +133,7 @@ static void *base_define(void *arg)
{
pair_data *res;
void *name = head(arg);
- void *value = head(tail(arg));
+ void *value = csx_eval(head(tail(arg)));
if (type(context) == type_null) {
void *nameval = new_pair(name, value);
context = new_pair(new_pair(nameval, null), null);
@@ -171,24 +171,12 @@ static void *base_is_name(void *arg)
return type(head(arg)) == type_name ? one : null;
}
-static void *base_is_base(void *arg)
-{
- arg = eval_each(arg);
- return type(head(arg)) == type_base ? one : null;
-}
-
static void *base_is_num(void *arg)
{
arg = eval_each(arg);
return type(head(arg)) == type_num ? one : null;
}
-static void *base_is_fn(void *arg)
-{
- arg = eval_each(arg);
- return type(head(arg)) == type_fn ? one : null;
-}
-
static void *base_sum(void *arg)
{
arg = eval_each(arg);
@@ -436,7 +424,7 @@ tailcall:
void *ops = tail(arg);
applycall:
if (type(fn) == type_base) {
- base_data *base = fn;
+ csx_base_data *base = (void *)fn;
if (*base == base_eval) {
ops = eval_each(ops);
arg = head(ops);
@@ -510,6 +498,8 @@ static void new_context()
base_define(csx_list(new_name("define"), new_base(base_define), 0));
base_define(csx_list(new_name("fn"), new_base(base_fn), 0));
base_define(csx_list(new_name("if"), new_base(base_if), 0));
+ base_define(csx_list(new_name("and"), new_base(base_and), 0));
+ base_define(csx_list(new_name("or"), new_base(base_or), 0));
}