summaryrefslogtreecommitdiff
path: root/src/kompsos-collector.ads
diff options
context:
space:
mode:
authorJedidiah Barber <contact@jedbarber.id.au>2025-12-14 19:53:01 +1300
committerJedidiah Barber <contact@jedbarber.id.au>2025-12-14 19:53:01 +1300
commit826b9d2dad1031a3eca29dd2fb8b6643e53e5fc1 (patch)
tree40a689365738f8cce48e1b285955e28466641383 /src/kompsos-collector.ads
parent3086d133950cb813c01a89e97e009f7b400b5371 (diff)
Core rewritten with memoisation, but somehow Zebra example is buggedHEADmaster
Diffstat (limited to 'src/kompsos-collector.ads')
-rw-r--r--src/kompsos-collector.ads94
1 files changed, 94 insertions, 0 deletions
diff --git a/src/kompsos-collector.ads b/src/kompsos-collector.ads
new file mode 100644
index 0000000..4bca3b4
--- /dev/null
+++ b/src/kompsos-collector.ads
@@ -0,0 +1,94 @@
+
+
+-- Programmed by Jedidiah Barber
+-- Licensed under the Sunset License v1.0
+
+-- See license.txt for further details
+
+
+private with
+
+ Ada.Containers.Ordered_Maps,
+ Ada.Containers.Vectors,
+ Ada.Finalization;
+
+
+generic
+ Source : in World;
+package Kompsos.Collector is
+
+
+ State_Not_Found_Error : exception;
+
+
+ function Has_Next
+ return Boolean;
+
+ function Next
+ return State;
+
+ function Next
+ (Default : in State)
+ return State;
+
+ procedure Reset;
+
+
+private
+
+
+ type World_Access is access all World;
+
+ type Constant_World_Access is access constant World;
+
+ function "<"
+ (Left, Right : in World_Component_Access)
+ return Boolean;
+
+ type Eval_Kind is
+ (Unify_Data,
+ Disjunct_Data,
+ Conjunct_Data,
+ Recurse_Data);
+
+ type Eval_Data (Kind : Eval_Kind := Unify_Data) is record
+ case Kind is
+ when Unify_Data =>
+ Uni_Offset : Long_Natural := 0;
+ when Disjunct_Data =>
+ Dis_Flag : Boolean := True;
+ Dis_Next1 : Long_Positive := 1;
+ Dis_Next2 : Long_Positive := 1;
+ Dis_Gone1 : Boolean := False;
+ Dis_Gone2 : Boolean := False;
+ when Conjunct_Data =>
+ Con_Part : World_Access := null;
+ Con_From : Long_Positive := 1;
+ Con_Next : Long_Positive := 1;
+ Con_Gone : Boolean := False;
+ when Recurse_Data =>
+ Rec_Next : Long_Positive := 1;
+ Rec_Gone : Boolean := False;
+ end case;
+ end record;
+
+ package Eval_Maps is new Ada.Containers.Ordered_Maps
+ (Key_Type => World_Component_Access,
+ Element_Type => Eval_Data);
+
+ type Managed_Map is new Ada.Finalization.Controlled with record
+ Actual : Eval_Maps.Map;
+ end record;
+
+ overriding procedure Finalize
+ (This : in out Managed_Map);
+
+ package Cache_Maps is new Ada.Containers.Ordered_Maps
+ (Key_Type => World_Component_Access,
+ Element_Type => State_Vectors.Vector,
+ "=" => State_Vectors."=");
+
+
+end Kompsos.Collector;
+
+