From 81c4526fa275a256bfefe0f8a7cd638369ea1252 Mon Sep 17 00:00:00 2001 From: Jed Barber Date: Sat, 28 Nov 2020 16:24:04 +1100 Subject: Cleaned up Lexer, Util package names --- test/packrat-lexers-debug.adb | 119 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 119 insertions(+) create mode 100644 test/packrat-lexers-debug.adb (limited to 'test/packrat-lexers-debug.adb') diff --git a/test/packrat-lexers-debug.adb b/test/packrat-lexers-debug.adb new file mode 100644 index 0000000..d748fd4 --- /dev/null +++ b/test/packrat-lexers-debug.adb @@ -0,0 +1,119 @@ + + +package body Packrat.Lexers.Debug is + + + function Create_Result + (Finish : in Natural; + Status : in Result_Status) + return Combinator_Result is + begin + return (Finish, Status); + end Create_Result; + + + function Join + (Left, Right : in Combinator_Result) + return Combinator_Result is + begin + if Left.Status = Success or Left.Status = Optional_More then + return Right; + elsif Left.Status = Needs_More then + return (Left.Finish, Failure); + else + return Left; + end if; + end Join; + + + function Status + (This : in Combinator_Result) + return Result_Status is + begin + return This.Status; + end Status; + + + function Debug_String + (This : in Combinator_Result) + return String is + begin + return Integer'Image (This.Finish) + & " " & Result_Status'Image (This.Status); + end Debug_String; + + + + + + function So_Far + (This : in Lexer_Context) + return Token_Vector is + begin + return (This.Result_So_Far with null record); + end So_Far; + + function Position + (This : in Lexer_Context) + return Positive is + begin + return This.Position; + end Position; + + function Status + (This : in Lexer_Context) + return Result_Status is + begin + return This.Status; + end Status; + + function Has_Pass + (This : in Lexer_Context) + return Boolean is + begin + return not This.Pass_Forward.Is_Empty; + end Has_Pass; + + function Pass + (This : in Lexer_Context) + return Traits.Element_Array is + begin + return This.Pass_Forward.Element; + end Pass; + + function Length + (Vec : in Token_Vector) + return Natural is + begin + return Integer (Token_Vectors.Vector (Vec).Length); + end Length; + + function Element + (Vec : in Token_Vector; + Dex : in Positive) + return Traits.Tokens.Token is + begin + return Token_Vectors.Vector (Vec).Element (Dex); + end Element; + + + + + function Is_Failure + (Result : in Component_Result) + return Boolean is + begin + return Result = Component_Failure; + end Is_Failure; + + function Is_Success + (Result : in Component_Result) + return Boolean is + begin + return Result = Component_Success; + end Is_Success; + + +end Packrat.Lexers.Debug; + + -- cgit