annotate gcc/ada/libgnat/a-zchuni.ads @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents 84e7813d76e9
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 ------------------------------------------------------------------------------
kono
parents:
diff changeset
2 -- --
kono
parents:
diff changeset
3 -- GNAT RUN-TIME COMPONENTS --
kono
parents:
diff changeset
4 -- --
kono
parents:
diff changeset
5 -- A D A . W I D E _ W I D E _ C H A R A C T E R T S . U N I C O D E --
kono
parents:
diff changeset
6 -- --
kono
parents:
diff changeset
7 -- S p e c --
kono
parents:
diff changeset
8 -- --
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
9 -- Copyright (C) 2005-2019, Free Software Foundation, Inc. --
111
kono
parents:
diff changeset
10 -- --
kono
parents:
diff changeset
11 -- GNAT is free software; you can redistribute it and/or modify it under --
kono
parents:
diff changeset
12 -- terms of the GNU General Public License as published by the Free Soft- --
kono
parents:
diff changeset
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
kono
parents:
diff changeset
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
kono
parents:
diff changeset
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
kono
parents:
diff changeset
16 -- or FITNESS FOR A PARTICULAR PURPOSE. --
kono
parents:
diff changeset
17 -- --
kono
parents:
diff changeset
18 -- As a special exception under Section 7 of GPL version 3, you are granted --
kono
parents:
diff changeset
19 -- additional permissions described in the GCC Runtime Library Exception, --
kono
parents:
diff changeset
20 -- version 3.1, as published by the Free Software Foundation. --
kono
parents:
diff changeset
21 -- --
kono
parents:
diff changeset
22 -- You should have received a copy of the GNU General Public License and --
kono
parents:
diff changeset
23 -- a copy of the GCC Runtime Library Exception along with this program; --
kono
parents:
diff changeset
24 -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
kono
parents:
diff changeset
25 -- <http://www.gnu.org/licenses/>. --
kono
parents:
diff changeset
26 -- --
kono
parents:
diff changeset
27 -- GNAT was originally developed by the GNAT team at New York University. --
kono
parents:
diff changeset
28 -- Extensive contributions were provided by Ada Core Technologies Inc. --
kono
parents:
diff changeset
29 -- --
kono
parents:
diff changeset
30 ------------------------------------------------------------------------------
kono
parents:
diff changeset
31
kono
parents:
diff changeset
32 -- Unicode categorization routines for Wide_Wide_Character
kono
parents:
diff changeset
33
kono
parents:
diff changeset
34 with System.UTF_32;
kono
parents:
diff changeset
35
kono
parents:
diff changeset
36 package Ada.Wide_Wide_Characters.Unicode is
kono
parents:
diff changeset
37 pragma Pure;
kono
parents:
diff changeset
38
kono
parents:
diff changeset
39 -- The following type defines the categories from the unicode definitions.
kono
parents:
diff changeset
40 -- The one addition we make is Fe, which represents the characters FFFE
kono
parents:
diff changeset
41 -- and FFFF in any of the planes.
kono
parents:
diff changeset
42
kono
parents:
diff changeset
43 type Category is new System.UTF_32.Category;
kono
parents:
diff changeset
44 -- Cc Other, Control
kono
parents:
diff changeset
45 -- Cf Other, Format
kono
parents:
diff changeset
46 -- Cn Other, Not Assigned
kono
parents:
diff changeset
47 -- Co Other, Private Use
kono
parents:
diff changeset
48 -- Cs Other, Surrogate
kono
parents:
diff changeset
49 -- Ll Letter, Lowercase
kono
parents:
diff changeset
50 -- Lm Letter, Modifier
kono
parents:
diff changeset
51 -- Lo Letter, Other
kono
parents:
diff changeset
52 -- Lt Letter, Titlecase
kono
parents:
diff changeset
53 -- Lu Letter, Uppercase
kono
parents:
diff changeset
54 -- Mc Mark, Spacing Combining
kono
parents:
diff changeset
55 -- Me Mark, Enclosing
kono
parents:
diff changeset
56 -- Mn Mark, Nonspacing
kono
parents:
diff changeset
57 -- Nd Number, Decimal Digit
kono
parents:
diff changeset
58 -- Nl Number, Letter
kono
parents:
diff changeset
59 -- No Number, Other
kono
parents:
diff changeset
60 -- Pc Punctuation, Connector
kono
parents:
diff changeset
61 -- Pd Punctuation, Dash
kono
parents:
diff changeset
62 -- Pe Punctuation, Close
kono
parents:
diff changeset
63 -- Pf Punctuation, Final quote
kono
parents:
diff changeset
64 -- Pi Punctuation, Initial quote
kono
parents:
diff changeset
65 -- Po Punctuation, Other
kono
parents:
diff changeset
66 -- Ps Punctuation, Open
kono
parents:
diff changeset
67 -- Sc Symbol, Currency
kono
parents:
diff changeset
68 -- Sk Symbol, Modifier
kono
parents:
diff changeset
69 -- Sm Symbol, Math
kono
parents:
diff changeset
70 -- So Symbol, Other
kono
parents:
diff changeset
71 -- Zl Separator, Line
kono
parents:
diff changeset
72 -- Zp Separator, Paragraph
kono
parents:
diff changeset
73 -- Zs Separator, Space
kono
parents:
diff changeset
74 -- Fe relative position FFFE/FFFF in plane
kono
parents:
diff changeset
75
kono
parents:
diff changeset
76 function Get_Category (U : Wide_Wide_Character) return Category;
kono
parents:
diff changeset
77 pragma Inline (Get_Category);
kono
parents:
diff changeset
78 -- Given a Wide_Wide_Character, returns corresponding Category, or Cn if
kono
parents:
diff changeset
79 -- the code does not have an assigned unicode category.
kono
parents:
diff changeset
80
kono
parents:
diff changeset
81 -- The following functions perform category tests corresponding to lexical
kono
parents:
diff changeset
82 -- classes defined in the Ada standard. There are two interfaces for each
kono
parents:
diff changeset
83 -- function. The second takes a Category (e.g. returned by Get_Category).
kono
parents:
diff changeset
84 -- The first takes a Wide_Wide_Character. The form taking the
kono
parents:
diff changeset
85 -- Wide_Wide_Character is typically more efficient than calling
kono
parents:
diff changeset
86 -- Get_Category, but if several different tests are to be performed on the
kono
parents:
diff changeset
87 -- same code, it is more efficient to use Get_Category to get the category,
kono
parents:
diff changeset
88 -- then test the resulting category.
kono
parents:
diff changeset
89
kono
parents:
diff changeset
90 function Is_Letter (U : Wide_Wide_Character) return Boolean;
kono
parents:
diff changeset
91 function Is_Letter (C : Category) return Boolean;
kono
parents:
diff changeset
92 pragma Inline (Is_Letter);
kono
parents:
diff changeset
93 -- Returns true iff U is a letter that can be used to start an identifier,
kono
parents:
diff changeset
94 -- or if C is one of the corresponding categories, which are the following:
kono
parents:
diff changeset
95 -- Letter, Uppercase (Lu)
kono
parents:
diff changeset
96 -- Letter, Lowercase (Ll)
kono
parents:
diff changeset
97 -- Letter, Titlecase (Lt)
kono
parents:
diff changeset
98 -- Letter, Modifier (Lm)
kono
parents:
diff changeset
99 -- Letter, Other (Lo)
kono
parents:
diff changeset
100 -- Number, Letter (Nl)
kono
parents:
diff changeset
101
kono
parents:
diff changeset
102 function Is_Digit (U : Wide_Wide_Character) return Boolean;
kono
parents:
diff changeset
103 function Is_Digit (C : Category) return Boolean;
kono
parents:
diff changeset
104 pragma Inline (Is_Digit);
kono
parents:
diff changeset
105 -- Returns true iff U is a digit that can be used to extend an identifer,
kono
parents:
diff changeset
106 -- or if C is one of the corresponding categories, which are the following:
kono
parents:
diff changeset
107 -- Number, Decimal_Digit (Nd)
kono
parents:
diff changeset
108
kono
parents:
diff changeset
109 function Is_Line_Terminator (U : Wide_Wide_Character) return Boolean;
kono
parents:
diff changeset
110 pragma Inline (Is_Line_Terminator);
kono
parents:
diff changeset
111 -- Returns true iff U is an allowed line terminator for source programs,
kono
parents:
diff changeset
112 -- if U is in the category Zp (Separator, Paragaph), or Zs (Separator,
kono
parents:
diff changeset
113 -- Line), or if U is a conventional line terminator (CR, LF, VT, FF).
kono
parents:
diff changeset
114 -- There is no category version for this function, since the set of
kono
parents:
diff changeset
115 -- characters does not correspond to a set of Unicode categories.
kono
parents:
diff changeset
116
kono
parents:
diff changeset
117 function Is_Mark (U : Wide_Wide_Character) return Boolean;
kono
parents:
diff changeset
118 function Is_Mark (C : Category) return Boolean;
kono
parents:
diff changeset
119 pragma Inline (Is_Mark);
kono
parents:
diff changeset
120 -- Returns true iff U is a mark character which can be used to extend an
kono
parents:
diff changeset
121 -- identifier, or if C is one of the corresponding categories, which are
kono
parents:
diff changeset
122 -- the following:
kono
parents:
diff changeset
123 -- Mark, Non-Spacing (Mn)
kono
parents:
diff changeset
124 -- Mark, Spacing Combining (Mc)
kono
parents:
diff changeset
125
kono
parents:
diff changeset
126 function Is_Other (U : Wide_Wide_Character) return Boolean;
kono
parents:
diff changeset
127 function Is_Other (C : Category) return Boolean;
kono
parents:
diff changeset
128 pragma Inline (Is_Other);
kono
parents:
diff changeset
129 -- Returns true iff U is an other format character, which means that it
kono
parents:
diff changeset
130 -- can be used to extend an identifier, but is ignored for the purposes of
kono
parents:
diff changeset
131 -- matching of identiers, or if C is one of the corresponding categories,
kono
parents:
diff changeset
132 -- which are the following:
kono
parents:
diff changeset
133 -- Other, Format (Cf)
kono
parents:
diff changeset
134
kono
parents:
diff changeset
135 function Is_Punctuation (U : Wide_Wide_Character) return Boolean;
kono
parents:
diff changeset
136 function Is_Punctuation (C : Category) return Boolean;
kono
parents:
diff changeset
137 pragma Inline (Is_Punctuation);
kono
parents:
diff changeset
138 -- Returns true iff U is a punctuation character that can be used to
kono
parents:
diff changeset
139 -- separate pices of an identifier, or if C is one of the corresponding
kono
parents:
diff changeset
140 -- categories, which are the following:
kono
parents:
diff changeset
141 -- Punctuation, Connector (Pc)
kono
parents:
diff changeset
142
kono
parents:
diff changeset
143 function Is_Space (U : Wide_Wide_Character) return Boolean;
kono
parents:
diff changeset
144 function Is_Space (C : Category) return Boolean;
kono
parents:
diff changeset
145 pragma Inline (Is_Space);
kono
parents:
diff changeset
146 -- Returns true iff U is considered a space to be ignored, or if C is one
kono
parents:
diff changeset
147 -- of the corresponding categories, which are the following:
kono
parents:
diff changeset
148 -- Separator, Space (Zs)
kono
parents:
diff changeset
149
kono
parents:
diff changeset
150 function Is_Non_Graphic (U : Wide_Wide_Character) return Boolean;
kono
parents:
diff changeset
151 function Is_Non_Graphic (C : Category) return Boolean;
kono
parents:
diff changeset
152 pragma Inline (Is_Non_Graphic);
kono
parents:
diff changeset
153 -- Returns true iff U is considered to be a non-graphic character, or if C
kono
parents:
diff changeset
154 -- is one of the corresponding categories, which are the following:
kono
parents:
diff changeset
155 -- Other, Control (Cc)
kono
parents:
diff changeset
156 -- Other, Private Use (Co)
kono
parents:
diff changeset
157 -- Other, Surrogate (Cs)
kono
parents:
diff changeset
158 -- Separator, Line (Zl)
kono
parents:
diff changeset
159 -- Separator, Paragraph (Zp)
kono
parents:
diff changeset
160 -- FFFE or FFFF positions in any plane (Fe)
kono
parents:
diff changeset
161 --
kono
parents:
diff changeset
162 -- Note that the Ada category format effector is subsumed by the above
kono
parents:
diff changeset
163 -- list of Unicode categories.
kono
parents:
diff changeset
164 --
kono
parents:
diff changeset
165 -- Note that Other, Unassiged (Cn) is quite deliberately not included
kono
parents:
diff changeset
166 -- in the list of categories above. This means that should any of these
kono
parents:
diff changeset
167 -- code positions be defined in future with graphic characters they will
kono
parents:
diff changeset
168 -- be allowed without a need to change implementations or the standard.
kono
parents:
diff changeset
169 --
kono
parents:
diff changeset
170 -- Note that Other, Format (Cf) is also quite deliberately not included
kono
parents:
diff changeset
171 -- in the list of categories above. This means that these characters can
kono
parents:
diff changeset
172 -- be included in character and string literals.
kono
parents:
diff changeset
173
kono
parents:
diff changeset
174 -- The following function is used to fold to upper case, as required by
kono
parents:
diff changeset
175 -- the Ada 2005 standard rules for identifier case folding. Two
kono
parents:
diff changeset
176 -- identifiers are equivalent if they are identical after folding all
kono
parents:
diff changeset
177 -- letters to upper case using this routine. A fold to lower routine is
kono
parents:
diff changeset
178 -- also provided.
kono
parents:
diff changeset
179
kono
parents:
diff changeset
180 function To_Lower_Case
kono
parents:
diff changeset
181 (U : Wide_Wide_Character) return Wide_Wide_Character;
kono
parents:
diff changeset
182 pragma Inline (To_Lower_Case);
kono
parents:
diff changeset
183 -- If U represents an upper case letter, returns the corresponding lower
kono
parents:
diff changeset
184 -- case letter, otherwise U is returned unchanged. The folding is locale
kono
parents:
diff changeset
185 -- independent as defined by documents referenced in the note in section
kono
parents:
diff changeset
186 -- 1 of ISO/IEC 10646:2003
kono
parents:
diff changeset
187
kono
parents:
diff changeset
188 function To_Upper_Case
kono
parents:
diff changeset
189 (U : Wide_Wide_Character) return Wide_Wide_Character;
kono
parents:
diff changeset
190 pragma Inline (To_Upper_Case);
kono
parents:
diff changeset
191 -- If U represents a lower case letter, returns the corresponding upper
kono
parents:
diff changeset
192 -- case letter, otherwise U is returned unchanged. The folding is locale
kono
parents:
diff changeset
193 -- independent as defined by documents referenced in the note in section
kono
parents:
diff changeset
194 -- 1 of ISO/IEC 10646:2003
kono
parents:
diff changeset
195
kono
parents:
diff changeset
196 end Ada.Wide_Wide_Characters.Unicode;