1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289
|
{ Parse implementation section.
Must be tested with --implementation-comments=join --define PASDOC }
unit ok_parse_impl;
interface
uses IntfUnit;
{$ifdef PASDOC}
{$define FPC}
{$define DCC}
{$endif}
// This is Foo (intf)
procedure Foo;
procedure Bar;
// This is Laz
procedure Laz;
procedure Dex;
procedure NoDescr;
// @exclude
procedure Ignored;
procedure Overloaded; overload;
// @exclude
procedure Overloaded(b: Char); overload;
procedure Overloaded(a: Byte); overload;
type
TClass = class
type
TInnerClass = class
procedure Method;
private
procedure Hidden;
end;
public
constructor Create; overload;
class function Create(const S: string): TClass; overload; static; inline;
destructor Destroy;
procedure Method;
class operator Implicit(const S: string): TClass;
end;
TMyType = record end;
{$ifdef FPC}
Operator := (C : TMyType) z : TMyType;
{$endif}
// bugfix: this comment must not descend to "NoDescr"
implementation
{$ifdef PASDOC}
procedure NoDescr; // place it before "uses" because ParseUses clears comment too
begin end;
{$endif}
uses ImplUnit;
// type/var/const sections inside implementation section - they all must be ignored
{ }
type
TInnerRec = record
// must be ignored
end;
TInnerClass = class
// must be ignored
type
TInnerSubClass = class
// must be ignored
end;
end;
{$ifdef DCC}
TProc = reference to procedure ; //< lambda type with intentional whitespace after keyword
TProc2 = reference to procedure (par: byte); //< lambda type with parameter
{$endif}
var
bla: byte;
Rec: record
// must be ignored
end;
proc: procedure; //< proc keyword in var section
function ExternalFn: BOOL; stdcall; external kernel32; //< bugfix: external functions break parsing
// Fully asm inner proc
procedure AsmProc;
asm
MOV AX,BX;
end;
// This is Foo (impl)
procedure Foo;
// must be ignored
// lots of stuff inside proc...
{ }
type
TRec = record
// must be ignored
end;
TClass2 = class
// must be ignored
end;
{$ifdef DCC}
TProc = reference to procedure;
TProc1 = reference to procedure ;
TProc2 = reference to procedure (par: byte);
{$endif}
// Nested FooBar with some directives - must be ignored
procedure FooBar; inline; deprecated 'foobar';
// some stuff in nested proc
var a: byte;
type foo = byte;
begin
writeln(0);
// check nested begin - end
begin
end;
end;
var
bla: byte;
Rec: record
// must be ignored
end;
lambda: TProc;
lambda2: TProc2;
proc: procedure;
begin
Func :=
procedure(var Res: NativeInt)
begin
Res := form.ShowModal;
end;
// must be ignored
writeln(0);
// many nested blocks...
begin
// must be ignored
end;
asm
// must be ignored
end;
case bla of
1:;// must be ignored
end;
try try
// must be ignored
except end;
finally end;
{$ifdef DCC}
lambda := procedure
begin
// must be ignored
end;
lambda2 := procedure(par: byte)
begin
// must be ignored
end;
lambda2 := procedure (par: byte)
begin
// must be ignored
end;
RunLambda( procedure begin writeln(0); end );
RunLambdas( [ procedure begin writeln(0); end, procedure begin writeln(0); end ] );
{$endif}
end;
// This is Bar (impl)
procedure Bar;
begin
end;
{
This is Laz
And it must not be doubled
}
procedure Laz;
begin
end;
procedure Dex;
{< This is Dex described inside method body }
begin
end;
// This is internal routine and must be hidden
procedure Hidden;
begin
end;
// This routine is ignored in intf section
procedure Ignored;
begin
end;
// This is overloaded proc #1
procedure Overloaded;
begin
end;
// This is overloaded proc #3 that must be ignored
procedure Overloaded(b: Char);
begin
end;
// This is overloaded proc #2
procedure Overloaded(a: Byte);
begin
end;
{ TClass }
// Creates instance of TClass
constructor TClass . Create; // whitespace is intentional
begin
end;
// Static factory
class function TClass.Create(const S: string): TClass;
begin
end;
// Destroys instance of TClass
destructor TClass.Destroy;
// some stuff inside
var
bla: byte;
type
TRec = record
// must be ignored
end;
begin
end;
// Does something
procedure TClass.Method;
begin
end;
// Assignment operator
class operator TClass.Implicit(const S: string): TClass;
begin
end;
{ TClass.TInnerClass }
// Method of an inner class
procedure TClass.TInnerClass.Method;
begin
end;
// Hidden method of an inner class
procedure TClass.TInnerClass.Hidden;
begin
end;
{$ifdef FPC}
// This is assignment operator
Operator := (C : TMyType2) z : TMyType;
begin
end;
{$endif}
procedure ForwardFn; forward; //< bugfix: forward functions break parsing
procedure ForwardFn;
begin
end;
end . // whitespace is intentional
// Text after END must be ignored
procedure Boo;
|