1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1992-2015, 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. --
18 -- As a special exception under Section 7 of GPL version 3, you are granted --
19 -- additional permissions described in the GCC Runtime Library Exception, --
20 -- version 3.1, as published by the Free Software Foundation. --
22 -- You should have received a copy of the GNU General Public License and --
23 -- a copy of the GCC Runtime Library Exception along with this program; --
24 -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
25 -- <http://www.gnu.org/licenses/>. --
27 -- GNAT was originally developed by the GNAT team at New York University. --
28 -- Extensive contributions were provided by Ada Core Technologies Inc. --
30 ------------------------------------------------------------------------------
32 with Namet
; use Namet
;
33 with Types
; use Types
;
37 -- This package contains data and subprograms to support the feature that
38 -- recognizes the letter case styles used in the source program being
39 -- compiled, and uses this information for error message formatting, and
40 -- for recognizing reserved words that are misused as identifiers.
42 -------------------------------
43 -- Case Control Declarations --
44 -------------------------------
46 -- Declaration of type for describing casing convention
51 -- All letters are upper case
54 -- All letters are lower case
57 -- The initial letter, and any letters after underlines are upper case.
58 -- All other letters are lower case
61 -- Used if an identifier does not distinguish between the above cases,
62 -- (e.g. X, Y_3, M4, A_B, or if it is inconsistent ABC_def).
65 subtype Known_Casing
is Casing_Type
range All_Upper_Case
.. Mixed_Case
;
66 -- Exclude Unknown casing
68 ------------------------------
69 -- Case Control Subprograms --
70 ------------------------------
73 (Buf
: in out Bounded_String
;
75 D
: Casing_Type
:= Mixed_Case
);
76 -- Takes the name stored in Buf and modifies it to be consistent with the
77 -- casing given by C, or if C = Unknown, then with the casing given by
78 -- D. The name is basically treated as an identifier, except that special
79 -- separator characters other than underline are permitted and treated like
80 -- underlines (this handles cases like minus and period in unit names,
81 -- apostrophes in error messages, angle brackets in names like <any_type>,
84 procedure Set_Casing
(C
: Casing_Type
; D
: Casing_Type
:= Mixed_Case
);
85 -- Uses Buf => Global_Name_Buffer
87 procedure Set_All_Upper_Case
;
88 pragma Inline
(Set_All_Upper_Case
);
89 -- This procedure is called with an identifier name stored in Name_Buffer.
90 -- On return, the identifier is converted to all upper case. The call is
91 -- equivalent to Set_Casing (All_Upper_Case).
93 function Determine_Casing
(Ident
: Text_Buffer
) return Casing_Type
;
94 -- Determines the casing of the identifier/keyword string Ident. A special
95 -- test is made for SPARK_Mode which is considered to be mixed case, since
96 -- this gives a better general behavior.