Warning, /frameworks/ktexteditor/autotests/input/indent/pascal/longtest1/origin 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:   f(32);  //CHECK: label forced to margin, statement is on new line with comment
0202 end;
0203 
0204 for i := 0 to 100 do
0205 begin
0206 with p^ do
0207 begin s1; s2; s3 end
0208 end;
0209 
0210 with p^ do
0211 begin s1; s2; s3 end;
0212 
0213                         for i := firstCh to lastCh do chtype[chr(i)] := none;
0214                         value['0'] := 0; value['1'] := 1; value['2'] := 2;
0215                         value['3'] := 3; value['4'] := 4; value['5'] := 5;
0216                         value['6'] := 6; value['7'] := 7; value['8'] := 8;
0217                         value['9'] := 9;
0218                         value['A'] := 10; value['B'] := 11; value['C'] := 12;
0219                         value['D'] := 13; value['E'] := 14; value['F'] := 15;
0220                         value['a'] := 10; value['b'] := 11; value['c'] := 12;
0221                         value['d'] := 13; value['e'] := 14; value['f'] := 15;
0222  
0223 IF NOT (CH IN ['{','}']) THEN
0224 // comment
0225 BEGIN  IF CH <= 'Z' THEN CMDCH := CH ELSE CMDCH := CHR(ORD(CH)-ORD('a')+ORD('A') );
0226 NEXTCH;
0227 IF CMDCH = 'L' THEN
0228 COMMAND(LISTON)
0229 ELSE IF CMDCH = 'T' THEN
0230 COMMAND(TRACEON)
0231 ELSE IF CMDCH = 'I' THEN
0232 COMMAND(INCLUDE)
0233 ELSE IF CMDCH = 'Z' THEN
0234 REPEAT
0235 BEGIN
0236 www.fred.com;
0237 REPEAT commandIn UNTIL numRem = 0;
0238 s1;
0239 s2;
0240 END;
0241 UNTIL False
0242 ELSE IF CMDCH = 'Q' THEN begin
0243 COMMAND(QUIET)
0244 end ELSE IF CMDCH = 'V' THEN
0245 COMMAND(VERBOSE)
0246 else if COMMAND.STRVAL = 'unknown' then
0247 begin
0248 IF
0249 (numStr[0] >= 0) AND
0250 (numStr[1] IN ['+', '-', '0' .. '9', '?']) // CHECK: indent
0251 THEN
0252 Power.Supply := '"AC' ELSE Power.Supply := '"DC'
0253 end else  if CommandResult.Str = 'helpIamLost' then begin
0254 Power.Supply := SetPowerSupplyCommands(Plus15V.Increase(Amps));
0255 end else if (line = 'SHORT') OR (line = 'OPEN') THEN  BEGIN
0256 OpenCircuit;
0257 {*smoke billows out*}
0258 IF SPARKS THEN
0259 BEGIN
0260 SPARKS := FALSE;
0261 ShutDown
0262 END
0263 END ELSE IF
0264 (line = 'OPEN') OR (line = 'CLOSED') THEN
0265 BEGIN;
0266 AddFuse(Low);
0267 IF SPARKS THEN
0268 BEGIN;
0269 SPARKS := False;
0270 CircuitBreaker(wishfulThinking)
0271 END else if cond then
0272 statement;
0273 END ELSE IF (line = 'PLUS') OR (line = 'MINUS') THEN Transform(RedPhase)
0274 ELSE IF (line = 'RED') OR (line = 'BLACK') THEN Transform(BluePhase)
0275 ELSE IF line = 'XX' THEN Transistor
0276 ELSE IF line = 'YYYY' THEN SetCurrent(FiveAmps)
0277 ELSE IF line = 'QQQQ' THEN SetPower(FiveWatts)
0278 ELSE IF line = 'AAAAA' THEN Power(FiveAmps)
0279 ELSE IF
0280    {* QWERTY COMMENT LLLLLLLLL ####### *}
0281    line = 'SSSSS' THEN
0282 BEGIN
0283 actualphase := YellowPhase;
0284 AdjustLinePhase(NewPhase);
0285 END
0286 ELSE IF
0287 line = 'Noisy' THEN Filter
0288 ELSE IF line = 'BLUE' THEN
0289 BEGIN
0290 AdjustLinePhase(XPhase);
0291 Erase := True
0292 END ELSE IF
0293 line = 'RED' THEN BEGIN Swap; Hope END
0294 ELSE IF
0295    line = '415' THEN iNumPut415
0296 ELSE IF
0297    // a statement like this has no chance of being correctly indented ...
0298    // otoh, it shouldn't turn out catastrophically wrong.
0299    line = 'REFL' THEN FOR i := 1 TO numLines DO
0300 WriteLn('level=', powerLevel[i], ' ', name[i]+'='+power[i])
0301 ELSE IF
0302    line = 'HIGH' THEN reduce
0303 ELSE IF
0304    line = 'LOW' THEN increase
0305 ELSE IF
0306    line = 'END' THEN
0307 BEGIN
0308 WHILE powerlevel[NumPowers] = level DO NumPowers := NumPowers-1;
0309 level := level-1;
0310 END
0311 ELSE IF
0312    line = 'WAIT' THEN
0313 BEGIN
0314 Z := ReActivate;
0315 Z := X*240.0 + i*Y*240;
0316 ROTATE(ABS(Z))
0317 END
0318 ELSE IF line = 'HILD' THEN motor(induction)
0319 ELSE IF (line = 'REV') THEN        BEGIN
0320 v := YellowPhase;
0321 IF (NOT(v IN [#14..#240])) THEN
0322 WriteLn(' POWER SUPPLY OUT OF SPEC') ELSE specValue := v;
0323 specValidate
0324 END
0325 ELSE IF (line = 'OK') THEN BEGIN
0326 IncomingSupply := True; specValidate END
0327 ELSE IF (line = 'NOK') THEN BEGIN IncomingSupply := False; specValidate END
0328 else    begin
0329 GeneratedPowerLine.IncreasePower(
0330               'Unknown input power "%s"', [SwitchPower.Current]);    // CHECK: string should not cause problems
0331 end;
0332 END;
0333 
0334 
0335 end (* AVeryVeryLongFunctionName *) ;  // check that only necessary work is done to align