Changeset 55 for branches/DelphiToC/Analyze/UParser.pas
- Timestamp:
- Aug 10, 2010, 1:48:38 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DelphiToC/Analyze/UParser.pas
r54 r55 51 51 procedure ParseExpression(SourceCode: TExpression); 52 52 procedure ParseUsedModuleList(SourceCode: TUsedModuleList); 53 procedure ParseModule(SourceCode: TModule); 54 procedure ParseUnit(SourceCode: TModule); 55 procedure ParseProgram(SourceCode: TModule); 53 function ParseModule: TModule; 54 procedure ParseUnit(SourceCode: TModuleUnit); 55 procedure ParseUnitInterface(SourceCode: TUnitInterface); 56 procedure ParseUnitImplementation(SourceCode: TUnitImplementation); 57 procedure ParseProgram(SourceCode: TModuleProgram); 56 58 procedure ParseCommonBlock(SourceCode: TCommonBlock; EndSymbol: char = ';'); 57 59 function ParseCommand(SourceCode: TCommonBlock): TCommand; … … 628 630 { TParserModule } 629 631 630 procedure TPascalParser.ParseModule(SourceCode: TModule); 631 begin 632 if FNextToken = 'program' then 633 ParseProgram(SourceCode) 634 else if FNextToken = 'unit' then 635 ParseUnit(SourceCode) 636 else 637 ParseProgram(SourceCode); 638 end; 639 640 procedure TPascalParser.ParseProgram(SourceCode: TModule); 632 function TPascalParser.ParseModule: TModule; 633 begin 634 if FNextToken = 'unit' then begin 635 Result := TModuleUnit.Create; 636 ParseUnit(TModuleUnit(Result)); 637 end else begin //if FNextToken = 'program' then begin 638 Result := TModuleProgram.Create; 639 ParseProgram(TModuleProgram(Result)); 640 end; 641 end; 642 643 procedure TPascalParser.ParseProgram(SourceCode: TModuleProgram); 641 644 var 642 645 Identifier: string; 643 646 begin 644 with SourceCode do 645 begin 646 if FNextToken = 'program' then 647 begin 647 with SourceCode do begin 648 if FNextToken = 'program' then begin 648 649 Expect('program'); 649 650 Name := ReadCode; 650 ModuleType := mdProgram;651 651 Expect(';'); 652 652 end else Name := ''; … … 656 656 ParseUsedModuleList(UsedModules); 657 657 658 ParseCommonBlock( SourceCode, '.');659 end; 660 end; 661 662 procedure TPascalParser.ParseUnit(SourceCode: TModule );658 ParseCommonBlock(Body, '.'); 659 end; 660 end; 661 662 procedure TPascalParser.ParseUnit(SourceCode: TModuleUnit); 663 663 var 664 664 NewModule: TModule; 665 665 begin 666 666 Expect('unit'); 667 with Sourcecode do 668 begin 667 with Sourcecode do begin 669 668 Name := ReadCode; 670 ModuleType := mdUnit;671 669 end; 672 670 Expect(';'); 673 //ParseInterface; 674 //ParseImplementation; 675 end; 676 677 { TParserProgram } 671 672 ParseUnitInterface(SourceCode.InterfaceSection); 673 if FNextToken = 'implementation' then 674 ParseUnitImplementation(SourceCode.ImplementationSection); 675 end; 676 677 procedure TPascalParser.ParseUnitInterface(SourceCode: TUnitInterface); 678 begin 679 Expect('interface'); 680 // Uses section 681 if FNextToken = 'uses' then 682 ParseUsedModuleList(SourceCode.UsedModules); 683 684 ParseCommonBlock(SourceCode.Body, '.'); 685 end; 686 687 procedure TPascalParser.ParseUnitImplementation(SourceCode: TUnitImplementation); 688 begin 689 Expect('implementation'); 690 691 // Uses section 692 if FNextToken = 'uses' then 693 ParseUsedModuleList(SourceCode.UsedModules); 694 695 ParseCommonBlock(SourceCode.Body, '.'); 696 end; 678 697 679 698 { TParserCommonBlock }
Note:
See TracChangeset
for help on using the changeset viewer.