summaryrefslogtreecommitdiff
path: root/src/packrat-tokens.adb
diff options
context:
space:
mode:
authorJed Barber <jjbarber@y7mail.com>2019-01-10 00:11:30 +1100
committerJed Barber <jjbarber@y7mail.com>2019-01-10 00:11:30 +1100
commit7009e51c15ed51d716102540d5914e3d14a8a128 (patch)
tree6a271a11429758c4364e79a9d7b42a6feca44f8e /src/packrat-tokens.adb
parent81f7e19f212f9d1ac75e04e62933e6c918219cfc (diff)
Debug_String functions added to Packrat.Errors and Packrat.Tokens
Diffstat (limited to 'src/packrat-tokens.adb')
-rw-r--r--src/packrat-tokens.adb21
1 files changed, 20 insertions, 1 deletions
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;
+
+