Commit e948a5928f339cbc08f651f97d16e6b674407edc

Thomas de Grivel 2023-08-01T17:56:42

wip ic3

diff --git a/lib/c3/0.1/c3.facts b/lib/c3/0.1/c3.facts
index 9732d2c..6644589 100644
--- a/lib/c3/0.1/c3.facts
+++ b/lib/c3/0.1/c3.facts
@@ -66,11 +66,9 @@ add {C3.>, :operator_associativity, :left}
 add {C3.!, :arity, 1}
 add {C3.!, :cfn, cfn :bool "tag_not" (:tag)}
 add {C3.!, :is_a, :operator}
-add {C3.!, :operator_precedence, 4}
 add {C3._"()", :arity, 1}
 add {C3._"()", :cfn, cfn :tag "tag_paren" (:tag)}
 add {C3._"()", :is_a, :operator}
-add {C3._"()", :operator_precedence, 4}
 add {C3.&&, :arity, 2}
 add {C3.&&, :cfn, cfn :bool "tag_and" (:tag, :tag)}
 add {C3.&&, :is_a, :operator}
diff --git a/libc3/buf_inspect.c b/libc3/buf_inspect.c
index bce8758..6c0e593 100644
--- a/libc3/buf_inspect.c
+++ b/libc3/buf_inspect.c
@@ -305,6 +305,13 @@ sw buf_inspect_call_op (s_buf *buf, const s_call *call, s8 op_precedence)
   return result;
 }
 
+sw buf_inspect_call_op_unary (s_buf *buf, const s_call *call)
+{
+  (void) buf;
+  (void) call;
+  return 0;
+}
+
 sw buf_inspect_call_args (s_buf *buf, const s_list *args)
 {
   sw r;
diff --git a/libc3/buf_inspect.h b/libc3/buf_inspect.h
index de5ee62..c5557f5 100644
--- a/libc3/buf_inspect.h
+++ b/libc3/buf_inspect.h
@@ -57,6 +57,7 @@ sw buf_inspect_call (s_buf *buf, const s_call *call);
 sw buf_inspect_call_args (s_buf *buf, const s_list *args);
 sw buf_inspect_call_op (s_buf *buf, const s_call *call,
                         s8 op_precedence);
+sw buf_inspect_call_op_unary (s_buf *buf, const s_call *call);
 sw buf_inspect_call_size (const s_call *call);
 sw buf_inspect_cfn (s_buf *buf, const s_cfn *cfn);
 sw buf_inspect_cfn_size (const s_cfn *cfn);
diff --git a/libc3/buf_parse.c b/libc3/buf_parse.c
index 7c34e4a..16a881d 100644
--- a/libc3/buf_parse.c
+++ b/libc3/buf_parse.c
@@ -2204,17 +2204,16 @@ sw buf_parse_tag_primary (s_buf *buf, s_tag *dest)
       goto restore;
     result += r;
   }
-  if ((r = buf_parse_tag_array(buf, dest)) != 0 ||
-      (r = buf_parse_tag_call(buf, dest)) != 0 ||
-      (r = buf_parse_tag_call_paren(buf, dest)) != 0 ||
-      (r = buf_parse_tag_call_op_unary(buf, dest)) != 0 ||
-      (r = buf_parse_tag_bool(buf, dest)) != 0)
-    goto end;
   if ((r = buf_parse_tag_integer(buf, dest)) != 0) {
     tag_integer_reduce(dest);
     goto end;
   }
