testunit1.pp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964
  1. //This is only for testing the parser, it is not intended to be runable in a real
  2. //program but for checking the contructs to be parsed well.
  3. //All statements are written like testparser would print them out to diff the
  4. //result with this file again to show differences.
  5. //Based on /utils/fpdoc/testunit.pp
  6. {$mode objfpc}
  7. {$h+}
  8. unit testunit1;
  9. interface
  10. uses
  11. SysUtils,Classes;
  12. resourcestring
  13. SParserErrorAtToken = 'parser error at token';
  14. const
  15. AnIntegerConst=1;
  16. AStringConst='Hello, World!';
  17. AFLoatconst=1.23;
  18. ABooleanConst=True;
  19. ATypedConst: Integer=3;
  20. AnArrayConst: Array[1..3] of Integer=(1,2,3);
  21. ARecordConst: TMethod=(Code:nil;Data:nil);
  22. ASetConst=[true,false];
  23. ADeprecatedConst=1 deprecated;
  24. Type
  25. TLineEndStr = string [3];
  26. TDeprecatedType = Integer deprecated;
  27. TDeprecatedRecord = Record
  28. x,Y : Integer;
  29. end deprecated;
  30. TDeprecatedFieldsRecord = Record
  31. x,Y : Integer deprecated;
  32. end;
  33. TDeprecatedFieldsRecord2 = Record
  34. x,Y : Integer deprecated
  35. end;
  36. TAnEnumType=(one,two,three);
  37. TASetType=set of TAnEnumType;
  38. TIntegerSet = Set of 0..SizeOf(Integer)*8-1;
  39. TAnArrayType=Array[1..10] of Integer;
  40. TASubRangeType=one..two;
  41. TABooleanArrayType=Array[Boolean] of Integer;
  42. TDay = (monday,tuesday,wednesday,thursday,friday,saturday,sunday);
  43. TShortDay = (mon,tue,wed,thu,fri,sat,sun);
  44. TShortDays = set of TShortDay;
  45. TDays = set of TDay;
  46. TMyInteger = Integer;
  47. ADouble = type double;
  48. arangetypealias = type 0..$FF;
  49. TARecordType=record
  50. X,Y: Integer;
  51. Z: String;
  52. end;
  53. TAVariantRecordType=record
  54. A: String;
  55. Case Integer of
  56. 1: (X,Y : Integer);
  57. 2: (phi,Omega : Real);
  58. end;
  59. TAVariantRecordType2=record
  60. A: String;
  61. Case Atype : Integer of
  62. 1 : (X,Y : Integer);
  63. 2 : (phi,Omega : Real);
  64. end;
  65. MyRec = Record
  66. X : Longint;
  67. Case byte of
  68. 2 : (Y : Longint;
  69. case byte of
  70. 3 : (Z : Longint);
  71. );
  72. end;
  73. TYPE
  74. PPoint = ^TPoint;
  75. TPoint = OBJECT
  76. X, Y: Sw_Integer;
  77. END;
  78. PRect = ^TRect;
  79. TRect = OBJECT
  80. A, B: TPoint; { Corner points }
  81. FUNCTION Empty: Boolean;
  82. FUNCTION Equals (R: TRect): Boolean;
  83. FUNCTION Contains (P: TPoint): Boolean;
  84. PROCEDURE Copy (R: TRect);
  85. PROCEDURE Union (R: TRect);
  86. PROCEDURE Intersect (R: TRect);
  87. PROCEDURE Move (ADX, ADY: Sw_Integer);
  88. PROCEDURE Grow (ADX, ADY: Sw_Integer);
  89. PROCEDURE Assign (XA, YA, XB, YB: Sw_Integer);
  90. END;
  91. TNotifyEvent = Procedure (Sender : TObject) of object;
  92. TNotifyEvent2 = Function (Sender : TObject) : Integer of object;
  93. // TADeprecatedType = Integer deprecated;
  94. TMyChildClass = Class;
  95. MyInterface = Interface;
  96. { TMyParentClass }
  97. TMyParentClass=Class(TComponent)
  98. Private
  99. FI: Integer;
  100. Function GetA(AIndex: Integer): String;
  101. Function GetIP(AIndex: integer): String;
  102. procedure SetA(AIndex: Integer; const AValue: String);
  103. procedure SetIP(AIndex: integer; const AValue: String);
  104. Procedure WriteI(AI: Integer);
  105. Function ReadI: Integer;
  106. Protected
  107. Procedure AProtectedMethod;
  108. Property AProtectedProp: Integer Read FI Write FI;
  109. Public
  110. Constructor Create(AOwner: TComponent); override;
  111. Destructor Destroy; override;
  112. Procedure AVirtualProc; virtual;
  113. Procedure AnAbstractProc; virtual; abstract;
  114. Procedure AMessageProc(var Msg);message 123;
  115. Procedure AStringMessageProc(var Msg);message '123';
  116. Procedure ADeprecatedProc; deprecated;
  117. Procedure APlatformProc; Platform;
  118. Property IntProp: Integer Read FI Write Fi;
  119. Property IntROProp: Integer Read FI;
  120. Property GetIntProp: Integer Read ReadI Write WriteI;
  121. Property AnArrayProp[AIndex: Integer]: String Read GetA Write SetA;
  122. Property AnIndexProp: String Index 1 Read GetIP Write SetIP;
  123. Property AnIndexProp2: String Index 2 Read GetIP Write SetIP;
  124. Published
  125. Procedure SomePublishedMethod;
  126. end;
  127. { TMyChildClass }
  128. TMyChildClass=Class(TMyParentClass)
  129. Public
  130. Procedure AVirtualProc; Override;
  131. Procedure AnAbstractProc; Override;
  132. Published
  133. Property AProtectedProp;
  134. end;
  135. TC = TMyChildClass;
  136. TPasFunctionType=Class(TObject)
  137. public
  138. destructor Destroy; override;
  139. Class Function TypeName: string;
  140. Function ElementTypeName: string;
  141. Function GetDeclaration(Full: boolean): string;
  142. Procedure Something; strict
  143. Private
  144. Procedure SomethingElse;
  145. public
  146. ResultEl: TObject;
  147. end;
  148. TPropModifiers = Class(TObject)
  149. Private
  150. FB : Integer;
  151. Function IsStored : Boolean;
  152. Function GetI(AI : Integer) : Integer;
  153. Procedure SetI(AI : Integer; AVal : Integer);
  154. Published
  155. Property A : Integer Read FB Write FB Stored False;
  156. Property B : Integer Read FB Write FB Stored True;
  157. Property C : Integer Read FB Write FB Stored IsStored;
  158. Property D : Integer Read FB Write FB Default 1;
  159. Property E : Integer Read FB Write FB Stored True Default 1;
  160. Public
  161. Property Ints[AI : Integer] : Integer Read GetI Write SetI; default;
  162. end;
  163. TPropModifiers2 = class(TPropModifiers)
  164. Public
  165. Property Ints[AI : Integer] : Integer Read GetI Write SetI; default; deprecated;
  166. end;
  167. TEdit = Class(TObject)
  168. Text : String;
  169. end;
  170. var
  171. ASimpleVar: Integer;
  172. ATypedVar: TMethod;
  173. ARecordVar: Record
  174. A,B: Integer;
  175. end;
  176. AnArrayVar: Array[1..10] of Integer;
  177. ATypedArray: Array[TanEnumType] of Integer;
  178. AInitVar: Integer=1;
  179. ADeprecatedVar: Integer deprecated;
  180. ACVarVar: Integer ; cvar;
  181. AnExternalVar1: Integer; external;
  182. AnExternalVar2: Integer; external name 'avar';
  183. AnExternalLibVar: Integer; external 'library' name 'avar';
  184. APublicVar : String; public;
  185. APublicVar2 : String; public name 'ANAME';
  186. APublicVar3 : String; export;
  187. APublicVar4 : String; export name 'nono';
  188. APublicVar5 : String; cvar; external;
  189. APublicVar6 : String; external name 'me';
  190. APublicVar7 : String deprecated; external name 'me';
  191. Procedure SimpleProc;
  192. Procedure OverloadedProc(A: Integer);
  193. Procedure OverloadedProc(B: String);
  194. Function SimpleFunc: Integer;
  195. Function OverloadedFunc(A: Integer): Integer;
  196. Function OverloadedFunc(B: String): Integer;
  197. Procedure ConstArgProc(const A: Integer);
  198. Procedure VarArgProc(var A: Integer);
  199. Procedure OutArgProc(out A: Integer);
  200. Procedure UntypedVarArgProc(var A);
  201. Procedure UntypedConstArgProc(const A);
  202. Procedure UntypedOutArgProc(out A);
  203. Procedure ArrayArgProc(A: TAnArrayType);
  204. Procedure OpenArrayArgProc(A: Array of string);
  205. Procedure ConstArrayArgProc(A: Array of const);
  206. Procedure externalproc; external;
  207. Procedure externalnameProc; external name 'aname';
  208. Procedure externallibnameProc; external 'alibrary' name 'aname';
  209. Function hi(q : QWord) : DWord; [INTERNPROC: fpc_in_hi_qword];
  210. Type
  211. generic TFPGListEnumerator<T> = class(TObject)
  212. protected
  213. FList: TFPList;
  214. FPosition: Integer;
  215. function GetCurrent: T;
  216. end;
  217. TFPGListEnumeratorSpec = specialize TFPGListEnumerator<TPasFunctionType>;
  218. Implementation
  219. Procedure SimpleProc;
  220. procedure SubProc;
  221. Var S : String;
  222. begin
  223. s:= s+'a';
  224. end;
  225. Var
  226. a,B,c,i : integer;
  227. begin
  228. a:= 1;
  229. c:= a+b;
  230. for i:= 1 to 10 do
  231. write(a);
  232. end;
  233. Procedure OverloadedProc(A: Integer);
  234. Var
  235. i : integer;
  236. begin
  237. if i=1 then ;
  238. end;
  239. Procedure OverloadedProc(B: String);
  240. begin
  241. end;
  242. Function SimpleFunc: Integer;
  243. begin
  244. end;
  245. Function OverloadedFunc(A: Integer): Integer;
  246. begin
  247. end;
  248. Function OverloadedFunc(B: String): Integer;
  249. begin
  250. end;
  251. Procedure ArrayArgProc(A: TAnArrayType);
  252. begin
  253. end;
  254. Procedure OpenArrayArgProc(A: Array of String);
  255. begin
  256. end;
  257. Procedure ConstArrayArgProc(A: Array of const);
  258. begin
  259. end;
  260. Procedure ConstArgProc(const A: Integer);
  261. begin
  262. end;
  263. Procedure VarArgProc(var A: Integer);
  264. begin
  265. end;
  266. Procedure OutArgProc(out A: Integer);
  267. begin
  268. end;
  269. Procedure UntypedVarArgProc(var A);
  270. begin
  271. end;
  272. Procedure UntypedConstArgProc(const A);
  273. begin
  274. end;
  275. Procedure UntypedOutArgProc(out A);
  276. begin
  277. end;
  278. { TMyChildClass }
  279. procedure TMyChildClass.AVirtualProc;
  280. begin
  281. inherited AVirtualProc;
  282. end;
  283. procedure TMyChildClass.AnAbstractProc;
  284. procedure SubCProc;
  285. Var sc : string;
  286. begin
  287. sc:= sc+'ac';
  288. end;
  289. begin
  290. // Cannot call ancestor
  291. end;
  292. { TMyParentClass }
  293. procedure TMyParentClass.WriteI(AI: Integer);
  294. begin
  295. end;
  296. Function TMyParentClass.GetA(AIndex: Integer): String;
  297. begin
  298. end;
  299. Function TMyParentClass.GetIP(AIndex: integer): String;
  300. begin
  301. end;
  302. procedure TMyParentClass.SetA(AIndex: Integer; const AValue: String);
  303. begin
  304. end;
  305. procedure TMyParentClass.SetIP(AIndex: integer; const AValue: String);
  306. begin
  307. end;
  308. Function TMyParentClass.ReadI: Integer;
  309. begin
  310. end;
  311. procedure TMyParentClass.AProtectedMethod;
  312. begin
  313. end;
  314. constructor TMyParentClass.Create(AOwner: TComponent);
  315. begin
  316. inherited Create(AOwner);
  317. end;
  318. destructor TMyParentClass.Destroy;
  319. begin
  320. inherited Destroy;
  321. end;
  322. procedure TMyParentClass.AVirtualProc;
  323. begin
  324. end;
  325. procedure TMyParentClass.AMessageProc(var Msg);
  326. begin
  327. end;
  328. procedure TMyParentClass.AStringMessageProc(var Msg);
  329. begin
  330. end;
  331. procedure TMyParentClass.ADeprecatedProc;
  332. begin
  333. end;
  334. procedure TMyParentClass.APlatformProc;
  335. begin
  336. end;
  337. procedure TMyParentClass.SomePublishedMethod;
  338. begin
  339. end;
  340. Class Function TPasFunctionType.TypeName: String;
  341. begin
  342. Result:= 'Function';
  343. end;
  344. Type
  345. TI = Class(TComponent)
  346. Public
  347. FP : Integer;
  348. Procedure SetP1(A : Integer); virtual;
  349. Procedure M1;virtual;
  350. Function F1 : Integer; virtual;
  351. procedure test; virtual;
  352. property P : Integer Read FP Write SetP1;
  353. end;
  354. Procedure TI.M1;
  355. begin
  356. end;
  357. Procedure TI.Test;
  358. begin
  359. end;
  360. Function TI.F1 : Integer;
  361. begin
  362. Result:=0;
  363. end;
  364. Procedure TI.SetP1(A : Integer);
  365. begin
  366. FP:=A;
  367. end;
  368. TYpe
  369. TI2 = Class(TI)
  370. procedure write(s : string);
  371. Procedure SetP1(A : Integer); override;
  372. Procedure M1;override;
  373. Procedure Test;override;
  374. Function F1 : integer; override;
  375. procedure donothing;
  376. property P : Integer Read F1 Write SetP1;
  377. end;
  378. Procedure TI2.M1;
  379. begin
  380. Inherited;
  381. end;
  382. Procedure TI2.Write(s : string);
  383. begin
  384. writeln(s);
  385. end;
  386. Function TI2.F1 :Integer;
  387. begin
  388. Result:=0;
  389. end;
  390. Procedure TI2.Test;
  391. begin
  392. if true then
  393. Inherited Test
  394. else
  395. DoNothing;
  396. Inherited test;
  397. if true then
  398. Inherited
  399. else
  400. DoNothing;
  401. end;
  402. Procedure TI2.DoNothing;
  403. function escapetext(s : string) : string;
  404. begin
  405. end;
  406. var
  407. Atext : string;
  408. begin
  409. Self.Write(EscapeText(AText));
  410. TComponent.Create(Self);
  411. end;
  412. Procedure TI2.SetP1(A : Integer);
  413. begin
  414. FP:=A;
  415. Inherited P:= 3;
  416. Inherited SetP1(3);
  417. Inherited P:= Ord(A);
  418. end;
  419. procedure usage;
  420. begin
  421. end;
  422. Procedure DoSomething;
  423. begin
  424. end;
  425. Procedure DoSomethingElse;
  426. begin
  427. end;
  428. procedure stat1;
  429. begin
  430. end;
  431. procedure stat2;
  432. begin
  433. end;
  434. procedure stat3;
  435. begin
  436. end;
  437. procedure stat4;
  438. begin
  439. end;
  440. procedure stat5;
  441. begin
  442. end;
  443. procedure stat6;
  444. begin
  445. end;
  446. procedure stat7;
  447. begin
  448. end;
  449. procedure stat8;
  450. begin
  451. end;
  452. procedure stat9;
  453. begin
  454. end;
  455. procedure doit;
  456. begin
  457. end;
  458. procedure statement;
  459. begin
  460. end;
  461. procedure work;
  462. begin
  463. end;
  464. procedure kissdwarf(i : integer);
  465. begin
  466. writeln('kiss dwarf',i);
  467. end;
  468. procedure Statements;
  469. const
  470. cint=1;
  471. cint1=-1;
  472. creal=3.1415;
  473. Addi=1+2;
  474. Subs=2-3;
  475. Muti=3*3;
  476. Divi=3/5;
  477. //Powe=2^3;
  478. Modu=5 mod 3;
  479. IDiv=5 div 3;
  480. fals= not TRUE;
  481. cand=true and false;
  482. cor=true or false;
  483. cxor=true xor false;
  484. lt=2<3;
  485. gt=3>2;
  486. let=2<=3;
  487. get=3>=2;
  488. LeftShift=2 shl 3;
  489. RightShift=2 shr 3;
  490. ConstString='01'+'ab';
  491. Type
  492. Passenger=Record
  493. Name: String[30];
  494. Flight: String[10];
  495. end;
  496. Type
  497. AR=record
  498. X,Y: LongInt;
  499. end;
  500. TScanner = record
  501. currow,curcolumn : integer;
  502. curfilename : string;
  503. end;
  504. //PAR = Record;
  505. var
  506. msg,curtokenname : string;
  507. TheCustomer: Passenger;
  508. L: ^LongInt;
  509. P: PPChar;
  510. S,T: Ar;
  511. M, X,Y : Double;
  512. Done : Boolean;
  513. Weather,Good: Boolean;
  514. c : char;
  515. j,dwarfs,i,Number,Block : integer;
  516. exp1,exp2,exp3,exp4,exp5,exp6,exp7,exp8,exp9 : boolean;
  517. o : Tobject;
  518. day,today : tday;
  519. A,B,D : Passenger;
  520. E : Exception;
  521. scanner : tscanner;
  522. begin
  523. O:=Nil;
  524. X:= X+Y;
  525. //EparserError on C++ style
  526. //X+=Y; { Same as X := X+Y, needs -Sc command line switch}
  527. //x-=y;
  528. //X/=2; { Same as X := X/2, needs -Sc command line switch}
  529. //x*=y;
  530. Done:= False;
  531. Weather:= Good;
  532. //MyPi := 4* Tan(1); warum * ?
  533. L^:= 3;
  534. P^^:= 'A';
  535. Usage;
  536. WriteLn('Pascal is an easy language !');
  537. Doit();
  538. //label jumpto;
  539. //Jumpto :
  540. // Statement;
  541. //Goto jumpto;
  542. Case i of
  543. 6: DoSomething;
  544. 1..5: DoSomethingElse;
  545. end;
  546. Case C of
  547. 'a': WriteLn('A pressed');
  548. 'b': WriteLn('B pressed');
  549. 'c': WriteLn('C pressed');
  550. else
  551. WriteLn('unknown letter pressed : ',C);
  552. end;
  553. Case C of
  554. 'a','e','i','o','u': WriteLn('vowel pressed');
  555. 'y': WriteLn('This one depends on the language');
  556. else
  557. WriteLn('Consonant pressed');
  558. end;
  559. Case Number of
  560. 1..10: WriteLn('Small number');
  561. 11..100: WriteLn('Normal, medium number');
  562. else
  563. WriteLn('HUGE number');
  564. end;
  565. case block of
  566. 1: begin
  567. writeln('1');
  568. end;
  569. 2: writeln('2');
  570. else
  571. writeln('3');
  572. writeln('4');
  573. end;
  574. If exp1 Then
  575. If exp2 then
  576. Stat1
  577. else
  578. stat2;
  579. If exp3 Then
  580. begin
  581. If exp4 then
  582. Stat5
  583. else
  584. stat6
  585. end;
  586. If exp7 Then
  587. begin
  588. If exp8 then
  589. Stat9
  590. end
  591. else
  592. stat2;
  593. if o is TObject then
  594. begin
  595. write('object');
  596. end
  597. else
  598. if o is TMyParentClass then
  599. begin
  600. write('real');
  601. end
  602. else
  603. write('0');
  604. if Today in [Monday..Friday] then
  605. WriteLn('Must work harder')
  606. else
  607. WriteLn('Take a day off.');
  608. for Day:= Monday to Friday do
  609. Work;
  610. for I:= 100 downto 1 do
  611. WriteLn('Counting down : ',i);
  612. for I:= 1 to 7*dwarfs do
  613. KissDwarf(i);
  614. for i:= 0 to 10 do
  615. begin
  616. j:= 2+1;
  617. write(i,j);
  618. end;
  619. repeat
  620. WriteLn('I =',i);
  621. I:= I+2;
  622. until I>100;
  623. repeat
  624. X:= X/2;
  625. until x<10e-3;
  626. I:= I+2;
  627. while i<=100 do
  628. begin
  629. WriteLn('I =',i);
  630. I:= I+2;
  631. end;
  632. X:= X/2;
  633. while i>=10e-3 do
  634. dec(i);
  635. while i>0 do
  636. while j>0 do
  637. begin
  638. dec(i);
  639. dec(j);
  640. end;
  641. while i>0 do
  642. if i>2 then
  643. dec(i)
  644. else
  645. dec(i,2);
  646. X:= 2+3;
  647. TheCustomer.Name:= 'Michael';
  648. TheCustomer.Flight:= 'PS901';
  649. With TheCustomer do
  650. begin
  651. Name:= 'Michael';
  652. Flight:= 'PS901';
  653. end;
  654. With A,B,D do
  655. Statement;
  656. With A do
  657. With B do
  658. With D do
  659. Statement;
  660. S.X:= 1;S.Y:= 1;
  661. T.X:= 2;T.Y:= 2;
  662. With S,T do
  663. WriteLn(X,' ',Y);
  664. {asm
  665. Movl $1,%ebx
  666. Movl $0,%eax
  667. addl %eax,%ebx
  668. end; ['EAX','EBX'];}
  669. try
  670. try
  671. M:= Y;
  672. except
  673. on excep: EParserError do
  674. begin
  675. writeln(excep.message,' : ',excep.classname);
  676. raise ;
  677. end;
  678. end;
  679. FreeAndNil(M);
  680. finally
  681. FreeAndNil(E)
  682. end;
  683. raise EParserError.Create(Format(SParserErrorAtToken, [Msg, CurTokenName]) {$ifdef addlocation}+' ('+inttostr(scanner.currow)+' '+inttostr(scanner.curcolumn)+')'{$endif});
  684. // try else
  685. end;
  686. function addone : integer;
  687. begin
  688. end;
  689. procedure myproc;
  690. begin
  691. end;
  692. procedure Expression;
  693. Var
  694. A,b,c,d,e,f,i,j : Integer;
  695. x : double;
  696. u : Boolean;
  697. fu : function : integer;
  698. ad : boolean;
  699. z : tdays;
  700. today,tomorrow : tday;
  701. bs : set of byte;
  702. cs : set of char;
  703. cc : char;
  704. W : TShortDays;
  705. buffer : array[1..10] of byte;
  706. P : Pointer;
  707. SErrMultipleSourceFiles,FileName,Dirname,S : string;
  708. o,co : tobject;
  709. begin
  710. x:= a+b *c /(-e+f)*(3 div 2) + 4 mod 5 - 2 shl 3 + 3 shr 1 ;
  711. b:= (a and not b) or c xor d;
  712. u:= (i<=2) or (a<>b) or (j>=3);
  713. u:= (i=1) or (a>b) or (b<a) or (i<>2);
  714. u:= i in [1..2];
  715. If Fu=@AddOne Then
  716. WriteLn('Functions are equal');
  717. If Fu()=Addone then
  718. WriteLn('Functions return same values ');
  719. z:= [today,tomorrow];
  720. z:= [Monday..Friday,Sunday];
  721. bs:= [2,3*2,6*2,9*2];
  722. cs:= ['A'..'Z','a'..'z','0'..'9'];
  723. i:= Byte('A');
  724. cc:= Char(48);
  725. ad:= boolean(1);
  726. i:= longint(@Buffer);
  727. i:= Integer('A');
  728. cc:= Char(225);
  729. i:= Word(@Buffer);
  730. B:= Byte(C);
  731. S:= TObject(P).ClassName;
  732. P:= @MyProc; //warum @ ? fix pparser 769 ?
  733. Dirname:= Dirname+'\';
  734. W:= [mon,tue]+[wed,thu,fri]; // equals [mon,tue,wed,thu,fri]
  735. W:= [mon,tue,wed]-[wed]; // equals [mon,tue]
  736. W:= [mon,tue,wed]*[wed,thu,fri]; // equals [wed] warum * ?
  737. (Co as TEdit).Text:= 'Some text';
  738. Co:= O as TComponent;
  739. if co is TComponent then ;
  740. If co is TC then ;
  741. raise Exception.Create(SErrMultipleSourceFiles);
  742. if Filename<>'' then
  743. raise Exception.Create(SErrMultipleSourceFiles);
  744. if Filename<>'' then
  745. raise Exception.Create(SErrMultipleSourceFiles)
  746. else
  747. Filename:= s;
  748. end;
  749. constructor TPasPackage.Create(const AName: String; AParent: TPasElement);
  750. begin
  751. if (Length(AName)>0)and(AName[1]<>'#') then
  752. Inherited Create('#'+AName,AParent)
  753. else
  754. Inherited Create(AName,AParent);
  755. Modules:= TList.Create;
  756. end;
  757. Function TPascalScanner.FetchToken: TToken;
  758. var
  759. IncludeStackItem: TIncludeStackItem;
  760. begin
  761. while true do
  762. begin
  763. Result:= DoFetchToken;
  764. if FCurToken=tkEOF then
  765. if FIncludeStack.Count>0 then
  766. begin
  767. CurSourceFile.Free;
  768. IncludeStackItem:= TIncludeStackItem(FIncludeStack[FIncludeStack.Count-1]);
  769. FIncludeStack.Delete(FIncludeStack.Count-1);
  770. FCurSourceFile:= IncludeStackItem.SourceFile;
  771. FCurFilename:= IncludeStackItem.Filename;
  772. FCurToken:= IncludeStackItem.Token;
  773. FCurTokenString:= IncludeStackItem.TokenString;
  774. FCurLine:= IncludeStackItem.Line;
  775. FCurRow:= IncludeStackItem.Row;
  776. TokenStr:= IncludeStackItem.TokenStr;
  777. IncludeStackItem.Free;
  778. Result:= FCurToken;
  779. end
  780. else
  781. break
  782. else
  783. if not PPIsSkipping then
  784. break;
  785. end;
  786. end;
  787. Procedure IFS;
  788. begin
  789. if true then
  790. repeat
  791. until false
  792. else
  793. Noting;
  794. end;
  795. Procedure IFS(x: integer); overload;
  796. begin
  797. if true then
  798. case x of
  799. 1: writeln;
  800. 2: write;
  801. else
  802. writeln('#');
  803. end
  804. else
  805. Noting;
  806. end;
  807. Procedure IFS1;
  808. begin
  809. if true then
  810. while true do
  811. Something
  812. else
  813. Noting;
  814. end;
  815. Procedure IFS3;
  816. begin
  817. if true then
  818. if true then
  819. write
  820. else
  821. writeln;
  822. end;
  823. Initialization
  824. hallo:= valid;
  825. end.