blob: 97e42728d5c5ab2f8a37e4c3bf47280dbcf1fae9 (
plain)
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
|
with
Ada.Characters.Latin_1;
package body Packrat.Utilities is
package Latin renames Ada.Characters.Latin_1;
package Strmaps renames Ada.Strings.Maps;
function In_Set
(Element : in Character)
return Boolean is
begin
return Strmaps.Is_In (Element, Set);
end In_Set;
function Not_In_Set
(Element : in Character)
return Boolean is
begin
return not Strmaps.Is_In (Element, Set);
end Not_In_Set;
function Is_Digit
(Char : in Character)
return Boolean is
begin
return (Char >= '0' and Char <= '9');
end Is_Digit;
function Is_Hex
(Char : in Character)
return Boolean is
begin
return
(Char >= '0' and Char <= '9') or
(Char >= 'A' and Char <= 'F') or
(Char >= 'a' and Char <= 'f');
end Is_Hex;
function Is_Letter
(Char : in Character)
return Boolean is
begin
return
(Char >= 'A' and Char <= 'Z') or
(Char >= 'a' and Char <= 'z');
end Is_Letter;
function Is_Alphanumeric
(Char : in Character)
return Boolean is
begin
return Is_Digit (Char) or Is_Letter (Char);
end Is_Alphanumeric;
function Is_Punctuation
(Char : in Character)
return Boolean is
begin
return
(Char >= '!' and Char <= '/') or
(Char >= ':' and Char <= '@') or
(Char >= '[' and Char <= '`') or
(Char >= '{' and Char <= '~');
end Is_Punctuation;
function Is_ASCII
(Char : in Character)
return Boolean is
begin
return Char <= Character'Val (127);
end Is_ASCII;
function Is_Extended_ASCII
(Char : in Character)
return Boolean is
begin
return Char >= Character'Val (128);
end Is_Extended_ASCII;
function Is_Space
(Char : in Character)
return Boolean is
begin
return Char = ' ';
end Is_Space;
function Is_Linespace
(Char : in Character)
return Boolean is
begin
return (Char = ' ' or Char = Latin.HT);
end Is_Linespace;
function Is_End_Of_Line
(Char : in Character)
return Boolean is
begin
return (Char = Latin.LF or Char = Latin.CR);
end Is_End_Of_Line;
function Is_Whitespace
(Char : in Character)
return Boolean is
begin
return
Char = Latin.HT or
Char = Latin.LF or
Char = Latin.CR or
Char = ' ';
end Is_Whitespace;
function Not_Whitespace
(Char : in Character)
return Boolean is
begin
return not Is_Whitespace (Char);
end Not_Whitespace;
end Packrat.Utilities;
|