Procedure CompileUnit;
Var CurrentUnitInstance: PUnitHeader;
begin
SourceType := stUnitInterface;
ExpectTokenAndGetNext (Token_UNIT);
ExpectIdentifier;
CreateUnitIdentiferSymbolTableAndStoreMainUnitName;
GetNextToken;
ExpectTokenAndGetNext (Token_Semicolon);
ExpectTokenAndGetNext (Token_INTERFACE);
SetModuleFlagsAndProcessUsedUnits;
If not (cmoCompileOnlyInterface in CompilerModeOptions) or not IsLastUnitAlreadyLoaded (CurrentUnitInstance) then
begin
ProcessDeclarations;
CalculateIdentifiersChecksum;
SourceType := stUnitImplementation;
ExpectTokenAndGetNext (Token_IMPLEMENTATION);
ProcessUsedUnits;
ProcessDeclarations;
If Token = Token_BEGIN then ProcessMainProgramBlock { Initialization part }
else ExpectTokenAndGetNext (Token_END);
CheckForPeriodAndModuleEnd;
ImportObjectFiles;
CheckForUndefined_FORWARD_Or_EXTERNAL (Ptr (SymbolTable [stProcedures].Segment, 8));
RemovePrivateIdentifiersFromUnit;
JoinSymbolTablesAndCreateUnit;
CreateUnitFile;
end else JoinSymbolTablesAndCreateUnit;
CopySegmentsOfSymbolTablesToUnitHeader;
end;