OSDN Git Service

2005-03-29 Robert Dewar <dewar@adacore.com>
[pf3gnuchains/gcc-fork.git] / gcc / ada / styleg.ads
1 ------------------------------------------------------------------------------
2 --                                                                          --
3 --                         GNAT COMPILER COMPONENTS                         --
4 --                                                                          --
5 --                              S T Y L E G                                 --
6 --                                                                          --
7 --                                 S p e c                                  --
8 --                                                                          --
9 --          Copyright (C) 1992-2005 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 generic package collects 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 --  Styleg does not depends on the GNAT tree (Atree, Sinfo, ...).
32
33 --  For the compiler, there is also a child package Styleg.C that depends
34 --  on the GNAT tree.
35
36 with Types; use Types;
37
38 generic
39    with procedure Error_Msg (Msg : String; Flag_Location : Source_Ptr);
40    --  Output a message at specified location
41
42    with procedure Error_Msg_S (Msg : String);
43    --  Output a message at current scan pointer location
44
45    with procedure Error_Msg_SC (Msg : String);
46    --  Output a message at the start of the current token
47
48    with procedure Error_Msg_SP (Msg : String);
49    --  Output a message at the start of the previous token
50
51 package Styleg is
52
53    procedure Check_Abs_Not;
54    --  Called after scanning an ABS or NOT operator to check spacing
55
56    procedure Check_Apostrophe;
57    --  Called after scanning an apostrophe to check spacing
58
59    procedure Check_Arrow;
60    --  Called after scanning out an arrow to check spacing
61
62    procedure Check_Attribute_Name (Reserved : Boolean);
63    --  The current token is an attribute designator. Check that it
64    --  is capitalized in an appropriate manner. Reserved is set if
65    --  the attribute designator is a reserved word (access, digits,
66    --  delta or range) to allow differing rules for the two cases.
67
68    procedure Check_Box;
69    --  Called after scanning out a box to check spacing
70
71    procedure Check_Binary_Operator;
72    --  Called after scanning out a binary operator other than a plus, minus
73    --  or exponentiation operator. Intended for checking spacing rules.
74
75    procedure Check_Exponentiation_Operator;
76    --  Called after scanning out an exponentiation operator. Intended for
77    --  checking spacing rules.
78
79    procedure Check_Colon;
80    --  Called after scanning out colon to check spacing
81
82    procedure Check_Colon_Equal;
83    --  Called after scanning out colon equal to check spacing
84
85    procedure Check_Comma;
86    --  Called after scanning out comma to check spacing
87
88    procedure Check_Comment;
89    --  Called with Scan_Ptr pointing to the first minus sign of a comment.
90    --  Intended for checking any specific rules for comment placement/format.
91
92    procedure Check_Dot_Dot;
93    --  Called after scanning out dot dot to check spacing
94
95    procedure Check_HT;
96    --  Called with Scan_Ptr pointing to a horizontal tab character
97
98    procedure Check_Indentation;
99    --  Called at the start of a new statement or declaration, with Token_Ptr
100    --  pointing to the first token of the statement or declaration. The check
101    --  is that the starting column is appropriate to the indentation rules if
102    --  Token_Ptr is the first token on the line.
103
104    procedure Check_Left_Paren;
105    --  Called after scanning out a left parenthesis to check spacing.
106
107    procedure Check_Line_Max_Length (Len : Int);
108    --  Called with Scan_Ptr pointing to the first line terminator character
109    --  terminating the current line. Used to check for appropriate line length.
110    --  The parameter Len is the length of the current line.
111
112    procedure Check_Line_Terminator (Len : Int);
113    --  Called with Scan_Ptr pointing to the first line terminator terminating
114    --  the current line, used to check for appropriate line terminator usage.
115    --  The parameter Len is the length of the current line.
116
117    procedure Check_Pragma_Name;
118    --  The current token is a pragma identifier. Check that it is spelled
119    --  properly (i.e. with an appropriate casing convention).
120
121    procedure Check_Right_Paren;
122    --  Called after scanning out a right parenthesis to check spacing.
123
124    procedure Check_Semicolon;
125    --  Called after scanning out a semicolon to check spacing
126
127    procedure Check_Then (If_Loc : Source_Ptr);
128    --  Called to check that THEN and IF keywords are appropriately positioned.
129    --  The parameters show the first characters of the two keywords. This
130    --  procedure is called only if THEN appears at the start of a line with
131    --  Token_Ptr pointing to the THEN keyword.
132
133    procedure Check_Unary_Plus_Or_Minus;
134    --  Called after scanning a unary plus or minus to check spacing
135
136    procedure Check_Vertical_Bar;
137    --  Called after scanning a vertical bar to check spacing
138
139    procedure Check_Xtra_Parens (Loc : Source_Ptr);
140    --  Called after scanning a conditional expression that has at least one
141    --  level of parentheses around the entire expression.
142
143    procedure No_End_Name (Name : Node_Id);
144    --  Called if an END is encountered where a name is allowed but not present.
145    --  The parameter is the node whose name is the name that is permitted in
146    --  the END line, and the scan pointer is positioned so that if an error
147    --  message is to be generated in this situation, it should be generated
148    --  using Error_Msg_SP.
149
150    procedure No_Exit_Name (Name : Node_Id);
151    --  Called when exiting a named loop, but a name is not present on the EXIT.
152    --  The parameter is the node whose name should have followed EXIT, and the
153    --  scan pointer is positioned so that if an error message is to be
154    --  generated, it should be generated using Error_Msg_SP.
155
156    procedure Non_Lower_Case_Keyword;
157    --  Called if a reserved keyword is scanned which is not spelled in all
158    --  lower case letters. On entry Token_Ptr points to the keyword token.
159    --  This is not used for keywords appearing as attribute designators,
160    --  where instead Check_Attribute_Name (True) is called.
161
162    function RM_Column_Check return Boolean;
163    pragma Inline (RM_Column_Check);
164    --  Determines whether style checking is active and the RM column check
165    --  mode is set requiring checking of RM format layout.
166
167 end Styleg;