1
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
5
* This file is a part of "Artistic Style" - an indentation and
6
* reformatting tool for C, C++, C# and Java source files.
7
* http://astyle.sourceforge.net
9
* The "Artistic Style" project, including all files needed to
10
* compile it, is free software; you can redistribute it and/or
11
* modify it under the terms of the GNU Lesser General Public
12
* License as published by the Free Software Foundation; either
13
* version 2.1 of the License, or (at your option) any later
16
* This program is distributed in the hope that it will be useful,
17
* but WITHOUT ANY WARRANTY; without even the implied warranty of
18
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
* GNU Lesser General Public License for more details.
21
* You should have received a copy of the GNU Lesser General Public
22
* License along with this project; if not, write to the
23
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24
* Boston, MA 02110-1301, USA.
26
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
34
const string ASResource::AS_IF = string("if");
35
const string ASResource::AS_ELSE = string("else");
36
const string ASResource::AS_FOR = string("for");
37
const string ASResource::AS_DO = string("do");
38
const string ASResource::AS_WHILE = string("while");
39
const string ASResource::AS_SWITCH = string("switch");
40
const string ASResource::AS_CASE = string("case");
41
const string ASResource::AS_DEFAULT = string("default");
42
const string ASResource::AS_CLASS = string("class");
43
const string ASResource::AS_STRUCT = string("struct");
44
const string ASResource::AS_UNION = string("union");
45
const string ASResource::AS_INTERFACE = string("interface");
46
const string ASResource::AS_NAMESPACE = string("namespace");
47
const string ASResource::AS_EXTERN = string("extern");
48
const string ASResource::AS_PUBLIC = string("public");
49
const string ASResource::AS_PROTECTED = string("protected");
50
const string ASResource::AS_PRIVATE = string("private");
51
const string ASResource::AS_STATIC = string("static");
52
const string ASResource::AS_SYNCHRONIZED = string("synchronized");
53
const string ASResource::AS_OPERATOR = string("operator");
54
const string ASResource::AS_TEMPLATE = string("template");
55
const string ASResource::AS_TRY = string("try");
56
const string ASResource::AS_CATCH = string("catch");
57
const string ASResource::AS_FINALLY = string("finally");
58
const string ASResource::AS_THROWS = string("throws");
59
const string ASResource::AS_CONST = string("const");
61
const string ASResource::AS_ASM = string("asm");
63
const string ASResource::AS_BAR_DEFINE = string("#define");
64
const string ASResource::AS_BAR_INCLUDE = string("#include");
65
const string ASResource::AS_BAR_IF = string("#if");
66
const string ASResource::AS_BAR_EL = string("#el");
67
const string ASResource::AS_BAR_ENDIF = string("#endif");
69
const string ASResource::AS_OPEN_BRACKET = string("{");
70
const string ASResource::AS_CLOSE_BRACKET = string("}");
71
const string ASResource::AS_OPEN_LINE_COMMENT = string("//");
72
const string ASResource::AS_OPEN_COMMENT = string("/*");
73
const string ASResource::AS_CLOSE_COMMENT = string("*/");
75
const string ASResource::AS_ASSIGN = string("=");
76
const string ASResource::AS_PLUS_ASSIGN = string("+=");
77
const string ASResource::AS_MINUS_ASSIGN = string("-=");
78
const string ASResource::AS_MULT_ASSIGN = string("*=");
79
const string ASResource::AS_DIV_ASSIGN = string("/=");
80
const string ASResource::AS_MOD_ASSIGN = string("%=");
81
const string ASResource::AS_OR_ASSIGN = string("|=");
82
const string ASResource::AS_AND_ASSIGN = string("&=");
83
const string ASResource::AS_XOR_ASSIGN = string("^=");
84
const string ASResource::AS_GR_GR_ASSIGN = string(">>=");
85
const string ASResource::AS_LS_LS_ASSIGN = string("<<=");
86
const string ASResource::AS_GR_GR_GR_ASSIGN = string(">>>=");
87
const string ASResource::AS_LS_LS_LS_ASSIGN = string("<<<=");
88
const string ASResource::AS_RETURN = string("return");
90
const string ASResource::AS_EQUAL = string("==");
91
const string ASResource::AS_PLUS_PLUS = string("++");
92
const string ASResource::AS_MINUS_MINUS = string("--");
93
const string ASResource::AS_NOT_EQUAL = string("!=");
94
const string ASResource::AS_GR_EQUAL = string(">=");
95
const string ASResource::AS_GR_GR = string(">>");
96
const string ASResource::AS_GR_GR_GR = string(">>>");
97
const string ASResource::AS_LS_EQUAL = string("<=");
98
const string ASResource::AS_LS_LS = string("<<");
99
const string ASResource::AS_LS_LS_LS = string("<<<");
100
const string ASResource::AS_ARROW = string("->");
101
const string ASResource::AS_AND = string("&&");
102
const string ASResource::AS_OR = string("||");
103
const string ASResource::AS_COLON_COLON = string("::");
104
const string ASResource::AS_PAREN_PAREN = string("()");
105
const string ASResource::AS_BLPAREN_BLPAREN = string("[]");
107
const string ASResource::AS_PLUS = string("+");
108
const string ASResource::AS_MINUS = string("-");
109
const string ASResource::AS_MULT = string("*");
110
const string ASResource::AS_DIV = string("/");
111
const string ASResource::AS_MOD = string("%");
112
const string ASResource::AS_GR = string(">");
113
const string ASResource::AS_LS = string("<");
114
const string ASResource::AS_NOT = string("!");
115
const string ASResource::AS_BIT_OR = string("|");
116
const string ASResource::AS_BIT_AND = string("&");
117
const string ASResource::AS_BIT_NOT = string("~");
118
const string ASResource::AS_BIT_XOR = string("^");
119
const string ASResource::AS_QUESTION = string("?");
120
const string ASResource::AS_COLON = string(":");
121
const string ASResource::AS_COMMA = string(",");
122
const string ASResource::AS_SEMICOLON = string(";");
124
const string ASResource::AS_FOREACH = string("foreach");
125
const string ASResource::AS_LOCK = string("lock");
126
const string ASResource::AS_UNSAFE = string("unsafe");
127
const string ASResource::AS_FIXED = string("fixed");
128
const string ASResource::AS_GET = string("get");
129
const string ASResource::AS_SET = string("set");
130
const string ASResource::AS_ADD = string("add");
131
const string ASResource::AS_REMOVE = string("remove");
133
const string ASResource::AS_CONST_CAST = string("const_cast");
134
const string ASResource::AS_DYNAMIC_CAST = string("dynamic_cast");
135
const string ASResource::AS_REINTERPRET_CAST = string("reinterpret_cast");
136
const string ASResource::AS_STATIC_CAST = string("static_cast");
140
* Build the vector of assignment operators.
141
* Used by BOTH ASFormatter.cpp and ASBeautifier.cpp
143
* @param assignmentOperators a reference to the vector to be built.
145
void ASResource::buildAssignmentOperators(vector<const string*> &assignmentOperators)
147
assignmentOperators.push_back(&AS_ASSIGN);
148
assignmentOperators.push_back(&AS_PLUS_ASSIGN);
149
assignmentOperators.push_back(&AS_MINUS_ASSIGN);
150
assignmentOperators.push_back(&AS_MULT_ASSIGN);
151
assignmentOperators.push_back(&AS_DIV_ASSIGN);
152
assignmentOperators.push_back(&AS_MOD_ASSIGN);
153
assignmentOperators.push_back(&AS_OR_ASSIGN);
154
assignmentOperators.push_back(&AS_AND_ASSIGN);
155
assignmentOperators.push_back(&AS_XOR_ASSIGN);
158
assignmentOperators.push_back(&AS_GR_GR_GR_ASSIGN);
159
assignmentOperators.push_back(&AS_GR_GR_ASSIGN);
160
assignmentOperators.push_back(&AS_LS_LS_ASSIGN);
163
assignmentOperators.push_back(&AS_LS_LS_LS_ASSIGN);
165
assignmentOperators.push_back(&AS_RETURN);
169
* Build the vector of C++ cast operators.
170
* Used by ONLY ASFormatter.cpp
172
* @param castOperators a reference to the vector to be built.
174
void ASResource::buildCastOperators(vector<const string*> &castOperators)
176
castOperators.push_back(&AS_CONST_CAST);
177
castOperators.push_back(&AS_DYNAMIC_CAST);
178
castOperators.push_back(&AS_REINTERPRET_CAST);
179
castOperators.push_back(&AS_STATIC_CAST);
183
* Build the vector of header words.
184
* Used by BOTH ASFormatter.cpp and ASBeautifier.cpp
186
* @param headers a reference to the vector to be built.
188
void ASResource::buildHeaders(vector<const string*> &headers, int fileType, bool beautifier)
190
headers.push_back(&AS_IF);
191
headers.push_back(&AS_ELSE);
192
headers.push_back(&AS_FOR);
193
headers.push_back(&AS_WHILE);
194
headers.push_back(&AS_DO);
195
headers.push_back(&AS_SWITCH);
196
headers.push_back(&AS_TRY);
197
headers.push_back(&AS_CATCH);
201
headers.push_back(&AS_CASE);
202
headers.push_back(&AS_DEFAULT);
203
headers.push_back(&AS_CONST);
204
headers.push_back(&AS_STATIC);
205
headers.push_back(&AS_EXTERN);
206
headers.push_back(&AS_TEMPLATE);
209
if (fileType == JAVA_TYPE)
211
headers.push_back(&AS_FINALLY);
212
headers.push_back(&AS_SYNCHRONIZED);
215
if (fileType == SHARP_TYPE)
217
headers.push_back(&AS_FINALLY);
218
headers.push_back(&AS_FOREACH);
219
headers.push_back(&AS_LOCK);
220
headers.push_back(&AS_UNSAFE);
221
headers.push_back(&AS_FIXED);
222
headers.push_back(&AS_GET);
223
headers.push_back(&AS_SET);
224
headers.push_back(&AS_ADD);
225
headers.push_back(&AS_REMOVE);
230
* Build the vector of non-assignment operators.
231
* Used by ONLY ASBeautifier.cpp
233
* @param nonParenHeaders a reference to the vector to be built.
235
void ASResource::buildNonAssignmentOperators(vector<const string*> &nonAssignmentOperators)
237
nonAssignmentOperators.push_back(&AS_EQUAL);
238
nonAssignmentOperators.push_back(&AS_PLUS_PLUS);
239
nonAssignmentOperators.push_back(&AS_MINUS_MINUS);
240
nonAssignmentOperators.push_back(&AS_NOT_EQUAL);
241
nonAssignmentOperators.push_back(&AS_GR_EQUAL);
242
nonAssignmentOperators.push_back(&AS_GR_GR_GR);
243
nonAssignmentOperators.push_back(&AS_GR_GR);
244
nonAssignmentOperators.push_back(&AS_LS_EQUAL);
245
nonAssignmentOperators.push_back(&AS_LS_LS_LS);
246
nonAssignmentOperators.push_back(&AS_LS_LS);
247
nonAssignmentOperators.push_back(&AS_ARROW);
248
nonAssignmentOperators.push_back(&AS_AND);
249
nonAssignmentOperators.push_back(&AS_OR);
253
* Build the vector of header non-paren headers.
254
* Used by BOTH ASFormatter.cpp and ASBeautifier.cpp
256
* @param nonParenHeaders a reference to the vector to be built.
258
void ASResource::buildNonParenHeaders(vector<const string*> &nonParenHeaders, int fileType, bool beautifier)
260
nonParenHeaders.push_back(&AS_ELSE);
261
nonParenHeaders.push_back(&AS_DO);
262
nonParenHeaders.push_back(&AS_TRY);
266
nonParenHeaders.push_back(&AS_CASE);
267
nonParenHeaders.push_back(&AS_DEFAULT);
268
nonParenHeaders.push_back(&AS_CONST);
269
nonParenHeaders.push_back(&AS_STATIC);
270
nonParenHeaders.push_back(&AS_EXTERN);
271
nonParenHeaders.push_back(&AS_TEMPLATE);
274
if (fileType == JAVA_TYPE)
276
nonParenHeaders.push_back(&AS_FINALLY);
279
if (fileType == SHARP_TYPE)
281
nonParenHeaders.push_back(&AS_FINALLY);
282
nonParenHeaders.push_back(&AS_UNSAFE);
283
nonParenHeaders.push_back(&AS_GET);
284
nonParenHeaders.push_back(&AS_SET);
285
nonParenHeaders.push_back(&AS_ADD);
286
nonParenHeaders.push_back(&AS_REMOVE);
291
* Build the vector of operators.
292
* Used by ONLY ASFormatter.cpp
294
* @param operators a reference to the vector to be built.
296
void ASResource::buildOperators(vector<const string*> &operators)
298
operators.push_back(&AS_PLUS_ASSIGN);
299
operators.push_back(&AS_MINUS_ASSIGN);
300
operators.push_back(&AS_MULT_ASSIGN);
301
operators.push_back(&AS_DIV_ASSIGN);
302
operators.push_back(&AS_MOD_ASSIGN);
303
operators.push_back(&AS_OR_ASSIGN);
304
operators.push_back(&AS_AND_ASSIGN);
305
operators.push_back(&AS_XOR_ASSIGN);
306
operators.push_back(&AS_EQUAL);
307
operators.push_back(&AS_PLUS_PLUS);
308
operators.push_back(&AS_MINUS_MINUS);
309
operators.push_back(&AS_NOT_EQUAL);
310
operators.push_back(&AS_GR_EQUAL);
311
operators.push_back(&AS_GR_GR_GR_ASSIGN);
312
operators.push_back(&AS_GR_GR_ASSIGN);
313
operators.push_back(&AS_GR_GR_GR);
314
operators.push_back(&AS_GR_GR);
315
operators.push_back(&AS_LS_EQUAL);
316
operators.push_back(&AS_LS_LS_LS_ASSIGN);
317
operators.push_back(&AS_LS_LS_ASSIGN);
318
operators.push_back(&AS_LS_LS_LS);
319
operators.push_back(&AS_LS_LS);
320
operators.push_back(&AS_ARROW);
321
operators.push_back(&AS_AND);
322
operators.push_back(&AS_OR);
323
operators.push_back(&AS_COLON_COLON);
324
operators.push_back(&AS_PLUS);
325
operators.push_back(&AS_MINUS);
326
operators.push_back(&AS_MULT);
327
operators.push_back(&AS_DIV);
328
operators.push_back(&AS_MOD);
329
operators.push_back(&AS_QUESTION);
330
operators.push_back(&AS_COLON);
331
operators.push_back(&AS_ASSIGN);
332
operators.push_back(&AS_LS);
333
operators.push_back(&AS_GR);
334
operators.push_back(&AS_NOT);
335
operators.push_back(&AS_BIT_OR);
336
operators.push_back(&AS_BIT_AND);
337
operators.push_back(&AS_BIT_NOT);
338
operators.push_back(&AS_BIT_XOR);
339
operators.push_back(&AS_OPERATOR);
340
operators.push_back(&AS_COMMA);
341
operators.push_back(&AS_RETURN);
345
* Build the vector of pre-block statements.
346
* Used by ONLY ASBeautifier.cpp
348
* @param preBlockStatements a reference to the vector to be built.
350
void ASResource::buildPreBlockStatements(vector<const string*> &preBlockStatements)
352
preBlockStatements.push_back(&AS_CLASS);
353
preBlockStatements.push_back(&AS_STRUCT);
354
preBlockStatements.push_back(&AS_UNION);
355
preBlockStatements.push_back(&AS_INTERFACE);
356
preBlockStatements.push_back(&AS_NAMESPACE);
357
preBlockStatements.push_back(&AS_THROWS);
358
preBlockStatements.push_back(&AS_EXTERN);
362
* Build the vector of pre-command headers.
363
* Used by ONLY ASFormatter.cpp
365
* @param preCommandHeaders a reference to the vector to be built.
367
void ASResource::buildPreCommandHeaders(vector<const string*> &preCommandHeaders)
369
preCommandHeaders.push_back(&AS_EXTERN);
370
preCommandHeaders.push_back(&AS_THROWS);
371
preCommandHeaders.push_back(&AS_CONST);
375
* Build the vector of pre-definition headers.
376
* Used by ONLY ASFormatter.cpp
378
* @param preDefinitionHeaders a reference to the vector to be built.
380
void ASResource::buildPreDefinitionHeaders(vector<const string*> &preDefinitionHeaders)
382
preDefinitionHeaders.push_back(&AS_CLASS);
383
preDefinitionHeaders.push_back(&AS_INTERFACE);
384
preDefinitionHeaders.push_back(&AS_NAMESPACE);
385
preDefinitionHeaders.push_back(&AS_STRUCT);
389
} // end namespace astyle