OSDN Git Service

Add Fariborz to my last change.
[pf3gnuchains/gcc-fork.git] / gcc / ada / style.ads
1 ------------------------------------------------------------------------------
2 --                                                                          --
3 --                         GNAT COMPILER COMPONENTS                         --
4 --                                                                          --
5 --                                S T Y L E                                 --
6 --                                                                          --
7 --                                 S p e c                                  --
8 --                                                                          --
9 --          Copyright (C) 1992-2004 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,  59 Temple Place - Suite 330,  Boston, --
20 -- MA 02111-1307, USA.                                                      --
21 --                                                                          --
22 -- GNAT was originally developed  by the GNAT team at  New York University. --
23 -- Extensive contributions were provided by Ada Core Technologies Inc.      --
24 --                                                                          --
25 ------------------------------------------------------------------------------
26
27 --  This package collects all the routines used for style checking, as
28 --  activated by the relevant command line option. These are gathered in
29 --  a separate package so that they can more easily be customized. Calls
30 --  to these subprograms are only made if Opt.Style_Check is set True.
31
32 with Errout;
33 with Styleg;
34 with Styleg.C;
35 with Types; use Types;
36
37 package Style is
38
39    package Style_Inst is new Styleg
40      (Errout.Error_Msg,
41       Errout.Error_Msg_S,
42       Errout.Error_Msg_SC,
43       Errout.Error_Msg_SP);
44    --  Instantiation of Styleg for all subprograms that do not depend directly
45    --  depend on the GNAT tree.
46
47    package Style_C_Inst is new Style_Inst.C
48      (Errout.Error_Msg_N);
49    --  Instantiation of Styleg.C for the subprograms that depend directly
50    --  on the GNAT tree.
51
52    --  All subroutines below are renames of subroutines in the two
53    --  instantiations above.
54
55    procedure Body_With_No_Spec (N : Node_Id)
56      renames Style_C_Inst.Body_With_No_Spec;
57    --  Called where N is a subprogram body node for a subprogram body
58    --  for which no spec was given, i.e. a body acting as its own spec.
59
60    procedure Check_Abs_Not
61      renames Style_Inst.Check_Abs_Not;
62    --  Called after scanning an ABS or NOT operator to check spacing
63
64    procedure Check_Apostrophe
65      renames Style_Inst.Check_Apostrophe;
66    --  Called after scanning an apostrophe to check spacing
67
68    procedure Check_Arrow
69      renames Style_Inst.Check_Arrow;
70    --  Called after scanning out an arrow to check spacing
71
72    procedure Check_Attribute_Name (Reserved : Boolean)
73      renames Style_Inst.Check_Attribute_Name;
74    --  The current token is an attribute designator. Check that it
75    --  is capitalized in an appropriate manner. Reserved is set if
76    --  the attribute designator is a reserved word (access, digits,
77    --  delta or range) to allow differing rules for the two cases.
78
79    procedure Check_Box
80      renames Style_Inst.Check_Box;
81    --  Called after scanning out a box to check spacing
82
83    procedure Check_Binary_Operator
84      renames Style_Inst.Check_Binary_Operator;
85    --  Called after scanning out a binary operator other than a plus, minus
86    --  or exponentiation operator. Intended for checking spacing rules.
87
88    procedure Check_Exponentiation_Operator
89      renames Style_Inst.Check_Exponentiation_Operator;
90    --  Called after scanning out an exponentiation operator. Intended for
91    --  checking spacing rules.
92
93    procedure Check_Colon
94      renames Style_Inst.Check_Colon;
95    --  Called after scanning out colon to check spacing
96
97    procedure Check_Colon_Equal
98      renames Style_Inst.Check_Colon_Equal;
99    --  Called after scanning out colon equal to check spacing
100
101    procedure Check_Comma
102      renames Style_Inst.Check_Comma;
103    --  Called after scanning out comma to check spacing
104
105    procedure Check_Comment
106      renames Style_Inst.Check_Comment;
107    --  Called with Scan_Ptr pointing to the first minus sign of a comment.
108    --  Intended for checking any specific rules for comment placement/format.
109
110    procedure Check_Dot_Dot
111      renames Style_Inst.Check_Dot_Dot;
112    --  Called after scanning out dot dot to check spacing
113
114    procedure Check_HT
115      renames Style_Inst.Check_HT;
116    --  Called with Scan_Ptr pointing to a horizontal tab character
117
118    procedure Check_Identifier
119      (Ref : Node_Or_Entity_Id;
120       Def : Node_Or_Entity_Id)
121      renames Style_C_Inst.Check_Identifier;
122    --  Check style of identifier occurrence. Ref is an N_Identifier node whose
123    --  spelling is to be checked against the Chars spelling in identifier node
124    --  Def (which may be either an N_Identifier, or N_Defining_Identifier node)
125
126    procedure Check_Indentation
127      renames Style_Inst.Check_Indentation;
128    --  Called at the start of a new statement or declaration, with Token_Ptr
129    --  pointing to the first token of the statement or declaration. The check
130    --  is that the starting column is appropriate to the indentation rules if
131    --  Token_Ptr is the first token on the line.
132
133    procedure Check_Left_Paren
134      renames Style_Inst.Check_Left_Paren;
135    --  Called after scanning out a left parenthesis to check spacing.
136
137    procedure Check_Line_Terminator (Len : Int)
138      renames Style_Inst.Check_Line_Terminator;
139    --  Called with Scan_Ptr pointing to the first line terminator terminating
140    --  the current line, used to check for appropriate line terminator and
141    --  to check the line length (Len is the length of the current line).
142    --  Note that the terminator may be the EOF character.
143
144    procedure Check_Pragma_Name
145      renames Style_Inst.Check_Pragma_Name;
146    --  The current token is a pragma identifier. Check that it is spelled
147    --  properly (i.e. with an appropriate casing convention).
148
149    procedure Check_Right_Paren
150      renames Style_Inst.Check_Right_Paren;
151    --  Called after scanning out a right parenthesis to check spacing.
152
153    procedure Check_Semicolon
154      renames Style_Inst.Check_Semicolon;
155    --  Called after scanning out a semicolon to check spacing
156
157    procedure Check_Then (If_Loc : Source_Ptr)
158      renames Style_Inst.Check_Then;
159    --  Called to check that THEN and IF keywords are appropriately positioned.
160    --  The parameters show the first characters of the two keywords. This
161    --  procedure is called only if THEN appears at the start of a line with
162    --  Token_Ptr pointing to the THEN keyword.
163
164    procedure Check_Unary_Plus_Or_Minus
165      renames Style_Inst.Check_Unary_Plus_Or_Minus;
166    --  Called after scanning a unary plus or minus to check spacing
167
168    procedure Check_Vertical_Bar
169      renames Style_Inst.Check_Vertical_Bar;
170    --  Called after scanning a vertical bar to check spacing
171
172    procedure No_End_Name (Name : Node_Id)
173      renames Style_Inst.No_End_Name;
174    --  Called if an END is encountered where a name is allowed but not present.
175    --  The parameter is the node whose name is the name that is permitted in
176    --  the END line, and the scan pointer is positioned so that if an error
177    --  message is to be generated in this situation, it should be generated
178    --  using Error_Msg_SP.
179
180    procedure No_Exit_Name (Name : Node_Id)
181      renames Style_Inst.No_Exit_Name;
182    --  Called when exiting a named loop, but a name is not present on the EXIT.
183    --  The parameter is the node whose name should have followed EXIT, and the
184    --  scan pointer is positioned so that if an error message is to be
185    --  generated, it should be generated using Error_Msg_SP.
186
187    procedure Non_Lower_Case_Keyword
188      renames Style_Inst.Non_Lower_Case_Keyword;
189    --  Called if a reserved keyword is scanned which is not spelled in all
190    --  lower case letters. On entry Token_Ptr points to the keyword token.
191    --  This is not used for keywords appearing as attribute designators,
192    --  where instead Check_Attribute_Name (True) is called.
193
194    function RM_Column_Check return Boolean
195      renames Style_Inst.RM_Column_Check;
196    --  Determines whether style checking is active and the RM column check
197    --  mode is set requiring checking of RM format layout.
198
199    procedure Subprogram_Not_In_Alpha_Order (Name : Node_Id)
200      renames Style_C_Inst.Subprogram_Not_In_Alpha_Order;
201    --  Called if Name is the name of a subprogram body in a package body
202    --  that is not in alphabetical order.
203
204 end Style;