Changeset 7
- Timestamp:
- Nov 5, 2010, 1:50:02 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Compiler/Analyze/UPascalParser.pas
r6 r7 33 33 function ParseUnitInterface(SourceCode: TModuleUnit): Boolean; 34 34 function ParseUnitImplementation(SourceCode: TModuleUnit): Boolean; 35 procedure ParseProgram(SourceCode: TModuleProgram);35 function ParseProgram(var SourceCode: TModuleProgram; ProgramCode: TProgram): Boolean; 36 36 procedure ParseCommonBlock(SourceCode: TCommonBlock; EndSymbol: char = ';'; 37 37 WithBody: Boolean = True); … … 396 396 begin 397 397 Self.ProgramCode := ProgramCode; 398 if not ParseUnit(TModuleUnit(Result), ProgramCode) then begin 399 Result := TModuleProgram.Create; 400 Result.ParentProgram := ProgramCode; 401 ParseProgram(TModuleProgram(Result)); 402 end else 398 if not ParseUnit(TModuleUnit(Result), ProgramCode) then 399 if not ParseProgram(TModuleProgram(Result), ProgramCode) then 403 400 ErrorMessage(SUnknownModuleType, [NextToken]); 404 401 end; 405 402 406 procedure TPascalParser.ParseProgram(SourceCode: TModuleProgram);403 function TPascalParser.ParseProgram(var SourceCode: TModuleProgram; ProgramCode: TProgram): Boolean; 407 404 var 408 405 Identifier: string; 409 406 begin 410 407 with SourceCode do begin 408 SourceCode := TModuleProgram.Create; 409 SourceCode.ParentProgram := ProgramCode; 411 410 if NextToken = 'program' then begin 412 411 Expect('program'); … … 421 420 ParseCommonBlock(Body, '.'); 422 421 SourceCode.ParentProgram.Modules.Add(SourceCode); 422 Result := True; 423 423 end; 424 424 end; … … 427 427 var 428 428 NewModule: TModule; 429 NewCommand: TCommand; 429 430 begin 430 431 if NextToken = 'unit' then begin … … 447 448 if NextToken = 'initialization' then begin 448 449 Expect('initialization'); 450 while (NextToken <> 'end') and (NextToken <> 'finalization') 451 and (NextTokenType <> ttEndOfFile) do 452 begin 453 NewCommand := ParseCommand(SourceCode.InititializeSection); 454 if Assigned(NewCommand) then 455 SourceCode.InititializeSection.Code.Commands.Add(NewCommand); 456 //ShowMessage(NextCode); 457 if NextToken = ';' then 458 ReadToken; 459 end; 449 460 end; 450 461 if NextToken = 'finalization' then begin 451 462 Expect('finalization'); 452 end; 463 while (NextToken <> 'end') and (NextTokenType <> ttEndOfFile) do 464 begin 465 NewCommand := ParseCommand(SourceCode.FinalalizeSection); 466 if Assigned(NewCommand) then 467 SourceCode.FinalalizeSection.Code.Commands.Add(NewCommand); 468 //ShowMessage(NextCode); 469 if NextToken = ';' then 470 ReadToken; 471 end; 472 end; 473 Expect('end'); 474 Expect('.'); 453 475 Result := True; 454 476 end else Result := False; … … 487 509 begin 488 510 with SourceCode do begin 489 while (NextToken <> EndSymbol) do begin511 while (NextToken <> EndSymbol) and (NextTokenType <> ttEndOfFile) do begin 490 512 if not ParseVariableList(Variables) then 491 513 if not ParseConstantList(Constants) then … … 1270 1292 end; 1271 1293 1272 1273 1294 end. 1274 1295 -
trunk/Compiler/USourceCode.pas
r6 r7 418 418 419 419 TModuleUnit = class(TModule) 420 InititializeSection: TCommonBlock; 421 FinalalizeSection: TCommonBlock; 420 422 constructor Create; 421 423 destructor Destroy; override; … … 1030 1032 begin 1031 1033 inherited; 1034 InititializeSection := TCommonBlock.Create; 1035 InititializeSection.ParentModule := Self; 1036 FinalalizeSection := TCommonBlock.Create; 1037 FinalalizeSection.ParentModule := Self; 1032 1038 end; 1033 1039 1034 1040 destructor TModuleUnit.Destroy; 1035 1041 begin 1042 InititializeSection.Free; 1043 FinalalizeSection.Free; 1036 1044 inherited Destroy; 1037 1045 end; -
trunk/Transpascal.lpi
r6 r7 212 212 <EditorIndex Value="0"/> 213 213 <WindowIndex Value="0"/> 214 <TopLine Value=" 58"/>215 <CursorPos X=" 26" Y="73"/>214 <TopLine Value="162"/> 215 <CursorPos X="17" Y="175"/> 216 216 <UsageCount Value="103"/> 217 217 <Loaded Value="True"/> … … 348 348 <Filename Value="Compiler\Produce\UProducerDynamicC.pas"/> 349 349 <UnitName Value="UProducerDynamicC"/> 350 <IsVisibleTab Value="True"/>351 350 <EditorIndex Value="11"/> 352 351 <WindowIndex Value="0"/> 353 <TopLine Value="2 95"/>354 <CursorPos X=" 49" Y="308"/>352 <TopLine Value="268"/> 353 <CursorPos X="39" Y="283"/> 355 354 <UsageCount Value="113"/> 356 355 <Loaded Value="True"/> … … 379 378 <Filename Value="Compiler\Analyze\UPascalParser.pas"/> 380 379 <UnitName Value="UPascalParser"/> 380 <IsVisibleTab Value="True"/> 381 381 <EditorIndex Value="8"/> 382 382 <WindowIndex Value="0"/> 383 <TopLine Value=" 269"/>384 <CursorPos X=" 26" Y="289"/>383 <TopLine Value="450"/> 384 <CursorPos X="17" Y="474"/> 385 385 <UsageCount Value="110"/> 386 386 <Loaded Value="True"/> … … 425 425 <TopLine Value="1"/> 426 426 <CursorPos X="28" Y="22"/> 427 <UsageCount Value="19 6"/>427 <UsageCount Value="198"/> 428 428 <DefaultSyntaxHighlighter Value="Delphi"/> 429 429 </Unit38> … … 762 762 </Unit78> 763 763 </Units> 764 <JumpHistory Count=" 29" HistoryIndex="28">764 <JumpHistory Count="30" HistoryIndex="27"> 765 765 <Position1> 766 <Filename Value="Compiler\ Analyze\UPascalParser.pas"/>767 <Caret Line=" 149" Column="1" TopLine="136"/>766 <Filename Value="Compiler\Produce\UProducerDynamicC.pas"/> 767 <Caret Line="308" Column="33" TopLine="295"/> 768 768 </Position1> 769 769 <Position2> 770 <Filename Value="Compiler\ Analyze\UPascalParser.pas"/>771 <Caret Line=" 150" Column="1" TopLine="136"/>770 <Filename Value="Compiler\Produce\UProducerDynamicC.pas"/> 771 <Caret Line="38" Column="70" TopLine="25"/> 772 772 </Position2> 773 773 <Position3> 774 <Filename Value="Compiler\ Analyze\UPascalParser.pas"/>775 <Caret Line=" 151" Column="1" TopLine="136"/>774 <Filename Value="Compiler\Produce\UProducerDynamicC.pas"/> 775 <Caret Line="286" Column="25" TopLine="277"/> 776 776 </Position3> 777 777 <Position4> 778 <Filename Value="Compiler\ Analyze\UPascalParser.pas"/>779 <Caret Line=" 152" Column="1" TopLine="136"/>778 <Filename Value="Compiler\Produce\UProducerDynamicC.pas"/> 779 <Caret Line="281" Column="1" TopLine="276"/> 780 780 </Position4> 781 781 <Position5> 782 <Filename Value="Compiler\ Analyze\UPascalParser.pas"/>783 <Caret Line="2 31" Column="1" TopLine="218"/>782 <Filename Value="Compiler\Produce\UProducerDynamicC.pas"/> 783 <Caret Line="283" Column="1" TopLine="276"/> 784 784 </Position5> 785 785 <Position6> 786 <Filename Value="Compiler\ Analyze\UPascalParser.pas"/>787 <Caret Line="2 32" Column="1" TopLine="218"/>786 <Filename Value="Compiler\Produce\UProducerDynamicC.pas"/> 787 <Caret Line="284" Column="1" TopLine="276"/> 788 788 </Position6> 789 789 <Position7> 790 <Filename Value="Compiler\ Analyze\UPascalParser.pas"/>791 <Caret Line="2 36" Column="1" TopLine="218"/>790 <Filename Value="Compiler\Produce\UProducerDynamicC.pas"/> 791 <Caret Line="290" Column="1" TopLine="276"/> 792 792 </Position7> 793 793 <Position8> 794 <Filename Value="Compiler\ Analyze\UPascalParser.pas"/>795 <Caret Line="2 37" Column="1" TopLine="218"/>794 <Filename Value="Compiler\Produce\UProducerDynamicC.pas"/> 795 <Caret Line="292" Column="1" TopLine="276"/> 796 796 </Position8> 797 797 <Position9> 798 <Filename Value="Compiler\ Analyze\UPascalParser.pas"/>799 <Caret Line="2 76" Column="1" TopLine="263"/>798 <Filename Value="Compiler\Produce\UProducerDynamicC.pas"/> 799 <Caret Line="293" Column="1" TopLine="276"/> 800 800 </Position9> 801 801 <Position10> 802 <Filename Value="Compiler\ Analyze\UPascalParser.pas"/>803 <Caret Line=" 278" Column="1" TopLine="263"/>802 <Filename Value="Compiler\Produce\UProducerDynamicC.pas"/> 803 <Caret Line="316" Column="1" TopLine="303"/> 804 804 </Position10> 805 805 <Position11> 806 <Filename Value="Compiler\ Analyze\UPascalParser.pas"/>807 <Caret Line="2 79" Column="1" TopLine="263"/>806 <Filename Value="Compiler\Produce\UProducerDynamicC.pas"/> 807 <Caret Line="281" Column="1" TopLine="268"/> 808 808 </Position11> 809 809 <Position12> 810 <Filename Value="Compiler\ Analyze\UPascalParser.pas"/>811 <Caret Line=" 287" Column="1" TopLine="269"/>810 <Filename Value="Compiler\Produce\UProducerDynamicC.pas"/> 811 <Caret Line="8" Column="69" TopLine="6"/> 812 812 </Position12> 813 813 <Position13> 814 <Filename Value="Compiler\ Analyze\UPascalParser.pas"/>815 <Caret Line=" 289" Column="26" TopLine="269"/>814 <Filename Value="Compiler\Produce\UProducerDynamicC.pas"/> 815 <Caret Line="38" Column="34" TopLine="25"/> 816 816 </Position13> 817 817 <Position14> 818 818 <Filename Value="Compiler\Produce\UProducerDynamicC.pas"/> 819 <Caret Line=" 305" Column="37" TopLine="287"/>819 <Caret Line="241" Column="68" TopLine="228"/> 820 820 </Position14> 821 821 <Position15> 822 822 <Filename Value="Compiler\Produce\UProducerDynamicC.pas"/> 823 <Caret Line=" 308" Column="33" TopLine="295"/>823 <Caret Line="277" Column="48" TopLine="264"/> 824 824 </Position15> 825 825 <Position16> 826 826 <Filename Value="Compiler\Produce\UProducerDynamicC.pas"/> 827 <Caret Line="3 8" Column="70" TopLine="25"/>827 <Caret Line="308" Column="49" TopLine="295"/> 828 828 </Position16> 829 829 <Position17> 830 <Filename Value="Compiler\ Produce\UProducerDynamicC.pas"/>831 <Caret Line=" 286" Column="25" TopLine="277"/>830 <Filename Value="Compiler\Analyze\UPascalParser.pas"/> 831 <Caret Line="398" Column="17" TopLine="395"/> 832 832 </Position17> 833 833 <Position18> 834 <Filename Value="Compiler\ Produce\UProducerDynamicC.pas"/>835 <Caret Line=" 281" Column="1" TopLine="276"/>834 <Filename Value="Compiler\Analyze\UPascalParser.pas"/> 835 <Caret Line="401" Column="14" TopLine="395"/> 836 836 </Position18> 837 837 <Position19> 838 <Filename Value="Compiler\ Produce\UProducerDynamicC.pas"/>839 <Caret Line=" 283" Column="1" TopLine="276"/>838 <Filename Value="Compiler\Analyze\UPascalParser.pas"/> 839 <Caret Line="398" Column="17" TopLine="395"/> 840 840 </Position19> 841 841 <Position20> 842 <Filename Value="Compiler\ Produce\UProducerDynamicC.pas"/>843 <Caret Line=" 284" Column="1" TopLine="276"/>842 <Filename Value="Compiler\Analyze\UPascalParser.pas"/> 843 <Caret Line="431" Column="24" TopLine="426"/> 844 844 </Position20> 845 845 <Position21> 846 <Filename Value="Compiler\ Produce\UProducerDynamicC.pas"/>847 <Caret Line=" 290" Column="1" TopLine="276"/>846 <Filename Value="Compiler\Analyze\UPascalParser.pas"/> 847 <Caret Line="426" Column="57" TopLine="426"/> 848 848 </Position21> 849 849 <Position22> 850 <Filename Value="Compiler\ Produce\UProducerDynamicC.pas"/>851 <Caret Line=" 292" Column="1" TopLine="276"/>850 <Filename Value="Compiler\Analyze\UPascalParser.pas"/> 851 <Caret Line="449" Column="17" TopLine="429"/> 852 852 </Position22> 853 853 <Position23> 854 <Filename Value="Compiler\ Produce\UProducerDynamicC.pas"/>855 <Caret Line=" 293" Column="1" TopLine="276"/>854 <Filename Value="Compiler\Analyze\UPascalParser.pas"/> 855 <Caret Line="1274" Column="15" TopLine="1251"/> 856 856 </Position23> 857 857 <Position24> 858 <Filename Value="Compiler\ Produce\UProducerDynamicC.pas"/>859 <Caret Line=" 316" Column="1" TopLine="303"/>858 <Filename Value="Compiler\Analyze\UPascalParser.pas"/> 859 <Caret Line="1277" Column="14" TopLine="1253"/> 860 860 </Position24> 861 861 <Position25> 862 <Filename Value="Compiler\ Produce\UProducerDynamicC.pas"/>863 <Caret Line=" 281" Column="1" TopLine="268"/>862 <Filename Value="Compiler\Analyze\UPascalParser.pas"/> 863 <Caret Line="449" Column="11" TopLine="435"/> 864 864 </Position25> 865 865 <Position26> 866 <Filename Value="Compiler\ Produce\UProducerDynamicC.pas"/>867 <Caret Line=" 8" Column="69" TopLine="6"/>866 <Filename Value="Compiler\Analyze\UPascalParser.pas"/> 867 <Caret Line="442" Column="27" TopLine="435"/> 868 868 </Position26> 869 869 <Position27> 870 <Filename Value="Compiler\ Produce\UProducerDynamicC.pas"/>871 <Caret Line=" 38" Column="34" TopLine="25"/>870 <Filename Value="Compiler\Analyze\UPascalParser.pas"/> 871 <Caret Line="453" Column="55" TopLine="444"/> 872 872 </Position27> 873 873 <Position28> 874 <Filename Value="Compiler\ Produce\UProducerDynamicC.pas"/>875 <Caret Line=" 241" Column="68" TopLine="228"/>874 <Filename Value="Compiler\Analyze\UPascalParser.pas"/> 875 <Caret Line="455" Column="43" TopLine="438"/> 876 876 </Position28> 877 877 <Position29> 878 <Filename Value="Compiler\ Produce\UProducerDynamicC.pas"/>879 <Caret Line=" 277" Column="48" TopLine="264"/>878 <Filename Value="Compiler\USourceCode.pas"/> 879 <Caret Line="175" Column="17" TopLine="162"/> 880 880 </Position29> 881 <Position30> 882 <Filename Value="Compiler\USourceCode.pas"/> 883 <Caret Line="78" Column="3" TopLine="65"/> 884 </Position30> 881 885 </JumpHistory> 882 886 </ProjectOptions> … … 920 924 </CompilerOptions> 921 925 <Debugging> 922 <BreakPoints Count="1">923 <Item1>924 <Source Value="Compiler\Produce\UProducerDynamicC.pas"/>925 <Line Value="281"/>926 </Item1>927 </BreakPoints>928 926 <Exceptions Count="3"> 929 927 <Item1>
Note:
See TracChangeset
for help on using the changeset viewer.