Warning, /frameworks/ktexteditor/autotests/input/indent/pascal/longtest2/origin is written in an unsupported language. File is not indexed.

0001 // kate: space-indent on; indent-width 4; replace-tabs on; remove-trailing-spaces all;
0002 // kate: syntax pascal; indent-mode pascal;
0003 
0004 // these variables are understood by the pascal indenter ...
0005 // kate: cfgIndentCase false;          // indent elements in a case statement
0006 // kate: cfgIndentBegin 2;            // indent 'begin' this many spaces
0007 // kate: debugMode false;              // show how indent is determined
0008 // kate: cfgAutoInsertStar true;      // auto insert '*' in (* ... *)-comments
0009 // kate: cfgSnapParen true;           // snap '* )' to '*)' in comments
0010 
0011 
0012 unit unit1;
0013 
0014 interface
0015        type t = real;
0016 
0017 implementation
0018 
0019 FUNCTION f(
0020             alf : real;
0021 fred : integer;  // should line up with alf
0022 bill : boolean;
0023 joe: char;
0024 );
0025 VAR s : string;
0026 BEGIN s := do; WriteLn(s) END;
0027 
0028 
0029 procedure getbyte;   // CHECK: cr after this line is **not** indented
0030 
0031 var  // CHECK: cr after this line **is** indented
0032 ch : char;
0033 
0034                                              begin
0035 
0036                                                 // need to consider:
0037                                                 // if c then begin s1; s2 end; // strip these lines
0038                                                 // begin   // normal case
0039                                                 // end     // normal case
0040                                                 // end else if begin // should be OK since /end/ tested last
0041                                                 // need to consider ...
0042                                                 //                  if c1 then begin s1; s2 end
0043                                                 //                  else s3;
0044                                         // <-- align this line
0045 
0046                                         { checking multi line statements }
0047 
0048 
0049                                                 while aaaaaaaaaaaaaaaaaaaaaaa
0050          and bbbbbbbbbbb  do
0051 if c1 then begin
0052 s1;
0053 for i := 1
0054       to 10 do
0055 s3
0056 end;
0057 s4;
0058 s5; // the ';' here links to the ';' after the 'case' below
0059 
0060 if c1 then
0061 case e01 of
0062 111111111:    s1;
0063 23:
0064 writeln(x, 
0065 'fred', 
0066 notCaseValue:4,
0067  x);
0068 
0069 2:
0070 case e05 of
0071 1: s1;   // CHECK: cr here should go to new case value!
0072 88:
0073 s3;
0074 
0075 2:  begin
0076 s2;
0077 s3;
0078 end;
0079 
0080 3:
0081 case e09 of
0082 1: s1;   // CHECK: cr here should go to new case value!
0083 88:
0084 s3;
0085 
0086 2:  
0087 begin
0088 s2;
0089 s3;
0090 end;
0091 
0092 3: s3;
0093 4,5,6..9: s6;
0094 
0095 otherwise
0096 writeln('lots');
0097 writeln(' and lots');
0098 end; {case}
0099 
0100 4,5,6..9: s6;
0101 
0102 otherwise
0103 writeln('lots');
0104 writeln(' and lots');
0105 end; {case}
0106 
0107 4: if e then
0108 begin   // CHECK: should be indented after case value
0109 s1;
0110 s2
0111 end
0112 else if ee
0113 and ee1
0114 then begin
0115 s1;
0116 s2;
0117 end;
0118 
0119 99: a:= 13;
0120 100: if e then s1;
0121 
0122 333333: if c then 
0123 begin // CKECK: should indent one level from case value
0124 s3; // CHECK: should be indented another level
0125 s4
0126 end;
0127 
0128 30:
0129 if c then begin // cr here is OK
0130 s3;
0131 s4
0132 end;
0133 4: writeln('fred',
0134 notCaseValue:4,
0135 x
0136 );
0137 s4;             // incorrect code, indenter should expect a case value here
0138 88:
0139 if c1 then 
0140 begin
0141 s6;
0142 s7
0143 else
0144 s8
0145 end;     // stress test: else/end crossed over !!
0146 end; {case}
0147 s6;
0148 
0149 a := 1;
0150 a := 2;
0151 a := 3;
0152 if c1
0153 and c2 then begin // can be aligned manually
0154 a := 12;             // should be indented one level from if statement
0155 f(x)
0156 end;
0157 if c1
0158 and c2  // can be aligned manually
0159 then 
0160 begin
0161 a := 12;             // should be indented one level from if statement
0162 f(x)
0163 end;
0164 if c then
0165 if c then
0166 if c then
0167 repeat s1 until c
0168 else
0169 a[    i,
0170 j,
0171 zzzzzzzzzz[ a,
0172 b
0173 ],
0174     vvvvv   // CHECK: indent lines with zzzzzzzzz
0175 ] := x
0176 + 10;
0177 if a then
0178 if b then
0179 if c then begin
0180 s1;
0181 s2;
0182 end; {if}
0183 while z do s1;
0184 
0185 
0186 while not (  ((currchar.value = '*') and (nextchar.value = ')'))
0187 or (currchar.value = '}') // args should line up inside parens
0188 or (nextchar.name = endofline)
0189 or ( sym^.length >= maxsymbolsize-2 )
0190 or (nextchar.name = filemark)) do
0191 storenextchar(sym^.length,sym^.value);  // should be indented from while
0192 
0193 while not (currchar.value = '*') and (nextchar.value = ')')
0194       or (currchar.value = '}')           // possible to realign first line manually
0195 or (nextchar.name = endofline)      // CHECK: other lines should follow first line  // CHECK:: indents line up
0196           or ( sym^.length >= maxsymbolsize-2 )
0197   or (nextchar.name = filemark) do
0198  storenextchar(sym^.length,sym^.value);  // should be indented from while
0199 
0200 while not (currchar.value = '*') and (nextchar.value = ')')
0201       or (currchar.value = '}')           // possible to realign first line manually
0202 or (nextchar.name = endofline)      // CHECK: other lines should follow first line  // CHECK:: indents line up
0203           or ( sym^.length >= maxsymbolsize-2 )
0204   or (nextchar.name = filemark) 
0205 do
0206  storenextchar(sym^.length,sym^.value);  // should be indented from while
0207 
0208 dblchar[becomes] := ':=';
0209 dblchar[opencomment] := '(*';  // not start of comment!
0210 sglchar[semicolon] := ';';
0211 sglchar[colon]     := ':';
0212 sglchar[equals]    := '=';
0213 sglchar[openparen] := '(';
0214 sglchar[closeparen] := ')';
0215 sglchar[period]    := '.';
0216 sglchar[opencomment] := '{';
0217 sglchar[closecomment] := '}';
0218 
0219 with nextchar do
0220 if eof(infile) then 
0221 begin
0222 name := filemark;
0223 if ch in ['0'..'9'] then
0224 name := digit
0225 else if ch = '''' then begin
0226 name := quote
0227 end else if (ch = blank) or (ch = chr(tab)) then
0228 name := space
0229 else name := otherchar
0230 value := blank
0231 end
0232 else if eoln(infile) then 
0233 begin
0234 name := endofline;
0235 value := blank;
0236 if c1 then begin s1; s2 end
0237 else s7;
0238 inlines := inlines + 1;
0239 readln(infile)
0240 end
0241 else
0242 begin
0243 read(infile,ch);
0244 value := ch;
0245 if ch in ['a'..'z','A'..'Z','_'] then
0246 name := letter
0247 else
0248 if ch in ['0'..'9'] then
0249 name := digit
0250 else if ch = '''' then while c do
0251  begin
0252 s1;
0253 name := quote
0254 end;
0255 else if (ch = blank) or (ch = chr(tab)) then
0256 name := space
0257 else name := otherchar
0258       end;
0259 
0260       { CHECK:
0261                 # pp lines go to start of line, unless they are in a comment
0262       }
0263 
0264                 #if
0265                 #endif
0266                 cccccc; // CHECK: this aligns with code
0267                 # // CHECK: preprocessor lines go to start of line
0268 
0269 if c1 then
0270 if c2 then while c do
0271 s
0272 else
0273 s2;
0274 s3;
0275 s4;
0276 
0277 end; { getbyte }