From 30d59f09f6908aa0de2ec3a58a0736c8030ffda5 Mon Sep 17 00:00:00 2001 From: Jed Barber Date: Thu, 21 Jan 2021 16:33:47 +1100 Subject: Piecewise parsing fixed, unit tested --- src/packrat-errors.adb | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/packrat-errors.adb') diff --git a/src/packrat-errors.adb b/src/packrat-errors.adb index 3f7c38f..0122b7d 100644 --- a/src/packrat-errors.adb +++ b/src/packrat-errors.adb @@ -313,6 +313,30 @@ package body Packrat.Errors is end Decode; + + + + function Equivalent + (Left, Right : in Error_Info_Array) + return Boolean + is + Marked : array (Left'Range) of Boolean := (others => False); + begin + if Left'Length /= Right'Length then + return False; + end if; + for L_Index in Left'Range loop + for R of Right loop + if Left (L_Index) = R and not Marked (L_Index) then + Marked (L_Index) := True; + exit; + end if; + end loop; + end loop; + return (for all M of Marked => M = True); + end Equivalent; + + end Packrat.Errors; -- cgit