Commit 69d6993c0efcc636d1f97c5f5e99f547fe31a4df

Thomas de Grivel 2022-12-03T19:34:23

wip fn

diff --git a/.gitignore b/.gitignore
index dd85be9..cc7fb82 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,7 +2,13 @@
 c3-*/
 c3-*.tar.gz
 c3c/c3c
+c3c/c3c.asan
+c3c/c3c.cov
+c3c/c3c.debug
 c3s/c3s
+c3s/c3s.asan
+c3s/c3s.cov
+c3s/c3s.debug
 config.mk
 *.core
 *.css
diff --git a/libc3/arg.c b/libc3/arg.c
index 46b322d..96f0d7d 100644
--- a/libc3/arg.c
+++ b/libc3/arg.c
@@ -33,11 +33,10 @@ void arg_delete_all (s_arg *arg)
     arg = arg_delete(arg);
 }
 
-s_arg * arg_init (s_arg *arg, s_arg *next)
+s_arg * arg_init (s_arg *arg)
 {
   assert(arg);
   bzero(arg, sizeof(s_arg));
-  arg->next = next;
   return arg;
 }
 
diff --git a/libc3/arg.h b/libc3/arg.h
index b14ea20..e8906c9 100644
--- a/libc3/arg.h
+++ b/libc3/arg.h
@@ -17,7 +17,7 @@
 #include "types.h"
 
 /* stack-allocation compatible functions */
-s_arg * arg_init (s_arg *arg, s_arg *next);
+s_arg * arg_init (s_arg *arg);
 
 /* constructors */
 s_arg * arg_new ();
diff --git a/libc3/buf_parse.c b/libc3/buf_parse.c
index 5432c1b..20ecfab 100644
--- a/libc3/buf_parse.c
+++ b/libc3/buf_parse.c
@@ -493,17 +493,40 @@ sw buf_parse_fn_args (s_buf *buf, s_arg **dest)
   sw r;
   sw result = 0;
   s_buf_save save;
-  s_tag tag;
+  const s_sym *sym;
   assert(buf);
   assert(dest);
   buf_save_init(buf, &save);
   if ((r = buf_read_1(buf, "(")) < 0)
     goto restore;
-  while (1) {
-    if ((r = buf_parse_tag(buf, &tag)) < 0)
+  result += r;
+  if ((r = buf_ignore_spaces(buf)) < 0)
+    goto restore;
+  result += r;
+  r = 0;
+  while (! r) {
+    if ((r = buf_parse_sym(buf, &sym)) <= 0)
+      goto restore;
+    result += r;
+    *dest = arg_new();
+    (*dest)->name = sym;
+    dest = &(*dest)->next;
+    if ((r = buf_ignore_spaces(buf)) < 0)
+      goto restore;
+    result += r;
+    if ((r = buf_read_1(buf, ",")) < 0)
+      goto restore;
+    result += r;
+    if (r > 0) {
+      if ((r = buf_ignore_spaces(buf)) < 0)
+        goto restore;
+      result += r;
+      continue;
+    }
+    if ((r = buf_read_1(buf, ")")) < 0)
       goto restore;
     result += r;
-    if ((r = buf_
+  }
   r = result;
   goto clean;
  restore:
diff --git a/libc3/eval.c b/libc3/eval.c
index 62e1eab..97572d8 100644
--- a/libc3/eval.c
+++ b/libc3/eval.c
@@ -56,7 +56,7 @@ s_tag * eval_call_fn (s_env *env, s_call *call, s_tag *dest)
     return NULL;
   }
   env->frame = &frame;
-  eval_progn(env, fn->program, dest);
+  eval_progn(env, fn->algo, dest);
   env->frame = frame_clean(&frame);
   return dest;
 }