-  if ((r = buf_parse_tag_character(buf, dest)) != 0 ||
+  if ((r = buf_parse_tag_array(buf, dest)) != 0 ||
+      (r = buf_parse_tag_call(buf, dest)) != 0 ||
+      (r = buf_parse_tag_call_paren(buf, dest)) != 0 ||
+      (r = buf_parse_tag_call_op_unary(buf, dest)) != 0 ||
+      (r = buf_parse_tag_bool(buf, dest)) != 0 ||
+      (r = buf_parse_tag_character(buf, dest)) != 0 ||
       (r = buf_parse_tag_str(buf, dest)) != 0 ||
       (r = buf_parse_tag_tuple(buf, dest)) != 0 ||
       (r = buf_parse_tag_quote(buf, dest)) != 0 ||
diff --git a/test/facts_test.c b/test/facts_test.c
index c1ecef8..22c5400 100644
--- a/test/facts_test.c
+++ b/test/facts_test.c
@@ -436,8 +436,8 @@ TEST_CASE(facts_open_file)
     ":b",
     "B",
     "b",
-    "(())",
-    "((()), ())",
+    "(() | ())",
+    "((() | ()), ())",
     "{:b, :b}",
     "{{:b, :b}, {:c, :d}}",
     "{b, b}",
diff --git a/test/facts_test_open_file.1.expected.facts b/test/facts_test_open_file.1.expected.facts
index ad96522..0c95440 100644
--- a/test/facts_test_open_file.1.expected.facts
+++ b/test/facts_test_open_file.1.expected.facts
@@ -50,8 +50,8 @@ add {"b", "b", "b"}
 add {:b, :b, :b}
 add {B, B, B}
 add {b, b, b}
-add {(()), (()), (())}
-add {((()), ()), ((()), ()), ((()), ())}
+add {(() | ()), (() | ()), (() | ())}
+add {((() | ()), ()), ((() | ()), ()), ((() | ()), ())}
 add {{:b, :b}, {:b, :b}, {:b, :b}}
 add {{{:b, :b}, {:c, :d}}, {{:b, :b}, {:c, :d}}, {{:b, :b}, {:c, :d}}}
 add {{b, b}, {b, b}, {b, b}}
diff --git a/test/facts_test_open_file.2.facts b/test/facts_test_open_file.2.facts
new file mode 100644
index 0000000..f1449ea
--- /dev/null
+++ b/test/facts_test_open_file.2.facts
@@ -0,0 +1,48 @@
+%{module: C3.Facts.Dump,
+  version: 1}
+add {a, a, a}
+add {-18446744073709551616, -18446744073709551616, -18446744073709551616}
+add {18446744073709551616, 18446744073709551616, 18446744073709551616}
+add {-4294967296, -4294967296, -4294967296}
+add {-65536, -65536, -65536}
+add {-256, -256, -256}
+add {-10, -10, -10}
+add {-1, -1, -1}
+add {0, 0, 0}
+add {1, 1, 1}
+add {10, 10, 10}
+add {256, 256, 256}
+add {65536, 65536, 65536}
+add {4294967296, 4294967296, 4294967296}
+add {(), (), ()}
+add {((), ()), ((), ()), ((), ())}
+add {"a", "a", "a"}
+add {A, A, A}
+add {:a, :a, :a}
+add {{a, b}, {a, b}, {a, b}}
+add {{:a, :b}, {:a, :b}, {:a, :b}}
+add {{{a, b}, {c, d}}, {{a, b}, {c, d}}, {{a, b}, {c, d}}}
+add {{{:a, :b}, {:c, :d}}, {{:a, :b}, {:c, :d}}, {{:a, :b}, {:c, :d}}}
+add {b, b, b}
+add {-18446744073709551617, -18446744073709551617, -18446744073709551617}
+add {18446744073709551617, 18446744073709551617, 18446744073709551617}
+add {-4294967297, -4294967297, -4294967297}
+add {-65537, -65537, -65537}
+add {-257, -257, -257}
+add {-11, -11, -11}
+add {-2, -2, -2}
+add {2, 2, 2}
+add {3, 3, 3}
+add {11, 11, 11}
+add {257, 257, 257}
+add {65537, 65537, 65537}
+add {4294967297, 4294967297, 4294967297}
+add {(()), (()), (())}
+add {((()), ()), ((()), ()), ((()), ())}
+add {"b", "b", "b"}
+add {B, B, B}
+add {:b, :b, :b}
+add {{b, b}, {b, b}, {b, b}}
+add {{:b, :b}, {:b, :b}, {:b, :b}}
+add {{{b, b}, {c, d}}, {{b, b}, {c, d}}, {{b, b}, {c, d}}}
+add {{{:b, :b}, {:c, :d}}, {{:b, :b}, {:c, :d}}, {{:b, :b}, {:c, :d}}}