/ Published in: Pascal
This is how Turbo Pascal works.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
Procedure CompileProgram; begin SourceType := stProgram; If CheckAndGetNextToken (Token_PROGRAM) then begin ExpectIdentifier; CreateSymbolTableAndStoreMainModuleNameIdentifier; GetNextToken; If CheckAndGetNextToken (Token_LeftParenthesis) then begin Repeat ExpectTokenAndGetNext (Token_Identifier); until not CheckAndGetNextToken (Token_Comma); ExpectTokenAndGetNext (Token_RightParenthesis); end; ExpectTokenAndGetNext (Token_Semicolon); end else begin CopyStringToCurrentIdentifier ('PROGRAM'); CreateSymbolTableAndStoreMainModuleNameIdentifier; end; SetModuleFlagsAndProcessUsedUnits; ProcessDeclarations; ProcessMainProgramBlock; CheckForPeriodAndModuleEnd; ImportObjectFiles; CheckForUndefined_FORWARD_Or_EXTERNAL (Ptr (SymbolTable [stProcedures].Segment, SizeOf (TProceduresBlockRecord))); JoinSymbolTablesAndCreateUnit; CopySegmentsOfSymbolTablesToUnitHeader; end;