summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJed Barber <jjbarber@y7mail.com>2019-01-14 14:59:54 +1100
committerJed Barber <jjbarber@y7mail.com>2019-01-14 14:59:54 +1100
commitc0ba281a0bf3edc564a4fee61375691f35632be4 (patch)
treeb6628e49035f21b1f744ad22d684a1b63bafff6b
parent93406e9b26f9e4439a8e4d57659489323a4e57b4 (diff)
Merged Packrat.Lexer.Combinators into Packrat.Lexer, separated debugging functions into subpackage in /test subdir
-rw-r--r--packrat_parser_lib_notes.txt22
-rw-r--r--src/packrat-lexer-combinators.adb316
-rw-r--r--src/packrat-lexer-combinators.ads143
-rw-r--r--src/packrat-lexer.adb387
-rw-r--r--src/packrat-lexer.ads166
-rw-r--r--test/packrat-lexer-debug.adb91
-rw-r--r--test/packrat-lexer-debug.ads37
-rw-r--r--test/ratnest-tests.adb248
8 files changed, 741 insertions, 669 deletions
diff --git a/packrat_parser_lib_notes.txt b/packrat_parser_lib_notes.txt
index d292a94..e48ebe8 100644
--- a/packrat_parser_lib_notes.txt
+++ b/packrat_parser_lib_notes.txt
@@ -4,17 +4,17 @@ package structure:
Packrat
Packrat.Parser (generic over memoize enum, input item type, array of input items, graph of output item subarrays)
-Packrat.Parser.Combinators
+Packrat.Parser.Combinators (merged into Packrat.Parser)
Packrat.Lexer (generic over stamp enum, input item type, array of input items, array of output items wrapped as tokens)
-Packrat.Lexer.Combinators
+Packrat.Lexer.Combinators (merged into Packrat.Lexer)
Packrat.Util
Packrat.Errors (nested)
Packrat.Graphs (nested, generic over leaf array type)
Packrat.Tokens (nested, generic over contained array)
-Packrat.Instant
-Packrat.Instant.Standard (nested, generic over parser/lexer label enums)
-Packrat.Instant.Wide (nested, generic over parser/lexer label enums)
-Packrat.Instant.Wide_Wide (nested, generic over parser/lexer label enums)
+Packrat.Text
+Packrat.Text.Std (nested, generic over parser/lexer label enums)
+Packrat.Text.Wide (nested, generic over parser/lexer label enums)
+Packrat.Text.Wide_Wide (nested, generic over parser/lexer label enums)
Ratnest.Tests
Ratnest.Examples
@@ -34,14 +34,12 @@ Packrat.Util
Packrat.Errors
Packrat.Tokens
Packrat.Lexer
-Packrat.Lexer.Combinators
Packrat.Graphs
Packrat.Parser
-Packrat.Parser.Combinators
-Packrat.Instant
-Packrat.Instant.Standard
-Packrat.Instant.Wide
-Packrat.Instant.Wide_Wide
+Packrat.Text
+Packrat.Text.Std
+Packrat.Text.Wide
+Packrat.Text.Wide_Wide
Calculator
Tomita
Off_Side
diff --git a/src/packrat-lexer-combinators.adb b/src/packrat-lexer-combinators.adb
deleted file mode 100644
index 1090398..0000000
--- a/src/packrat-lexer-combinators.adb
+++ /dev/null
@@ -1,316 +0,0 @@
-
-
-package body Packrat.Lexer.Combinators is
-
-
- function Sequence
- (Input : in Element_Array;
- Start : in Positive)
- return Combinator_Result
- is
- Result : Combinator_Result := Create_Result (0, Success, Empty_Array);
- Position : Positive := Start;
- begin
- if Start > Input'Last then
- return Empty_Fail;
- end if;
- for C of Params loop
- if Position > Input'Last then
- Result.Status := Needs_More;
- exit;
- end if;
- Result := Result.Join (C (Input, Position));
- exit when Result.Status = Failure;
- Position := Start + Result.Length;
- end loop;
- return Result;
- end Sequence;
-
-
- function Count
- (Input : in Element_Array;
- Start : in Positive)
- return Combinator_Result
- is
- Result : Combinator_Result := Create_Result (0, Success, Empty_Array);
- Position : Positive := Start;
- begin
- if Start > Input'Last then
- return Empty_Fail;
- end if;
- for I in Integer range 1 .. Number loop
- if Position > Input'Last then
- Result.Status := Needs_More;
- exit;
- end if;
- Result := Result.Join (Param (Input, Position));
- exit when Result.Status = Failure;
- Position := Start + Result.Length;
- end loop;
- return Result;
- end Count;
-
-
- function Many
- (Input : in Element_Array;
- Start : in Positive)
- return Combinator_Result
- is
- Result : Combinator_Result := Create_Result (0, Success, Empty_Array);
- Temp : Combinator_Result;
- Position : Positive := Start;
- Counter : Natural := 0;
- begin
- if Start > Input'Last then
- return Empty_Fail;
- end if;
- loop
- exit when Position > Input'Last;
- Temp := Param (Input, Position);
- exit when Temp.Status = Failure or Temp.Status = Needs_More;
- Result := Result.Join (Temp);
- Counter := Counter + 1;
- Position := Start + Result.Length;
- end loop;
- if Counter < Minimum then
- if Position > Input'Last or Temp.Status = Needs_More then
- Result.Status := Needs_More;
- else
- Result.Status := Failure;
- end if;
- elsif Position > Input'Last or Temp.Status = Needs_More then
- Result.Status := Optional_More;
- else
- Result.Status := Success;
- end if;
- return Result;
- end Many;
-
-
- function Many_Until
- (Input : in Element_Array;
- Start : in Positive)
- return Combinator_Result
- is
- Result : Combinator_Result := Create_Result (0, Success, Empty_Array);
- Temp : Combinator_Result;
- Position : Positive := Start;
- Counter : Natural := 0;
- begin
- if Start > Input'Last then
- return Empty_Fail;
- end if;
- loop
- exit when Position > Input'Last;
- Temp := Param (Input, Position);
- exit when Temp.Status = Failure or Temp.Status = Needs_More or Test (Input (Position));
- Result := Result.Join (Temp);
- Counter := Counter + 1;
- Position := Start + Result.Length;
- end loop;
- if Counter < Minimum then
- if Position > Input'Last or Temp.Status = Needs_More then
- Result.Status := Needs_More;
- else
- Result.Status := Failure;
- end if;
- elsif Position > Input'Last then
- Result.Status := Needs_More;
- elsif Temp.Status = Needs_More and Test (Input (Position)) then
- Result.Status := Optional_More;
- elsif Test (Input (Position)) then
- Result.Status := Success;
- else
- Result.Status := Failure;
- end if;
- return Result;
- end Many_Until;
-
-
-
-
-
- function Satisfy
- (Input : in Element_Array;
- Start : in Positive)
- return Combinator_Result is
- begin
- if Start > Input'Last then
- return Empty_Fail;
- elsif Test (Input (Start)) then
- return Create_Result (1, Success, (1 => Input (Start)));
- else
- return Empty_Fail;
- end if;
- end Satisfy;
-
-
- function Satisfy_With
- (Input : in Element_Array;
- Start : in Positive)
- return Combinator_Result is
- begin
- if Start > Input'Last then
- return Empty_Fail;
- elsif Test (Change (Input (Start))) then
- return Create_Result (1, Success, (1 => Input (Start)));
- else
- return Empty_Fail;
- end if;
- end Satisfy_With;
-
-
- function Match
- (Input : in Element_Array;
- Start : in Positive)
- return Combinator_Result is
- begin
- if Start > Input'Last then
- return Empty_Fail;
- elsif Input (Start) = Item then
- return Create_Result (1, Success, (1 => Item));
- else
- return Empty_Fail;
- end if;
- end Match;
-
-
- function Match_With
- (Input : in Element_Array;
- Start : in Positive)
- return Combinator_Result is
- begin
- if Start > Input'Last then
- return Empty_Fail;
- elsif Change (Input (Start)) = Item then
- return Create_Result (1, Success, (1 => Input (Start)));
- else
- return Empty_Fail;
- end if;
- end Match_With;
-
-
- function Multimatch
- (Input : in Element_Array;
- Start : in Positive)
- return Combinator_Result
- is
- Current_Offset : Natural := 0;
- begin
- if Items'Length = 0 then
- return Create_Result (0, Success, Empty_Array);
- end if;
-
- if Input'Last - Start + 1 <= 0 then
- return Empty_Fail;
- end if;
-
- while Input (Start + Current_Offset) = Items (Items'First + Current_Offset) loop
- if Items'First + Current_Offset = Items'Last then
- return Create_Result (Current_Offset + 1, Success, Items);
- elsif Start + Current_Offset = Input'Last then
- return Create_Result (Current_Offset + 1, Needs_More, Input (Start .. Input'Last));
- end if;
- Current_Offset := Current_Offset + 1;
- end loop;
- return Create_Result (Current_Offset, Failure, Input (Start .. Start + Current_Offset - 1));
- end Multimatch;
-
-
- function Take
- (Input : in Element_Array;
- Start : in Positive)
- return Combinator_Result is
- begin
- if Start > Input'Last then
- return Empty_Fail;
- elsif Start + Number - 1 > Input'Last then
- return Create_Result (Input'Last - Start + 1, Needs_More, Input (Start .. Input'Last));
- else
- return Create_Result (Number, Success, Input (Start .. Start + Number - 1));
- end if;
- end Take;
-
-
- function Take_While
- (Input : in Element_Array;
- Start : in Positive)
- return Combinator_Result
- is
- Finish : Positive := Start;
- Status : Result_Status;
- begin
- if Start > Input'Last or else not Test (Input (Start)) then
- return Empty_Fail;
- end if;
- while Finish <= Input'Last and then Test (Input (Finish)) loop
- Finish := Finish + 1;
- end loop;
- if Finish > Input'Last then
- Status := Optional_More;
- else
- Status := Success;
- end if;
- return Create_Result (Finish - Start, Status, Input (Start .. Finish - 1));
- end Take_While;
-
-
- function Take_Until
- (Input : in Element_Array;
- Start : in Positive)
- return Combinator_Result
- is
- Finish : Positive := Start;
- Status : Result_Status;
- begin
- if Start > Input'Last or else Test (Input (Start)) then
- return Empty_Fail;
- end if;
- while Finish <= Input'Last and then not Test (Input (Finish)) loop
- Finish := Finish + 1;
- end loop;
- if Finish > Input'Last then
- Status := Optional_More;
- else
- Status := Success;
- end if;
- return Create_Result (Finish - Start, Status, Input (Start .. Finish - 1));
- end Take_Until;
-
-
-
-
-
- function Line_End
- (Input : in Element_Array;
- Start : in Positive)
- return Combinator_Result is
- begin
- if Start > Input'Last then
- return Empty_Fail;
- elsif Input (Start) = EOL_Item then
- return Create_Result (1, Success, (1 => EOL_Item));
- else
- return Empty_Fail;
- end if;
- end Line_End;
-
-
- function Input_End
- (Input : in Element_Array;
- Start : in Positive)
- return Combinator_Result is
- begin
- if Start > Input'Last then
- return Empty_Fail;
- elsif Input (Start) = EOF_Item then
- return Create_Result (1, Success, (1 => EOF_Item));
- else
- return Empty_Fail;
- end if;
- end Input_End;
-
-
-end Packrat.Lexer.Combinators;
-
-
diff --git a/src/packrat-lexer-combinators.ads b/src/packrat-lexer-combinators.ads
deleted file mode 100644
index 98df3d5..0000000
--- a/src/packrat-lexer-combinators.ads
+++ /dev/null
@@ -1,143 +0,0 @@
-
-
-generic
-package Packrat.Lexer.Combinators is
-
-
- generic
- Params : in Combinator_Array;
- function Sequence
- (Input : in Element_Array;
- Start : in Positive)
- return Combinator_Result;
-
- generic
- with function Param
- (Input : in Element_Array;
- Start : in Positive)
- return Combinator_Result;
- Number : in Positive;
- function Count
- (Input : in Element_Array;
- Start : in Positive)
- return Combinator_Result;
-
- generic
- with function Param
- (Input : in Element_Array;
- Start : in Positive)
- return Combinator_Result;
- Minimum : in Natural := 0;
- function Many
- (Input : in Element_Array;
- Start : in Positive)
- return Combinator_Result;
-
- generic
- with function Param
- (Input : in Element_Array;
- Start : in Positive)
- return Combinator_Result;
- with function Test
- (Item : in Element)
- return Boolean;
- Minimum : in Natural := 0;
- function Many_Until
- (Input : in Element_Array;
- Start : in Positive)
- return Combinator_Result;
-
-
-
-
- generic
- with function Test
- (Item : in Element)
- return Boolean;
- function Satisfy
- (Input : in Element_Array;
- Start : in Positive)
- return Combinator_Result;
-
- generic
- with function Test
- (Item : in Element)
- return Boolean;
- with function Change
- (From : in Element)
- return Element;
- function Satisfy_With
- (Input : in Element_Array;
- Start : in Positive)
- return Combinator_Result;
-
- generic
- Item : in Element;
- function Match
- (Input : in Element_Array;
- Start : in Positive)
- return Combinator_Result;
-
- generic
- Item : in Element;
- with function Change
- (From : in Element)
- return Element;
- function Match_With
- (Input : in Element_Array;
- Start : in Positive)
- return Combinator_Result;
-
- generic
- Items : in Element_Array;
- function Multimatch
- (Input : in Element_Array;
- Start : in Positive)
- return Combinator_Result;
-
- generic
- Number : in Positive := 1;
- function Take
- (Input : in Element_Array;
- Start : in Positive)
- return Combinator_Result;
-
- generic
- with function Test
- (Item : in Element)
- return Boolean;
- function Take_While
- (Input : in Element_Array;
- Start : in Positive)
- return Combinator_Result;
-
- generic
- with function Test
- (Item : in Element)
- return Boolean;
- function Take_Until
- (Input : in Element_Array;
- Start : in Positive)
- return Combinator_Result;
-
-
-
-
- generic
- EOL_Item : in Element;
- function Line_End
- (Input : in Element_Array;
- Start : in Positive)
- return Combinator_Result;
-
- generic
- EOF_Item : in Element;
- function Input_End
- (Input : in Element_Array;
- Start : in Positive)
- return Combinator_Result;
-
-
-end Packrat.Lexer.Combinators;
-
-
diff --git a/src/packrat-lexer.adb b/src/packrat-lexer.adb
index 614452b..e1765d9 100644
--- a/src/packrat-lexer.adb
+++ b/src/packrat-lexer.adb
@@ -46,6 +46,33 @@ package body Packrat.Lexer is
+ function "="
+ (Left, Right : in Combinator_Result)
+ return Boolean
+ is
+ Left_Valsize, Right_Valsize : Natural;
+ begin
+ if Left.Value = null then
+ Left_Valsize := 0;
+ else
+ Left_Valsize := Left.Value.all'Length;
+ end if;
+ if Right.Value = null then
+ Right_Valsize := 0;
+ else
+ Right_Valsize := Right.Value.all'Length;
+ end if;
+
+ return Left.Length = Right.Length and
+ Left.Status = Right.Status and
+ Left_Valsize = Right_Valsize and
+ (Left_Valsize = 0 or else Left.Value.all = Right.Value.all);
+ end "=";
+
+
+
+
+
function Create_Result
(Length : in Natural;
Status : in Result_Status;
@@ -104,55 +131,6 @@ package body Packrat.Lexer is
end Join;
- function "="
- (Left, Right : in Combinator_Result)
- return Boolean
- is
- Left_Valsize, Right_Valsize : Natural;
- begin
- if Left.Value = null then
- Left_Valsize := 0;
- else
- Left_Valsize := Left.Value.all'Length;
- end if;
- if Right.Value = null then
- Right_Valsize := 0;
- else
- Right_Valsize := Right.Value.all'Length;
- end if;
-
- return Left.Length = Right.Length and
- Left.Status = Right.Status and
- Left_Valsize = Right_Valsize and
- (Left_Valsize = 0 or else Left.Value.all = Right.Value.all);
- end "=";
-
-
- 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
- Value_Length : Natural;
- 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);
- end Debug_String;
-
-
@@ -233,6 +211,317 @@ package body Packrat.Lexer is
end Scan_Set_With;
+
+
+
+ function Sequence
+ (Input : in Element_Array;
+ Start : in Positive)
+ return Combinator_Result
+ is
+ Result : Combinator_Result := Create_Result (0, Success, Empty_Array);
+ Position : Positive := Start;
+ begin
+ if Start > Input'Last then
+ return Empty_Fail;
+ end if;
+ for C of Params loop
+ if Position > Input'Last then
+ Result.Status := Needs_More;
+ exit;
+ end if;
+ Result := Join (Result, C (Input, Position));
+ exit when Result.Status = Failure;
+ Position := Start + Result.Length;
+ end loop;
+ return Result;
+ end Sequence;
+
+
+ function Count
+ (Input : in Element_Array;
+ Start : in Positive)
+ return Combinator_Result
+ is
+ Result : Combinator_Result := Create_Result (0, Success, Empty_Array);
+ Position : Positive := Start;
+ begin
+ if Start > Input'Last then
+ return Empty_Fail;
+ end if;
+ for I in Integer range 1 .. Number loop
+ if Position > Input'Last then
+ Result.Status := Needs_More;
+ exit;
+ end if;
+ Result := Join (Result, Param (Input, Position));
+ exit when Result.Status = Failure;
+ Position := Start + Result.Length;
+ end loop;
+ return Result;
+ end Count;
+
+
+ function Many
+ (Input : in Element_Array;
+ Start : in Positive)
+ return Combinator_Result
+ is
+ Result : Combinator_Result := Create_Result (0, Success, Empty_Array);
+ Temp : Combinator_Result;
+ Position : Positive := Start;
+ Counter : Natural := 0;
+ begin
+ if Start > Input'Last then
+ return Empty_Fail;
+ end if;
+ loop
+ exit when Position > Input'Last;
+ Temp := Param (Input, Position);
+ exit when Temp.Status = Failure or Temp.Status = Needs_More;
+ Result := Join (Result, Temp);
+ Counter := Counter + 1;
+ Position := Start + Result.Length;
+ end loop;
+ if Counter < Minimum then
+ if Position > Input'Last or Temp.Status = Needs_More then
+ Result.Status := Needs_More;
+ else
+ Result.Status := Failure;
+ end if;
+ elsif Position > Input'Last or Temp.Status = Needs_More then
+ Result.Status := Optional_More;
+ else
+ Result.Status := Success;
+ end if;
+ return Result;
+ end Many;
+
+
+ function Many_Until
+ (Input : in Element_Array;
+ Start : in Positive)
+ return Combinator_Result
+ is
+ Result : Combinator_Result := Create_Result (0, Success, Empty_Array);
+ Temp : Combinator_Result;
+ Position : Positive := Start;
+ Counter : Natural := 0;
+ begin
+ if Start > Input'Last then
+ return Empty_Fail;
+ end if;
+ loop
+ exit when Position > Input'Last;
+ Temp := Param (Input, Position);
+ exit when Temp.Status = Failure or Temp.Status = Needs_More or Test (Input (Position));
+ Result := Join (Result, Temp);
+ Counter := Counter + 1;
+ Position := Start + Result.Length;
+ end loop;
+ if Counter < Minimum then
+ if Position > Input'Last or Temp.Status = Needs_More then
+ Result.Status := Needs_More;
+ else
+ Result.Status := Failure;
+ end if;
+ elsif Position > Input'Last then
+ Result.Status := Needs_More;
+ elsif Temp.Status = Needs_More and Test (Input (Position)) then
+ Result.Status := Optional_More;
+ elsif Test (Input (Position)) then
+ Result.Status := Success;
+ else
+ Result.Status := Failure;
+ end if;
+ return Result;
+ end Many_Until;
+
+
+
+
+
+ function Satisfy
+ (Input : in Element_Array;
+ Start : in Positive)
+ return Combinator_Result is
+ begin
+ if Start > Input'Last then
+ return Empty_Fail;
+ elsif Test (Input (Start)) then
+ return Create_Result (1, Success, (1 => Input (Start)));
+ else
+ return Empty_Fail;
+ end if;
+ end Satisfy;
+
+
+ function Satisfy_With
+ (Input : in Element_Array;
+ Start : in Positive)
+ return Combinator_Result is
+ begin
+ if Start > Input'Last then
+ return Empty_Fail;
+ elsif Test (Change (Input (Start))) then
+ return Create_Result (1, Success, (1 => Input (Start)));
+ else
+ return Empty_Fail;
+ end if;
+ end Satisfy_With;
+
+
+ function Match
+ (Input : in Element_Array;
+ Start : in Positive)
+ return Combinator_Result is
+ begin
+ if Start > Input'Last then
+ return Empty_Fail;
+ elsif Input (Start) = Item then
+ return Create_Result (1, Success, (1 => Item));
+ else
+ return Empty_Fail;
+ end if;
+ end Match;
+
+
+ function Match_With
+ (Input : in Element_Array;
+ Start : in Positive)
+ return Combinator_Result is
+ begin
+ if Start > Input'Last then
+ return Empty_Fail;
+ elsif Change (Input (Start)) = Item then
+ return Create_Result (1, Success, (1 => Input (Start)));
+ else
+ return Empty_Fail;
+ end if;
+ end Match_With;
+
+
+ function Multimatch
+ (Input : in Element_Array;
+ Start : in Positive)
+ return Combinator_Result
+ is
+ Current_Offset : Natural := 0;
+ begin
+ if Items'Length = 0 then
+ return Create_Result (0, Success, Empty_Array);
+ end if;
+
+ if Input'Last - Start + 1 <= 0 then
+ return Empty_Fail;
+ end if;
+
+ while Input (Start + Current_Offset) = Items (Items'First + Current_Offset) loop
+ if Items'First + Current_Offset = Items'Last then
+ return Create_Result (Current_Offset + 1, Success, Items);
+ elsif Start + Current_Offset = Input'Last then
+ return Create_Result (Current_Offset + 1, Needs_More, Input (Start .. Input'Last));
+ end if;
+ Current_Offset := Current_Offset + 1;
+ end loop;
+ return Create_Result (Current_Offset, Failure, Input (Start .. Start + Current_Offset - 1));
+ end Multimatch;
+
+
+ function Take
+ (Input : in Element_Array;
+ Start : in Positive)
+ return Combinator_Result is
+ begin
+ if Start > Input'Last then
+ return Empty_Fail;
+ elsif Start + Number - 1 > Input'Last then
+ return Create_Result (Input'Last - Start + 1, Needs_More, Input (Start .. Input'Last));
+ else
+ return Create_Result (Number, Success, Input (Start .. Start + Number - 1));
+ end if;
+ end Take;
+
+
+ function Take_While
+ (Input : in Element_Array;
+ Start : in Positive)
+ return Combinator_Result
+ is
+ Finish : Positive := Start;
+ Status : Result_Status;
+ begin
+ if Start > Input'Last or else not Test (Input (Start)) then
+ return Empty_Fail;
+ end if;
+ while Finish <= Input'Last and then Test (Input (Finish)) loop
+ Finish := Finish + 1;
+ end loop;
+ if Finish > Input'Last then
+ Status := Optional_More;
+ else
+ Status := Success;
+ end if;
+ return Create_Result (Finish - Start, Status, Input (Start .. Finish - 1));
+ end Take_While;
+
+
+ function Take_Until
+ (Input : in Element_Array;
+ Start : in Positive)
+ return Combinator_Result
+ is
+ Finish : Positive := Start;
+ Status : Result_Status;
+ begin
+ if Start > Input'Last or else Test (Input (Start)) then
+ return Empty_Fail;
+ end if;
+ while Finish <= Input'Last and then not Test (Input (Finish)) loop
+ Finish := Finish + 1;
+ end loop;
+ if Finish > Input'Last then
+ Status := Optional_More;
+ else
+ Status := Success;
+ end if;
+ return Create_Result (Finish - Start, Status, Input (Start .. Finish - 1));
+ end Take_Until;
+
+
+
+
+
+ function Line_End
+ (Input : in Element_Array;
+ Start : in Positive)
+ return Combinator_Result is
+ begin
+ if Start > Input'Last then
+ return Empty_Fail;
+ elsif Input (Start) = EOL_Item then
+ return Create_Result (1, Success, (1 => EOL_Item));
+ else
+ return Empty_Fail;
+ end if;
+ end Line_End;
+
+
+ function Input_End
+ (Input : in Element_Array;
+ Start : in Positive)
+ return Combinator_Result is
+ begin
+ if Start > Input'Last then
+ return Empty_Fail;
+ elsif Input (Start) = EOF_Item then
+ return Create_Result (1, Success, (1 => EOF_Item));
+ else
+ return Empty_Fail;
+ end if;
+ end Input_End;
+
+
end Packrat.Lexer;
diff --git a/src/packrat-lexer.ads b/src/packrat-lexer.ads
index d331645..382b7ff 100644
--- a/src/packrat-lexer.ads
+++ b/src/packrat-lexer.ads
@@ -20,31 +20,10 @@ package Packrat.Lexer is
type Combinator_Array is array (Positive range <>) of Combinator;
- Empty_Fail : constant Combinator_Result;
-
-
- function Create_Result
- (Length : in Natural;
- Status : in Result_Status;
- Value : in Element_Array)
- return Combinator_Result;
-
- function Join
- (Left, Right : in Combinator_Result)
- return Combinator_Result;
-
function "="
(Left, Right : in Combinator_Result)
return Boolean;
- function Status
- (This : in Combinator_Result)
- return Result_Status;
-
- function Debug_String
- (This : in Combinator_Result)
- return String;
-
@@ -60,6 +39,9 @@ package Packrat.Lexer is
type Component_Array is array (Positive range <>) of Lexer_Component;
+
+
+
generic
Label : in Label_Enum;
Combo : in Combinator;
@@ -124,22 +106,158 @@ package Packrat.Lexer is
Output : out Gen_Tokens.Token_Array);
+
+
+ generic
+ Params : in Combinator_Array;
+ function Sequence
+ (Input : in Element_Array;
+ Start : in Positive)
+ return Combinator_Result;
+
+ generic
+ with function Param
+ (Input : in Element_Array;
+ Start : in Positive)
+ return Combinator_Result;
+ Number : in Positive;
+ function Count
+ (Input : in Element_Array;
+ Start : in Positive)
+ return Combinator_Result;
+
+ generic
+ with function Param
+ (Input : in Element_Array;
+ Start : in Positive)
+ return Combinator_Result;
+ Minimum : in Natural := 0;
+ function Many
+ (Input : in Element_Array;
+ Start : in Positive)
+ return Combinator_Result;
+
+ generic
+ with function Param
+ (Input : in Element_Array;
+ Start : in Positive)
+ return Combinator_Result;
+ with function Test
+ (Item : in Element)
+ return Boolean;
+ Minimum : in Natural := 0;
+ function Many_Until
+ (Input : in Element_Array;
+ Start : in Positive)
+ return Combinator_Result;
+
+
+
+
+ generic
+ with function Test
+ (Item : in Element)
+ return Boolean;
+ function Satisfy
+ (Input : in Element_Array;
+ Start : in Positive)
+ return Combinator_Result;
+
+ generic
+ with function Test
+ (Item : in Element)
+ return Boolean;
+ with function Change
+ (From : in Element)
+ return Element;
+ function Satisfy_With
+ (Input : in Element_Array;
+ Start : in Positive)
+ return Combinator_Result;
+
+ generic
+ Item : in Element;
+ function Match
+ (Input : in Element_Array;
+ Start : in Positive)
+ return Combinator_Result;
+
+ generic
+ Item : in Element;
+ with function Change
+ (From : in Element)
+ return Element;
+ function Match_With
+ (Input : in Element_Array;
+ Start : in Positive)
+ return Combinator_Result;
+
+ generic
+ Items : in Element_Array;
+ function Multimatch
+ (Input : in Element_Array;
+ Start : in Positive)
+ return Combinator_Result;
+
+ generic
+ Number : in Positive := 1;
+ function Take
+ (Input : in Element_Array;
+ Start : in Positive)
+ return Combinator_Result;
+
+ generic
+ with function Test
+ (Item : in Element)
+ return Boolean;
+ function Take_While
+ (Input : in Element_Array;
+ Start : in Positive)
+ return Combinator_Result;
+
+ generic
+ with function Test
+ (Item : in Element)
+ return Boolean;
+ function Take_Until
+ (Input : in Element_Array;
+ Start : in Positive)
+ return Combinator_Result;
+
+
+
+
+ generic
+ EOL_Item : in Element;
+ function Line_End
+ (Input : in Element_Array;
+ Start : in Positive)
+ return Combinator_Result;
+
+ generic
+ EOF_Item : in Element;
+ function Input_End
+ (Input : in Element_Array;
+ Start : in Positive)
+ return Combinator_Result;
+
+
private
type Element_Array_Access is access Element_Array;
-
Empty_Array : Element_Array (1 .. 0);
+
+
type Combinator_Result is new Ada.Finalization.Controlled with record
Length : Natural;
Status : Result_Status;
Value : Element_Array_Access;
end record;
-
overriding procedure Initialize
(This : in out Combinator_Result);
@@ -149,7 +267,6 @@ private
overriding procedure Finalize
(This : in out Combinator_Result);
-
Empty_Fail : constant Combinator_Result :=
(Ada.Finalization.Controlled with
Length => 0,
@@ -161,7 +278,6 @@ private
type Lexer_Context is new Ada.Finalization.Controlled with null record;
-
Empty_Context : constant Lexer_Context := (Ada.Finalization.Controlled with null record);
diff --git a/test/packrat-lexer-debug.adb b/test/packrat-lexer-debug.adb
new file mode 100644
index 0000000..fdd9ae4
--- /dev/null
+++ b/test/packrat-lexer-debug.adb
@@ -0,0 +1,91 @@
+
+
+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;
+ begin
+ This.Length := Length;
+ This.Status := Status;
+ This.Value := new Element_Array (1 .. Value'Length);
+ This.Value.all := Value;
+ return This;
+ end Create_Result;
+
+
+ function Join
+ (Left, Right : in Combinator_Result)
+ return Combinator_Result
+ is
+ Merge : Combinator_Result;
+ Left_Valsize, Right_Valsize, Total_Valsize : Natural;
+ 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;
+ elsif Left.Status = Needs_More then
+ Merge := Left;
+ Merge.Status := Failure;
+ return Merge;
+ 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
+ Value_Length : Natural;
+ 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);
+ end Debug_String;
+
+
+end Packrat.Lexer.Debug;
+
+
diff --git a/test/packrat-lexer-debug.ads b/test/packrat-lexer-debug.ads
new file mode 100644
index 0000000..e8ddf7b
--- /dev/null
+++ b/test/packrat-lexer-debug.ads
@@ -0,0 +1,37 @@
+
+
+generic
+package Packrat.Lexer.Debug is
+
+
+ Empty_Fail : constant Combinator_Result;
+
+
+ function Create_Result
+ (Length : in Natural;
+ Status : in Result_Status;
+ Value : in Element_Array)
+ return Combinator_Result;
+
+ function Join
+ (Left, Right : in Combinator_Result)
+ return Combinator_Result;
+
+ function Status
+ (This : in Combinator_Result)
+ return Result_Status;
+
+ function Debug_String
+ (This : in Combinator_Result)
+ return String;
+
+
+private
+
+
+ Empty_Fail : constant Combinator_Result := Packrat.Lexer.Empty_Fail;
+
+
+end Packrat.Lexer.Debug;
+
+
diff --git a/test/ratnest-tests.adb b/test/ratnest-tests.adb
index 6f649d9..ebe4dae 100644
--- a/test/ratnest-tests.adb
+++ b/test/ratnest-tests.adb
@@ -4,7 +4,7 @@ with
Ada.Characters.Latin_1,
Ada.Strings.Maps,
- Packrat.Lexer.Combinators,
+ Packrat.Lexer.Debug,
Packrat.Util;
@@ -237,7 +237,7 @@ package body Ratnest.Tests is
package String_Tokens is new Packrat.Tokens (My_Labels, Character, String);
package Slexy is new Packrat.Lexer (My_Labels, Character, String, String_Tokens);
- package Strombo is new Slexy.Combinators;
+ package Slebug is new Slexy.Debug;
use type Slexy.Combinator_Result;
@@ -250,35 +250,35 @@ package body Ratnest.Tests is
return Test_Result
is
One : Slexy.Combinator_Result :=
- Slexy.Create_Result (1, Packrat.Success, "a");
+ Slebug.Create_Result (1, Packrat.Success, "a");
Two : Slexy.Combinator_Result :=
- Slexy.Create_Result (2, Packrat.Success, "bc");
+ Slebug.Create_Result (2, Packrat.Success, "bc");
Three : Slexy.Combinator_Result :=
- Slexy.Create_Result (3, Packrat.Success, "abc");
+ Slebug.Create_Result (3, Packrat.Success, "abc");
Four : Slexy.Combinator_Result :=
- Slexy.Create_Result (3, Packrat.Failure, "xyz");
+ Slebug.Create_Result (3, Packrat.Failure, "xyz");
Five : Slexy.Combinator_Result :=
- Slexy.Create_Result (4, Packrat.Failure, "axyz");
+ Slebug.Create_Result (4, Packrat.Failure, "axyz");
Six : Slexy.Combinator_Result :=
- Slexy.Create_Result (4, Packrat.Needs_More, "cd");
+ Slebug.Create_Result (4, Packrat.Needs_More, "cd");
Seven : Slexy.Combinator_Result :=
- Slexy.Create_Result (5, Packrat.Needs_More, "acd");
+ Slebug.Create_Result (5, Packrat.Needs_More, "acd");
Eight : Slexy.Combinator_Result :=
- Slexy.Create_Result (4, Packrat.Failure, "cd");
+ Slebug.Create_Result (4, Packrat.Failure, "cd");
Nine : Slexy.Combinator_Result :=
- Slexy.Create_Result (3, Packrat.Optional_More, "abc");
+ Slebug.Create_Result (3, Packrat.Optional_More, "abc");
Ten : Slexy.Combinator_Result :=
- Slexy.Create_Result (5, Packrat.Success, "abcbc");
+ Slebug.Create_Result (5, Packrat.Success, "abcbc");
begin
- if One.Join (Two) /= Three or One.Join (Four) /= Five or
- One.Join (Six) /= Seven or Four.Join (Six) /= Four or
- Five.Join (Two) /= Five or Six.Join (Three) /= Eight or
- Slexy.Empty_Fail.Join (One) /= Slexy.Empty_Fail or
- Nine.Join (Two) /= Ten
+ if Slebug.Join (One, Two) /= Three or Slebug.Join (One, Four) /= Five or
+ Slebug.Join (One, Six) /= Seven or Slebug.Join (Four, Six) /= Four or
+ Slebug.Join (Five, Two) /= Five or Slebug.Join (Six, Three) /= Eight or
+ Slebug.Join (Slebug.Empty_Fail, One) /= Slebug.Empty_Fail or
+ Slebug.Join (Nine, Two) /= Ten
then
return Fail;
end if;
@@ -290,11 +290,11 @@ package body Ratnest.Tests is
return Test_Result
is
One : Slexy.Combinator_Result :=
- Slexy.Create_Result (3, Packrat.Success, "abc");
+ Slebug.Create_Result (3, Packrat.Success, "abc");
Two : Slexy.Combinator_Result :=
- Slexy.Create_Result (0, Packrat.Failure, "");
+ Slebug.Create_Result (0, Packrat.Failure, "");
begin
- if One = Two or Two /= Slexy.Empty_Fail then
+ if One = Two or Two /= Slebug.Empty_Fail then
return Fail;
end if;
return Pass;
@@ -307,10 +307,10 @@ package body Ratnest.Tests is
function Sequence_Check
return Test_Result
is
- function Match_A is new Strombo.Match ('a');
- function Match_B is new Strombo.Match ('b');
- function Match_C is new Strombo.Match ('c');
- function Seq_Abc is new Strombo.Sequence
+ function Match_A is new Slexy.Match ('a');
+ function Match_B is new Slexy.Match ('b');
+ function Match_C is new Slexy.Match ('c');
+ function Seq_Abc is new Slexy.Sequence
((Match_A'Unrestricted_Access,
Match_B'Unrestricted_Access,
Match_C'Unrestricted_Access));
@@ -318,14 +318,14 @@ package body Ratnest.Tests is
Test_Str : String := "aababcabcab";
Result1 : Slexy.Combinator_Result :=
- Slexy.Create_Result (1, Packrat.Failure, "a");
+ Slebug.Create_Result (1, Packrat.Failure, "a");
Result2 : Slexy.Combinator_Result :=
- Slexy.Create_Result (2, Packrat.Needs_More, "ab");
+ Slebug.Create_Result (2, Packrat.Needs_More, "ab");
Result3 : Slexy.Combinator_Result :=
- Slexy.Create_Result (3, Packrat.Success, "abc");
- Result4 : Slexy.Combinator_Result := Slexy.Empty_Fail;
+ Slebug.Create_Result (3, Packrat.Success, "abc");
+ Result4 : Slexy.Combinator_Result := Slebug.Empty_Fail;
Result5 : Slexy.Combinator_Result :=
- Slexy.Create_Result (2, Packrat.Failure, "ab");
+ Slebug.Create_Result (2, Packrat.Failure, "ab");
begin
if Seq_Abc (Test_Str, 1) /= Result1 or Seq_Abc (Test_Str, 2) /= Result5 or
Seq_Abc (Test_Str, 4) /= Result3 or Seq_Abc (Test_Str, 10) /= Result2 or
@@ -341,24 +341,24 @@ package body Ratnest.Tests is
function Count_Check
return Test_Result
is
- function Match_A is new Strombo.Match ('a');
- function Match_B is new Strombo.Match ('b');
- function Count_2A is new Strombo.Count (Match_A, 2);
- function Count_3B is new Strombo.Count (Match_B, 3);
+ function Match_A is new Slexy.Match ('a');
+ function Match_B is new Slexy.Match ('b');
+ function Count_2A is new Slexy.Count (Match_A, 2);
+ function Count_3B is new Slexy.Count (Match_B, 3);
Test_Str : String := "abaabbaaabbbaaaabbbb";
Result1 : Slexy.Combinator_Result :=
- Slexy.Create_Result (1, Packrat.Failure, "a");
+ Slebug.Create_Result (1, Packrat.Failure, "a");
Result2 : Slexy.Combinator_Result :=
- Slexy.Create_Result (2, Packrat.Success, "aa");
+ Slebug.Create_Result (2, Packrat.Success, "aa");
Result3 : Slexy.Combinator_Result :=
- Slexy.Create_Result (1, Packrat.Failure, "b");
+ Slebug.Create_Result (1, Packrat.Failure, "b");
Result4 : Slexy.Combinator_Result :=
- Slexy.Create_Result (2, Packrat.Needs_More, "bb");
+ Slebug.Create_Result (2, Packrat.Needs_More, "bb");
Result5 : Slexy.Combinator_Result :=
- Slexy.Create_Result (3, Packrat.Success, "bbb");
- Result6 : Slexy.Combinator_Result := Slexy.Empty_Fail;
+ Slebug.Create_Result (3, Packrat.Success, "bbb");
+ Result6 : Slexy.Combinator_Result := Slebug.Empty_Fail;
begin
if Count_2A (Test_Str, 1) /= Result1 or Count_2A (Test_Str, 3) /= Result2 or
Count_3B (Test_Str, 2) /= Result3 or Count_3B (Test_Str, 19) /= Result4 or
@@ -375,39 +375,39 @@ package body Ratnest.Tests is
function Many_Check
return Test_Result
is
- function Match_A is new Strombo.Match ('a');
- function Many_0 is new Strombo.Many (Match_A);
- function Many_4 is new Strombo.Many (Match_A, 4);
+ function Match_A is new Slexy.Match ('a');
+ function Many_0 is new Slexy.Many (Match_A);
+ function Many_4 is new Slexy.Many (Match_A, 4);
- function Match_B is new Strombo.Match ('b');
- function Match_C is new Strombo.Match ('c');
- function Seq_Abc is new Strombo.Sequence
+ function Match_B is new Slexy.Match ('b');
+ function Match_C is new Slexy.Match ('c');
+ function Seq_Abc is new Slexy.Sequence
((Match_A'Unrestricted_Access,
Match_B'Unrestricted_Access,
Match_C'Unrestricted_Access));
- function Many_Seq_0 is new Strombo.Many (Seq_Abc);
- function Many_Seq_4 is new Strombo.Many (Seq_Abc, 4);
+ function Many_Seq_0 is new Slexy.Many (Seq_Abc);
+ function Many_Seq_4 is new Slexy.Many (Seq_Abc, 4);
Test_Str : String := "aaabbaaaaabaa";
Test_Str2 : String := "aababcabcab";
Result1 : Slexy.Combinator_Result :=
- Slexy.Create_Result (3, Packrat.Success, "aaa");
+ Slebug.Create_Result (3, Packrat.Success, "aaa");
Result2 : Slexy.Combinator_Result :=
- Slexy.Create_Result (2, Packrat.Optional_More, "aa");
+ Slebug.Create_Result (2, Packrat.Optional_More, "aa");
Result3 : Slexy.Combinator_Result :=
- Slexy.Create_Result (5, Packrat.Success, "aaaaa");
+ Slebug.Create_Result (5, Packrat.Success, "aaaaa");
Result4 : Slexy.Combinator_Result :=
- Slexy.Create_Result (3, Packrat.Failure, "aaa");
- Result5 : Slexy.Combinator_Result := Slexy.Empty_Fail;
+ Slebug.Create_Result (3, Packrat.Failure, "aaa");
+ Result5 : Slexy.Combinator_Result := Slebug.Empty_Fail;
Result6 : Slexy.Combinator_Result :=
- Slexy.Create_Result (2, Packrat.Needs_More, "aa");
+ Slebug.Create_Result (2, Packrat.Needs_More, "aa");
Result7 : Slexy.Combinator_Result :=
- Slexy.Create_Result (0, Packrat.Success, "");
+ Slebug.Create_Result (0, Packrat.Success, "");
Result8 : Slexy.Combinator_Result :=
- Slexy.Create_Result (6, Packrat.Optional_More, "abcabc");
+ Slebug.Create_Result (6, Packrat.Optional_More, "abcabc");
Result9 : Slexy.Combinator_Result :=
- Slexy.Create_Result (6, Packrat.Needs_More, "abcabc");
+ Slebug.Create_Result (6, Packrat.Needs_More, "abcabc");
begin
if Many_0 (Test_Str, 1) /= Result1 or Many_4 (Test_Str, 1) /= Result4 or
Many_4 (Test_Str, 6) /= Result3 or Many_0 (Test_Str, 4) /= Result7 or
@@ -424,19 +424,19 @@ package body Ratnest.Tests is
function Many_Until_Check
return Test_Result
is
- function Match_A is new Strombo.Match ('a');
- function Many_Until_0 is new Strombo.Many_Until (Match_A, PU.Is_Digit);
- function Many_Until_3 is new Strombo.Many_Until (Match_A, PU.Is_Digit, 3);
+ function Match_A is new Slexy.Match ('a');
+ function Many_Until_0 is new Slexy.Many_Until (Match_A, PU.Is_Digit);
+ function Many_Until_3 is new Slexy.Many_Until (Match_A, PU.Is_Digit, 3);
Test_Str : String := "aaaabbaaa123aaa";
Result1 : Slexy.Combinator_Result :=
- Slexy.Create_Result (4, Packrat.Failure, "aaaa");
+ Slebug.Create_Result (4, Packrat.Failure, "aaaa");
Result2 : Slexy.Combinator_Result :=
- Slexy.Create_Result (3, Packrat.Success, "aaa");
+ Slebug.Create_Result (3, Packrat.Success, "aaa");
Result3 : Slexy.Combinator_Result :=
- Slexy.Create_Result (3, Packrat.Needs_More, "aaa");
- Result4 : Slexy.Combinator_Result := Slexy.Empty_Fail;
+ Slebug.Create_Result (3, Packrat.Needs_More, "aaa");
+ Result4 : Slexy.Combinator_Result := Slebug.Empty_Fail;
begin
if Many_Until_0 (Test_Str, 1) /= Result1 or
Many_Until_0 (Test_Str, 7) /= Result2 or
@@ -468,16 +468,16 @@ package body Ratnest.Tests is
return Char = 'a' or Char = 'b' or Char = 'c';
end Is_Abc;
- function Satisfy_123 is new Strombo.Satisfy (Is_123);
- function Satisfy_Abc is new Strombo.Satisfy (Is_Abc);
+ function Satisfy_123 is new Slexy.Satisfy (Is_123);
+ function Satisfy_Abc is new Slexy.Satisfy (Is_Abc);
Test_Str : String := "abc123456def";
Result1 : Slexy.Combinator_Result :=
- Slexy.Create_Result (1, Packrat.Success, "b");
+ Slebug.Create_Result (1, Packrat.Success, "b");
Result2 : Slexy.Combinator_Result :=
- Slexy.Create_Result (1, Packrat.Success, "3");
- Result3 : Slexy.Combinator_Result := Slexy.Empty_Fail;
+ Slebug.Create_Result (1, Packrat.Success, "3");
+ Result3 : Slexy.Combinator_Result := Slebug.Empty_Fail;
begin
if Satisfy_123 (Test_Str, 6) /= Result2 or
Satisfy_Abc (Test_Str, 2) /= Result1 or
@@ -512,16 +512,16 @@ package body Ratnest.Tests is
return Character'Val (Character'Pos (Char) - 1);
end Minus_One;
- function Satisfy_Bcd is new Strombo.Satisfy_With (Is_Abc, Minus_One);
- function Satisfy_234 is new Strombo.Satisfy_With (Is_123, Minus_One);
+ function Satisfy_Bcd is new Slexy.Satisfy_With (Is_Abc, Minus_One);
+ function Satisfy_234 is new Slexy.Satisfy_With (Is_123, Minus_One);
Test_Str : String := "abcde12345";
Result1 : Slexy.Combinator_Result :=
- Slexy.Create_Result (1, Packrat.Success, "c");
+ Slebug.Create_Result (1, Packrat.Success, "c");
Result2 : Slexy.Combinator_Result :=
- Slexy.Create_Result (1, Packrat.Success, "2");
- Result3 : Slexy.Combinator_Result := Slexy.Empty_Fail;
+ Slebug.Create_Result (1, Packrat.Success, "2");
+ Result3 : Slexy.Combinator_Result := Slebug.Empty_Fail;
begin
if Satisfy_Bcd (Test_Str, 3) /= Result1 or
Satisfy_234 (Test_Str, 7) /= Result2 or
@@ -537,19 +537,19 @@ package body Ratnest.Tests is
function Match_Check
return Test_Result
is
- function Match_A is new Strombo.Match ('a');
- function Match_Slash is new Strombo.Match ('/');
- function Match_4 is new Strombo.Match ('4');
+ function Match_A is new Slexy.Match ('a');
+ function Match_Slash is new Slexy.Match ('/');
+ function Match_4 is new Slexy.Match ('4');
Test_Str : String := "abc1234./5";
Result1 : Slexy.Combinator_Result :=
- Slexy.Create_Result (1, Packrat.Success, "a");
+ Slebug.Create_Result (1, Packrat.Success, "a");
Result2 : Slexy.Combinator_Result :=
- Slexy.Create_Result (1, Packrat.Success, "/");
+ Slebug.Create_Result (1, Packrat.Success, "/");
Result3 : Slexy.Combinator_Result :=
- Slexy.Create_Result (1, Packrat.Success, "4");
- Result4 : Slexy.Combinator_Result := Slexy.Empty_Fail;
+ Slebug.Create_Result (1, Packrat.Success, "4");
+ Result4 : Slexy.Combinator_Result := Slebug.Empty_Fail;
begin
if Match_A (Test_Str, 1) /= Result1 or
Match_Slash (Test_Str, 9) /= Result2 or
@@ -573,16 +573,16 @@ package body Ratnest.Tests is
return Character'Val (Character'Pos (Char) + 1);
end Plus_One;
- function Match_A is new Strombo.Match_With ('b', Plus_One);
- function Match_6 is new Strombo.Match_With ('7', Plus_One);
+ function Match_A is new Slexy.Match_With ('b', Plus_One);
+ function Match_6 is new Slexy.Match_With ('7', Plus_One);
Test_Str : String := "abc5678";
Result1 : Slexy.Combinator_Result :=
- Slexy.Create_Result (1, Packrat.Success, "a");
+ Slebug.Create_Result (1, Packrat.Success, "a");
Result2 : Slexy.Combinator_Result :=
- Slexy.Create_Result (1, Packrat.Success, "6");
- Result3 : Slexy.Combinator_Result := Slexy.Empty_Fail;
+ Slebug.Create_Result (1, Packrat.Success, "6");
+ Result3 : Slexy.Combinator_Result := Slebug.Empty_Fail;
begin
if Match_A (Test_Str, 1) /= Result1 or
Match_6 (Test_Str, 5) /= Result2 or
@@ -598,20 +598,20 @@ package body Ratnest.Tests is
function Multimatch_Check
return Test_Result
is
- function Match_String1 is new Strombo.Multimatch ("abc");
- function Match_String2 is new Strombo.Multimatch ("hello");
+ function Match_String1 is new Slexy.Multimatch ("abc");
+ function Match_String2 is new Slexy.Multimatch ("hello");
Test_Str : String := "abcdefabhelloworldab";
Result1 : Slexy.Combinator_Result :=
- Slexy.Create_Result (3, Packrat.Success, "abc");
+ Slebug.Create_Result (3, Packrat.Success, "abc");
Result2 : Slexy.Combinator_Result :=
- Slexy.Create_Result (2, Packrat.Needs_More, "ab");
+ Slebug.Create_Result (2, Packrat.Needs_More, "ab");
Result3 : Slexy.Combinator_Result :=
- Slexy.Create_Result (5, Packrat.Success, "hello");
+ Slebug.Create_Result (5, Packrat.Success, "hello");
Result4 : Slexy.Combinator_Result :=
- Slexy.Create_Result (2, Packrat.Failure, "ab");
- Result5 : Slexy.Combinator_Result := Slexy.Empty_Fail;
+ Slebug.Create_Result (2, Packrat.Failure, "ab");
+ Result5 : Slexy.Combinator_Result := Slebug.Empty_Fail;
begin
if Match_String1 (Test_Str, 1) /= Result1 or
Match_String1 (Test_Str, 7) /= Result4 or
@@ -629,18 +629,18 @@ package body Ratnest.Tests is
function Take_Check
return Test_Result
is
- function Take_1 is new Strombo.Take;
- function Take_5 is new Strombo.Take (5);
+ function Take_1 is new Slexy.Take;
+ function Take_5 is new Slexy.Take (5);
Test_Str : String := "abcdefghi";
Result1 : Slexy.Combinator_Result :=
- Slexy.Create_Result (1, Packrat.Success, "b");
+ Slebug.Create_Result (1, Packrat.Success, "b");
Result2 : Slexy.Combinator_Result :=
- Slexy.Create_Result (3, Packrat.Needs_More, "ghi");
+ Slebug.Create_Result (3, Packrat.Needs_More, "ghi");
Result3 : Slexy.Combinator_Result :=
- Slexy.Create_Result (5, Packrat.Success, "cdefg");
- Result4 : Slexy.Combinator_Result := Slexy.Empty_Fail;
+ Slebug.Create_Result (5, Packrat.Success, "cdefg");
+ Result4 : Slexy.Combinator_Result := Slebug.Empty_Fail;
begin
if Take_1 (Test_Str, 2) /= Result1 or Take_5 (Test_Str, 7) /= Result2 or
Take_5 (Test_Str, 3) /= Result3 or
@@ -655,23 +655,23 @@ package body Ratnest.Tests is
function Take_While_Check
return Test_Result
is
- function Take_Letters is new Strombo.Take_While (PU.Is_Letter);
- function Take_Punch is new Strombo.Take_While (PU.Is_Punctuation);
- function Take_Digits is new Strombo.Take_While (PU.Is_Digit);
+ function Take_Letters is new Slexy.Take_While (PU.Is_Letter);
+ function Take_Punch is new Slexy.Take_While (PU.Is_Punctuation);
+ function Take_Digits is new Slexy.Take_While (PU.Is_Digit);
Test_Str : String := "abcde,./;'fghi[]=-^563";
Result1 : Slexy.Combinator_Result :=
- Slexy.Create_Result (4, Packrat.Success, "bcde");
+ Slebug.Create_Result (4, Packrat.Success, "bcde");
Result2 : Slexy.Combinator_Result :=
- Slexy.Create_Result (2, Packrat.Success, "hi");
+ Slebug.Create_Result (2, Packrat.Success, "hi");
Result3 : Slexy.Combinator_Result :=
- Slexy.Create_Result (5, Packrat.Success, ",./;'");
+ Slebug.Create_Result (5, Packrat.Success, ",./;'");
Result4 : Slexy.Combinator_Result :=
- Slexy.Create_Result (3, Packrat.Success, "=-^");
- Result5 : Slexy.Combinator_Result := Slexy.Empty_Fail;
+ Slebug.Create_Result (3, Packrat.Success, "=-^");
+ Result5 : Slexy.Combinator_Result := Slebug.Empty_Fail;
Result6 : Slexy.Combinator_Result :=
- Slexy.Create_Result (3, Packrat.Optional_More, "563");
+ Slebug.Create_Result (3, Packrat.Optional_More, "563");
begin
if Take_Letters (Test_Str, 2) /= Result1 or
Take_Letters (Test_Str, 13) /= Result2 or
@@ -690,20 +690,20 @@ package body Ratnest.Tests is
function Take_Until_Check
return Test_Result
is
- function Take_Till_Punch is new Strombo.Take_Until (PU.Is_Punctuation);
- function Take_Till_Digit is new Strombo.Take_Until (PU.Is_Digit);
+ function Take_Till_Punch is new Slexy.Take_Until (PU.Is_Punctuation);
+ function Take_Till_Digit is new Slexy.Take_Until (PU.Is_Digit);
Test_Str : String := "abcde12345;;;fghi67";
Result1 : Slexy.Combinator_Result :=
- Slexy.Create_Result (7, Packrat.Success, "de12345");
+ Slebug.Create_Result (7, Packrat.Success, "de12345");
Result2 : Slexy.Combinator_Result :=
- Slexy.Create_Result (4, Packrat.Optional_More, "hi67");
+ Slebug.Create_Result (4, Packrat.Optional_More, "hi67");
Result3 : Slexy.Combinator_Result :=
- Slexy.Create_Result (5, Packrat.Success, "abcde");
+ Slebug.Create_Result (5, Packrat.Success, "abcde");
Result4 : Slexy.Combinator_Result :=
- Slexy.Create_Result (6, Packrat.Success, ";;fghi");
- Result5 : Slexy.Combinator_Result := Slexy.Empty_Fail;
+ Slebug.Create_Result (6, Packrat.Success, ";;fghi");
+ Result5 : Slexy.Combinator_Result := Slebug.Empty_Fail;
begin
if Take_Till_Punch (Test_Str, 4) /= Result1 or
Take_Till_Punch (Test_Str, 16) /= Result2 or
@@ -721,16 +721,16 @@ package body Ratnest.Tests is
function Line_End_Check
return Test_Result
is
- function LF_End is new Strombo.Line_End (Latin.LF);
- function C_End is new Strombo.Line_End ('c');
+ function LF_End is new Slexy.Line_End (Latin.LF);
+ function C_End is new Slexy.Line_End ('c');
Test_Str : String := "abcd" & Latin.LF & "e";
Result1 : Slexy.Combinator_Result :=
- Slexy.Create_Result (1, Packrat.Success, (1 => Latin.LF));
+ Slebug.Create_Result (1, Packrat.Success, (1 => Latin.LF));
Result2 : Slexy.Combinator_Result :=
- Slexy.Create_Result (1, Packrat.Success, "c");
- Result3 : Slexy.Combinator_Result := Slexy.Empty_Fail;
+ Slebug.Create_Result (1, Packrat.Success, "c");
+ Result3 : Slexy.Combinator_Result := Slebug.Empty_Fail;
begin
if LF_End (Test_Str, 5) /= Result1 or C_End (Test_Str, 3) /= Result2 or
LF_End (Test_Str, Test_Str'Last + 5) /= Result3 or LF_End (Test_Str, 1) /= Result3
@@ -744,16 +744,16 @@ package body Ratnest.Tests is
function Input_End_Check
return Test_Result
is
- function C_End is new Strombo.Input_End ('c');
- function E_End is new Strombo.Input_End ('e');
+ function C_End is new Slexy.Input_End ('c');
+ function E_End is new Slexy.Input_End ('e');
Test_Str : String := "abcde";
Result1 : Slexy.Combinator_Result :=
- Slexy.Create_Result (1, Packrat.Success, "e");
+ Slebug.Create_Result (1, Packrat.Success, "e");
Result2 : Slexy.Combinator_Result :=
- Slexy.Create_Result (1, Packrat.Success, "c");
- Result3 : Slexy.Combinator_Result := Slexy.Empty_Fail;
+ Slebug.Create_Result (1, Packrat.Success, "c");
+ Result3 : Slexy.Combinator_Result := Slebug.Empty_Fail;
begin
if C_End (Test_Str, 3) /= Result2 or E_End (Test_Str, 5) /= Result1 or
C_End (Test_Str, 6) /= Result3 or E_End (Test_Str, 6) /= Result3 or