1------------------------------------------------------------------------------
2--                                                                          --
3--                         GNAT COMPILER COMPONENTS                         --
4--                                                                          --
5--                               C A S I N G                                --
6--                                                                          --
7--                                 S p e c                                  --
8--                                                                          --
9--          Copyright (C) 1992-2010, 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 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.                                     --
17--                                                                          --
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.               --
21--                                                                          --
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/>.                                          --
26--                                                                          --
27-- GNAT was originally developed  by the GNAT team at  New York University. --
28-- Extensive contributions were provided by Ada Core Technologies Inc.      --
29--                                                                          --
30------------------------------------------------------------------------------
31
32with Types; use Types;
33
34package Casing is
35
36   --  This package contains data and subprograms to support the feature that
37   --  recognizes the letter case styles used in the source program being
38   --  compiled, and uses this information for error message formatting, and
39   --  for recognizing reserved words that are misused as identifiers.
40
41   -------------------------------
42   -- Case Control Declarations --
43   -------------------------------
44
45   --  Declaration of type for describing casing convention
46
47   type Casing_Type is (
48
49      All_Upper_Case,
50      --  All letters are upper case
51
52      All_Lower_Case,
53      --  All letters are lower case
54
55      Mixed_Case,
56      --  The initial letter, and any letters after underlines are upper case.
57      --  All other letters are lower case
58
59      Unknown
60      --  Used if an identifier does not distinguish between the above cases,
61      --  (e.g. X, Y_3, M4, A_B, or if it is inconsistent ABC_def).
62   );
63
64   subtype Known_Casing is Casing_Type range All_Upper_Case .. Mixed_Case;
65   --  Exclude Unknown casing
66
67   ------------------------------
68   -- Case Control Subprograms --
69   ------------------------------
70
71   procedure Set_Casing (C : Casing_Type; D : Casing_Type := Mixed_Case);
72   --  Takes the name stored in the first Name_Len positions of Name_Buffer
73   --  and modifies it to be consistent with the casing given by C, or if
74   --  C = Unknown, then with the casing given by D. The name is basically
75   --  treated as an identifier, except that special separator characters
76   --  other than underline are permitted and treated like underlines (this
77   --  handles cases like minus and period in unit names, apostrophes in error
78   --  messages, angle brackets in names like <any_type>, etc).
79
80   procedure Set_All_Upper_Case;
81   pragma Inline (Set_All_Upper_Case);
82   --  This procedure is called with an identifier name stored in Name_Buffer.
83   --  On return, the identifier is converted to all upper case. The call is
84   --  equivalent to Set_Casing (All_Upper_Case).
85
86   function Determine_Casing (Ident : Text_Buffer) return Casing_Type;
87   --  Determines the casing of the identifier/keyword string Ident
88
89end Casing;
90