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