1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
10 -- Copyright (C) 1992-2000 Free Software Foundation, Inc. --
12 -- GNAT is free software; you can redistribute it and/or modify it under --
13 -- terms of the GNU General Public License as published by the Free Soft- --
14 -- ware Foundation; either version 2, or (at your option) any later ver- --
15 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
16 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
17 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
18 -- for more details. You should have received a copy of the GNU General --
19 -- Public License distributed with GNAT; see file COPYING. If not, write --
20 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
21 -- MA 02111-1307, USA. --
23 -- GNAT was originally developed by the GNAT team at New York University. --
24 -- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). --
26 ------------------------------------------------------------------------------
28 -- This package collects all the routines used for style checking, as
29 -- activated by the relevant command line option. These are gathered in
30 -- a separate package so that they can more easily be customized. Calls
31 -- to these subprograms are only made if Opt.Style_Check is set True.
33 with Types
; use Types
;
37 procedure Body_With_No_Spec
(N
: Node_Id
);
38 -- Called where N is a subprogram body node for a subprogram body
39 -- for which no spec was given, i.e. a body acting as its own spec.
41 procedure Check_Abs_Not
;
42 -- Called after scanning an ABS or NOT operator to check spacing
44 procedure Check_Arrow
;
45 -- Called after scanning out an arrow to check spacing
47 procedure Check_Attribute_Name
(Reserved
: Boolean);
48 -- The current token is an attribute designator. Check that it is
49 -- capitalized in an appropriate manner. Reserved is set if the
50 -- attribute designator is a reserved word (access, digits, delta
51 -- or range) to allow differing rules for the two cases.
54 -- Called after scanning out a box to check spacing
56 procedure Check_Binary_Operator
;
57 -- Called after scanning out a binary operator other than a plus, minus
58 -- or exponentiation operator. Intended for checking spacing rules.
60 procedure Check_Exponentiation_Operator
;
61 -- Called after scanning out an exponentiation operator. Intended for
62 -- checking spacing rules.
64 procedure Check_Colon
;
65 -- Called after scanning out colon to check spacing
67 procedure Check_Colon_Equal
;
68 -- Called after scanning out colon equal to check spacing
70 procedure Check_Comma
;
71 -- Called after scanning out comma to check spacing
73 procedure Check_Comment
;
74 -- Called with Scan_Ptr pointing to the first minus sign of a comment.
75 -- Intended for checking any specific rules for comment placement/format.
77 procedure Check_Dot_Dot
;
78 -- Called after scanning out dot dot to check spacing
81 -- Called with Scan_Ptr pointing to a horizontal tab character
83 procedure Check_Identifier
84 (Ref
: Node_Or_Entity_Id
;
85 Def
: Node_Or_Entity_Id
);
86 -- Check style of identifier occurrence. Ref is an N_Identifier node whose
87 -- spelling is to be checked against the Chars spelling in identifier node
88 -- Def (which may be either an N_Identifier, or N_Defining_Identifier node)
90 procedure Check_Indentation
;
91 -- Called at the start of a new statement or declaration, with Token_Ptr
92 -- pointing to the first token of the statement or declaration. The check
93 -- is that the starting column is appropriate to the indentation rules if
94 -- Token_Ptr is the first token on the line.
96 procedure Check_Left_Paren
;
97 -- Called after scanning out a left parenthesis to check spacing.
99 procedure Check_Line_Terminator
(Len
: Int
);
100 -- Called with Scan_Ptr pointing to the first line terminator terminating
101 -- the current line, used to check for appropriate line terminator and
102 -- to check the line length (Len is the length of the current line).
103 -- Note that the terminator may be the EOF character.
105 procedure Check_Pragma_Name
;
106 -- The current token is a pragma identifier. Check that it is spelled
107 -- properly (i.e. with an appropriate casing convention).
109 procedure Check_Right_Paren
;
110 -- Called after scanning out a right parenthesis to check spacing.
112 procedure Check_Semicolon
;
113 -- Called after scanning out a semicolon to check spacing
115 procedure Check_Then
(If_Loc
: Source_Ptr
);
116 -- Called to check that THEN and IF keywords are appropriately positioned.
117 -- The parameters show the first characters of the two keywords. This
118 -- procedure is called only if THEN appears at the start of a line with
119 -- Token_Ptr pointing to the THEN keyword.
121 procedure Check_Unary_Plus_Or_Minus
;
122 -- Called after scanning a unary plus or minus to check spacing
124 procedure Check_Vertical_Bar
;
125 -- Called after scanning a vertical bar to check spacing
127 procedure No_End_Name
(Name
: Node_Id
);
128 -- Called if an END is encountered where a name is allowed but not present.
129 -- The parameter is the node whose name is the name that is permitted in
130 -- the END line, and the scan pointer is positioned so that if an error
131 -- message is to be generated in this situation, it should be generated
132 -- using Error_Msg_SP.
134 procedure No_Exit_Name
(Name
: Node_Id
);
135 -- Called when exiting a named loop, but a name is not present on the EXIT.
136 -- The parameter is the node whose name should have followed EXIT, and the
137 -- scan pointer is positioned so that if an error message is to be
138 -- generated, it should be generated using Error_Msg_SP.
140 procedure Non_Lower_Case_Keyword
;
141 -- Called if a reserved keyword is scanned which is not spelled in all
142 -- lower case letters. On entry Token_Ptr points to the keyword token.
143 -- This is not used for keywords appearing as attribute designators,
144 -- where instead Check_Attribute_Name (True) is called.
146 function RM_Column_Check
return Boolean;
147 pragma Inline
(RM_Column_Check
);
148 -- Determines whether style checking is active and the RM column check
149 -- mode is set requiring checking of RM format layout.
151 procedure Subprogram_Not_In_Alpha_Order
(Name
: Node_Id
);
152 -- Called if Name is the name of a subprogram body in a package body
153 -- that is not in alphabetical order.