Commit 7b533df1abdc2f92441ba5bdbf539de8f8406eaa

Thomas de Grivel 2024-07-06T13:45:25

buf_parese_call_access

diff --git a/.ic3_history b/.ic3_history
index fe346ab..4a377e3 100644
--- a/.ic3_history
+++ b/.ic3_history
@@ -95,3 +95,5 @@ quote [a: 1, b: 2]
 quote [{:a, 1}, {:b, 2}]
 %C3.Operator{}
 %GL.Vertex{}
+123.456
+abc.def
diff --git a/libc3/buf_parse.c b/libc3/buf_parse.c
index 5d57726..8e24f9f 100644
--- a/libc3/buf_parse.c
+++ b/libc3/buf_parse.c
@@ -745,6 +745,44 @@ sw buf_parse_call_args_paren (s_buf *buf, s_call *dest)
   return r;
 }
 
+sw buf_parse_call_access (s_buf *buf, s_call *dest)
+{
+  sw r;
+  sw result = 0;
+  s_buf_save save;
+  s_tag *tag_sym;
+  s_call tmp = {0};
+  assert(buf);
+  assert(dest);
+  buf_save_init(buf, &save);
+  if (! call_init_op(&tmp)) {
+    r = -1;
+    goto clean;
+  }
+  tag_sym = &tmp.arguments->next.data.list->tag;
+  tmp.ident.module = &g_sym_C3;
+  tmp.ident.sym = &g_sym_access;
+  r = buf_parse_tag_primary(buf, &tmp.arguments->tag);
+  if (r <= 0)
+    goto clean;
+  result += r;
+  if ((r = buf_read_1(buf, ".")) <= 0)
+    goto restore;
+  result += r;
+  r = buf_parse_ident_sym(buf, &tag_sym->data.sym);
+  if (r <= 0)
+    goto restore;
+  result += r;
+  *dest = tmp;
+  r = result;
+  goto clean;
+ restore:
+  buf_save_restore_rpos(buf, &save);
+ clean:
+  buf_save_clean(buf, &save);
+  return r;
+}
+
 sw buf_parse_call_op (s_buf *buf, s_call *dest)
 {
   s_ident next_op;
@@ -3393,7 +3431,8 @@ sw buf_parse_tag (s_buf *buf, s_tag *dest)
       goto restore;
     result += r;
   }
-  if ((r = buf_parse_tag_call_op(buf, dest)) != 0 ||
+  if ((r = buf_parse_tag_call_access(buf, dest)) != 0 ||
+      (r = buf_parse_tag_call_op(buf, dest)) != 0 ||
       (r = buf_parse_tag_brackets(buf, dest)) != 0 ||
       (r = buf_parse_tag_primary(buf, dest)) != 0)
     goto end;
@@ -3464,6 +3503,16 @@ sw buf_parse_tag_call (s_buf *buf, s_tag *dest)
   return r;
 }
 
+sw buf_parse_tag_call_access (s_buf *buf, s_tag *dest)
+{
+  sw r;
+  assert(buf);
+  assert(dest);
+  if ((r = buf_parse_call_access(buf, &dest->data.call)) > 0)
+    dest->type = TAG_CALL;
+  return r;
+}
+
 sw buf_parse_tag_call_op (s_buf *buf, s_tag *dest)
 {
   sw r;
@@ -3694,8 +3743,8 @@ sw buf_parse_tag_primary (s_buf *buf, s_tag *dest)
       (r = buf_parse_tag_cfn(buf, dest)) != 0 ||
       (r = buf_parse_tag_fn(buf, dest)) != 0 ||
       (r = buf_parse_tag_struct(buf, dest)) != 0 ||
-      (r = buf_parse_tag_ident(buf, dest)) != 0 ||
       (r = buf_parse_tag_list(buf, dest)) != 0 ||
+      (r = buf_parse_tag_ident(buf, dest)) != 0 ||
       (r = buf_parse_tag_sym(buf, dest)) != 0)
     goto end;
   goto restore;
diff --git a/libc3/buf_parse.h b/libc3/buf_parse.h
index 7a3a20a..3768158 100644
--- a/libc3/buf_parse.h
+++ b/libc3/buf_parse.h
@@ -109,6 +109,7 @@ sw buf_parse_tag_array (s_buf *buf, s_tag *dest);
 sw buf_parse_tag_bool (s_buf *buf, s_tag *dest);
 sw buf_parse_tag_brackets (s_buf *buf, s_tag *dest);
 sw buf_parse_tag_call (s_buf *buf, s_tag *dest);
+sw buf_parse_tag_call_access (s_buf *buf, s_tag *dest);
 sw buf_parse_tag_call_op (s_buf *buf, s_tag *dest);
 sw buf_parse_tag_call_paren (s_buf *buf, s_tag *dest);
 sw buf_parse_tag_cfn (s_buf *buf, s_tag *dest);
diff --git a/libc3/sym.c b/libc3/sym.c
index 3b284b9..159199a 100644
--- a/libc3/sym.c
+++ b/libc3/sym.c
@@ -71,6 +71,7 @@ const s_sym g_sym_Uw              = {{{NULL},  2, {"Uw"}}};
 const s_sym g_sym_Uw_brackets     = {{{NULL},  4, {"Uw[]"}}};
 const s_sym g_sym_Var             = {{{NULL},  3, {"Var"}}};
 const s_sym g_sym_Void            = {{{NULL},  4, {"Void"}}};
+const s_sym g_sym_access          = {{{NULL},  6, {"access"}}};
 const s_sym g_sym_arity           = {{{NULL},  5, {"arity"}}};
 const s_sym g_sym_cast            = {{{NULL},  4, {"cast"}}};
 const s_sym g_sym_clean           = {{{NULL},  5, {"clean"}}};
@@ -344,6 +345,7 @@ void sym_init_g_sym (void)
   sym_register(&g_sym_Uw_brackets, NULL);
   sym_register(&g_sym_Var, NULL);
   sym_register(&g_sym_Void, NULL);
+  sym_register(&g_sym_access, NULL);
   sym_register(&g_sym_arity, NULL);
   sym_register(&g_sym_cast, NULL);
   sym_register(&g_sym_clean, NULL);
diff --git a/libc3/sym.h b/libc3/sym.h
index f3cd727..512d8e4 100644
--- a/libc3/sym.h
+++ b/libc3/sym.h
@@ -76,6 +76,7 @@ extern const s_sym g_sym_Uw;
 extern const s_sym g_sym_Uw_brackets;
 extern const s_sym g_sym_Var;
 extern const s_sym g_sym_Void;
+extern const s_sym g_sym_access;
 extern const s_sym g_sym_arity;
 extern const s_sym g_sym_cast;
 extern const s_sym g_sym_clean;