summaryrefslogtreecommitdiff
path: root/test/packrat-lexers-debug.adb
diff options
context:
space:
mode:
authorJed Barber <jjbarber@y7mail.com>2020-11-28 16:24:04 +1100
committerJed Barber <jjbarber@y7mail.com>2020-11-28 16:24:04 +1100
commit81c4526fa275a256bfefe0f8a7cd638369ea1252 (patch)
tree9792101c649932617db8848ec5c88ab493705490 /test/packrat-lexers-debug.adb
parent6c296b5615699eac0fb569b5cfe29e96986904a5 (diff)
Cleaned up Lexer, Util package names
Diffstat (limited to 'test/packrat-lexers-debug.adb')
-rw-r--r--test/packrat-lexers-debug.adb119
1 files changed, 119 insertions, 0 deletions
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;
+
+