Changeset 58 for branches/Transpascal/Analyze/UParser.pas
- Timestamp:
- Aug 10, 2010, 3:41:49 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/Transpascal/Analyze/UParser.pas
r55 r58 57 57 procedure ParseProgram(SourceCode: TModuleProgram); 58 58 procedure ParseCommonBlock(SourceCode: TCommonBlock; EndSymbol: char = ';'); 59 procedure ParseCommonBlockInterface(SourceCode: TCommonBlock); 59 60 function ParseCommand(SourceCode: TCommonBlock): TCommand; 60 61 procedure ParseBeginEnd(SourceCode: TBeginEnd); 61 procedure ParseFunctionList(SourceCode: TFunctionList );62 procedure ParseFunctionList(SourceCode: TFunctionList; IncludeBody: Boolean = True); 62 63 procedure ParseIfThenElse(SourceCode: TIfThenElse); 63 64 procedure ParseForToDo(SourceCode: TForToDo); … … 682 683 ParseUsedModuleList(SourceCode.UsedModules); 683 684 684 ParseCommonBlock (SourceCode.Body, '.');685 ParseCommonBlockInterface(SourceCode.Body); 685 686 end; 686 687 … … 725 726 end; 726 727 728 procedure TPascalParser.ParseCommonBlockInterface(SourceCode: TCommonBlock); 729 begin 730 with SourceCode do begin 731 while FNextToken <> 'implementation' do begin 732 if FNextToken = 'var' then 733 ParseVariableList(Variables) 734 else if FNextToken = 'const' then 735 ParseConstantList(Constants) 736 else if FNextToken = 'type' then 737 ParseTypeList(Types) 738 else if FNextToken = 'procedure' then 739 ParseFunctionList(Functions, False) 740 else if FNextToken = 'function' then 741 ParseFunctionList(Functions, False) 742 else ErrorMessage(SUnknownIdentifier, [FNextToken]); 743 end; 744 end; 745 end; 746 727 747 { TParserBeginEnd } 728 748 … … 750 770 { TParserParseFunctionList } 751 771 752 procedure TPascalParser.ParseFunctionList(SourceCode: TFunctionList );772 procedure TPascalParser.ParseFunctionList(SourceCode: TFunctionList; IncludeBody: Boolean = True); 753 773 var 754 774 Identifiers: TStringList; … … 760 780 begin 761 781 Identifiers := TStringList.Create; 762 with SourceCode do 763 begin 764 with TFunction(Items[Add(TFunction.Create)]) do 765 begin 782 with SourceCode do begin 783 with TFunction(Items[Add(TFunction.Create)]) do begin 766 784 Parent := SourceCode.Parent; 767 785 if FNextToken = 'procedure' then … … 834 852 end; 835 853 end; 836 end; 837 Expect(';'); 838 ParseCommonBlock(TFunction(Last)); 854 Expect(';'); 855 856 // Check directives 857 if FNextToken = 'internal' then begin 858 Expect('internal'); 859 Expect(';'); 860 System := True; 861 end; 862 end; 863 864 if IncludeBody then ParseCommonBlock(TFunction(Last)); 839 865 end; 840 866 Identifiers.Destroy;
Note:
See TracChangeset
for help on using the changeset viewer.