summaryrefslogtreecommitdiff
path: root/src/packrat-tokens.adb
diff options
context:
space:
mode:
authorJed Barber <jjbarber@y7mail.com>2020-11-07 01:21:54 +1100
committerJed Barber <jjbarber@y7mail.com>2020-11-07 01:21:54 +1100
commit8828e68cb86c865d625961c07c7ce2eb4ae191bc (patch)
treea90555326581688a32cf38fef15d0893e3df1f3d /src/packrat-tokens.adb
parent731e861f233ab90078c00b3dad5ace4eaed45e95 (diff)
Parse_Graphs complete aside from isomorphism and testing
Diffstat (limited to 'src/packrat-tokens.adb')
-rw-r--r--src/packrat-tokens.adb39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/packrat-tokens.adb b/src/packrat-tokens.adb
index e0ea10d..08e0181 100644
--- a/src/packrat-tokens.adb
+++ b/src/packrat-tokens.adb
@@ -16,6 +16,45 @@ package body Tokens is
+ function "<"
+ (Left, Right : in Token)
+ return Boolean
+ is
+ Left_Index, Right_Index : Positive;
+ begin
+ if Left.Start_At = Right.Start_At then
+ if Left.Identifier = Right.Identifier then
+ Left_Index := Left.Token_Value.Constant_Reference.Element'First;
+ Right_Index := Right.Token_Value.Constant_Reference.Element'First;
+ while Left_Index <= Left.Token_Value.Constant_Reference.Element'Last and
+ Right_Index <= Right.Token_Value.Constant_Reference.Element'Last
+ loop
+ if Left.Token_Value.Constant_Reference.Element (Left_Index) <
+ Right.Token_Value.Constant_Reference.Element (Right_Index)
+ then
+ return True;
+ elsif Left.Token_Value.Constant_Reference.Element (Left_Index) /=
+ Right.Token_Value.Constant_Reference.Element (Right_Index)
+ then
+ return False;
+ end if;
+ Left_Index := Left_Index + 1;
+ Right_Index := Right_Index + 1;
+ end loop;
+ return Left.Token_Value.Constant_Reference.Element'Length <
+ Right.Token_Value.Constant_Reference.Element'Length;
+ else
+ return Left.Identifier < Right.Identifier;
+ end if;
+ else
+ return Left.Start_At < Right.Start_At;
+ end if;
+ end "<";
+
+
+
+
+
function Create
(Ident : in Label_Enum;
Start : in Positive;