Natools

Check-in [1b11361e94]
Login
Overview
Comment:s_expressions-parsers: add a memory-backed parser
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 1b11361e94163b0f0759c5ed3d89934f15dacc78
User & Date: nat on 2017-04-10 21:30:17
Other Links: manifest | tags
Context
2017-04-11
21:28
s_expressions-parsers-tests: test the new memory-backed parser check-in: 35261eb800 user: nat tags: trunk
2017-04-10
21:30
s_expressions-parsers: add a memory-backed parser check-in: 1b11361e94 user: nat tags: trunk
2017-03-03
20:02
smaz_implementations-base_64_tools: remove unneeded funct. Symbol_Count check-in: aaf366bd15 user: nat tags: trunk
Changes

Modified src/natools-s_expressions-parsers.adb from [5ca94300aa] to [34cbfd8f4f].

493
494
495
496
497
498
499























500
      Self.Input.Read (Item, Last);

      if Last in Item'Range then
         Buffer.Append (Item (Item'First .. Last));
      end if;
   end Read_More;
























end Natools.S_Expressions.Parsers;







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
      Self.Input.Read (Item, Last);

      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;

Modified src/natools-s_expressions-parsers.ads from [d3a8d580f5] to [e90f7c8d46].

71
72
73
74
75
76
77












78
79
80
81
82
83
84



   type Stream_Parser (Input : access Ada.Streams.Root_Stream_Type'Class) is
     limited new Lockable.Descriptor with private;
   pragma Preelaborable_Initialization (Stream_Parser);













private

   type Internal_State is
     (Waiting,          --  waiting for a marker
      Base64_Atom,      --  reading an atom encoded in base 64
      Base64_Expr,      --  reading an expression encoded in base 64
      Hex_Atom,         --  reading an atom encoded in hexadecimal







>
>
>
>
>
>
>
>
>
>
>
>







71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96



   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
      Base64_Expr,      --  reading an expression encoded in base 64
      Hex_Atom,         --  reading an atom encoded in hexadecimal
123
124
125
126
127
128
129
130







131

   type Stream_Parser (Input : access Ada.Streams.Root_Stream_Type'Class) is
     limited new Parser with null record;

   overriding procedure Read_More
     (Self : in out Stream_Parser;
      Buffer : out Atom_Buffers.Atom_Buffer);








end Natools.S_Expressions.Parsers;








>
>
>
>
>
>
>

135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150

   type Stream_Parser (Input : access Ada.Streams.Root_Stream_Type'Class) is
     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;