2005-12-29 Paul Brook <paul@codesourcery.com>
[official-gcc.git] / gcc / ada / a-wichun.ads
blobb112a61b3baddd3d7ea7f91f67854453f24d239c
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT RUN-TIME COMPONENTS --
4 -- --
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 --
6 -- --
7 -- S p e c --
8 -- --
9 -- Copyright (C) 2005, Free Software Foundation, Inc. --
10 -- --
11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 2, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNAT; see file COPYING. If not, write --
19 -- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
20 -- Boston, MA 02110-1301, USA. --
21 -- --
22 -- As a special exception, if other files instantiate generics from this --
23 -- unit, or you link this unit with other files to produce an executable, --
24 -- this unit does not by itself cause the resulting executable to be --
25 -- covered by the GNU General Public License. This exception does not --
26 -- however invalidate any other reasons why the executable file might be --
27 -- covered by the GNU Public License. --
28 -- --
29 -- GNAT was originally developed by the GNAT team at New York University. --
30 -- Extensive contributions were provided by Ada Core Technologies Inc. --
31 -- --
32 ------------------------------------------------------------------------------
34 -- Unicode categorization routines for Wide_Character. Note that this
35 -- package is strictly speaking Ada 2005 (since it is a child of an
36 -- Ada 2005 unit), but we make it available in Ada 95 mode, since it
37 -- only deals with wide characters.
39 with GNAT.UTF_32;
41 package Ada.Wide_Characters.Unicode is
43 -- The following type defines the categories from the unicode definitions.
44 -- The one addition we make is Fe, which represents the characters FFFE
45 -- and FFFF in any of the planes.
47 type Category is new GNAT.UTF_32.Category;
48 -- Cc Other, Control
49 -- Cf Other, Format
50 -- Cn Other, Not Assigned
51 -- Co Other, Private Use
52 -- Cs Other, Surrogate
53 -- Ll Letter, Lowercase
54 -- Lm Letter, Modifier
55 -- Lo Letter, Other
56 -- Lt Letter, Titlecase
57 -- Lu Letter, Uppercase
58 -- Mc Mark, Spacing Combining
59 -- Me Mark, Enclosing
60 -- Mn Mark, Nonspacing
61 -- Nd Number, Decimal Digit
62 -- Nl Number, Letter
63 -- No Number, Other
64 -- Pc Punctuation, Connector
65 -- Pd Punctuation, Dash
66 -- Pe Punctuation, Close
67 -- Pf Punctuation, Final quote
68 -- Pi Punctuation, Initial quote
69 -- Po Punctuation, Other
70 -- Ps Punctuation, Open
71 -- Sc Symbol, Currency
72 -- Sk Symbol, Modifier
73 -- Sm Symbol, Math
74 -- So Symbol, Other
75 -- Zl Separator, Line
76 -- Zp Separator, Paragraph
77 -- Zs Separator, Space
78 -- Fe relative position FFFE/FFFF in plane
80 function Get_Category (U : Wide_Character) return Category;
81 pragma Inline (Get_Category);
82 -- Given a Wide_Character, returns corresponding Category, or Cn if the
83 -- code does not have an assigned unicode category.
85 -- The following functions perform category tests corresponding to lexical
86 -- classes defined in the Ada standard. There are two interfaces for each
87 -- function. The second takes a Category (e.g. returned by Get_Category).
88 -- The first takes a Wide_Character. The form taking the Wide_Character is
89 -- typically more efficient than calling Get_Category, but if several
90 -- different tests are to be performed on the same code, it is more
91 -- efficient to use Get_Category to get the category, then test the
92 -- resulting category.
94 function Is_Letter (U : Wide_Character) return Boolean;
95 function Is_Letter (C : Category) return Boolean;
96 pragma Inline (Is_Letter);
97 -- Returns true iff U is a letter that can be used to start an identifier,
98 -- or if C is one of the corresponding categories, which are the following:
99 -- Letter, Uppercase (Lu)
100 -- Letter, Lowercase (Ll)
101 -- Letter, Titlecase (Lt)
102 -- Letter, Modifier (Lm)
103 -- Letter, Other (Lo)
104 -- Number, Letter (Nl)
106 function Is_Digit (U : Wide_Character) return Boolean;
107 function Is_Digit (C : Category) return Boolean;
108 pragma Inline (Is_Digit);
109 -- Returns true iff U is a digit that can be used to extend an identifer,
110 -- or if C is one of the corresponding categories, which are the following:
111 -- Number, Decimal_Digit (Nd)
113 function Is_Line_Terminator (U : Wide_Character) return Boolean;
114 pragma Inline (Is_Line_Terminator);
115 -- Returns true iff U is an allowed line terminator for source programs,
116 -- if U is in the category Zp (Separator, Paragaph), or Zs (Separator,
117 -- Line), or if U is a conventional line terminator (CR, LF, VT, FF).
118 -- There is no category version for this function, since the set of
119 -- characters does not correspond to a set of Unicode categories.
121 function Is_Mark (U : Wide_Character) return Boolean;
122 function Is_Mark (C : Category) return Boolean;
123 pragma Inline (Is_Mark);
124 -- Returns true iff U is a mark character which can be used to extend an
125 -- identifier, or if C is one of the corresponding categories, which are
126 -- the following:
127 -- Mark, Non-Spacing (Mn)
128 -- Mark, Spacing Combining (Mc)
130 function Is_Other (U : Wide_Character) return Boolean;
131 function Is_Other (C : Category) return Boolean;
132 pragma Inline (Is_Other);
133 -- Returns true iff U is an other format character, which means that it
134 -- can be used to extend an identifier, but is ignored for the purposes of
135 -- matching of identiers, or if C is one of the corresponding categories,
136 -- which are the following:
137 -- Other, Format (Cf)
139 function Is_Punctuation (U : Wide_Character) return Boolean;
140 function Is_Punctuation (C : Category) return Boolean;
141 pragma Inline (Is_Punctuation);
142 -- Returns true iff U is a punctuation character that can be used to
143 -- separate pices of an identifier, or if C is one of the corresponding
144 -- categories, which are the following:
145 -- Punctuation, Connector (Pc)
147 function Is_Space (U : Wide_Character) return Boolean;
148 function Is_Space (C : Category) return Boolean;
149 pragma Inline (Is_Space);
150 -- Returns true iff U is considered a space to be ignored, or if C is one
151 -- of the corresponding categories, which are the following:
152 -- Separator, Space (Zs)
154 function Is_Non_Graphic (U : Wide_Character) return Boolean;
155 function Is_Non_Graphic (C : Category) return Boolean;
156 pragma Inline (Is_Non_Graphic);
157 -- Returns true iff U is considered to be a non-graphic character, or if C
158 -- is one of the corresponding categories, which are the following:
159 -- Other, Control (Cc)
160 -- Other, Private Use (Co)
161 -- Other, Surrogate (Cs)
162 -- Separator, Line (Zl)
163 -- Separator, Paragraph (Zp)
164 -- FFFE or FFFF positions in any plane (Fe)
166 -- Note that the Ada category format effector is subsumed by the above
167 -- list of Unicode categories.
169 -- Note that Other, Unassiged (Cn) is quite deliberately not included
170 -- in the list of categories above. This means that should any of these
171 -- code positions be defined in future with graphic characters they will
172 -- be allowed without a need to change implementations or the standard.
174 -- Note that Other, Format (Cf) is also quite deliberately not included
175 -- in the list of categories above. This means that these characters can
176 -- be included in character and string literals.
178 -- The following function is used to fold to upper case, as required by
179 -- the Ada 2005 standard rules for identifier case folding. Two
180 -- identifiers are equivalent if they are identical after folding all
181 -- letters to upper case using this routine.
183 function To_Upper_Case (U : Wide_Character) return Wide_Character;
184 pragma Inline (To_Upper_Case);
185 -- If U represents a lower case letter, returns the corresponding upper
186 -- case letter, otherwise U is returned unchanged. The folding is locale
187 -- independent as defined by documents referenced in the note in section
188 -- 1 of ISO/IEC 10646:2003
190 end Ada.Wide_Characters.Unicode;