Index: src/natools-s_expressions-parsers.adb ================================================================== --- src/natools-s_expressions-parsers.adb +++ src/natools-s_expressions-parsers.adb @@ -495,6 +495,29 @@ if Last in Item'Range then Buffer.Append (Item (Item'First .. Last)); end if; end Read_More; + + + ------------------- + -- Memory Parser -- + ------------------- + + not overriding function Create + (Data : in Ada.Streams.Stream_Element_Array) + return Memory_Parser is + begin + return P : Memory_Parser do + P.Pending.Append (Data); + P.Pending.Invert; + end return; + end Create; + + + not overriding function Create_From_String + (Data : in String) return Memory_Parser is + begin + return Create (To_Atom (Data)); + end Create_From_String; + end Natools.S_Expressions.Parsers; Index: src/natools-s_expressions-parsers.ads ================================================================== --- src/natools-s_expressions-parsers.ads +++ src/natools-s_expressions-parsers.ads @@ -73,10 +73,22 @@ type Stream_Parser (Input : access Ada.Streams.Root_Stream_Type'Class) is limited new Lockable.Descriptor with private; pragma Preelaborable_Initialization (Stream_Parser); + + + type Memory_Parser (<>) is limited new Lockable.Descriptor with private; + pragma Preelaborable_Initialization (Memory_Parser); + + not overriding function Create + (Data : in Ada.Streams.Stream_Element_Array) + return Memory_Parser; + + not overriding function Create_From_String + (Data : in String) return Memory_Parser; + private type Internal_State is (Waiting, -- waiting for a marker Base64_Atom, -- reading an atom encoded in base 64 @@ -125,7 +137,14 @@ limited new Parser with null record; overriding procedure Read_More (Self : in out Stream_Parser; Buffer : out Atom_Buffers.Atom_Buffer); + + type Memory_Parser is limited new Parser with null record; + + overriding procedure Read_More + (Self : in out Memory_Parser; + Buffer : out Atom_Buffers.Atom_Buffer) + is null; end Natools.S_Expressions.Parsers;