annotate gcc/ada/libgnat/a-wichun.ads @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children 1830386684a0
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 _ C H A R A C T E R 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 -- --
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
9 -- Copyright (C) 2005-2018, 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_Character. Note that this
kono
parents:
diff changeset
33 -- package is strictly speaking Ada 2005 (since it is a child of an
kono
parents:
diff changeset
34 -- Ada 2005 unit), but we make it available in Ada 95 mode, since it
kono
parents:
diff changeset
35 -- only deals with wide characters.
kono
parents:
diff changeset
36
kono
parents:
diff changeset
37 with System.UTF_32;
kono
parents:
diff changeset
38
kono
parents:
diff changeset
39 package Ada.Wide_Characters.Unicode is
kono
parents:
diff changeset
40 pragma Pure;
kono
parents:
diff changeset
41
kono
parents:
diff changeset
42 -- The following type defines the categories from the unicode definitions.
kono
parents:
diff changeset
43 -- The one addition we make is Fe, which represents the characters FFFE
kono
parents:
diff changeset
44 -- and FFFF in any of the planes.
kono
parents:
diff changeset
45
kono
parents:
diff changeset
46 type Category is new System.UTF_32.Category;
kono
parents:
diff changeset
47 -- Cc Other, Control
kono
parents:
diff changeset
48 -- Cf Other, Format
kono
parents:
diff changeset
49 -- Cn Other, Not Assigned
kono
parents:
diff changeset
50 -- Co Other, Private Use
kono
parents:
diff changeset
51 -- Cs Other, Surrogate
kono
parents:
diff changeset
52 -- Ll Letter, Lowercase
kono
parents:
diff changeset
53 -- Lm Letter, Modifier
kono
parents:
diff changeset
54 -- Lo Letter, Other
kono
parents:
diff changeset
55 -- Lt Letter, Titlecase
kono
parents:
diff changeset
56 -- Lu Letter, Uppercase
kono
parents:
diff changeset
57 -- Mc Mark, Spacing Combining
kono
parents:
diff changeset
58 -- Me Mark, Enclosing
kono
parents:
diff changeset
59 -- Mn Mark, Nonspacing
kono
parents:
diff changeset
60 -- Nd Number, Decimal Digit
kono
parents:
diff changeset
61 -- Nl Number, Letter
kono
parents:
diff changeset
62 -- No Number, Other
kono
parents:
diff changeset
63 -- Pc Punctuation, Connector
kono
parents:
diff changeset
64 -- Pd Punctuation, Dash
kono
parents:
diff changeset
65 -- Pe Punctuation, Close
kono
parents:
diff changeset
66 -- Pf Punctuation, Final quote
kono
parents:
diff changeset
67 -- Pi Punctuation, Initial quote
kono
parents:
diff changeset
68 -- Po Punctuation, Other
kono
parents:
diff changeset
69 -- Ps Punctuation, Open
kono
parents:
diff changeset
70 -- Sc Symbol, Currency
kono
parents:
diff changeset
71 -- Sk Symbol, Modifier
kono
parents:
diff changeset
72 -- Sm Symbol, Math
kono
parents:
diff changeset
73 -- So Symbol, Other
kono
parents:
diff changeset
74 -- Zl Separator, Line
kono
parents:
diff changeset
75 -- Zp Separator, Paragraph
kono
parents:
diff changeset
76 -- Zs Separator, Space
kono
parents:
diff changeset
77 -- Fe relative position FFFE/FFFF in plane
kono
parents:
diff changeset
78
kono
parents:
diff changeset
79 function Get_Category (U : Wide_Character) return Category;
kono
parents:
diff changeset
80 pragma Inline (Get_Category);
kono
parents:
diff changeset
81 -- Given a Wide_Character, returns corresponding Category, or Cn if the
kono
parents:
diff changeset
82 -- code does not have an assigned unicode category.
kono
parents:
diff changeset
83
kono
parents:
diff changeset
84 -- The following functions perform category tests corresponding to lexical
kono
parents:
diff changeset
85 -- classes defined in the Ada standard. There are two interfaces for each
kono
parents:
diff changeset
86 -- function. The second takes a Category (e.g. returned by Get_Category).
kono
parents:
diff changeset
87 -- The first takes a Wide_Character. The form taking the Wide_Character is
kono
parents:
diff changeset
88 -- typically more efficient than calling Get_Category, but if several
kono
parents:
diff changeset
89 -- different tests are to be performed on the same code, it is more
kono
parents:
diff changeset
90 -- efficient to use Get_Category to get the category, then test the
kono
parents:
diff changeset
91 -- resulting category.
kono
parents:
diff changeset
92
kono
parents:
diff changeset
93 function Is_Letter (U : Wide_Character) return Boolean;
kono
parents:
diff changeset
94 function Is_Letter (C : Category) return Boolean;
kono
parents:
diff changeset
95 pragma Inline (Is_Letter);
kono
parents:
diff changeset
96 -- Returns true iff U is a letter that can be used to start an identifier,
kono
parents:
diff changeset
97 -- or if C is one of the corresponding categories, which are the following:
kono
parents:
diff changeset
98 -- Letter, Uppercase (Lu)
kono
parents:
diff changeset
99 -- Letter, Lowercase (Ll)
kono
parents:
diff changeset
100 -- Letter, Titlecase (Lt)
kono
parents:
diff changeset
101 -- Letter, Modifier (Lm)
kono
parents:
diff changeset
102 -- Letter, Other (Lo)
kono
parents:
diff changeset
103 -- Number, Letter (Nl)
kono
parents:
diff changeset
104
kono
parents:
diff changeset
105 function Is_Digit (U : Wide_Character) return Boolean;
kono
parents:
diff changeset
106 function Is_Digit (C : Category) return Boolean;
kono
parents:
diff changeset
107 pragma Inline (Is_Digit);
kono
parents:
diff changeset
108 -- Returns true iff U is a digit that can be used to extend an identifer,
kono
parents:
diff changeset
109 -- or if C is one of the corresponding categories, which are the following:
kono
parents:
diff changeset
110 -- Number, Decimal_Digit (Nd)
kono
parents:
diff changeset
111
kono
parents:
diff changeset
112 function Is_Line_Terminator (U : Wide_Character) return Boolean;
kono
parents:
diff changeset
113 pragma Inline (Is_Line_Terminator);
kono
parents:
diff changeset
114 -- Returns true iff U is an allowed line terminator for source programs,
kono
parents:
diff changeset
115 -- if U is in the category Zp (Separator, Paragaph), or Zs (Separator,
kono
parents:
diff changeset
116 -- Line), or if U is a conventional line terminator (CR, LF, VT, FF).
kono
parents:
diff changeset
117 -- There is no category version for this function, since the set of
kono
parents:
diff changeset
118 -- characters does not correspond to a set of Unicode categories.
kono
parents:
diff changeset
119
kono
parents:
diff changeset
120 function Is_Mark (U : Wide_Character) return Boolean;
kono
parents:
diff changeset
121 function Is_Mark (C : Category) return Boolean;
kono
parents:
diff changeset
122 pragma Inline (Is_Mark);
kono
parents:
diff changeset
123 -- Returns true iff U is a mark character which can be used to extend an
kono
parents:
diff changeset
124 -- identifier, or if C is one of the corresponding categories, which are
kono
parents:
diff changeset
125 -- the following:
kono
parents:
diff changeset
126 -- Mark, Non-Spacing (Mn)
kono
parents:
diff changeset
127 -- Mark, Spacing Combining (Mc)
kono
parents:
diff changeset
128
kono
parents:
diff changeset
129 function Is_Other (U : Wide_Character) return Boolean;
kono
parents:
diff changeset
130 function Is_Other (C : Category) return Boolean;
kono
parents:
diff changeset
131 pragma Inline (Is_Other);
kono
parents:
diff changeset
132 -- Returns true iff U is an other format character, which means that it
kono
parents:
diff changeset
133 -- can be used to extend an identifier, but is ignored for the purposes of
kono
parents:
diff changeset
134 -- matching of identiers, or if C is one of the corresponding categories,
kono
parents:
diff changeset
135 -- which are the following:
kono
parents:
diff changeset
136 -- Other, Format (Cf)
kono
parents:
diff changeset
137
kono
parents:
diff changeset
138 function Is_Punctuation (U : Wide_Character) return Boolean;
kono
parents:
diff changeset
139 function Is_Punctuation (C : Category) return Boolean;
kono
parents:
diff changeset
140 pragma Inline (Is_Punctuation);
kono
parents:
diff changeset
141 -- Returns true iff U is a punctuation character that can be used to
kono
parents:
diff changeset
142 -- separate pices of an identifier, or if C is one of the corresponding
kono
parents:
diff changeset
143 -- categories, which are the following:
kono
parents:
diff changeset
144 -- Punctuation, Connector (Pc)
kono
parents:
diff changeset
145
kono
parents:
diff changeset
146 function Is_Space (U : Wide_Character) return Boolean;
kono
parents:
diff changeset
147 function Is_Space (C : Category) return Boolean;
kono
parents:
diff changeset
148 pragma Inline (Is_Space);
kono
parents:
diff changeset
149 -- Returns true iff U is considered a space to be ignored, or if C is one
kono
parents:
diff changeset
150 -- of the corresponding categories, which are the following:
kono
parents:
diff changeset
151 -- Separator, Space (Zs)
kono
parents:
diff changeset
152
kono
parents:
diff changeset
153 function Is_Non_Graphic (U : Wide_Character) return Boolean;
kono
parents:
diff changeset
154 function Is_Non_Graphic (C : Category) return Boolean;
kono
parents:
diff changeset
155 pragma Inline (Is_Non_Graphic);
kono
parents:
diff changeset
156 -- Returns true iff U is considered to be a non-graphic character, or if C
kono
parents:
diff changeset
157 -- is one of the corresponding categories, which are the following:
kono
parents:
diff changeset
158 -- Other, Control (Cc)
kono
parents:
diff changeset
159 -- Other, Private Use (Co)
kono
parents:
diff changeset
160 -- Other, Surrogate (Cs)
kono
parents:
diff changeset
161 -- Separator, Line (Zl)
kono
parents:
diff changeset
162 -- Separator, Paragraph (Zp)
kono
parents:
diff changeset
163 -- FFFE or FFFF positions in any plane (Fe)
kono
parents:
diff changeset
164 --
kono
parents:
diff changeset
165 -- Note that the Ada category format effector is subsumed by the above
kono
parents:
diff changeset
166 -- list of Unicode categories.
kono
parents:
diff changeset
167 --
kono
parents:
diff changeset
168 -- Note that Other, Unassiged (Cn) is quite deliberately not included
kono
parents:
diff changeset
169 -- in the list of categories above. This means that should any of these
kono
parents:
diff changeset
170 -- code positions be defined in future with graphic characters they will
kono
parents:
diff changeset
171 -- be allowed without a need to change implementations or the standard.
kono
parents:
diff changeset
172 --
kono
parents:
diff changeset
173 -- Note that Other, Format (Cf) is also quite deliberately not included
kono
parents:
diff changeset
174 -- in the list of categories above. This means that these characters can
kono
parents:
diff changeset
175 -- be included in character and string literals.
kono
parents:
diff changeset
176
kono
parents:
diff changeset
177 -- The following function is used to fold to upper case, as required by
kono
parents:
diff changeset
178 -- the Ada 2005 standard rules for identifier case folding. Two
kono
parents:
diff changeset
179 -- identifiers are equivalent if they are identical after folding all
kono
parents:
diff changeset
180 -- letters to upper case using this routine. A corresponding function to
kono
parents:
diff changeset
181 -- fold to lower case is also provided.
kono
parents:
diff changeset
182
kono
parents:
diff changeset
183 function To_Lower_Case (U : Wide_Character) return Wide_Character;
kono
parents:
diff changeset
184 pragma Inline (To_Lower_Case);
kono
parents:
diff changeset
185 -- If U represents an upper case letter, returns the corresponding lower
kono
parents:
diff changeset
186 -- case letter, otherwise U is returned unchanged. The folding is locale
kono
parents:
diff changeset
187 -- independent as defined by documents referenced in the note in section
kono
parents:
diff changeset
188 -- 1 of ISO/IEC 10646:2003
kono
parents:
diff changeset
189
kono
parents:
diff changeset
190 function To_Upper_Case (U : Wide_Character) return Wide_Character;
kono
parents:
diff changeset
191 pragma Inline (To_Upper_Case);
kono
parents:
diff changeset
192 -- If U represents a lower case letter, returns the corresponding upper
kono
parents:
diff changeset
193 -- case letter, otherwise U is returned unchanged. The folding is locale
kono
parents:
diff changeset
194 -- independent as defined by documents referenced in the note in section
kono
parents:
diff changeset
195 -- 1 of ISO/IEC 10646:2003
kono
parents:
diff changeset
196
kono
parents:
diff changeset
197 end Ada.Wide_Characters.Unicode;