summaryrefslogtreecommitdiff
path: root/src/packrat-tokens.adb
diff options
context:
space:
mode:
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;