From 6537721f85aa4f0d8607c9df506a343fb0093bef Mon Sep 17 00:00:00 2001 From: Jed Barber Date: Sun, 13 Jan 2019 00:31:06 +1100 Subject: Added equals function overload for Tokens --- src/packrat-tokens.adb | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'src/packrat-tokens.adb') diff --git a/src/packrat-tokens.adb b/src/packrat-tokens.adb index 240ecee..382b8d8 100644 --- a/src/packrat-tokens.adb +++ b/src/packrat-tokens.adb @@ -74,6 +74,31 @@ package body Tokens is end Create; + function "=" + (Left, Right : in Token) + return Boolean + is + Left_Valsize, Right_Valsize : Natural; + begin + if Left.Token_Value = null then + Left_Valsize := 0; + else + Left_Valsize := Left.Token_Value.all'Length; + end if; + if Right.Token_Value = null then + Right_Valsize := 0; + else + Right_Valsize := Right.Token_Value.all'Length; + end if; + + return Left.Identifier = Right.Identifier and + Left.Start_At = Right.Start_At and + Left.Finish_At = Right.Finish_At and + Left_Valsize = Right_Valsize and + (Left_Valsize = 0 or else Left.Token_Value.all = Right.Token_Value.all); + end "="; + + -- cgit