summaryrefslogtreecommitdiff
path: root/test/packrat-lexer-debug.adb
diff options
context:
space:
mode:
Diffstat (limited to 'test/packrat-lexer-debug.adb')
-rw-r--r--test/packrat-lexer-debug.adb80
1 files changed, 27 insertions, 53 deletions
diff --git a/test/packrat-lexer-debug.adb b/test/packrat-lexer-debug.adb
index 335e3d2..d4cc2e2 100644
--- a/test/packrat-lexer-debug.adb
+++ b/test/packrat-lexer-debug.adb
@@ -4,57 +4,22 @@ package body Packrat.Lexer.Debug is
function Create_Result
- (Length : in Natural;
- Status : in Result_Status;
- Value : in Element_Array)
- return Combinator_Result
- is
- This : Combinator_Result;
+ (Finish : in Natural;
+ Status : in Result_Status)
+ return Combinator_Result is
begin
- This.Length := Length;
- This.Status := Status;
- This.Value := new Element_Array (1 .. Value'Length);
- This.Value.all := Value;
- return This;
+ return (Finish, Status);
end Create_Result;
function Join
(Left, Right : in Combinator_Result)
- return Combinator_Result
- is
- Merge : Combinator_Result;
- Left_Valsize, Right_Valsize, Total_Valsize : Natural;
+ return Combinator_Result is
begin
- if Left.Value /= null then
- Left_Valsize := Left.Value.all'Length;
- else
- Left_Valsize := 0;
- end if;
- if Right.Value /= null then
- Right_Valsize := Right.Value.all'Length;
- else
- Right_Valsize := 0;
- end if;
- Total_Valsize := Left_Valsize + Right_Valsize;
-
if Left.Status = Success or Left.Status = Optional_More then
- Merge.Length := Left.Length + Right.Length;
- Merge.Status := Right.Status;
- if Total_Valsize > 0 then
- Merge.Value := new Element_Array (1 .. Total_Valsize);
- if Left.Value /= null then
- Merge.Value.all (1 .. Left_Valsize) := Left.Value.all;
- end if;
- if Right.Value /= null then
- Merge.Value.all (Left_Valsize + 1 .. Total_Valsize) := Right.Value.all;
- end if;
- end if;
- return Merge;
+ return Right;
elsif Left.Status = Needs_More then
- Merge := Left;
- Merge.Status := Failure;
- return Merge;
+ return (Left.Finish, Failure);
else
return Left;
end if;
@@ -71,18 +36,10 @@ package body Packrat.Lexer.Debug is
function Debug_String
(This : in Combinator_Result)
- return String
- is
- Value_Length : Natural;
+ return String is
begin
- if This.Value = null then
- Value_Length := 0;
- else
- Value_Length := This.Value.all'Length;
- end if;
- return Integer'Image (This.Length)
- & " " & Result_Status'Image (This.Status)
- & " " & Integer'Image (Value_Length);
+ return Integer'Image (This.Finish)
+ & " " & Result_Status'Image (This.Status);
end Debug_String;
@@ -133,6 +90,23 @@ package body Packrat.Lexer.Debug is
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.Lexer.Debug;