summaryrefslogtreecommitdiff
path: root/src/packrat.ads
diff options
context:
space:
mode:
Diffstat (limited to 'src/packrat.ads')
-rw-r--r--src/packrat.ads79
1 files changed, 78 insertions, 1 deletions
diff --git a/src/packrat.ads b/src/packrat.ads
index 1c81958..c60b798 100644
--- a/src/packrat.ads
+++ b/src/packrat.ads
@@ -2,7 +2,8 @@
with
- Ada.Strings.Unbounded;
+ Ada.Strings.Unbounded,
+ Ada.Finalization;
package Packrat is
@@ -88,6 +89,82 @@ package Packrat is
end Errors;
+
+
+ generic
+ type Label_Enum is (<>);
+ type Element is private;
+ type Element_Array is array (Positive range <>) of Element;
+ package Tokens is
+
+
+ type Token is new Ada.Finalization.Controlled with private;
+
+
+ function Create
+ (Ident : in Label_Enum;
+ Start : in Positive;
+ Finish : in Natural;
+ Value : in Element_Array)
+ return Token;
+
+
+ -- Note: The Start and Finish indices indicate where the token was found
+ -- in whatever array it was lexed from. The Value does *not* have
+ -- to correspond with whatever is found in the Start .. Finish range.
+
+
+ function Initialized
+ (This : in Token)
+ return Boolean;
+
+
+ function Label
+ (This : in Token)
+ return Label_Enum
+ with Pre => Initialized (This);
+
+ function Start
+ (This : in Token)
+ return Positive;
+
+ function Finish
+ (This : in Token)
+ return Natural;
+
+ function Value
+ (This : in Token)
+ return Element_Array
+ with Pre => Initialized (This);
+
+
+ private
+
+
+ type Element_Array_Access is access Element_Array;
+
+
+ type Token is new Ada.Finalization.Controlled with record
+ Identifier : Label_Enum;
+ Start_At : Positive;
+ Finish_At : Natural;
+ Token_Value : Element_Array_Access;
+ end record;
+
+
+ overriding procedure Initialize
+ (This : in out Token);
+
+ overriding procedure Adjust
+ (This : in out Token);
+
+ overriding procedure Finalize
+ (This : in out Token);
+
+
+ end Tokens;
+
+
private