annotate gcc/ada/styleg.ads @ 115:4cb7a319550d

fix c-parser.c
author mir3636
date Tue, 28 Nov 2017 19:31:15 +0900
parents 04ced10e8804
children 84e7813d76e9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 ------------------------------------------------------------------------------
kono
parents:
diff changeset
2 -- --
kono
parents:
diff changeset
3 -- GNAT COMPILER COMPONENTS --
kono
parents:
diff changeset
4 -- --
kono
parents:
diff changeset
5 -- S T Y L E G --
kono
parents:
diff changeset
6 -- --
kono
parents:
diff changeset
7 -- S p e c --
kono
parents:
diff changeset
8 -- --
kono
parents:
diff changeset
9 -- Copyright (C) 1992-2017, Free Software Foundation, Inc. --
kono
parents:
diff changeset
10 -- --
kono
parents:
diff changeset
11 -- GNAT is free software; you can redistribute it and/or modify it under --
kono
parents:
diff changeset
12 -- terms of the GNU General Public License as published by the Free Soft- --
kono
parents:
diff changeset
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
kono
parents:
diff changeset
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
kono
parents:
diff changeset
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
kono
parents:
diff changeset
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
kono
parents:
diff changeset
17 -- for more details. You should have received a copy of the GNU General --
kono
parents:
diff changeset
18 -- Public License distributed with GNAT; see file COPYING3. If not, go to --
kono
parents:
diff changeset
19 -- http://www.gnu.org/licenses for a complete copy of the license. --
kono
parents:
diff changeset
20 -- --
kono
parents:
diff changeset
21 -- GNAT was originally developed by the GNAT team at New York University. --
kono
parents:
diff changeset
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
kono
parents:
diff changeset
23 -- --
kono
parents:
diff changeset
24 ------------------------------------------------------------------------------
kono
parents:
diff changeset
25
kono
parents:
diff changeset
26 -- This generic package collects the routines used for style checking, as
kono
parents:
diff changeset
27 -- activated by the relevant command line option. These are gathered in
kono
parents:
diff changeset
28 -- a separate package so that they can more easily be customized. Calls
kono
parents:
diff changeset
29 -- to these subprograms are only made if Opt.Style_Check is set True.
kono
parents:
diff changeset
30 -- Styleg does not depends on the GNAT tree (Atree, Sinfo, ...).
kono
parents:
diff changeset
31
kono
parents:
diff changeset
32 with Types; use Types;
kono
parents:
diff changeset
33
kono
parents:
diff changeset
34 generic
kono
parents:
diff changeset
35 with procedure Error_Msg (Msg : String; Flag_Location : Source_Ptr);
kono
parents:
diff changeset
36 -- Output a message at specified location
kono
parents:
diff changeset
37
kono
parents:
diff changeset
38 with procedure Error_Msg_S (Msg : String);
kono
parents:
diff changeset
39 -- Output a message at current scan pointer location
kono
parents:
diff changeset
40
kono
parents:
diff changeset
41 with procedure Error_Msg_SC (Msg : String);
kono
parents:
diff changeset
42 -- Output a message at the start of the current token
kono
parents:
diff changeset
43
kono
parents:
diff changeset
44 with procedure Error_Msg_SP (Msg : String);
kono
parents:
diff changeset
45 -- Output a message at the start of the previous token
kono
parents:
diff changeset
46
kono
parents:
diff changeset
47 package Styleg is
kono
parents:
diff changeset
48
kono
parents:
diff changeset
49 procedure Check_Abs_Not;
kono
parents:
diff changeset
50 -- Called after scanning an ABS or NOT operator to check spacing
kono
parents:
diff changeset
51
kono
parents:
diff changeset
52 procedure Check_Apostrophe;
kono
parents:
diff changeset
53 -- Called after scanning an apostrophe to check spacing
kono
parents:
diff changeset
54
kono
parents:
diff changeset
55 procedure Check_Arrow (Inside_Depends : Boolean := False);
kono
parents:
diff changeset
56 -- Called after scanning out an arrow to check spacing. Inside_Depends is
kono
parents:
diff changeset
57 -- True if the call is from an argument of the Depends or Refined_Depends
kono
parents:
diff changeset
58 -- aspect or pragma (where the allowed/required format is =>+).
kono
parents:
diff changeset
59
kono
parents:
diff changeset
60 procedure Check_Attribute_Name (Reserved : Boolean);
kono
parents:
diff changeset
61 -- The current token is an attribute designator. Check that it
kono
parents:
diff changeset
62 -- is capitalized in an appropriate manner. Reserved is set if
kono
parents:
diff changeset
63 -- the attribute designator is a reserved word (access, digits,
kono
parents:
diff changeset
64 -- delta or range) to allow differing rules for the two cases.
kono
parents:
diff changeset
65
kono
parents:
diff changeset
66 procedure Check_Boolean_Operator (Node : Node_Id);
kono
parents:
diff changeset
67 -- Node is a node for an AND or OR operator. Check that the usage meets
kono
parents:
diff changeset
68 -- the style rules.
kono
parents:
diff changeset
69
kono
parents:
diff changeset
70 procedure Check_Box;
kono
parents:
diff changeset
71 -- Called after scanning out a box to check spacing
kono
parents:
diff changeset
72
kono
parents:
diff changeset
73 procedure Check_Binary_Operator;
kono
parents:
diff changeset
74 -- Called after scanning out a binary operator other than a plus, minus
kono
parents:
diff changeset
75 -- or exponentiation operator. Intended for checking spacing rules.
kono
parents:
diff changeset
76
kono
parents:
diff changeset
77 procedure Check_Exponentiation_Operator;
kono
parents:
diff changeset
78 -- Called after scanning out an exponentiation operator. Intended for
kono
parents:
diff changeset
79 -- checking spacing rules.
kono
parents:
diff changeset
80
kono
parents:
diff changeset
81 procedure Check_Colon;
kono
parents:
diff changeset
82 -- Called after scanning out colon to check spacing
kono
parents:
diff changeset
83
kono
parents:
diff changeset
84 procedure Check_Colon_Equal;
kono
parents:
diff changeset
85 -- Called after scanning out colon equal to check spacing
kono
parents:
diff changeset
86
kono
parents:
diff changeset
87 procedure Check_Comma;
kono
parents:
diff changeset
88 -- Called after scanning out comma to check spacing
kono
parents:
diff changeset
89
kono
parents:
diff changeset
90 procedure Check_Comment;
kono
parents:
diff changeset
91 -- Called with Scan_Ptr pointing to the first minus sign of a comment.
kono
parents:
diff changeset
92 -- Intended for checking any specific rules for comment placement/format.
kono
parents:
diff changeset
93
kono
parents:
diff changeset
94 procedure Check_Dot_Dot;
kono
parents:
diff changeset
95 -- Called after scanning out dot dot to check spacing
kono
parents:
diff changeset
96
kono
parents:
diff changeset
97 procedure Check_EOF;
kono
parents:
diff changeset
98 -- Called after scanning out EOF mark
kono
parents:
diff changeset
99
kono
parents:
diff changeset
100 procedure Check_HT;
kono
parents:
diff changeset
101 -- Called with Scan_Ptr pointing to a horizontal tab character
kono
parents:
diff changeset
102
kono
parents:
diff changeset
103 procedure Check_Indentation;
kono
parents:
diff changeset
104 -- Called at the start of a new statement or declaration, with Token_Ptr
kono
parents:
diff changeset
105 -- pointing to the first token of the statement or declaration. The check
kono
parents:
diff changeset
106 -- is that the starting column is appropriate to the indentation rules if
kono
parents:
diff changeset
107 -- Token_Ptr is the first token on the line.
kono
parents:
diff changeset
108
kono
parents:
diff changeset
109 procedure Check_Left_Paren;
kono
parents:
diff changeset
110 -- Called after scanning out a left parenthesis to check spacing
kono
parents:
diff changeset
111
kono
parents:
diff changeset
112 procedure Check_Line_Max_Length (Len : Nat);
kono
parents:
diff changeset
113 -- Called with Scan_Ptr pointing to the first line terminator character
kono
parents:
diff changeset
114 -- terminating the current line. Used to check for appropriate line length.
kono
parents:
diff changeset
115 -- The parameter Len is the length of the current line.
kono
parents:
diff changeset
116
kono
parents:
diff changeset
117 procedure Check_Line_Terminator (Len : Nat);
kono
parents:
diff changeset
118 -- Called with Scan_Ptr pointing to the first line terminator terminating
kono
parents:
diff changeset
119 -- the current line, used to check for appropriate line terminator usage.
kono
parents:
diff changeset
120 -- The parameter Len is the length of the current line.
kono
parents:
diff changeset
121
kono
parents:
diff changeset
122 procedure Check_Not_In;
kono
parents:
diff changeset
123 -- Called with Scan_Ptr pointing to an IN token, and Prev_Token_Ptr
kono
parents:
diff changeset
124 -- pointing to a NOT token. Used to check proper layout of NOT IN.
kono
parents:
diff changeset
125
kono
parents:
diff changeset
126 procedure Check_Pragma_Name;
kono
parents:
diff changeset
127 -- The current token is a pragma identifier. Check that it is spelled
kono
parents:
diff changeset
128 -- properly (i.e. with an appropriate casing convention).
kono
parents:
diff changeset
129
kono
parents:
diff changeset
130 procedure Check_Right_Paren;
kono
parents:
diff changeset
131 -- Called after scanning out a right parenthesis to check spacing
kono
parents:
diff changeset
132
kono
parents:
diff changeset
133 procedure Check_Semicolon;
kono
parents:
diff changeset
134 -- Called after scanning out a semicolon to check spacing
kono
parents:
diff changeset
135
kono
parents:
diff changeset
136 procedure Check_Then (If_Loc : Source_Ptr);
kono
parents:
diff changeset
137 -- Called to check that THEN and IF keywords are appropriately positioned.
kono
parents:
diff changeset
138 -- The parameters show the first characters of the two keywords. This
kono
parents:
diff changeset
139 -- procedure is called with Token_Ptr pointing to the THEN keyword.
kono
parents:
diff changeset
140
kono
parents:
diff changeset
141 procedure Check_Separate_Stmt_Lines;
kono
parents:
diff changeset
142 pragma Inline (Check_Separate_Stmt_Lines);
kono
parents:
diff changeset
143 -- Called after scanning THEN (not preceded by AND) or ELSE (not preceded
kono
parents:
diff changeset
144 -- by OR). Used to check that no tokens follow on the same line (which
kono
parents:
diff changeset
145 -- would interfere with coverage testing). Handles case of THEN ABORT as
kono
parents:
diff changeset
146 -- an exception, as well as PRAGMA after ELSE.
kono
parents:
diff changeset
147
kono
parents:
diff changeset
148 procedure Check_Unary_Plus_Or_Minus (Inside_Depends : Boolean := False);
kono
parents:
diff changeset
149 -- Called after scanning a unary plus or minus to check spacing. The flag
kono
parents:
diff changeset
150 -- Inside_Depends is set if we are scanning within a Depends or
kono
parents:
diff changeset
151 -- Refined_Depends pragma or Aspect, in which case =>+ requires a
kono
parents:
diff changeset
152 -- following space.
kono
parents:
diff changeset
153
kono
parents:
diff changeset
154 procedure Check_Vertical_Bar;
kono
parents:
diff changeset
155 -- Called after scanning a vertical bar to check spacing
kono
parents:
diff changeset
156
kono
parents:
diff changeset
157 procedure Check_Xtra_Parens (Loc : Source_Ptr);
kono
parents:
diff changeset
158 -- Called after scanning an if, case, or quantified expression that has at
kono
parents:
diff changeset
159 -- least one level of parentheses around the entire expression.
kono
parents:
diff changeset
160
kono
parents:
diff changeset
161 function Mode_In_Check return Boolean;
kono
parents:
diff changeset
162 pragma Inline (Mode_In_Check);
kono
parents:
diff changeset
163 -- Determines whether style checking is active and the Mode_In_Check is
kono
parents:
diff changeset
164 -- set, forbidding the explicit use of mode IN.
kono
parents:
diff changeset
165
kono
parents:
diff changeset
166 procedure No_End_Name (Name : Node_Id);
kono
parents:
diff changeset
167 -- Called if an END is encountered where a name is allowed but not present.
kono
parents:
diff changeset
168 -- The parameter is the node whose name is the name that is permitted in
kono
parents:
diff changeset
169 -- the END line, and the scan pointer is positioned so that if an error
kono
parents:
diff changeset
170 -- message is to be generated in this situation, it should be generated
kono
parents:
diff changeset
171 -- using Error_Msg_SP.
kono
parents:
diff changeset
172
kono
parents:
diff changeset
173 procedure No_Exit_Name (Name : Node_Id);
kono
parents:
diff changeset
174 -- Called when exiting a named loop, but a name is not present on the EXIT.
kono
parents:
diff changeset
175 -- The parameter is the node whose name should have followed EXIT, and the
kono
parents:
diff changeset
176 -- scan pointer is positioned so that if an error message is to be
kono
parents:
diff changeset
177 -- generated, it should be generated using Error_Msg_SP.
kono
parents:
diff changeset
178
kono
parents:
diff changeset
179 procedure Non_Lower_Case_Keyword;
kono
parents:
diff changeset
180 -- Called if a reserved keyword is scanned which is not spelled in all
kono
parents:
diff changeset
181 -- lower case letters. On entry Token_Ptr points to the keyword token.
kono
parents:
diff changeset
182 -- This is not used for keywords appearing as attribute designators,
kono
parents:
diff changeset
183 -- where instead Check_Attribute_Name (True) is called.
kono
parents:
diff changeset
184
kono
parents:
diff changeset
185 end Styleg;