summaryrefslogtreecommitdiff
path: root/src/packrat-parse_graphs.ads
diff options
context:
space:
mode:
authorJed Barber <jjbarber@y7mail.com>2020-11-13 11:36:41 +1100
committerJed Barber <jjbarber@y7mail.com>2020-11-13 11:36:41 +1100
commit43eea37daf162473c8c8e8279c9159d8b052ffdf (patch)
treed3fdd283a9b0d1bc5b0a5cafb6b4c18534eeefe5 /src/packrat-parse_graphs.ads
parent2e075ca317211553a19d7c8706a9d66fabcc9d8d (diff)
Refactored Tokens, Errors, Traits
Diffstat (limited to 'src/packrat-parse_graphs.ads')
-rw-r--r--src/packrat-parse_graphs.ads44
1 files changed, 23 insertions, 21 deletions
diff --git a/src/packrat-parse_graphs.ads b/src/packrat-parse_graphs.ads
index 291a467..6d79802 100644
--- a/src/packrat-parse_graphs.ads
+++ b/src/packrat-parse_graphs.ads
@@ -2,7 +2,8 @@
with
- Ada.Containers;
+ Ada.Containers,
+ Packrat.Traits;
private with
@@ -14,13 +15,7 @@ private with
generic
- type Label_Enum is (<>);
- type Element_Type is private;
- type Element_Array is array (Positive range <>) of Element_Type;
-
- with function "<" (Left, Right : in Element_Type) return Boolean is <>;
-
- with package Gen_Tokens is new Tokens (Label_Enum, Element_Type, Element_Array);
+ with package Traits is new Packrat.Traits (<>);
package Packrat.Parse_Graphs is
@@ -54,7 +49,7 @@ package Packrat.Parse_Graphs is
type Finish_Array is array (Positive range <>) of Finish_Type;
type Finished_Token is record
- Token : Gen_Tokens.Token;
+ Token : Traits.Tokens.Token;
Finish : Finish_Type;
end record;
@@ -113,7 +108,7 @@ package Packrat.Parse_Graphs is
function Contains
(Container : in Parse_Graph;
- Token : in Gen_Tokens.Token)
+ Token : in Traits.Tokens.Token)
return Boolean;
function Contains
@@ -180,7 +175,7 @@ package Packrat.Parse_Graphs is
procedure Include
(Container : in out Parse_Graph;
- Token : in Gen_Tokens.Token)
+ Token : in Traits.Tokens.Token)
with Post => Container.Contains (Token);
procedure Connect
@@ -193,7 +188,7 @@ package Packrat.Parse_Graphs is
procedure Prune
(Container : in out Parse_Graph;
- Token : in Gen_Tokens.Token)
+ Token : in Traits.Tokens.Token)
with Post => not Container.Contains (Token);
procedure Prune
@@ -220,10 +215,10 @@ package Packrat.Parse_Graphs is
procedure Set_Root
(Container : in out Parse_Graph;
- Token : in Gen_Tokens.Token;
+ Token : in Traits.Tokens.Token;
Finishes : in Finish_Array)
with Pre => Container.Contains (Token) and
- (for all F of Finishes => F >= Gen_Tokens.Start (Token) - 1),
+ (for all F of Finishes => F >= Traits.Tokens.Start (Token) - 1),
Post => Container.Has_Root;
procedure Clear_Root
@@ -232,7 +227,7 @@ package Packrat.Parse_Graphs is
function Root_Token
(Container : in Parse_Graph)
- return Gen_Tokens.Token
+ return Traits.Tokens.Token
with Pre => Container.Has_Root;
function Root_Finish_List
@@ -254,7 +249,7 @@ package Packrat.Parse_Graphs is
function Finish_List
(Container : in Parse_Graph;
- Token : in Gen_Tokens.Token)
+ Token : in Traits.Tokens.Token)
return Finish_Array
with Pre => Container.Contains (Token),
Post => Is_Sorted (Finish_List'Result) and
@@ -360,10 +355,17 @@ package Packrat.Parse_Graphs is
private
+ use type Traits.Label_Enum;
+ use type Traits.Element_Type;
+ use type Traits.Element_Array;
+
+
+
+
type Node_ID_Type is new Positive;
type Edge_ID_Type is new Positive;
- subtype Node_Label_Type is Gen_Tokens.Token;
+ subtype Node_Label_Type is Traits.Tokens.Token;
subtype Group_ID_Type is Positive;
@@ -378,7 +380,7 @@ private
function To_Node
(Container : in Parse_Graph;
- Token : in Gen_Tokens.Token)
+ Token : in Traits.Tokens.Token)
return Node_ID_Type;
function To_Node
@@ -396,7 +398,7 @@ private
-- This 'use type' is to avoid some ambiguities with "=" functions when
-- instantiating the Base package.
- use type Gen_Tokens.Token;
+ use type Traits.Tokens.Token;
package Base is new Directed_Graphs
(Node_ID_Type => Node_ID_Type,
@@ -414,7 +416,7 @@ private
package Finish_Sort is new Finish_Vectors.Generic_Sorting;
package Node_Label_Maps is new Ada.Containers.Ordered_Maps
- (Key_Type => Gen_Tokens.Token,
+ (Key_Type => Traits.Tokens.Token,
Element_Type => Node_ID_Type);
type Parse_Graph is tagged record
@@ -468,7 +470,7 @@ private
Element_Type => Group_ID_Type);
package Enum_Node_Maps is new Ada.Containers.Ordered_Maps
- (Key_Type => Label_Enum,
+ (Key_Type => Traits.Label_Enum,
Element_Type => Node_Vectors.Vector,
"=" => Node_Vectors."=");