1
// kate: space-indent on; indent-width 3; replace-tabs on; remove-trailing-spaces all;
2
// kate: syntax pascal; indent-mode pascal;
4
(********************************************** // check: indent OK?
6
* Commment to test alignment *
9
**********************************************)
11
(*************************************************************************
14
Relative alignment should be kept ...
15
After indent, first character of this line should
16
still remain under the 'v' in relative
18
*************************************************************************)
32
type x = record a: real; c : char end;
34
// r = record ... vs unfinished typedef
35
rType = record // cr here ==> type def
36
a: aType; // this can be realigned manually
37
b: bType; // should follow line above
42
{ unfinished type declaration }
43
( red, // CHECK: everything should line up below this
44
orange, // this must follow line above
50
// CHECK: the comments should line up as well
51
// closing paren should align to list when it's left shifted
52
// to opening paren otherwise
55
otherTypeDef = integer;
57
// CHECK: next line should keep its relative alignment
59
ant = RECORD CASE F: BOOLEAN OF
62
); // parens should line up
68
END; // 'case' + 'record' share same 'end'
74
RW: ARRAY [AASY..ZZSY]
75
OF (*RESERVED WORDS*) PACKED ARRAY [1..RWLENGTH,
76
2..66 ] // CHECK: this line should be indented
77
OF CHAR; // CHECK: this line should be indented from array
79
RW: ARRAY [AASY..ZZSY] OF (*RESERVED WORDS*)
80
PACKED ARRAY [1..RWLENGTH] OF CHAR;
89
i: integer; // CHECK: can be aligned manually, but default indented from record
90
r: real; // should align with line immediately above
91
a: array[1..11] of char;
96
); // parens should line up
102
end; // 'case' + 'record' share same 'end'
104
tArray = array[0..17] of real; // should indent wrt 'type'
107
red, // CHECK: this line can be adjusted manually
108
orange, // this must follow line above
114
// CHECK: the comments should line up as well
115
// closing paren should align to list when it's left shifted
116
// to opening paren otherwise
119
blah = char; // should align after type
121
optionset = set of options;
126
r: real; // should line up with first member
127
a: array[0..7] of char;
128
end; // CHECK: end is outdented relative to first member
130
optionset : set of options;
132
options : ( crsupp,crbefore,blinbefore,
133
dindonkey,dindent,spbef,
135
inbytab, { indent current margin (was indent from symbol pos) }
137
finl { force symbol to follow on same line as previous symbol }
140
optionset = set of options;
142
aa: array[ 1..9, // should be indented after cr
144
of ( crsupp,crbefore,blinbefore,
145
dindonkey,dindent,spbef,
147
inbytab, { indent current margin (was indent from symbol pos) }
149
finl { force symbol to follow on same line as previous symbol }
155
of record // cr after here should indent from record
156
a: array[1..6] of char;
160
{ CHECK: following text should keep indent relative to open/close brace
161
when annotating, behavior of "external", "end" and possibly other keywords
162
depends on whether we are in procedure declaration,
163
item (var/const/type) declaration, or statements
167
procedure AVeryVeryLongFunctionName(const A : tRealArrayType;
169
var H : tRealArrayType); forward;
171
(*************************************************************************
172
CHECK: comment is correctly aligned with precedinging statement
177
N - longer description, but
178
still preserving relative format
181
H - other meaningful description
186
*************************************************************************)
188
var size : (small, medium, large);
191
var r : record i: integer; c: char end;
193
a: array[ 1..9, // should be indented after var
194
'a'..'z' // non-code, should line up with opening arg
197
begin (* AVeryVeryLongFunctionName *)
202
f(32); //CHECK: label forced to margin, statement is on new line with comment
212
begin s1; s2; s3 end;
214
for i := firstCh to lastCh do chtype[chr(i)] := none;
215
value['0'] := 0; value['1'] := 1; value['2'] := 2;
216
value['3'] := 3; value['4'] := 4; value['5'] := 5;
217
value['6'] := 6; value['7'] := 7; value['8'] := 8;
219
value['A'] := 10; value['B'] := 11; value['C'] := 12;
220
value['D'] := 13; value['E'] := 14; value['F'] := 15;
221
value['a'] := 10; value['b'] := 11; value['c'] := 12;
222
value['d'] := 13; value['e'] := 14; value['f'] := 15;
224
IF NOT (CH IN ['{','}']) THEN
226
BEGIN IF CH <= 'Z' THEN CMDCH := CH ELSE CMDCH := CHR(ORD(CH)-ORD('a')+ORD('A') );
230
ELSE IF CMDCH = 'T' THEN
232
ELSE IF CMDCH = 'I' THEN
234
ELSE IF CMDCH = 'Z' THEN
238
REPEAT commandIn UNTIL numRem = 0;
243
ELSE IF CMDCH = 'Q' THEN begin
245
end ELSE IF CMDCH = 'V' THEN
247
else if COMMAND.STRVAL = 'unknown' then
251
(numStr[1] IN ['+', '-', '0' .. '9', '?']) // CHECK: indent
253
Power.Supply := '"AC' ELSE Power.Supply := '"DC'
254
end else if CommandResult.Str = 'helpIamLost' then begin
255
Power.Supply := SetPowerSupplyCommands(Plus15V.Increase(Amps));
256
end else if (line = 'SHORT') OR (line = 'OPEN') THEN BEGIN
258
{*smoke billows out*}
265
(line = 'OPEN') OR (line = 'CLOSED') THEN
271
CircuitBreaker(wishfulThinking)
272
END else if cond then
274
END ELSE IF (line = 'PLUS') OR (line = 'MINUS') THEN Transform(RedPhase)
275
ELSE IF (line = 'RED') OR (line = 'BLACK') THEN Transform(BluePhase)
276
ELSE IF line = 'XX' THEN Transistor
277
ELSE IF line = 'YYYY' THEN SetCurrent(FiveAmps)
278
ELSE IF line = 'QQQQ' THEN SetPower(FiveWatts)
279
ELSE IF line = 'AAAAA' THEN Power(FiveAmps)
281
{* QWERTY COMMENT LLLLLLLLL ####### *}
284
actualphase := YellowPhase;
285
AdjustLinePhase(NewPhase);
288
line = 'Noisy' THEN Filter
289
ELSE IF line = 'BLUE' THEN
291
AdjustLinePhase(XPhase);
294
line = 'RED' THEN BEGIN Swap; Hope END
296
line = '415' THEN iNumPut415
298
// a statement like this has no chance of being correctly indented ...
299
// otoh, it shouldn't turn out catastrophically wrong.
300
line = 'REFL' THEN FOR i := 1 TO numLines DO
301
WriteLn('level=', powerLevel[i], ' ', name[i]+'='+power[i])
303
line = 'HIGH' THEN reduce
305
line = 'LOW' THEN increase
309
WHILE powerlevel[NumPowers] = level DO NumPowers := NumPowers-1;
316
Z := X*240.0 + i*Y*240;
319
ELSE IF line = 'HILD' THEN motor(induction)
320
ELSE IF (line = 'REV') THEN BEGIN
322
IF (NOT(v IN [#14..#240])) THEN
323
WriteLn(' POWER SUPPLY OUT OF SPEC') ELSE specValue := v;
326
ELSE IF (line = 'OK') THEN BEGIN
327
IncomingSupply := True; specValidate END
328
ELSE IF (line = 'NOK') THEN BEGIN IncomingSupply := False; specValidate END
330
GeneratedPowerLine.IncreasePower(
331
'Unknown input power "%s"', [SwitchPower.Current]); // CHECK: string should not cause problems
336
end (* AVeryVeryLongFunctionName *) ; // check that only necessary work is done to align