summaryrefslogtreecommitdiff
path: root/src/packrat-tokens.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-tokens.ads
parent2e075ca317211553a19d7c8706a9d66fabcc9d8d (diff)
Refactored Tokens, Errors, Traits
Diffstat (limited to 'src/packrat-tokens.ads')
-rw-r--r--src/packrat-tokens.ads73
1 files changed, 73 insertions, 0 deletions
diff --git a/src/packrat-tokens.ads b/src/packrat-tokens.ads
new file mode 100644
index 0000000..bfb70ac
--- /dev/null
+++ b/src/packrat-tokens.ads
@@ -0,0 +1,73 @@
+
+
+private with
+
+ Ada.Containers.Indefinite_Holders;
+
+
+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 <>;
+
+package Packrat.Tokens is
+
+
+ type Token is private;
+ type Token_Array is array (Positive range <>) of Token;
+
+
+ function "<"
+ (Left, Right : in Token)
+ return Boolean;
+
+
+ function Create
+ (Ident : in Label_Enum;
+ Start : in Positive;
+ Value : in Element_Array)
+ return Token;
+
+
+ -- Note: The Start index indicates where the token was found
+ -- in whatever array it was lexed from. The Value does *not*
+ -- have to correspond with whatever is found there.
+
+
+ function Debug_String
+ (This : in Token)
+ return String;
+
+
+ function Label
+ (This : in Token)
+ return Label_Enum;
+
+ function Start
+ (This : in Token)
+ return Positive;
+
+ function Value
+ (This : in Token)
+ return Element_Array;
+
+
+private
+
+
+ package Value_Holders is new Ada.Containers.Indefinite_Holders (Element_Array);
+
+
+ type Token is record
+ Identifier : Label_Enum;
+ Start_At : Positive;
+ Token_Value : Value_Holders.Holder;
+ end record;
+
+
+end Packrat.Tokens;
+
+