Warning, /frameworks/ktexteditor/autotests/input/indent/pascal/longtest1/expected is written in an unsupported language. File is not indexed.
0001 // kate: space-indent on; indent-width 3; replace-tabs on; remove-trailing-spaces all;
0002 // kate: syntax pascal; indent-mode pascal;
0003
0004 (********************************************** // check: indent OK?
0005 * *
0006 * Commment to test alignment *
0007 * *
0008 * *
0009 **********************************************)
0010
0011 (*************************************************************************
0012 Another Comment
0013
0014 Relative alignment should be kept ...
0015 After indent, first character of this line should
0016 still remain under the 'v' in relative
0017
0018 *************************************************************************)
0019
0020 program fred;
0021
0022 uses bbb;
0023
0024 label fred001;
0025 var i: integer;
0026
0027 const const0 = 0;
0028 c33 = 12;
0029 const1 = 17;
0030 const2 = 18.4;
0031
0032 type x = record a: real; c : char end;
0033
0034 // r = record ... vs unfinished typedef
0035 rType = record // cr here ==> type def
0036 a: aType; // this can be realigned manually
0037 b: bType; // should follow line above
0038 c: cType
0039 end;
0040
0041 colourType =
0042 { unfinished type declaration }
0043 ( red, // CHECK: everything should line up below this
0044 orange, // this must follow line above
0045 green,
0046 blue,
0047 indigo,
0048 yellow,
0049 violet
0050 // CHECK: the comments should line up as well
0051 // closing paren should align to list when it's left shifted
0052 // to opening paren otherwise
0053 );
0054
0055 otherTypeDef = integer;
0056
0057 // CHECK: next line should keep its relative alignment
0058 {next}
0059 ant = RECORD CASE F: BOOLEAN OF
0060 TRUE: ( fred : REAL;
0061 joe : INTEGER;
0062 ); // parens should line up
0063 FALSE: ( ted : ARRAY[
0064 1..16
0065 ] OF BOOLEAN;
0066 moe: CHAR;
0067 );
0068 END; // 'case' + 'record' share same 'end'
0069
0070
0071
0072 var a: real;
0073
0074 RW: ARRAY [AASY..ZZSY]
0075 OF (*RESERVED WORDS*) PACKED ARRAY [1..RWLENGTH,
0076 2..66 ] // CHECK: this line should be indented
0077 OF CHAR; // CHECK: this line should be indented from array
0078
0079 RW: ARRAY [AASY..ZZSY] OF (*RESERVED WORDS*)
0080 PACKED ARRAY [1..RWLENGTH] OF CHAR;
0081
0082 var
0083 sym : keysymbol;
0084 pos : hashIndex;
0085 len : charLenType;
0086
0087
0088 type tR = record
0089 i: integer; // CHECK: can be aligned manually, but default indented from record
0090 r: real; // should align with line immediately above
0091 a: array[1..11] of char;
0092
0093 case boolean of
0094 true: ( fred : real;
0095 joe : integer;
0096 ); // parens should line up
0097 false: ( ted : array[
0098 1..16
0099 ] of boolean;
0100 moe: char;
0101 );
0102 end; // 'case' + 'record' share same 'end'
0103
0104 tArray = array[0..17] of real; // should indent wrt 'type'
0105
0106 type colourType = (
0107 red, // CHECK: this line can be adjusted manually
0108 orange, // this must follow line above
0109 green,
0110 blue,
0111 indigo,
0112 yellow,
0113 violet
0114 // CHECK: the comments should line up as well
0115 // closing paren should align to list when it's left shifted
0116 // to opening paren otherwise
0117 );
0118
0119 blah = char; // should align after type
0120
0121 optionset = set of options;
0122
0123 var
0124 r1: record
0125 i: integer;
0126 r: real; // should line up with first member
0127 a: array[0..7] of char;
0128 end; // CHECK: end is outdented relative to first member
0129
0130 optionset : set of options;
0131
0132 options : ( crsupp,crbefore,blinbefore,
0133 dindonkey,dindent,spbef,
0134 spaft,gobsym,
0135 inbytab, { indent current margin (was indent from symbol pos) }
0136 crafter,
0137 finl { force symbol to follow on same line as previous symbol }
0138 );
0139
0140 optionset = set of options;
0141
0142 aa: array[ 1..9, // should be indented after cr
0143 3..22 ]
0144 of ( crsupp,crbefore,blinbefore,
0145 dindonkey,dindent,spbef,
0146 spaft,gobsym,
0147 inbytab, { indent current margin (was indent from symbol pos) }
0148 crafter,
0149 finl { force symbol to follow on same line as previous symbol }
0150 );
0151
0152 aaa: array[ 1..3,
0153 4..5,
0154 12..11 ]
0155 of record // cr after here should indent from record
0156 a: array[1..6] of char;
0157 i: integer;
0158 end;
0159
0160 { CHECK: following text should keep indent relative to open/close brace
0161 when annotating, behavior of "external", "end" and possibly other keywords
0162 depends on whether we are in procedure declaration,
0163 item (var/const/type) declaration, or statements
0164 }
0165
0166
0167 procedure AVeryVeryLongFunctionName(const A : tRealArrayType;
0168 N : tIntegerType;
0169 var H : tRealArrayType); forward;
0170
0171 (*************************************************************************
0172 CHECK: comment is correctly aligned with precedinging statement
0173
0174 Input parameters:
0175 A - description
0176
0177 N - longer description, but
0178 still preserving relative format
0179
0180 Output parameters:
0181 H - other meaningful description
0182
0183 Result:
0184 True, if successful
0185 False, otherwise
0186 *************************************************************************)
0187
0188 var size : (small, medium, large);
0189 fred : real;
0190
0191 var r : record i: integer; c: char end;
0192
0193 a: array[ 1..9, // should be indented after var
0194 'a'..'z' // non-code, should line up with opening arg
0195 ] of integer;
0196
0197 begin (* AVeryVeryLongFunctionName *)
0198
0199 if a then begin
0200 s1;
0201 16:
0202 f(32); //CHECK: label forced to margin, statement is on new line with comment
0203 end;
0204
0205 for i := 0 to 100 do
0206 begin
0207 with p^ do
0208 begin s1; s2; s3 end
0209 end;
0210
0211 with p^ do
0212 begin s1; s2; s3 end;
0213
0214 for i := firstCh to lastCh do chtype[chr(i)] := none;
0215 value['0'] := 0; value['1'] := 1; value['2'] := 2;
0216 value['3'] := 3; value['4'] := 4; value['5'] := 5;
0217 value['6'] := 6; value['7'] := 7; value['8'] := 8;
0218 value['9'] := 9;
0219 value['A'] := 10; value['B'] := 11; value['C'] := 12;
0220 value['D'] := 13; value['E'] := 14; value['F'] := 15;
0221 value['a'] := 10; value['b'] := 11; value['c'] := 12;
0222 value['d'] := 13; value['e'] := 14; value['f'] := 15;
0223
0224 IF NOT (CH IN ['{','}']) THEN
0225 // comment
0226 BEGIN IF CH <= 'Z' THEN CMDCH := CH ELSE CMDCH := CHR(ORD(CH)-ORD('a')+ORD('A') );
0227 NEXTCH;
0228 IF CMDCH = 'L' THEN
0229 COMMAND(LISTON)
0230 ELSE IF CMDCH = 'T' THEN
0231 COMMAND(TRACEON)
0232 ELSE IF CMDCH = 'I' THEN
0233 COMMAND(INCLUDE)
0234 ELSE IF CMDCH = 'Z' THEN
0235 REPEAT
0236 BEGIN
0237 www.fred.com;
0238 REPEAT commandIn UNTIL numRem = 0;
0239 s1;
0240 s2;
0241 END;
0242 UNTIL False
0243 ELSE IF CMDCH = 'Q' THEN begin
0244 COMMAND(QUIET)
0245 end ELSE IF CMDCH = 'V' THEN
0246 COMMAND(VERBOSE)
0247 else if COMMAND.STRVAL = 'unknown' then
0248 begin
0249 IF
0250 (numStr[0] >= 0) AND
0251 (numStr[1] IN ['+', '-', '0' .. '9', '?']) // CHECK: indent
0252 THEN
0253 Power.Supply := '"AC' ELSE Power.Supply := '"DC'
0254 end else if CommandResult.Str = 'helpIamLost' then begin
0255 Power.Supply := SetPowerSupplyCommands(Plus15V.Increase(Amps));
0256 end else if (line = 'SHORT') OR (line = 'OPEN') THEN BEGIN
0257 OpenCircuit;
0258 {*smoke billows out*}
0259 IF SPARKS THEN
0260 BEGIN
0261 SPARKS := FALSE;
0262 ShutDown
0263 END
0264 END ELSE IF
0265 (line = 'OPEN') OR (line = 'CLOSED') THEN
0266 BEGIN;
0267 AddFuse(Low);
0268 IF SPARKS THEN
0269 BEGIN;
0270 SPARKS := False;
0271 CircuitBreaker(wishfulThinking)
0272 END else if cond then
0273 statement;
0274 END ELSE IF (line = 'PLUS') OR (line = 'MINUS') THEN Transform(RedPhase)
0275 ELSE IF (line = 'RED') OR (line = 'BLACK') THEN Transform(BluePhase)
0276 ELSE IF line = 'XX' THEN Transistor
0277 ELSE IF line = 'YYYY' THEN SetCurrent(FiveAmps)
0278 ELSE IF line = 'QQQQ' THEN SetPower(FiveWatts)
0279 ELSE IF line = 'AAAAA' THEN Power(FiveAmps)
0280 ELSE IF
0281 {* QWERTY COMMENT LLLLLLLLL ####### *}
0282 line = 'SSSSS' THEN
0283 BEGIN
0284 actualphase := YellowPhase;
0285 AdjustLinePhase(NewPhase);
0286 END
0287 ELSE IF
0288 line = 'Noisy' THEN Filter
0289 ELSE IF line = 'BLUE' THEN
0290 BEGIN
0291 AdjustLinePhase(XPhase);
0292 Erase := True
0293 END ELSE IF
0294 line = 'RED' THEN BEGIN Swap; Hope END
0295 ELSE IF
0296 line = '415' THEN iNumPut415
0297 ELSE IF
0298 // a statement like this has no chance of being correctly indented ...
0299 // otoh, it shouldn't turn out catastrophically wrong.
0300 line = 'REFL' THEN FOR i := 1 TO numLines DO
0301 WriteLn('level=', powerLevel[i], ' ', name[i]+'='+power[i])
0302 ELSE IF
0303 line = 'HIGH' THEN reduce
0304 ELSE IF
0305 line = 'LOW' THEN increase
0306 ELSE IF
0307 line = 'END' THEN
0308 BEGIN
0309 WHILE powerlevel[NumPowers] = level DO NumPowers := NumPowers-1;
0310 level := level-1;
0311 END
0312 ELSE IF
0313 line = 'WAIT' THEN
0314 BEGIN
0315 Z := ReActivate;
0316 Z := X*240.0 + i*Y*240;
0317 ROTATE(ABS(Z))
0318 END
0319 ELSE IF line = 'HILD' THEN motor(induction)
0320 ELSE IF (line = 'REV') THEN BEGIN
0321 v := YellowPhase;
0322 IF (NOT(v IN [#14..#240])) THEN
0323 WriteLn(' POWER SUPPLY OUT OF SPEC') ELSE specValue := v;
0324 specValidate
0325 END
0326 ELSE IF (line = 'OK') THEN BEGIN
0327 IncomingSupply := True; specValidate END
0328 ELSE IF (line = 'NOK') THEN BEGIN IncomingSupply := False; specValidate END
0329 else begin
0330 GeneratedPowerLine.IncreasePower(
0331 'Unknown input power "%s"', [SwitchPower.Current]); // CHECK: string should not cause problems
0332 end;
0333 END;
0334
0335
0336 end (* AVeryVeryLongFunctionName *) ; // check that only necessary work is done to align