summaryrefslogtreecommitdiff
path: root/src/packrat-parsers.adb
diff options
context:
space:
mode:
Diffstat (limited to 'src/packrat-parsers.adb')
-rw-r--r--src/packrat-parsers.adb40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/packrat-parsers.adb b/src/packrat-parsers.adb
index e4fa97d..0ddd864 100644
--- a/src/packrat-parsers.adb
+++ b/src/packrat-parsers.adb
@@ -622,6 +622,46 @@ package body Packrat.Parsers is
end Stamp;
+ function Discard
+ (Input : in Traits.Element_Array;
+ Context : in out Parser_Context;
+ Start : in Positive)
+ return Combinator_Result
+ is
+ function Actual
+ (Context : in out Parser_Context)
+ return Combinator_Result
+ is
+ Salt : Combinator_Result := Combo (Input, Context, Start);
+ Processed : Result_Sets.Set;
+ begin
+ if Salt.Status = Failure then
+ declare
+ Error : String := Packrat.Errors.Encode
+ (Traits.Label_Enum'Image (Label), Start);
+ begin
+ if Ada.Strings.Unbounded.Index (Context.Error_String, Error) = 0 then
+ Ada.Strings.Unbounded.Append (Context.Error_String, Error);
+ end if;
+ end;
+ return Salt;
+ end if;
+ for R of Salt.Results loop
+ Processed.Include
+ ((Finish => R.Finish,
+ Value => Elem_Holds.Empty_Holder,
+ Tokens => Tok_Holds.Empty_Holder));
+ end loop;
+ Salt.Results := Processed;
+ return Salt;
+ end Actual;
+ function Memo is new Memoize (To_Key (Start, Discard'Access), Actual);
+ function Curt is new Curtailment (To_Key (Start, Discard'Access), Input, Memo);
+ begin
+ return Curt (Context);
+ end Discard;
+
+
function Ignore
(Input : in Traits.Element_Array;
Context : in out Parser_Context;