Natools

Diff
Login

Differences From Artifact [90e8bf6ef8]:

To Artifact [0a7601bdad]:


22
23
24
25
26
27
28

29
30
31
32
33
34
35
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36







+







-- Descriptor interface. A subparser is constrained to its initial nesting  --
-- level, and reports end-of-input instead of reaching lower.               --
------------------------------------------------------------------------------

with Ada.Streams;

with Natools.S_Expressions.Atom_Buffers;
with Natools.S_Expressions.Lockable;

package Natools.S_Expressions.Parsers is
   pragma Preelaborate (Natools.S_Expressions.Parsers);

   type Parser is tagged private;

   function Current_Event (P : in Parser) return Events.Event;
49
50
51
52
53
54
55
56

57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72










73
74
75
76
77
78
79
50
51
52
53
54
55
56

57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90







-
+
















+
+
+
+
+
+
+
+
+
+







     (P     : in out Parser;
      Input : not null access Ada.Streams.Root_Stream_Type'Class);


   type Subparser
     (Backend : access Parser;
      Input   : access Ada.Streams.Root_Stream_Type'Class)
   is new Descriptor with private;
   is new Lockable.Descriptor with private;

   overriding function Current_Event (P : in Subparser) return Events.Event;
   overriding function Current_Atom (P : in Subparser) return Atom;
   overriding function Current_Level (P : in Subparser) return Natural;

   overriding procedure Query_Atom
     (P : in Subparser;
      Process : not null access procedure (Data : in Atom));

   overriding procedure Read_Atom
     (P      : in Subparser;
      Data   : out Atom;
      Length : out Count);

   overriding procedure Next (P : in out Subparser; Event : out Events.Event);


   overriding procedure Lock
     (Object : in out Subparser;
      State : out Lockable.Lock_State);

   overriding procedure Unlock
     (Object : in out Subparser;
      State : in out Lockable.Lock_State;
      Finish : in Boolean := True);

   procedure Finish (P : in out Subparser);
      --  Read enough data to exhaust intial nesting level

private

   type Internal_State is
     (Waiting,          --  waiting for a marker
116
117
118
119
120
121
122
123
124


125
126
127
128
129
127
128
129
130
131
132
133


134
135
136
137
138
139
140







-
-
+
+





      Buffer       : Atom_Buffers.Atom_Buffer;
      Level        : Natural := 0;
   end record;

   type Subparser
     (Backend : access Parser;
      Input   : access Ada.Streams.Root_Stream_Type'Class)
   is new Descriptor with record
      Base_Level  : Natural := 0;
   is new Lockable.Descriptor with record
      Levels      : Lockable.Lock_Stack;
      Initialized : Boolean := False;
      Terminated  : Boolean := False;
   end record;

end Natools.S_Expressions.Parsers;