From 7009e51c15ed51d716102540d5914e3d14a8a128 Mon Sep 17 00:00:00 2001 From: Jed Barber Date: Thu, 10 Jan 2019 00:11:30 +1100 Subject: Debug_String functions added to Packrat.Errors and Packrat.Tokens --- src/packrat-tokens.adb | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'src/packrat-tokens.adb') diff --git a/src/packrat-tokens.adb b/src/packrat-tokens.adb index 4cb10bf..70a866a 100644 --- a/src/packrat-tokens.adb +++ b/src/packrat-tokens.adb @@ -2,13 +2,18 @@ with - Ada.Unchecked_Deallocation; + Ada.Unchecked_Deallocation, + Ada.Characters.Latin_1; separate (Packrat) package body Tokens is + package SU renames Ada.Strings.Unbounded; + package Latin renames Ada.Characters.Latin_1; + + procedure Free_Array is new Ada.Unchecked_Deallocation (Object => Element_Array, Name => Element_Array_Access); @@ -76,6 +81,20 @@ package body Tokens is end Initialized; + function Debug_String + (This : in Token) + return String + is + Result : SU.Unbounded_String := +""; + begin + SU.Append (Result, "Token " & Label_Enum'Image (This.Identifier) & + " at input position" & Integer'Image (This.Start_At) & " to" & + Integer'Image (This.Finish_At) & " with value length" & + Integer'Image (This.Token_Value'Length) & Latin.LF); + return -Result; + end Debug_String; + + -- cgit