summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/packrat-lexer.ads24
-rw-r--r--test/packrat-lexer-debug.adb32
-rw-r--r--test/packrat-lexer-debug.ads29
3 files changed, 83 insertions, 2 deletions
diff --git a/src/packrat-lexer.ads b/src/packrat-lexer.ads
index 382b7ff..fe5ff9d 100644
--- a/src/packrat-lexer.ads
+++ b/src/packrat-lexer.ads
@@ -1,5 +1,10 @@
+private with
+
+ Ada.Containers.Vectors;
+
+
generic
type Label_Enum is (<>);
@@ -276,9 +281,24 @@ private
- type Lexer_Context is new Ada.Finalization.Controlled with null record;
+ package Token_Vectors is new Ada.Containers.Vectors
+ (Index_Type => Positive,
+ Element_Type => Gen_Tokens.Token,
+ "=" => Gen_Tokens."=");
- Empty_Context : constant Lexer_Context := (Ada.Finalization.Controlled with null record);
+ type Lexer_Context is new Ada.Finalization.Controlled with record
+ Result_So_Far : Token_Vectors.Vector;
+ Position : Positive;
+ Status : Result_Status;
+ Pass_Forward : Element_Array_Access;
+ end record;
+
+ Empty_Context : constant Lexer_Context :=
+ (Ada.Finalization.Controlled with
+ Result_So_Far => Token_Vectors.Empty_Vector,
+ Position => 1,
+ Status => Success,
+ Pass_Forward => null);
end Packrat.Lexer;
diff --git a/test/packrat-lexer-debug.adb b/test/packrat-lexer-debug.adb
index fdd9ae4..f13a675 100644
--- a/test/packrat-lexer-debug.adb
+++ b/test/packrat-lexer-debug.adb
@@ -86,6 +86,38 @@ package body Packrat.Lexer.Debug is
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 Pass
+ (This : in Lexer_Context)
+ return access Element_Array is
+ begin
+ return This.Pass_Forward;
+ end Pass;
+
+
end Packrat.Lexer.Debug;
diff --git a/test/packrat-lexer-debug.ads b/test/packrat-lexer-debug.ads
index e8ddf7b..e68d6f4 100644
--- a/test/packrat-lexer-debug.ads
+++ b/test/packrat-lexer-debug.ads
@@ -1,5 +1,10 @@
+with
+
+ Ada.Containers.Vectors;
+
+
generic
package Packrat.Lexer.Debug is
@@ -26,12 +31,36 @@ package Packrat.Lexer.Debug is
return String;
+
+
+ type Token_Vector is private;
+
+ function So_Far
+ (This : in Lexer_Context)
+ return Token_Vector;
+
+ function Position
+ (This : in Lexer_Context)
+ return Positive;
+
+ function Status
+ (This : in Lexer_Context)
+ return Result_Status;
+
+ function Pass
+ (This : in Lexer_Context)
+ return access Element_Array;
+
+
private
Empty_Fail : constant Combinator_Result := Packrat.Lexer.Empty_Fail;
+ type Token_Vector is new Token_Vectors.Vector with null record;
+
+
end Packrat.Lexer.Debug;