1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1992-2023, Free Software Foundation, Inc. --
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 3, 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 COPYING3. If not, go to --
19 -- http://www.gnu.org/licenses for a complete copy of the license. --
21 -- GNAT was originally developed by the GNAT team at New York University. --
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
24 ------------------------------------------------------------------------------
26 with Namet
; use Namet
;
27 with Types
; use Types
;
31 -- This package contains data and subprograms to support the feature that
32 -- recognizes the letter case styles used in the source program being
33 -- compiled, and uses this information for error message formatting, and
34 -- for recognizing reserved words that are misused as identifiers.
36 -------------------------------
37 -- Case Control Declarations --
38 -------------------------------
40 -- Declaration of type for describing casing convention
45 -- All letters are upper case
48 -- All letters are lower case
51 -- The initial letter, and any letters after underlines are upper case.
52 -- All other letters are lower case
55 -- Used if an identifier does not distinguish between the above cases,
56 -- (e.g. X, Y_3, M4, A_B, or if it is inconsistent ABC_def).
59 subtype Known_Casing
is Casing_Type
range All_Upper_Case
.. Mixed_Case
;
60 -- Exclude Unknown casing
62 ------------------------------
63 -- Case Control Subprograms --
64 ------------------------------
67 (Buf
: in out Bounded_String
;
69 D
: Casing_Type
:= Mixed_Case
);
70 -- Takes the name stored in Buf and modifies it to be consistent with the
71 -- casing given by C, or if C = Unknown, then with the casing given by
72 -- D. The name is basically treated as an identifier, except that special
73 -- separator characters other than underline are permitted and treated like
74 -- underlines (this handles cases like minus and period in unit names,
75 -- apostrophes in error messages, angle brackets in names like <any_type>,
78 procedure Set_Casing
(C
: Casing_Type
; D
: Casing_Type
:= Mixed_Case
);
79 -- Uses Buf => Global_Name_Buffer
81 function Determine_Casing
(Ident
: Text_Buffer
) return Casing_Type
;
82 -- Determines the casing of the identifier/keyword string Ident. A special
83 -- test is made for SPARK_Mode which is considered to be mixed case, since
84 -- this gives a better general behavior.