diff options
Diffstat (limited to 'src/packrat-graphs.ads')
-rw-r--r-- | src/packrat-graphs.ads | 60 |
1 files changed, 59 insertions, 1 deletions
diff --git a/src/packrat-graphs.ads b/src/packrat-graphs.ads index cd5c364..76be2e4 100644 --- a/src/packrat-graphs.ads +++ b/src/packrat-graphs.ads @@ -252,7 +252,9 @@ package Packrat.Graphs is function Equal_Subgraph (Left, Right : in Cursor) - return Boolean; + return Boolean + with Pre => + Is_Node (Left) and Is_Node (Right); function Subgraph_Node_Count (Position : in Cursor) @@ -415,6 +417,54 @@ private subtype Node_Index is Positive; subtype Extended_Node_Index is Natural; + + + + function Choices + (My_Graph : in Graph; + My_Index : in Node_Index) + return Natural + with Pre => + My_Index <= My_Graph.Node_List.Last_Index; + + + procedure Delete_Loose_Subgraph + (Container : in out Graph; + Index : in Node_Index) + with Pre => + Index <= Container.Node_List.Last_Index and then + Container.Node_List.Element (Index).Kind /= Null_Node; + + procedure Delete_Up_Edge + (Container : in out Graph; + Current, Parent : in Node_Index) + with Pre => + Container.Up_Edges.Contains (Current) and then + Container.Up_Edges.Reference (Current).Contains (Parent); + + procedure Delete_Down_Edges + (Container : in out Graph; + From : in Node_Index; + Choice : in Positive) + with Pre => + Container.Choices.Contains (From) and then + Container.Choices.Element (From) > 0 and then + Container.Down_Edges.Contains ((From, Choice)), + Post => + not Container.Down_Edges.Contains ((From, Choice)); + + + function Equal_Subgraph + (Left_Graph, Right_Graph : in Graph; + Left_Index, Right_Index : in Node_Index) + return Boolean + with Pre => + Left_Index <= Left_Graph.Node_List.Last_Index and + Right_Index <= Right_Graph.Node_List.Last_Index; + + + + package Index_Vectors is new Ada.Containers.Vectors (Index_Type => Positive, Element_Type => Node_Index); @@ -422,6 +472,14 @@ private + function Node_Count + (Container : in Graph; + Root_List : in Index_Vectors.Vector) + return Natural; + + + + type Choice_Down is record From : Extended_Node_Index; Choice : Natural; |