1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
with
Ada.Strings.Fixed,
Ada.Strings.Maps;
use type
Ada.Strings.Maps.Character_Set;
separate (Packrat.Errors)
package body Parts is
package Str renames Ada.Strings;
package Fix renames Ada.Strings.Fixed;
package Map renames Ada.Strings.Maps;
ID_Start, ID_Finish : Positive := 1;
Pos_Start, Pos_Finish : Positive := 1;
Error_Count : Natural := Fix.Count (Message, Map.To_Set ('s'));
Letter_Range : Map.Character_Range := ('A', 'Z');
Digit_Range : Map.Character_Range := ('0', '9');
ID_Set : Map.Character_Set := Map.To_Set (Letter_Range) or Map.To_Set ('_');
Pos_Set : Map.Character_Set := Map.To_Set (Digit_Range);
function Length
return Natural is
begin
return Error_Count;
end Length;
procedure Reset_Position is
begin
ID_Start := 1;
ID_Finish := 1;
Pos_Start := 1;
Pos_Finish := 1;
end Reset_Position;
procedure Set_Position
(To : in Positive) is
begin
ID_Start := To;
ID_Finish := To;
Pos_Start := To;
Pos_Finish := To;
end Set_Position;
procedure Next_ID_Token
(Start : out Positive;
Finish : out Natural) is
begin
Fix.Find_Token (Message, ID_Set, Pos_Finish, Str.Inside, ID_Start, ID_Finish);
Start := ID_Start;
Finish := ID_Finish;
Pos_Finish := ID_Finish;
end Next_ID_Token;
procedure Next_Pos_Token
(Start : out Positive;
Finish : out Natural) is
begin
Fix.Find_Token (Message, Pos_Set, ID_Finish, Str.Inside, Pos_Start, Pos_Finish);
Start := Pos_Start;
Finish := Pos_Finish;
ID_Finish := Pos_Finish;
end Next_Pos_Token;
procedure Next_Full_Token
(Start : out Positive;
Finish : out Natural)
is
Dummy : Natural;
begin
Next_ID_Token (Start, Dummy);
Next_Pos_Token (Dummy, Finish);
Start := Start - 1;
end Next_Full_Token;
end Parts;
|