|
@@ -305,6 +305,7 @@ type
|
|
procedure ParseUnit(var Module: TPasModule);
|
|
procedure ParseUnit(var Module: TPasModule);
|
|
procedure ParseProgram(var Module: TPasModule; SkipHeader : Boolean = False);
|
|
procedure ParseProgram(var Module: TPasModule; SkipHeader : Boolean = False);
|
|
procedure ParseLibrary(var Module: TPasModule);
|
|
procedure ParseLibrary(var Module: TPasModule);
|
|
|
|
+ procedure ParseOptionalUsesList(ASection: TPasSection);
|
|
procedure ParseUsesList(ASection: TPasSection);
|
|
procedure ParseUsesList(ASection: TPasSection);
|
|
procedure ParseInterface;
|
|
procedure ParseInterface;
|
|
procedure ParseImplementation;
|
|
procedure ParseImplementation;
|
|
@@ -1920,6 +1921,7 @@ begin
|
|
end;
|
|
end;
|
|
Section := TProgramSection(CreateElement(TProgramSection, '', CurModule));
|
|
Section := TProgramSection(CreateElement(TProgramSection, '', CurModule));
|
|
PP.ProgramSection := Section;
|
|
PP.ProgramSection := Section;
|
|
|
|
+ ParseOptionalUsesList(Section);
|
|
ParseDeclarations(Section);
|
|
ParseDeclarations(Section);
|
|
finally
|
|
finally
|
|
FCurModule:=nil;
|
|
FCurModule:=nil;
|
|
@@ -1947,12 +1949,23 @@ begin
|
|
ParseExcTokenError(';');
|
|
ParseExcTokenError(';');
|
|
Section := TLibrarySection(CreateElement(TLibrarySection, '', CurModule));
|
|
Section := TLibrarySection(CreateElement(TLibrarySection, '', CurModule));
|
|
PP.LibrarySection := Section;
|
|
PP.LibrarySection := Section;
|
|
|
|
+ ParseOptionalUsesList(Section);
|
|
ParseDeclarations(Section);
|
|
ParseDeclarations(Section);
|
|
finally
|
|
finally
|
|
FCurModule:=nil;
|
|
FCurModule:=nil;
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+procedure TPasParser.ParseOptionalUsesList(ASection: TPasSection);
|
|
|
|
+// checks if next token is Uses keyword and read uses list
|
|
|
|
+begin
|
|
|
|
+ NextToken;
|
|
|
|
+ if CurToken=tkuses then
|
|
|
|
+ ParseUsesList(ASection)
|
|
|
|
+ else
|
|
|
|
+ UngetToken;
|
|
|
|
+end;
|
|
|
|
+
|
|
// Starts after the "interface" token
|
|
// Starts after the "interface" token
|
|
procedure TPasParser.ParseInterface;
|
|
procedure TPasParser.ParseInterface;
|
|
var
|
|
var
|
|
@@ -1960,6 +1973,7 @@ var
|
|
begin
|
|
begin
|
|
Section := TInterfaceSection(CreateElement(TInterfaceSection, '', CurModule));
|
|
Section := TInterfaceSection(CreateElement(TInterfaceSection, '', CurModule));
|
|
CurModule.InterfaceSection := Section;
|
|
CurModule.InterfaceSection := Section;
|
|
|
|
+ ParseOptionalUsesList(Section);
|
|
ParseDeclarations(Section);
|
|
ParseDeclarations(Section);
|
|
end;
|
|
end;
|
|
|
|
|
|
@@ -1970,6 +1984,7 @@ var
|
|
begin
|
|
begin
|
|
Section := TImplementationSection(CreateElement(TImplementationSection, '', CurModule));
|
|
Section := TImplementationSection(CreateElement(TImplementationSection, '', CurModule));
|
|
CurModule.ImplementationSection := Section;
|
|
CurModule.ImplementationSection := Section;
|
|
|
|
+ ParseOptionalUsesList(Section);
|
|
ParseDeclarations(Section);
|
|
ParseDeclarations(Section);
|
|
end;
|
|
end;
|
|
|
|
|
|
@@ -2118,8 +2133,10 @@ begin
|
|
break;
|
|
break;
|
|
end;
|
|
end;
|
|
tkUses:
|
|
tkUses:
|
|
- if Declarations is TPasSection then
|
|
|
|
- ParseUsesList(TPasSection(Declarations))
|
|
|
|
|
|
+ if Declarations.ClassType=TInterfaceSection then
|
|
|
|
+ ParseExcTokenError(TokenInfos[tkimplementation])
|
|
|
|
+ else if Declarations is TPasSection then
|
|
|
|
+ ParseExcTokenError(TokenInfos[tkend])
|
|
else
|
|
else
|
|
ParseExcSyntaxError;
|
|
ParseExcSyntaxError;
|
|
tkConst:
|
|
tkConst:
|