GY33 8000 0_ALGOL_F_Rel_21_Compiler_Logic_PLM_Jan72 0 ALGOL F Rel 21 Compiler Logic PLM Jan72
GY33-8000-0_ALGOL_F_Rel_21_Compiler_Logic_PLM_Jan72 GY33-8000-0_ALGOL_F_Rel_21_Compiler_Logic_PLM_Jan72
User Manual: GY33-8000-0_ALGOL_F_Rel_21_Compiler_Logic_PLM_Jan72
Open the PDF directly: View PDF .
Page Count: 326
Download | |
Open PDF In Browser | View PDF |
File Number S360-26 Order No. GC33-8000-0 y Program Logic OS ALGOL (F) Compiler Logic I Program Numbers: 360S-AL-531 (Compiler) 360S- LM-532 (Library Routines) OS Release 21 This manual describes the internal logic of the ALGOL (F) Compiler. It is intended for the use of IBM field engineers, systems analysts and programmers. The ALGOL (F) Compiler is a processing program of the IBM System/360 Operating System. It translates a source module written in the ALGOL language into an object module that can be processed into an executable load module by the Linkage Editor. Page of GY'l3-8000-0 Revised January 15, 1972 By TNL GN33-8129 PREFACE The IBM System/360 Operating System ALGOL Compiler consists of ten phases, or load modules. Chapter 1 of this manual provides an introductory survey of the main functions of the several phases. A more detailed description of the individual phases is provided in the subsequent chapters, as follows: Directory (IEXOO) Initialization (IEX10) Scan I/II (IEXll) Identifier Table Manipulation (IEX20) Diagnostic Output (IEX21) Scan III (IEX30) Diagnostic Output (IEX31) Subscript Handling (IEX40) Compilation Phase (IEXSO) Termination Phase (IEXS1) Chapter 2 Chapter 3 Chapter 4 Chapter Chapter Chapter Chapter Chapter Chapter Chapter 5 9 6 9 7 8 8 handles the output of diagnostic messages in the three phases mentioned, is described in Chapter 9. Chapter 10 describes the ALGOL Library, which consists of a set of load modules representing standard I/O procedures, mathematical functions, and the Fixed Storage Area. Chapter 11 describes the composition of the object module generated by the Compiler, and the organization of the load module at execution time. Other publications that will be useful to the reader in understanding the Compiler are: OS ALGOL Language, Order No.GC28-661S Two of the phases (Load Modules IEX21 and IEX31) are devoted exclusively to the editing and output of diagnostic messages. Diagnostic output is also provided for in the Termination Phase (Load Module IEXS1). The Error Message Editing Routine, which OS ALGOL Programmer's Guide, Order No. GC33-4000 OS FORTRAN IV Library, Order No. Order No. GC28-6S96 First Edition (September 1967) This edition applies to release 21 of the IBM System/360 Operating System, and to all subsequent modifications unless otherwise indicated in new editions or Technical Newsletters. Changes are continually made to the specifications herein; before using this publication in connection with the operation of IBM systems, consult the latest SRL Newsletter, Order No. GN20-0360 for the editions that are applicable and current. This publication was prepared for production using an IBM computer to update the text and to control the page and line format. Page impressions for photo-offset printing were obtained from an IBM 1403 printer using a special print chain. Requests for copies of IBM publications should be made to your IBM representative or to the IBM branch office serving your locality. A form is provided at the back of this publication for reader's comments. If the form has been removed, comments may be addressed to IBM Nordic Laboratory, Publications Development, Box 962, S-181 09 Lidingo 9, Sweden. Comments become the property of IBM. ©Copyright International Business Machines Corporation 1967 CONTENTS CHAPTER 1: INTRODU:TION. • • • 13 Purpose of the Compiler. • • 13 rhe Compiler and System/360 Operating System. • • • • • 13 Machine System • • • 13 )rganization of the :ompiler • • • • Directory (IEXOO) • • • • • Initialization Phase (IEX10) •• • Scan 1/11 Phase (IEX11) • • • • • Identifier rable Manipulation Phase (IEX20). • • • • • • • • • • • • Diagnostic Output (IEX21) • • • Scan III Phase (IEX30). • • • • • Diagnostic output (IEX31) • • • • Subscript Handling Phase (IEX40) • • • Compihtion Phase (IEX50) • • • • • • Termination (IEX51) • • • • • • • • • Diagnostic Output (IEX21, IEX31, and IEX51) • • • • • • • • ALGOL Library • The )bject Module. 13 13 13 15 15 15 15 15 15 16 16 • 16 Communication by Source rext and rable. • • • CHAPTER 3: INITIALIZATION PHASE (IEX10) • • • • • Purpose of the Phase • In~erphase 17 Use of Main Storage. • • Area Occupied by Directory Auxiliary Routines • • • • The Common ~ork Area • • • • Area occupied by Operative Module • Private Area Acquired by Operative Module • • • • • • Common Area conventions. • • • 20 CHAPTER 2: DIRECTORY (IEXOO) • 21 Purpose of the Directory • • • 21 ... Selection of Area Size Table (FNDARSIZ) • • • • • • • • • • Acquisition of Common Area • • 18 18 opening of Data Sets • 19 CHAPrER 4: SCAN • 19 • 19 Purpose of the Phase 21 21 21 21 21 22 23 23 24 24 • 24 24 • 24 • 24 • 24 • 25 • 25 • 25 • 26 26 Processing Compiler Options., DDnames, and Heading Information • • • • 26 :ompiler Options. • • 27 DDnames • • • • • • • • • 28 28 Heading Information • • • 18 Organization of the Directory. • • • • Control Section IEXOOOOO • • • Initial Entry Routine. • · • • Final Exit Routine • • • • Program Interrupt Routine (PI ROUT). • • • • • • • • • • • • 1/0 Error Routine (SYNAD) • • • • • Sysprint 110 Error Routine (SYNPR) • • • • • • • • • • • • • End of Data Routines (EODAD1, EODAD2, EODAD3, AND EODADIN) • • • Print Subroutine (PRINT) • • • • • Data Control Blocks. • • • • • • • • • • • • • • 26 Execution of the SPIE Macro. • 16 16 • • • 16 Input/)utput Activity. Control section IEX00001 (Common Work Area) • • • • • • • • • • Register Save Area • • • • DCB Addresses. • • • • • • • • • End of Data Exit Addresses • compiler Control Field (HCOMPMOD). • • • • • •• • Communication Area • • • • Area Size Table (INBLKS). • Headline Storage Area (PAGEHEAD) Preliminary Error Pool • • • • • Data Control Blocks for SYSIN and SYSUT1. • • • •••• • Tables • • • • • • • • Other Data • • • • • • • • • 1/11 • • 28 28 • • 28 PHASE (IEX11) • 30 30 Scan 1/11 Phase Operations • • • • • • • 31 Opening of Scopes • • • • • 33 processing of Declarations and Specifications • • • • • 34 Close of Scopes • • • • • • • 34 End of Phase. • 34 Phase Input/Output • • • • • • 35 Identifier Table (ITAB) •• • Identifier Entries. • • Program Block Heading Entries • For Statement Heading and Closing Entries. • • • • • • • • • processing of the Identifier Table. • 35 • 36 Scope Identification Scope Handling Stack. 41 • 42 • 38 • 39 • 40 22 22 23 23 Modification Level 1 Source Text • • • • 43 Group Table (GPTAB). • • • • • • • 45 Scope r3.ble (SprAB). Pro~r3.m • 45 Block Number Table (PBTAB1) • • • 46 processin~ of Opening Source Text • • • • 46 46 Close of Scan 1/11 Phase • Switches • • 48 Constituent Routines of Scan 1/11 Ph3.se • • • • • • • • Phase Initialization. • M3.in Loop (TESTLOOP) • • • • Blank (BLANK) • • • • • • • Test 3.n~ Transfer Operator (rRANSOP).. • ••••••••• RIGHTP~R. • • • • • • • • • POINr • • • • • • • • • • • •••• Decimal Point (DE:POINT). • Assi~nment (ASSIGN) • • • statement (Sr~rE) • • • • • • Apostrophe (APOSTROF) • • • Scale Factor (S:ALE). • • • Bl3.nk after Apostrophe (BLKAPOS) • • • Zeta after Apostrophe (ZETAAPO) • • • Invali~ Character after Apostrophe (NP~FrAPO) • • • • • • • • • Colon (COLON) • • • • • • • • Label (LABEL) • • • • • • • • • • Letter Delimiter (LETDEL) • • • • • • Semicolon (SEMCO and SEMC60) • • • Error Recording Routines. • • • Ch3.nge Input Buffer (:IB) • • • • Identifier Test (IDCHECK1) • • • • Change Output Buffer (COB and COBSPEC) • • • • • • • • Delimiter (DELIMIT) • • • • • • • Delimiter Error Routine (EROUT) • Type specification (TYPESPEC) • • • • Comment (COMSPEC) • • • • • • • • Opening Delimiter (STARTDEL) • • • • • Begin (BEGIN) • • • • • • • • • String (STRIN:;) • • • • • Norm3.l ~ction (NORMAL). • • Boolean Constant (BOLCON) • Goto-If (GIF) • • • • • • • • • • • • Then-Else-Do (rED). • • • • First Be~in (FIRSTBE3) • • • • • • • • Program Block (BEGl Subroutine) • End (END) • • • • • • • • • • Compound End (COMPDEND) • • • •• For Statement End (FOREND). • program Block End (PBLCKEND Subroutine). • • • • • Comment (COM) • • • • • • • • • For statement (FOR) • • • • • • • • • Type Declaration (TYPE) • • • • • • • Identifier Error (IER). • Code Procedure (CO;)E) • • • Specification (SPEC) • • • • • • • • • Parameter Specification (SPECENT and IDCHECK) • • • • • • • rype ~rray (rYPEARRY) • • • ~rray Declaration (~RRAY) • Array/Switch List (LIST). • Point in List (PONTLST) • • Right Parenthesis in List (RIGHTP~RL). • • • • • • Left Parenthesis in List (LEFTPARL) • 52 52 54 55 55 55 55 56 56 56 56 56 56 57 57 57 57 57 57 57 59 59 59 60 60 62 62 62 62 62 62 62 63 63 63 63 63 63 63 64 64 64 64 64 65 65 65 65 65 66 66 66 66 Comma in List (COMMALST). • • • 66 Colon in List (COLONLST). • • 66 Semicolon in List (SEMCLST) • 66 Slash in List (SLASHLST). • 67 Switch Declaration (SWITCH) 67 Procedure Declaration (PROCEDUR) • • • 67 Procedure Identifier (PROCID) • • 67 Termination (EODADIN) • • • • • • 67 Generate Subroutine • • • • • 68 CHAPTER 5: IDENTIFIER TABLE MANIPULATION PHASE (IEX20). 69 Purpose of the Phase • • • • • 69 Identifier Table Manipulation Phase operations. • • • • • 69 Phase Input/Output • • • • 70 Identifier Table (ITAB). 70 Program Block Table II (PBTAB2) • • • • • 70 Constituent Routines of Identifier Table Manipulation Phase. • • • Phase Initialization • • • • • • Identifier Scan (READBLIO • • • .• Storage Allocation (ALLOSTOR) • • write Identifier Table (WRITITAB) Print Identifier Table (ITABPRNT) rermination (CLOSE) • • • • • • • 71 • • • • • • • • • • • 71 72 72 73 73 73 CHAPTER 6: SCAN III PHASE (IEX30). • • • 74 Purpose of the Phase • • • • Scan III Phase Operations • • • • • • Opening and Close of Blocks and Procedures • • • • • • • • • • • Identifier Handling • • • • • Number Handling • • • • • • • Array Subscript Handling. • • Handling of Other Operators • Phase Termination • Phase Input/output • • 74 • • 75 • • • • • • • • • • 75 75 77 77 77 77 • • 77 Processing of the Identifier Table • • • 78 Classification of For Statements • • • • 79 Processing of For Statements. • • 80 Detection of Operators in For 80 List. . . . . . . . . . . Recognition of Identifiers in 80 For Statements. • • •• • • • Optimizable subscript Expressions • • • • 81 For Statement Table (FSTAB). • • 81 Left Variable Table (LVTAB) • • • • 82 subscript Table (SUTAB) • • • 82 Critical Identifier Table (CRIDTAB). 82 Array Identifier Stack (ARIDSTAB) • • • • 84 Modification Level 2 Source Text • •• • • 84 swi tches • • • • • • • • • • • • • • • • 85 Phase Input/Output • .102 constituent Routines of Scan III Phase • 86 Phase Initializati~n (INITIATE) • 86 General Test (GENTEST). • • • • • • • 88 Identifier Test (LETTER) • • • • • • • 88 IT~B Search (IDENT) • • • • • • • • • 88 Identifier Classification (FOLI) • • • 88 Noncritical Identifier (NOCRI) • • • • 89 Proce~ure/Parameter (PROFU) • 89 switch/Label (S~IL~) • • • • • • • • • 89 Critical Identifier (CRITI) • 89 Make Cridtab Entry (CRlMA). • • 90 CRIDTAB Overflow (CRIFLOW). • 90 Erase CRIDTAB (DELCRIV) • • 91 Up~ate CRIDT~B (CRIFODEL) • 91 Make LITTAB Entry (LETRAF) • • • 91 Nonzero Digit (DI3IT19) • 91 Zero Digit (DIGIrO) • • • • 92 Decimal Point (DECPOIN) • • 92 Scale Factor (SCAFACT). • • 93 Integer Conversion (INTCON) 93 Real Conversion (RE~LCON) • • 9~ Integer Handling (INTHAN) • • 9~ Real Handling (RE~LH~N) • • • 9~ Change Constant Pool (CPOLEX) • • 9~ output TXT Record (TXTTR~F) • 95 Generate (GENTXT) • • • • • • • 95 Apostrophe (~UOTE) • • • • • • • • • • 95 Block Be:Jin (BETA). • • • • • • • • • 95 Procedure Declaration (PIPHI) • • 95 Read ITAB Record (ITABMOVE) • • • • • 95 For statement (FOR) • • • • • • • • • 95 Program Block End (EPSILON) • 95 For Statement End (ETA) • • • 95 Do (DO) • • • • • • • • • • • 96 While (WHILE) • • • • • • • • 96 Semicolon/Delta (SEMIDELT). • 96 Opening Bracket (OPBRACK) • • 96 Comma (COMMA) • • • • • • • • • • 96 Closing Bracket (CLOBRACK). • 96 Scan subscript (S[JCRIDEL). • • • 96 Subscript Test (SUSCRITE) • 96 Operand Test (OPERAND). • • • • • 97 Multiplier-Operand (SUBMULT) • • • • • 97 Make SUTAB Entry (SUTABENT) • • • 98 Input Record End (ZETA) • • • • • 98 Change Input Buffer (ICHA). • 98 Code Procedure (G~MMA). • • 98 Program End (OMEGA) • • • • 98 Other Operators (OrHOP) • • • • • • • 98 Letter Delimiter (RHO). • • • • 99 Step (STEP) • • • • • • • • 99 ~rray (ARR~Y) • • • • • • • 99 Switch (SWITCH) • • • • • • 99 Divide/Power(OIPOW) • • • • 99 Change output Buffer (OUCHA). • 99 Incorrect Operand (INCOROP) • 99 Store Error (MOIlERRO) • • • • • • 99 Move Operand (MOllE) • • • • • • • 99 Check-Write (CHECK) • • • • • • .100 write SUTAB/LITTAB Record (WRITE) • • • 100 Optimization Table (OPTAB) • • .103 CHAPTER 7: SUBSCRIPT HANDLING PHASE (IEX~O). • • • • • • • • • • .101 Purpose of the Phase • • .101 Subscript, Left Variable and For Statement Tables. • • • • • • • • • 103 Constituent Routines of Subscript Handling Phase • • • • • • • • • • • • • 103 Initializa tion. • • • • • 103 Read SUTAB. • • • • .105 Scan SU'TAB. • • • • • • • • • • .105 Sort SUTAB (SORTSU) • • • • • • .106 Read and Sort LVTAB (SORTLE and SORTLE!) • • • • • • .106 Construct OPTAB (OPTAB) • • 106 Termination (TERMIN) • • • • • • • • • 107 ~rite OPTAB (OTACHA) • • • • • • • • • 107 Read SUTAB/LVTAB (READ) • • • .107 Sort SUTAB/LVTAB (SORT) • • • .107 CHAPTER 8: COMPILATION PHASE (IEX50) • • 108 Purpose of the Phase • • .108 Compilation Phase Operations • • .108 Phase Input/Output • • • • • • • 110 operator/Operand Stacks. • • .110 Control of Object Time Registers • .113 Decision Matrices • • • • .116 Compile Time Register Use. • .116 Constituent Routines of the Compilation Phase. • • • • • • 116 Phase Initialization. • .118 Scan to Next Operator (SNOT). • .119 Compare (CaMP). • • • • • • • • • • .119 Blocks and Compound Statements • • • • 120 Compiler Program No.O (CPO>' • • • 120 Compiler Program No.16 (CP16) • • • 120 Switches • • '• • • • • • • • • • • • • 120 Compiler Program No.~ (CP~) • • • • 121 Compiler Program No.85 (CP85) • • • 122 Compiler program No.56 (CP56) • • • 122 Compiler Program No.59 (CP59) • • • 122 Compiler Program No.~l (CP~1) • • • 122 Compiler Program No.38 (CP38) • • • 122 Labels. • • • • • • • • • • • .122 Compiler Program No.1 (CP1) • • • • 122 Goto Statements • • • • • • • • • • • 123 Compiler Program No.6 (CP6) • • • • 123 Compiler Program No.56 (CP56) • • • 123 Compiler Program No.62 (CP62) • • • 123 Arrays • • • • • • • • • • • • • • • • 124 Array Declarations • • • • • • • .125 Subscripted Variables • • • • • • • 126 Compiler Program No.~ (CP~) • • • • 127 Compiler Program No.52 (CP52) • • • 127 Compiler Program No.36 (CP36) • • • 128 compiler Program No.51 (CP51) • • • 128 Compiler Program No.5~ (CP5~) • • • 130 Compiler Program No.~l (CP41) • • • 130 Compiler Program No.38 (CP38) • • • 130 subscript Handling Phase Operations. • .101 Procedures • • .131 Proce:ture Declaration. • • • • .131 Procedure Call. • • • • • • • • .132 Compiler Program No.4 (CP4). .133 Operand Recognizer (OPDREC). .134 Compiler Program No.16 (CP16) • • • 134 Compiler Program No. 64 (CP64) • • • 134 compiler Program No.57 (CP57) • • • 134 Integer Power Routine (IUB1) .160 Real-Real Routine (DHEB2). • .160 Real-Integer Power Routine (IIB1) • • • • • • • • • • • .160 Real Power Routine (HOB1) • • • • .161 Compiler Program No.68 (CP68). • .161 Code Procedures. • • • • • • • • .135 Compiler Program No.83 (CP83) • • • 136 Semicolon Handling • • • • • • • • • • • 161 Compiler Program No.24 (CP24) • • • 161 Compiler Program No.25 (CP25) • • • 161 Compiler Program No.23 (CP23) • • • 161 compiler Program No.7 (CP7) • • • • 161 Standar:t Procedures. • • • • • • .136 Compiler Program No.64 (CP64) • • • 136 Compiler Program No.61 (CP61>. • .137 For statements • • • • • • • • • • • • .138 Counting Loops • .138 Elementary Loops • • .139 Normal Loops • • .140 Subscript Optimization • .143 Compiler Program No.6 (CP6). .144 Compiler Program No.40 (CP40). • .144 Compiler Program No.43 (CP43) • • • 147 Compiler Program No.45 (CP45) • • • 147 Compiler Program No.47 (CP47) • • • 147 Compiler Program No. 49 (CP49) • • • 148 Subscript Initialization Routine (DwG3 or USAl) • • • • • • • • • • 148 subscript Incrementation Routine (OVAl). • • • • • • • • • .151 Compiler Program No.81 (CP81) • • • 151 statements. • • • • • .151 Compiler Program No.12 (CP12) • • • 151 Compiler Program No.21 (CP21) • • • 151 Compiler Program No.20 (CP20) • • • 152 ~ssignment Conditional Statements Compiler Program Compiler Program Compiler Program Compiler Program No.8 (Cp8) • • • No.78 (CP78) •• No.17 (CP17). • No.18 (CP18) •• .153 .154 .154 .154 • 154 Conditional Expressions. • • COmpiler Program No. 64' Compiler Program No.80 Compiler Program No.34 Compiler Program No.65 Compiler Program No.78 Compiler Program No. 87 Compiler Program No.79 • • • • • .154 (CP64). • .156 (CP80) • • • 156 (CP34) • • • 156 (CP65) • • • 156 (CP78) • • • 156 (CP87) • • • 156 (CP79) • • • 157 Boolean Expressions. • Compiler Program Compiler Program Compiler program Compiler Program Compiler Program • . . . • . 157 No. 64 No.65 No.67 No.76 No.77 (CP64) • • • 158 (CP65)' •• 158 (CP67). • .158 (CP76) ~ •• 158 (CP77) • • • 158 Expressions and Relations • .158 Compiler Program No.64 (CP64) • • • 158 Compiler Program No.66 (CP66) • • • 158 compiler Program No.67 (CP67) • • • 159 Compiler Program No.63 (CP63) • • • 159 Compiler Program No.68 (CP68) • • • 159 compiler Program No.69 (CP69) • • • 159 Integer-Integer Routine (OHZB1) •• 160 Integer Division Routine (ISB1) •• 160 Integer Multiplication Routine (IPB1). • • • • • • • • • • • • .160 ~rithmetic context switching. • • Compiler Program compiler Program Compiler Program Compiler Program Compiler Program No.19 No.22 No.33 No.70 No.71 • • • • • • 161 (CP19). • .161 (CP22) • • • 162 (CP33) • • • 162 (CP70) • • • 162 (CP71). • .162 Logical Error Recognition. • Compiler Program No.26 Compiler Program No.27 Compiler Program No.28 Compiler Program No.29 Compiler Program No.30 Compiler Program No. 31 Compiler Program No.72 Compiler Program No. 73 Compiler Program No.74 Compiler Program No.75 Compiler Program No.84 Compiler Program No.86 • • • • • • 162 (CP26) • • • 162 (CP27) • • • 162 (CP28) • • • 163 (CP29). • .163 (CP30) . . . . 163 (CP31> • • • 163 (CP72) • • • 163 (CP73) • • • 163 (CP74). • .163 (CP75) • • • 163 (CP84) • • • 163 (CP86). • .164 Close of Source Module • • • 164 Compiler Program No.3 (CP3) • • • • 164 Subroutine Pool . . . . . . . . . . . . . . . . 164 Change Input Buffer (JBUFFER) • • • 164 Next OPTAB Entry (NXTOPT) • • • • • 164 Error Recording (SERR) • • • • • • 164 Conversion Integer-Real (TRINRE) .164 Conversion Real-Integer (TRREIN) .164 Generate Object Code (GENERATE) •• 165 Store Object Time Registers (CLE~RG) • • • • • • • • • • • .165 Operand Recognizer (OPDREC) •• • .165 Update OS~ Pointer (MAXCH) ..165 Semicolon Handling (SCHDLl • .165 ROUTINEl • • ••• • .165 ROUTINE2 • • .166 ROUTINE3 • • .166 ROUTINE4 • • .166 ROUTINES • • .166 ROUTINE6 • • .166 ROUTINE7 • • • • .. .. • • • • .166 ROUTINE8 • • • • • • • • .166 ROUTINE9 • • .166 ROUTINI0 • • .166 ROUTIN11 • • .166 ROUTIN12 • • .166 ROUTIN13 • • .166 ROUTIN14 • • .167 ROUTIN15 • • .167 Program Block Number Handling (PBNHDL) • • • • • • • .167 Parameterless procedure Statement (PLPRST). • .167 Termination Phase (IEX51) • • • • .167 Pro3ram Block Table IV (PBrAB4) • • • • • • • .167 L~bel ~ddress Table (LAT) • • .167 Data Set rable (DSTAB) • • • • • 168 ~ddress Table and END Record .169 Statement of Object Time storage Requirements • • • • • • • • • • • 169 Dia3nostic Output • • • • • • • • 169 End of CDmpilation. • • .169 CHAPrER 9: COMPILE TIME ERROR DETECTI~N AND DIAGNOSTIC OUTPUT • .170 Error Detection. • • • • • • • • .170 Warnin3 Errors (Severity Code W) • • • 170 serious Errors (Severity Code S) • • • 170 Scan 1/11 Phase (IEXll) • • • 170 Identifier Table Manipulation Phase (IEX20) • • • • • • • • • • 170 Scan III Phase (IEX30). .170 Subscript Handling Phase (IEX40) • • • • • • • • • • 170 Compilation Phase (IEX50) • • 170 Termination Phase (IEX51) • • 171 rerminatin3 Errors (severity Code T) • • • • • • • • • • • • • • • 171 Diagnostic output • • • • • 171 Error Pool • .172 Message POOl • • • • • • .172 Error Message • • • • .174 L03ic of the Error Message Editing Routine. . • • • • • • • • • .174 PUT/GET (IHIGPR) PUT • • • GET • • • ~UTPUT • • INPUT •• ~PENGP •• CLOSEGP • OPENEXIT. CAP1GP •• rHUNKOUT. THUNKIN • • • • • • • • • • • INARRAY/INTARRAY(IHIIAR) • .181 INBARRAY (IHIIBA). • .181 INBOOLEAN (IHIBO) • • • .182 INREAL/ININTEGER (IHIIDE). ALG~L LIBRARY • • • • .182 OUTREAL (IHISOR) • .182 OUTREAL (IHILOR) • .182 OUTARRAY (IHIOAR) • • • .182 OUTBARRAY (IHIOBA) • • • .182 OUTBOOLEAN (IHIOBO) • • • • .182 OUTINTEGER (IHIOIN) • • • .182 OUTSTRING (IHIOST) • .182 (IHIOSY) • • .183 OUTTARRAY (IHIOTA) • • .183 • .176 FiKed Storage Area (IHIFSA) • • • • • • 176 Common Data Area. • • • • • • • • • • 176 FiKed Storage Area Routines • .176 Initialization (ALGIN) • • • 177 Prologue (PROLOG) • • • • • • • .177 Epilogue (EPILOG) • • • • .177 Call Actual Parameter, Part 1 (CAP1) • • . • • • • • • • • • Call Actual Parameter, Part 2 (CAP2) • • • • • • • • • Value Call (VALUCALL). Return Routine (RETPR~G) • • C:'l.ll Switch Element, Part 1 (CSWE1) . • • • • • • • • . • C~ll Switch Element, Part 2 (CSWE2) . • • • ••• • Trace (TRACE).. • ••• Load Precompiled Procedure (LOADPP) • • • • • • • • • standard Procedure Declaration (SPDECL) • • • . • • • • • • Get Main Stora3e (GETMSTO) • • Program Interrupt (PIEROUT). FSAERR • • • • . • • • • • rermination (ALGrRt-lN) • • • • Integer tD Real Conversion (CNVIRD) • • • • • • • • • • Real to Integer ConVersion (CNVRDI/ENTIER) • • .177 .178 .178 .178 • .178 • 179 .179 • .179 .179 • .179 .179 • .179 .179 .179 .179 SYSACT (IHISYS). • • • SYSACT. • SYSACTl SYSACT2 SYSACT3 SYSACr4 SYShCT5 SYSACT6 SYShCT7 • SYSACT8 SYSACT9 • SYSACT10. SYSACTll. • • SYSACT12. SySACT13 • • • • • • SYSACT14. SYSACT15. Subroutine Pool (IHIIOR) • CLEARNOTTAB • CLOSE •• CLOSEPE • CONVERT • DCBEXIT • ENDOFDATA ENTRYNOTTAB • EVDSN •• NEXTREC • ~PEN. Input/output Procedures • • .182 INSYMBOL (IHIISY). OUTSYI~OL CHAPTER 10: .180 .180 .181 .181 .181 .181 .181 .181 .181 .181 .181 • • .180 SYNAD •• • • • .183 • • • • • • • 183 • • • 183 • .183 • .183 • .183 • .183 • .183 • • • • • .183 • .183 .184 • .184 • .184 • • • • • • .184 • • • • • • .184 • .184 • .184 • • • • • • • • • • • • .184 .184 .184 .185 .185 .185 .185 .185 .185 .185 .185 .185 ~~them~tical Standard Functions. • .185 APPENDIX Ill: COMPILER CONTROL FIELD (HCOMPMOD). • • • • • • • • • • • • .276 Jbject Time Error Routine (IHIERR) • • .186 APPENDIX V-A: PROGRAM CONTEXT MATRIX • • 278 CHAPTER 11: rHE OBJE:r MODULE. .181 Jbject Module. .181 APPENDIX V-B: STATEMENT CONTEXT MATRIX .279 Load Module. • • • • • Jbject Time Tables. • Program Block rable (PBT) L~bel Address Table (LAT) Data Set rable (DSTAB) • • ~ote Table (NOTTAB) • • • • • D~t~ storage Area (DSA) • storage Mapping Function (SMF) Return Address Stack (RAS) • Object rime Register Use. • • .188 • .188 .188 .189 .190 • .191 .191 • • 193 .193 • .194 APPENDIX V-C: EXPRESSION CONTEXT MATRIX. ·········· APPENDIX VI: COMPILE TIME ERROR DErECTION • ·········· APPENDIX VII: OBJECT TIME ERROR DErECTION . ·········· .219 .280 .283 APPENDIX VIII: COMPILE TIME WORK AREA SIZES, AS A FUNCTION OF THE SIZE oprION • • • • • • • • • • • • • • • • • 285 FLOwCHARrs • • • • • • • • • • • • • • • 196 APPENDIX I-A: CHARACrER SET -- FIRST TRA~SLATI0N JF THE SOUR:E MODULE IN rHE SCAN I/II PHASE • • • • • • • • • .212 APPENDIX I-B: CHARACTER SET -MJDIFICArION LEVEL 1 rEXr • • .212 APPENDIX I-C: CHARACrER SET -MJDIFICATION LEVEL 2 TEXT • • .212 APPENDIX 1-0: CHARA:TER SET -- STACK OPERArORS USED IN rHE COMPILATION p H~SE • • • • • • • • • • • • • • • • .273 APPENDIX II: INrERNAL REPRESENTATION OF JPERANDS • • • • • • • • • • • • • .274 III: INTERNAL REPRESENTATION OF SrANDARD PROCEDURE DESIGNATORS • • • 275 APPE~DIX APPENDIX IX-A: STORAGE MAPS OF THE CO~STITUENT LOAD MODULES OF THE ALGOL COMPILER. • • • • • • • • • • • • • • IEXOO - Directory. • • • • • IEX10 - Initialization Phase • • IEX11 - Scan 1/11 Phase. • • IEX20 - Identifier Table Manipulation Phase. • • • • IEX21 - Diagnostic output. IEX30 - Scan III Phase • • IEX31 - Diagnostic Output. IEX40 - Subscript Handling Phase IEX50 - Compilation Phase. • IEX51 - Termination Phase. • APPENDIX IX-B: STORAGE MAP OF THE OBJECT MODULE (AT EXECUTION) • • .286 .286 .287 .288 .289 .290 .290 .291 .292 .293 .294 .295 APPENDIX X: SUMMARY OF COMPILER PRJ GRAMS. • • • • • • • • • .296 APPENDIX XI: INDEX OF ROUTINES • • .307 FIGURES Figure 1. Constituent phases of the AL30L Compiler. • • • • • • • • •• Figure 2. I/O Activity by Data set and Phase • • • • • • • • • • • • • • • • • Figure 3. Activity Table showing the processing of source text and tables by phase. • • • • • • • • • • • Figure !I. Use of main storage by ALG~L Compiler. • • • • • • • Figure 5. Jption, DDname and Heading fields, and pointers • • • • • • • • • • Figure 6. PARMLIST Table entry for a Compiler option key-word. • • • • Figure 7. Scan 1/11 Phase. Diagram illustrating functions • • • • • • • • • Figure 8. Scan 1/11 Phase Input/Output. • • • • • • • • • • • • • Figure 9. Identifier Characteristic. Figure 10. Identifier Table entry for all identifiers except declared ~rr~y, procedure and switch identifiers and labels. • • • • • Figure 11. Identifier Table entry as constructed in the Scan 1/11 Phase for ~ declared array identifier • • Figure 12. Identifier Table entry for a declared procedure identifier • • • • Figure 13. Identifier Table entry constructed in the Scan 1/11 Phase for ~ declared switch identifier • • • • Figure 14. Identifier Table Entry constructed in the Scan 1/11 Phase for a declared label • • • • • • • • • • Figure 15. Program block heading entry • Figure 16. Program block heading entry, as transmitted to the SYSUT3 d~t~ set. . • • • • • • • • • • • • Figure 17. For statement heading entry ••••••••••••••• Figure 18. For statement closing entry •••••••••••• •• Figure 19. Diagram illustrating the processing of the Identifier Table • • • Figure 20. Scope Handling Stack oper~tors • • • • . • • • • . • • • • • Figure 21. Group Table entries for a for statement and for a block or procedure • • • • • • • • • • • • • • • Figure 22. One-byte Scope Table entry. Figure 23. One-byte Program Block Number rable entry. • • • • • . • •• Figure 2!1. Chart showing the logical flow in the search for the opening delimiter • • • • • • • • • • ~ • • Figure 25. Exits from Scan 1/11 Phase. Figure 26. Private ~rea acquired by the 3c:in 1/11 Phase, showing pointers initialized. • • • • • • • • • •• Figure 27. Source text buffers and pointers. • • • • • • • • • • . . • Figure 28. Heading Entry constructed at irritialization in Identifier Table for Program Block 0 • • • • • • • • • • 14 17 18 19 27 27 32 35 36 37 37 38 38 38 39 39 39 39 !l0 !l2 45 !l6 46 47 49 52 53 53 Figure 29. Switches used in Scan 1/11 Phase • • • • • • • • • • • 53 Figure 30. Branch Address Table BPRTAB. • • • • • • • • • • 54 Figure 31. KEYTAB keys used in TRANSOP routine • • • • • • • 55 Figure 32. Delimiter Table (WITAB) • • • 61 Figure 33. Internal Names of boolean constants 'TRUE' and 'FALSE' • • • • • • 63 Figure 3!1. Identifier Table Manipulation Phase. Diagram illustrating the functions of the principal constituent routines. • • 69 Figure 35. Identifier Table Manipulation Phase Input/Output • • • • 70 Figure 36. Identifier Table (ITAB) entry, showing the identifier's Data Storage Area displacement address, as inserted by the Identifier Table Manipulation Phase in bytes 9 and 10, for all identifiers except those of declared procedures, switches and labels. • • • • • • • • • • • • • • • • 70 Figure 37. Two-byte entry in Program Block Table II (PBTAB2) • • • • • • • • 71 Figure 38. Private Area acquired by the Identifier Table Manipulation Phase • • • • • • • • • • • • • • • 72 Figure 39. Scan III Phase • • • • • • • • 76 Figure !l0. Scan III Phase input/output. 78 Figure 41. Function of pointers NOTER and NOTEW in inputloutput operations on the SYSUT3 data set • • • • • • '• • • 78 Figure 42. Diagram illustrating the handling of Identifier Table (ITAB) records • • • • • • • • • • • • • 79 Figure 43. Entry in Left Variable Table • • • • • • • . • • • • • • • 82 Figure 44. Fourteen-byte Subscript Table entry • • • • • • 83 Figure 45. Entry in Critical Identifier Table (CRIDTAB). • • 83 Figure 46. Entry for an array identifier in the Array Identifier Stack (ARIDSTAB). • • • • • • • • • 8!1 Figure 47. Private Area acquired by Scan III Phase. • • • • • • • • • • • • 87 Figure 48. Subscript Handling Phase • • • 102 Figure 49. Subscript Handling Phase Input/Output • • • • • • • • • • • • • • 103 Figure 50. Optimization Table (OPTAB) entry • • • • • • • • • • • • • • • • • 10!l Figure 51. Diagram illustrating use of the private area • • • • • • • • • • • • 104 Figure 52. Compilation Phase. Diagram illustrating phase operations. • .109 Figure 53. Compilation Phase Input/Output. • • • • • • • • • .110 54. Diagram illustrating the fUnction of the ~perator/Operand stacks • • • • • • • • • • • • • • • • • 112 Figure 55. Five-byte operand representing an intermediate value or address contained in an object time re~ister or temporarily stored in the register's reserved storage field in a Data Stora~e ~rea • • • . • • • • • • • 113 Figure 56. Control Fields governing use of object time general purpose registers • • • • • • • • • • • • • • • 114 Figure 57. Control Fields governing use of floating point registers, • • • • 115 Figure 58. Diagram showing the compiler prograrr~ • • • • • • • • • • • 117 Figure 59. Private Area acquired by Control section IEX40001 for the Compilation Phase (IEX50) • • • • .118 Fi~ure 60. Entry in Program Block Table III (PBTAE3). • • • • • • • .120 Figure 61. Diagram showing code generatej for switch declaration and s~itch designator • • • • • • • • • • • 121 Figure 62. Object Time Storage Mapping FUnction of an array • • • • • • 125 Figure 63. Code generated for declared type procedure and procedure call • • • 132 Fi~ure 64. I/~ Table (IOT~B) • • .138 Figure 65. For statement classification byte in the For statement rable • • • • • • •• • .139 Figure 66. Logical structure of the code generated for a Counting Loop • • • 141 Figure 67. Logical structure of the code generated for an Elementary Loop or Normal Loop • • • • • • • • • • • • • 141 Fi~ure 68. Logical structure of the code generated for a Counting Loop • • • 142 Figure 69. Logical structure of the code generated for an Elementary Loop .145 Figure 70. Logical structure of the code generated for an Elementary Loop .146 Figure 71. Entry in subscript Table-C (SUTABC) • • • • • • • • • • • • • • • • 148 Fi~ure Figure 72. Logical structure of the code generated for a Normal Loop. • • .149 Figure 73. Logical structure of code generated for Elementary Loop or Normal Loop • • • • • • • • • • • • • • 150 Figure 74. :omposition and execution sequence of Load MOdules IEX21" IEX31, and IEX51, containing the Error Message Editing Routine (IEX60000) • • • • • • • • • • • •• 171 Figure 75. Error pattern stored in Error Pool. • • • • • • • • •• • .172 Figure 76. Message Pool entry. • • .172 Figure 77. Three-byte Insertion Code in the Message Pool entry (see Figure 76) • • • • • • • • • • • • .172 Figure 78. Format of the printed error message • • . • • • • . • • • • • • • • 174 Figure 79. Four-byte parameter list entry for a standard procedure call •• 180 Figure 80. Label of a PUT/GET record •• 180 Figure 81. Module names of mathematical standard functions contained in the ALGOL Library. .186 Figure 82. Composition of the object module. • • • • • • • • • • • • • .187 Figure 83. Sketch showing the organization of the load module • • • • 188 Figure 84. Object time Program Block Table • • • • • • • • • • • • • • • • .189 Figure 85. Object time Label Address rable (LAT) • • • • • • • • • • • • • • 189 Figure 86. Content of the data set entries and the PUT/GET Control Field .190 Figure 87. Entry in the object time Note Table (NOTTAB). • • • • • • • 191 Figure 88. Content of the Data Storage Area • • • • • • • • • • • • • • 192 Figure 89. Content of the 8-byte storage field of a formal parameter called. . . . . . . . . . . . . . . ." .193 Figure 90. Entry in the object time Return Address Stack (RAS) • • • • • • • 194 Figure 91. Object time register use. • .195 CHARTS ~LGJL Compiler - Jverall ~low. .197 Directory (IEKOO) • • • • • • • .198 Initialization Phase (IEX10) • • • .201 Scan 1/11 Phase (IEK11) • . • • • • 203 Identifier Table Manipulation Phase (IEX20) • • • • • • • • • • • • • • • .215 Diagnostic Output (IEX21) • • • • • .218 Scan III Phase (IEX30) • • • • • • .220 Dia~nostic Output (IEX31) • • • • • .234 subscript Handling Phase (IEX40) • .235 compilation Phase (IEX50) • • • • • 238 Termination Phase (IEX51) • • • .262 ALGJL Library • • • • • • • • • • • • • .265 Page of GY33-BOOO-O Revised January 15, 1972 By TNL GN33-B129 SUMMARY OF AMENDMENTS FOR GY33-8000-0 OS Release 21 TITLE CHANGES Maintenance Names of reference publications have been changed to reflect their current titles. 11 Page of GY33-8000-0 Revised January 15, 1972 By TNL GN33-8129 CHAPTER 1: INTRODUCTION PURPOSE OF THE COMPILER The OS/360 ALGOL Compiler translates a source program written in the OS/360 ALGOL Language into an object module which may be linkage edited and executed by an IBM Systeru/360 computer. The final load module consists in part of code generated by the Compiler and, in part" of routines (in load module form) drawn from the ALGOL Library. The Library is a data set containing ALGOL standard I/O procedures and mathematical functions, as well as auxiliary routines required by the object module at €xecution time. The Library routines are combined with the generated code at linkage edit time, to form an executable load module. The Compiler prints out a listing of the source module and of the Identifier Table, if the SOURCE option is specified" and prints out diagnostic messages reflecting syntactical errors detected in the source module, as well as other errors occurring during compilation. THE COMPILER AND SYSTEI'l SYSTE~1/360 OPERATING The ALGOL Compiler is a processing program of the System/360 Operating System. It is executed under the control of the OS supervisor" and utilizes the I/O and other services of the OS Control Program. A compilation is executed as a jOb step by means of the job control facilities of the Operating System. The use of the Compile!. is expla.ined in the OS AL~()~ l'rogt'~:r:~ s Gilide,. sole typewriter, device (magnetic reader) • and a sequential tape unit or card ORGANIZATION OF THE COMPILER Figure 1 indicates the modular structure of the ALGOL compiler as well as the essential operations performed in each of the constituent phases. The Compiler consists of ten load modules, the first of which, called the Directory" remains in main storage throughout compilation. The other nine modules" representing the Working phases of the compiler" are loaded and executed in sequence. DIRECTORY (IEXOO) The Directory consists of a preassembled Common Work Area, used by .all phases, as well as a number of auxiliary routines providing interface with the Operating System. The latter include the initial entry and final exit routines which receive control from, and return control to, the Operating System. INITIALIZATION PHASE (IEX10) The Initializatiqn Phase: MACHINE.SYSTEM 1. The m~n~mum machine configuration required for execution of a compilation using the ALGOL compiler is as follows: Sets up a control field in the Common Work Area. reflecting the opticns specified in the EXEC Statement invoking the Compiler. 2. Determines the sizes of the private work areas required by the individual phases. 3. Acquires main storage for a source text input buffer and for the Error Pool. 4. Opens data sets. 5. Executes a SPIE macro which specifies the address of the program interrupt routine in the Directory. 1. 2. An IBM System/360 Model 30, 40, 50, 65, 75, or 91, or an IBM System/370 Model 135 (or higher} with the scientific instruction set and at least 64K bytes of main storage capacity. At least one direct access input/output device; a printer; a con- Chapter 1: Introduction 13 ALGOL COMPILER EXEC CALL/LINK/XCTl ATTACH I EXOO IEXIO INITIALIZATION LINK DIRECTORY PHASE I I XCTL SYSIN IEXII Source oVtodule SCAN 1/11 5Y5UTl SY5UT3 .oV.odified Source Text (ModiFication level 1) Identifier Table r--- ----, ---I lv1ain Storoge I I lv1ain Storage I Errof Pool I P.B. No. Table SYSUT3 I L ______ Identifier Table I I f-- I Error Pool I Group Table I XCTl r-------, IEX20 (lTAB) ! I I I I Scape Table I P.B. No. Table I L ______ J ! I I PHASE IB) IB) IAJ RETURN SYSPRINT Scan 1/11 SYSPUNCH Source fv\odule listing Reads the source module and lists all valid identifiers declared or specified in the source module in the Identifier Table, together with descriptive internal names; stores character strings in the Constant Pool, replacing them in the output text by internal names containing the string's relative address; and generates TXT records of the strings stored in the Constant Pool. Replaces all delimiter words and multi-character operators by one-byte symbols in the output text (called Modification level 1). Detects syntactical errors and records them in the Error Pool. Prints out a listing of the source module if the SOURCE option is specified. ESDRecord & TXT Records of Constant Pool IDENTIFIER I TABLE /'MNIPULATION PHASE i Prog,Blk.Toblelll I Error Pool I L _ _ _ _ _ _ ...J I XCTl r- - - - - - , 1-- - - ---, ---1 lv1ain Storage I I Main Storage I Error Pool I IL I Diognostic Messoges f-DIAGNOSTIC _ _ _ _ _ _ ...l I SYSUT3 SYSPRINT -- Identifier Table Identifier Table listing IITAB) SySPR!NT IEX2l Ie) r--- OUTPUT IA) IB) SySUTl I-Aodified Source Text (Iv'oodification Levell) Identifier Table IITAB) r-------, I I Scope Table I I Group Table !--. L _ _ _ _ _ _ ..J I SYSUT2 I XCTl I Main Storage IEX30 Modified Source Text (Modification Level 2) PHASE r------'l Main Storage I Error Pool I For Statement IL Table ______ I XCTl r- - - - ----, I Main Storage r-· I I L _ _ _ _ _ _ --I DIAGNOSTIC OUTPUT IE) XCTL SYSUTJ r-------, I~~TAB) I N\oin Storage I I IFor Statement ~ I Table L _ _ _ _ _ _ -...l 'iAB) I I I ...JI I SYSLIN/ SYSUT3 SYSPUNCH Subscript Table (SUTAB) Left Variable Table (LVTAB) TXT Records of Constant Pool IEX3l I I Error Pool ! I SCAN III ..........j Ii;bl I--- SYSUT2 fv\odiFied Source Text (/IIoodification Level 2) SYSUT3 Optimization Table IOPTAB) ! I I r-- - --'-l Ifv\o;n Storage XCTl I Iprog.Blk.Table II I rIFor Statement ITable L _ _ _ _ _ _ -.JI IEX50 I COMPILATION PHASE XCTl ---- -l IEX5l Diagnostic Output IE) Subscript Handling Const-ructs the Optimization Table, listing optimizable subscript expressions in for statements, in which no term occurs as a 'eft variable in the for statement. Optimizable subscripts are identified by comparing each term in the expressions listed in the Subscript Table with the entries from the same for statement in the Left Variable Table. Also re-classifies for statements in the For Statement Table. IF) SYSUT3 Optimization Table (OPTAB) Compilation ......, Main Storage I I For Statement I Table I I IL _ _ _ _ _ _ J' SYSLIN/ SYSPUNCH . __ J TFR/ r------i ~i~t:teR:i::s~fs :~i~ Ss\~rr~~: ra~i::t~~;stsc~~~~jet~t SYSPRINT Storage ~~~ui~;~es~f~ Messages 14 muw ~ END, ESD, TXT & RlD Records for Loble Address, Program Block, ~d~~e~~ti abr~s ! RETURN I Figure 1. Generates TXT and RlD records of tables used by the object module at execution time, as well as ESD records for standard 1/0 procedures and mathematical functions, and the END record. Edits and prints out errors recorded in the Error Pool or prints I I Prog.Blk.T!;Oblel1ll I I/O Table I I label Addr.Tablel L~r~ ~~I___ J ATtn ij,~~;,i;;~'~;; Termination TXT & RLD Records of Generated Obiect Code I f-_ I I Reads the f.ioodification level 2 source text and generates an object module. Uses the Far Statement Table to determine the logical structure of the generated code for each for statement. Uses the Optimization Table to generate code which pre-calculates a bose address and an incremental displacement for optimizable subscripts of arrays occurring in for statements. Generates code to link precompiled standard functions and I/O procedures in the library t-o the object module. 1-------, ---1 fv\oin Storage I Reads the Modification Level I source text output by Scan 1/11 and generates a new source text (Iv\odification Level 2), in which externally represented operands in statements are replaced by the corresponding internal names in the Identifier Table, Stores constants in the Constant Pool, replacing them by intemal names containing the storage address, and generates TXT records of the Constant Pool. Classifies for statements in the For Statement Table and lists linear subscript expressions and left variables in counting loop and elementary loop for statements, in the Subscript Table and Left Variable Table, respectively. Edits the contents of the Error Pool and prints out diagnostic messages reflecting the errors detected by the Scan III Phose. ! IF) Scan III Diagnostic Messages IEX4Q· HANDLING PHASE Diagnostic OlJtput Edit~ tM contents of the Error Pool and prints out diagnostic messages reflecting the errors detected by the preceding phases. SYSPRINT SuBSCRIPT ID) Identifier Table f.iwJnipulation Allocates object time storage addresses to all identifiers (other than declared procedure ~nd switch identifiers and labels) listed in the Identifier Table, noting the relative addresses in the corresponding internal names in the table; records the total storage allocation for identifiers declared or specified in each block or procedure in Program Black Table II, and records multiple declaration errors in the Error Pool. Prints oot a listing of the Identifier Tobie if the SOURCE option is specified. (D) SYSUT3 I Initialization Determines sizes of work areas acquired by the individual phases, according to the SIZE option; opens data sets;. sets switches reflecting compilation options; and acquires storage for on input buffer and the Error Pool. Also executes the SPIE mocro-instroction. SYSLIN/ ..JI (lTAB) Directory Contains entry and exit routines which receive control from and return control to the Operating System. Also contains Common Work Area for inter-phase communication, as well as program interrvpt, SYNAD and EOD routines. Resident in main storage during compilation. Constituent phases of the ALGOL Compiler l the exit routine in the Directory. DIAGNOSTIC OUTPUT (IEX21) SCAN 1/11 PHASE (IEX11) The Scan 1/11 Phase reads the source module and constructs the Identifier Table, listing all identifiers declared or specified un the source module. The Identifier Table is used in constructing a five-byte internal name for each and every identifier declared or specified in the source module. In the case of declared labels, procedures, and switches, the internal name (constructed in its entirety in this phase) contains the relative address of an entry in the object time Label Address Table. In the case of all other identifiers, the internal name (constructed partly in this phase and partly in the succeeding phase) contains the relative address of an object time storage field. The internal name ultimately replaces all externally represented operands in the source text (see Scan III Phase below). The first of the Level in the Scan 1/11 Phase also generates the of two intermediate transformations source text, called Modification 1. The principal changes reflected first transformation include: 1. An initial translation of all ters to an internal code. charac- 2. The removal of all type declarations and specifications. 3. The replacement of ALGOL delimiter words and multicharacter operators by one-byte symbols. IDENTIFIER TABLE MANIPULATION PHASE (IEX20) The Identifier Table Manipulation Phase processes the Identifier Table constructed by the Scan 1/11 Phase. To each identifier listed in the table, excepting declared procedure and switch identifiers and labels, an object time storage field is aSSigned, the relative address being inserted in the corresponding entry in the Identifier Table. This address specifies the pOSition of the identifiers storage field, relative to the beginning of a Data Storage Area. The Data Storage Area consists of the total amount of object time storage space allocated to all identifiers declared or specified in the particular block or procedure. The size of the Data Storage Area allocated to each block and procedure is recorded in Program Block Table II and transmitted to the Compilation Phase via the Common Work Area. See "Diagnostic output" below. SCAN III PHASE (IEX30) The Scan III Phase reads the Modification Level 1 text output by the Scan 1/11 Phase and generates a further transforrration of the source text (called Modification Level 2). In this version, the external names of operands in statements are replaced by the internal names constructed for declared or specified identifiers in the Identifier Table. Similarly, all ccnstants are replaced by internal names containing a Constant Pool address. After being stored in the Constant Pool, ccnstants are subsequently transferred to TXT records. Logical features of all for staterrents are detected and recorded in the For Statement Table. Among other things, the For Statement Table assigns each for statement to one of three loop classificaticns (Normal Loops, Counting loops and Elementary Loops). The loop classification specifies the logical structure of the cede generated in the Compilation Phase for each for statement. Subscript expressions of arrays found in for statements, classified counting loops or Elementary Loops, are analyzed and stored in the SUbscript Table, provided they satisfy certain criteria with respect to the terms in the expression and their linearity within the for statement. Integer left variables in Counting and Elerrentary Loops are listed in the Left Variable Table. DIAGNOSTIC OUTPUT (IEX31) See "Diagnostic Output" belo'N. SUBSCRIPT HANDLING PHASE (IEX40) The Subscript Handling Phase constructs the Optimization Table, listing those subscript expressions of arrays contained in for statements. which can be optimized in the code generated for for statements. Optimization refers to the minimization of computing time involved in addressing the elements of an array. Chapter 1: Introduction 15 COMPILATION PHASE (IEX50) The Compilation Phase reads the Modification Level 2 text output by the Scan III Phase and generates object code to perform the operations designated by statements in the source module. operand addresses in the generated code are obtained from the internal names of operands in the Hodification Level 2 text. The logical structure of the object code generated for a for statement is governed by the particular for statement's loop classification in the For Statement Table. Where a for statement contains optimizable subscripts, the Optimization Table is used in generating code which minimizes the computing time involved in addressing array elements. TERMINATION (IEX51) The Termination Phase constructs the Data Set Table and Program Block Table IV; generates TXT and RLD records for the latter two tables and for the Label Address Table; generates an END record as well as ESD records for all Library routines to be combined with the oojectmodule; processes any errors detected in the Compilation Phase; and terminates the Compiler by releasing main storage and returning control to the invoking program via the Final Exit routine in the Directory. The Termination Phase logically constitutes an extension of the COllipilation Phase and is described in the same chaPter, namely Chapter 8. transferred directly to a terminating routine in the Termination Phase., after all recorded errors have been printed out ty the Error Message Editing Routine in the appropriate diagnostic output modUle (see Figure 1). ALGOL LIBRARY The Library is a partitioned data set (SYS1.ALGLIB) consisting of routines which perform the standard mathematical functions and I/O procedures defined in the ALGOL Language. The appropriate routines, corresponding to the standard functions or I/O procedures called in the source module, are linked to the object module at linkage edit time. ESD records to call standard fUnctions or I/O procedures are generated in the Termination Phase. The Library also contains the Fixed Storage Area, which consists of a set pf auxiliary routines and control fields required for execution of the object module. The auxiliary routines include the Initialization and Termination routines, as well as other routines which acquire or release main storage and administer the calling of procedures. The Library is further described in ChaFter 10. An ob ject tirr,e Error Routine is provided, which forms a module of the SYS1.LINKLIB data set. The Error Routine, which is loaded only if an Object time error is detected, prints out an appropriate error message and terminates the object program. The error routine is described in Chapter 10. DIAGNOSTIC OUTPUT (IEX21, IEX31, AND IEX51) THE OBJECT MODULE The compile time Error !1essage Editing Routine, which forms a control section of each of load modules IEX21, IEX31, and IEX51, prints out diagnostic messages reflecting errors detected by the preceding phase or phases in the source module. Any errors detected are recorded by the particular phase in the Error Pool, in the form of error patterns. At the conclusion of a phase, the Error Message Editing Routine processes the contents of the Error Pool and prints out appropriate diagnostic messages. Errors are classified as warning errors, serious errors, or terminating errors. The recognition by any phase of a terminating error causes control to be The structure of the object module is descr ibed in Chapter 11. 16 INPUT/OUTPUT ACTIVITY The data sets used by the Compiler are indicated in Figure 1. I/O operations in each of the several working phases are discussed in further detail in the relevant chapters. The table in Figure 2 summariZES I/O activity during compilation, in terms of the macro instructions issued. Data Set Tobi e SYSIN QSAM SYSUTI BSAM SYSUT2 BSAM Data Set SYSUT3 BSAM IEXOO CLOSE~ CLOSE CLOSE* IEX10 OPEN CLOSE* OPEN CLOSE* OPEN IEXll GET CLOSE WRITE CHECK Phase Access method used: .. IEX20 SYSLIN QSAM SYSPRINT QSAM SYSPUNCH QSAM CLOSE' CLOSE* CLOSE * PUT CLOSE* OPEN OPEN (if used) OPEN PUT OPEN (if used) WRITE CHECK PUT " PUT .. READ, CHECK WRITE, CHECK NOTE, POINT .. IEX21 IEX30 READ CHECK CLOSE WRITE CHECK CLOSE (1) READ, CHECK WRITE, CHECK NOTE, POINT PUT PUT .. IEX31 IEX40 EAD !,-HECK READ, CHECK POINT WRITE, CHECK IEX50 ~EAD, CHECK READ, CHECK PUT !,-LOSE CLOSE PUT CLOSE IEX51 IEX51 002 CLOSE' .. PUT PUT LOSE CLOSE * Data set closed in ever:'t of program interrupt or unrecoverable I/O error • .. In each of the modules indicated, a call is made to the PRINT subroutine in the Directory (IEXOO), which executes the PUT macro instruction. Figure 2. 1/0 Activity by Data Set and Phase INTERPHASE COMMUNICATION BY SOURCE TEXT TABLE A~ID The source module is subjected to two transformations before object code is generated in the Compilation Phase. These transformed versions of the source text are named Modification Levelland Modification Level 2. They are described in Chapters 3 and 5, respectively. Modification Level 1 is generated by the Scan 1/11 Phase, Modification Level 2 bY the Scan III Phase. MOdification Level 2 forms the main input to the Compilation Phase, which generates the ultimate object code. The Ta~les constructed in the several phases and transmitted to one or more subsequent phases are indicated in Figure 3. A detailed description of the function and contents of each table is given in the chapters indicated: Descri~ed Narre of Table Address Table Data Set Table (DSTAB) For Statement Table (FSTAB) Group Table (GPTAB) Identifier Table (ITAB) I/O Table (IOTAB) Label Address Table (LAT) Left Variable Table (LVTAB) Optimization Table (OPTAB) Program Block Number Ta~le (PBTAEl ) Program Block Table II (PBTAB2) Program Block Table III (PBTAB3) Program Block Ta~le IV (PBTAB4) Scope Table (SPTAB) Semicolon Table (SCTAE) subscript Table (SUTAB) in ChaQter 8 8, 11 6 4 4, 5, 6 8 8, 11 6 7 4 5 8 8, 11 4 4 6 Chapter 1: Introduction 17 Activity Table Text /Table Initialization Phase (IEXIO) Scan 1/11 Phase (IEXI1) (All table. except those marked by asterisks are transmitted between phases via the Comman Work Area) Identifier Table Manipulation Phase (lEX20) Diagnostic Ou~t (IE 21) Scan III Phase (IEX30) Diagnostic Ou~t (IE 31) Subscript Handling Phase (lEX40) -excluding Compilation Phase Compilation Phase (lEX50) Termination Phase (lEX51) Initialization Source Text. B A A Address Table C,W Data Set Table (l>STAB) C,W Far Statement Table (FSTAB) C Group Table (GPTAB) C Identifier Table (lTAB) *. C M T T T M I/O Table (lOTAB) C T lab.1 Address Table (LAT) C W Left Variable Table (LVTAB)· * C Optimization Table (OPTAB)· * T C Program Black Number Table (PBTABI C Program Black Tabl. II (PBTAB2) M,T C C Program Black Table III (PBTAB3) Scope Table (SPTAB) C Semicolon Table (SCTAB) C,T T C Subscript Table (SUTAB)* • The source text is transmitted between phases via external storage, unless the text is less than a full buffer in length. In the latter case it is transmitted ~ by way of Source Text Buffer I in the Comman Area. * lie Table trmsmitted between phases by way of ternal storage device (see Figure 1). Figure 3. CI1 ex- A B C M - Source Text transformed - Table canstucted - Table completed or madified T - Table utilized and terminated W - Table transmitted ta object module Activity Table showing the processing of source text and tatles by phase The storage maps in the layout of routines storage in each of compiler. In terms of storage utilized by divided into five main AREA OCCUPIED BY DIRECTORY AUXILIARY ROUTINES Appendix IX indicate and tables in main the phases of the function, the main the Compiler may be areas: Area occupied by auxiliary routines of the Directory (Control Section IEXOOOOO) 2. Corr~on 3. Areas occupied by the operative phase (the operative module) 4. Private area acquired by the operative phase 5. Common Area occupied by the Error Pool and Source Buffer 1 WOrk Area (Control IEXOOOOl Of the Directory) Section These areas are pictured in Figure 4. 18 T - Source Text terminated (object code generated) USE OF' MAIN STORAGE 1. T C,W Program Block Table IV (PBTAB4) * T T The composition of this control section, which contains auxiliary routines interfacing with the O~erating System, as well as Data Control B16cks for all data sets except SYSUTl and SYSIN, remains unchanged during compilation. THE COMMON WORK AREA The Common Work Area is an area of approximately 3500 bytes, resident in main storage throughout compilation. Except for the lower 540 bytes, whose assignment is fixed, the composition of the Corr.rr.on Work Area varies between ~hases and is defined by a Dummy Control Section in each phase. The Comrr.on Work Area functions as an interphase corr.munication and control area. It contains a control field, initialized by the Initialization Phase and modified in the subsequent phases; a save area; a general transmission area used for communicating addresses, parameters and counters used by all phases in common~ and a general work area. The general work area, which represents the major part of the Common Work Area, provides space for the construction and/or transmission between successive phases of small-size tables. In the Scan 1/11 Phase, an 80-byte field of the Common Work Area is used for processing card-image records of the (translated) source module. vate area for the construction of relatively large size tables which are transferred to external storage devices. The private area is in every case released at phase termination. The private work areas are described in the relevant chapters under the heading "Initialization". In the Scan 1/11 and Compilation Phases., the private area provides space for one source text buffer, while the Scan III Phase acquires three buffers. (See Corrmon Area.) Directo!l: Routines and DCS"s Common Work Area (Directory - IEXOO - comprising auxiliary routines and Common Work Area, is resident in main storage throughout compi lation) (Composition defined by dummy control section in each phase) Operative Module (lEX10, lEXll , lEX20, lEX21, 1000, lEX31, lEX40, lEXSO and lEX51, in sequence) (Nodules loaded in sequence) Private Area (Variable - acquired by each phase and released at phase termination) Common Area (Error Pool and Source Text Buffer 1) Figure 4. Use of main Compiler (Acquired by Initialization Phase - released at termination of compilation) storage by ALGOL AREA OCCUPIED BY OPERATIVE MODULE The operative module, which varies in size, is loaded adjacent to the Common work Area. COMMON AREA The Common Area is acquired by the Initialization Phase and is not released until Compiler termination. It provides space for the Error Pool and for Source Buffer No.1. The Common Area buffer is provided in order to enable the source text to be transmitted between phases via rrain storage, in the event the text occupies less than a full buffer. If either or both of the intermediate versions of the source text exceeds the buffer length, the text is transferred to external storage. In each of the phases which process the source text, one or more additional buffers are provided for in the private area acquired (and subsequently released) by the phase. In the Scan 1/11 and Compilation Phases, the private area contains one source buffer, while in the Scan III Phase, the private az'ea contains three buffers. In the Scan 1/11 Phase, the Modification Level 1 text is assembled and transmitted to the Scan III Phase in the Common Area buffer, unless the text exceeds the buffer length. In the latter case, the text is transferred to SYSUT1, using the Corrmon Area buffer and the private area buffer as output buffers. In the Scan III Phase, the Modification Level 1 source text is processed in the Common Area buffer (if the text was transmi tted in mai n storage) " or al ternati vely, in the OOmmon Area buffer and a private area buffer (if the text is input from the SYSUT1 data set). The Modification Level 2 text is assembled in one (or two) buffers in the private area and, if it exceeds the buffer length, it is transferred to SYSUT2. If the text is less than the buffer length, it is moved to the Common Area buffer, before the private area is released, for transmission to the Compilation Phase in main storage. PRIVATE AREA ACQUIRED BY OPERATIVE MODULE All of the phases of the Compiler" except load modules IEX21 and IEX31 (diagnostic output modules), acquire a pri- In the compilation Phase, the Modification Level 2 source text is processed in the Common Area buffer (if the entire text was transmitted in main storage) or, alternatively, in the Common Area buffer and a Chapter 1: Introduction 19 private area buffer (if the text was transmitted on the SYSUT2 data set). vention applies to operators used by the Compiler internally, e.g. Beta, Proc, Epsilon. ExceFt for the power, ! aSSignment and scale factor operators \ (represented respectively as Power, Assign, and Scale Factor), arith~etic and relational operators are represented by their commonly understood symbols, e. g. +, <, =. Parentheses and brackets are also represented symboli cally, as in (, ), [, ]. The complete range of internal character representation during the various phases of the Compiler is indicated in the code tables in Appendices i-a through i-d. CONVENTIONS The following conventions are this manual: observed in 1. ALGOL delimiter words in the text of a source module are represented in the manner defined by the IBM System/360 Operating System ALGOL Language, e.g. 'BEGIN' or 'REAL'. 2. With certain exceptions, one-b}'te characters in the internal code of the Compiler, representing ALGOL delimiter words, as well as other conventional delimiters, are represented as in the following exampIes: Beg:in, Goto, Power, Or, Comn;a, .QeciIl@.LRoint, Array. The same con- 3. 20 Syntactical, logical, or operational errors detected during co~pilation are identified by the serial nurrter in the corresponding diagnostic message key. Thus, for example, the error whose detection produces a diagnostiC message with the message key IEX034I, is identified in this manual as "error No. 34. n CHAPTER 2: DIRECTCRY (IEXOO) PURPOSE OF THE DIRECTORY The Directory (IEXOO) is the first of ten load modules of the ALGOL Compiler. It is the first module to be loaded in main storage, and unlike the other nine modules, which are loaded, executed and then displaced by the succeeding module, the Directory remains in main storage throughout compilation. The function of the Directory is: 1. 2. 3. To provide the requisite interface between the compiler, on the one hand, and the invoking program and the Operating System, on the other. This interface is provided by (a) the Initial Entry routine, which receives control from the invoking program and loads the next module (IEX10)i and the Final Exit routine, which returns control to the invoking program at the close of the Termination Phase (IEX51);(b) the Program Interrupt, SYNAD and EODAD routines, which receive control from the Operating System in the event of an unexpected interrupt and pass control to an appropriate routine in the operative phase; and (c) data control blocks for data sets used by the compiler. To provide a PRINT Subroutine., used in con~on by several phases, which prints out compilation output on the SYSPRINT data set, on call from the operative phase. The printed output includes diagnostic messages indicating syntactical errors detected in the source module, and, depending on the Computer options specified, listings of the source module and the Identifier Table. To provide the Common Work Area, an area of main storage used for the transmission of tables, addresses and other data between phases. Among other things, the Common Work Area contains a common register save area, a Control Field (HCOMPMOD see Appendix IV) which governs operations in each phase, and an Area Size Table which specifies the sizes of the private areas acquired by the several phases. The Control Field and Area Size Table, which are initialized or constructed by the Initialization Phase (IEX11), reflect the compiler options specified by the user. The program ATTACH control Directory is loaded by the invoking by means of a LOAD, XCTL, LINK, or macro instructicn, or by an EXEC card. ORGANIZATION OF THE DIRECTCRY The Directory consists of two control sections, named IEXOOOOO and IEX00001, respectively. Control Section IEXOOOOO contains the Initial Entry, Final Exit, Program Interrupt, SYNAD. EODAD, and Print routines, as well as data control tlocks for all except two of the data sets used by the compiler (the other two are contained in the Common Work Area). Control Section IEX00001 comprises the Common Work Area. CONTROL SECTION IEXOOOOO The principal components of Control Section IEXOOOOO are as follows: Initial Entry Routine The Initial Entry routine receives control from the invoking program. The rcutine saves registers in the Invoker's save area, loads register 13 with the address of a save area in IEXOOOOO, and executes a LINK macro instruction to load and activate the Initialization Phase (IEX10). Final Exit Routine The Final Exit routine is entered from the Termination Phase (IEX51). Registers are restored and control returned to the Invoker by a RETURN macro instruction. Program Interrupt Routine (PIROUT) PIROUT is activated by the control program in the event of a program interrupt. The address of PIROUT is specified by a SPIE macro instruction in the Initialization Phase (IEX10). Chapter 2: Directory (IEXOO) 21 PIROUT records error No.209 in the Error Pool (indicating a program interrupt) and transfers control to a closing routine in the operative phase, the address of which is stored at a location named ERET in the Common Work Area. ERET is updated by the initialization routine (as well as by other routines) in each of the several phases, so as to indicate the correct entry point of the closing routine in the particular phase. A switch (TERR -- see Appendix IV) turned on by PIROUT to indicate a terminating error, causes the terminating routine in the operative phase to transfer control to the Error Message Editing routine in the next diagnostic output module (IEX21, 31, or 51) for print-out of the errors recorded in the Error Pool. The same TERR switch causes the Error Message Editing Routine in the particular diagnostic output module to transfer control to the terminating routine in the Termination Phase (IEX51), rather than to the next successive phase. Where a program interrupt occurs in the closing routine of the operative phase (in which case the same program interrupt will recur after PIRou'r has returned control to the defective cloSing routine), PIROUT exits directly to the terminating routine in the Termination Phase. PIROUT is temporarily replaced as the program interrupt exit by the execution of a second, SPIE macro instruction in the initialization routine of the Scan III Phase. The substitute routine provides for special handling of exponent overflow and underflow interrupts, but passes control to PIROUT in all other cases. PI ROUT is restored as the program interrupt exit by a final SPIE macro instruction in the closing routine of the Scan III Phase. Sysprint I/O Error Routine (SYNPR) The Sysprint I/O Error Routine is activated by the control program in the event of an unrecoverable I/O error involving the SYSPRINT data set. The address of the routine is stored in the relevant DeB. The routine turns on a switch named PRT (Appendix IV) to indicate that the printer is down, and then enters the SYNAD routine to take the same actions as that taken for all other data sets. The PRT switch (if turned on) causes the Error Message Editing routine to print out a single message (for Error No. 210) on the console typewriter, indicating that the printer is inoperative. End of Data Routines (EODAD1" EODAD3, AND EODADIN). The End of Data routines are entered from the control program when a data input operation from the SYSUT1, SYSUT2, SYSU~3, or SYSIN data set is terminated at the end of the data set. The address of the particular End of Data routine is stored in the data set's DCB. The End of Data routine loads the entry point of the appropriate ECD exit routine in the operative phase, and then passes control to that routine. The entry point of the EOD exit routine is stored ty the initialization routine in each phase which processes a data set, at the appropriate one of the locations EODUT1, EODUT2, EODUT3, and EODIN in the Common Work Area. The phases which specify an EOD exit routine for an end of data condition, the data sets involved, and the locations where the entry points are stored, are as follows: Data Set I/O Error Routine (SYNAD) SYNAD is activated by the control program in the event of an unrecoverable I/O error involving the SYSIN, SYSLIN, SYSPu"NCH, SYSOT1, SYSUT2, and SYSUT3 data sets. The address of the routine is stored in the relevant DCBs. The routine closes the affected DCB, records error No. 210 in the Error Pool (using the ddname contained in the DCB), sets the TERR switch on to indicate a terminating error, and passes control to the closing routine in the operative phase, whose entry point is specified in the location ERET. (See also Program Interrupt Routine PIROUT). 22 EODAD2, Storage Field for EOD Exit IEXll SYSIN EODIN IEX20 SYSUT3 EODUT3 IEX30 SYSUT1 ECDUT1 SYSUT3 ECDUT3 IEX40 SYSUT3 ECDUT3 IEX50 SYSUT2 EODUT2 SYSUT3 EODUT3 Note that End of Data exit routines for SYSUT2 and SYSUT3 are specified toth in the the Compilation Phase initialization routine in IEX40. and at the start of IEX50 (see "Phase Initialization" in Chapter 8). Print Subroutine (PRINT) Data Control Blocks The PRINT subroutine prints out text on the SYSPRINT data set on call from the operative phase. Depending on the compiler options specified, the subroutine may be called by the following routines in the modules indicated: Control Section IEXOOOOO contains Data Control Blocks (DCBs) for the following data sets: CIB (IEX11) - Source module listing PRINTITB (IEX20) - Identifier listing SYSPRINT SYSLIN SYSPUNCH SYSUT2 SYSUT3 Table COT27 (IEX21, 31, 51) - Diagnostic messages PRINTT (IEX51) - Object module storage requirements The text printed out includes front page titles, headlines, as well as variatle (compiler-generated) text. A single line of text is printed by each call to PRINT. After a page shift, one or more headlines are printed at the top of the new page before the next line of text is printed. Text other than headlines is assembled ty the calling routine in a print buffer previously specified by. PRINT (in register 1). Headlines are transmitted by the calling routine in a Common Work Area field named PAGEHEAD (which accommodates up to three lines of text) and are subsequently moved by PRINT to a print buffer for output. The headlines are assembled at PAGEHEAD during initialization of each particular phase. PRINT maintains both a line and page count, and inserts the control character in the appropriate line of text to effect the required page shift. Before a page is shifted, the next line of text is temporarily moved from the print buffer to a save area, to enable the headline(s), together with the page number, to be printed at the top of a new page. Control characters governing line spacing between headlines are supplied by the calling routine in the headlines. These characters are used by PRINT to add the correct increment to the line count. The control character to effect a standard single-space line change is inserted by PRINT at the beginning of each new print buffer. special page shifts, e.g. following the title page, are specified by the calling routine by arbitrarily raising the line count, maintained in the Common Work Area. The calling routine may also suppress one or more headlines by inserting a special character at the beginning of the particular headline. The DCB addresses are listed in the Common Work Area, £cllowing the register save area. The foregoing data sets are required throughout compilation. DCBs for the SYSIN data set, which is not used after the Scan 1/11 Phase (IEX11), and the SYSUT1 data set, which is not used after the Scan III Phase (IEX30), are stored in the Corr.rron Work Area. Data Sets are opened ty the Initialization Phase (IEX10), which also modifies the information in the DCBs to reflect special user requirements concerning block sizes and record lengths. CONTROL SECTION IEX00001 (COMMON WORK AREA) The Common Work Area is an area of approxlinately 3500 bytes used by all phases of the Compiler., principally for the construction and/or transmission tetween phases of small-size tables, essential control information, and address data. Except for a limited number of fields which remain essentially unchanged throughout compilation, the composition of the CORmon Wcrk Area varies between phases. Its composition is defined by a dummy control section in each phase. The general layout of tables and other data in the Common Work Area in each phase is indicated in the storage maps in Appendix IX-a. The principal fields which remain fixed in position in the Common Work Area are the following. Register Save Area A standard format save area of 72 tytes., addressed throughout compilation by Register 13, is provided for saving registers when control is passed to the control program at any point during execution of the phases IEX10-IEX51. Chapter 2: Directory (IEXOO) 23 DCB Addresses The addresses of the Data Control Blocks of all seven data sets used by the Compiler are recorded in the Common Work Area, immediately below the general save area. in succession (e.g. the pointer PBPT, which is incremented in the Scan 1/11 and Scan I I I Phases to indicate the displacement of each point in the object module, beginning with the Constant Pool). Area Size Table (INBLKS) End of Data Exit Addresses This field contains the entry point(s) of the closing routine(s) to be entered in the operative phase in the event of an End of Data condition on anyone of the data sets SYSIN. SYSUT1. SYSUT2. and SYSUT3. The appropriate entry point is fetched from this field by the EODAD routine in the Directory when an EOD condition occurs. The field is updated by each phase at initialization so as to specify the correct closing routine in the phase. Compiler Control Field (HCONPMOD) The Area Size Table specifies the sizes of work areas or buffers acquired by the individual phases for the construction of tables transferred to auxiliary storage. It also specifies minimum block sizes for certain data sets. The relevant entries in the table are referenced by the initialization routines of the several phases, before the GETMAIN instruction for the particular phase's private area is issued. The Area Size Table is set up by the Initialization Phase (IEX10), Which determines the appropriate size for each wcrk area, according to the SIZE option specified by the user. The table in Appendix VIII shows the increase in work area sizes as the value of the SIZE option increases. A three-byte field in the Common Work Area named HCOMPMOD is used as a Compiler Control Field. All excel:lt one of the 24 binary positions in this field are used as switches to govern operations in each phase of the compiler. The significance of each switch is indicated in Appendix IV. Work areas for small-size tables transmitted between phases via the Common Work Area are defined by a DS statement in the durr.my control section defining the Common Hork Area in each phase. The Control Field. which is initialized by the Initialization Phase (IEX10). indicates. among other things, the Compiler options specified by the user. It also indicates significant error conditions detected by anyone phase, which may cause the Compiler to enter Syntax Check Mode, or alternatively, to terminate operations. The compiler options are listed in Chapter Headline Storage Area (PAGEHEAD) 3. Communication Area The Communication Area contains addresses. pointers, counters, and other information used by two or more phases in common. The address information may be variable (as in the case of the program interrupt or I/O error closing routine address at ERET, which changes with each phase) or invariable (as in the case of the address of the Common Area Source Text Buffer 1, stored at SRCE1F~D). Counters designate literal number values (e.g. the line count referenced by the PRINT subroutine at LINCNT). Pointers designate address displacement values which may be incremented by several phases 24 This area is provided for the headlines used in the printed output of the individual phases. The area accommodates up to three 90-character headlines. The appropriate headlines, which are stored in the area at initialization of each phase generating printed output, are fetched by the PRINT subroutine on call from the operative phase. The principal contents of the variable part of the Common Work Area during the several phases are as fOllows. Preliminary Error Pool A Preliminary Error Pool is provided in the originally assembled Common Work Area, for the recording of any errors which may occur before the main Error Pool is acquired by the Initialization Phase. Any recorded errors are immediately moved to the main Error Pool, after main storage for the latter has been acquired. The Prelirri- nary Error Pool is deleted after the of the Initialization Phase. Data close The above list does not include these tables which are transferred to external storage. The processing of all tables, except those used locally, is indicated in detail in Figure 3. ontrol Blocks for SYSIN and SYSUTl The DCBs for the SYSIN and SYSUTl data sets are stored in the variable part of the Conuuon Work Area, since the data sets are not used beyond a certain point, and the area occupied by the DCB's can be released for other uses. The DCB for SYSIN is deleted after the close of the SCAN 1/11 Phase, while the DCB for SYSUTl is deleted after the close of the Scan III Phase. Tables Other Data The remainder of the variatle part of the Common Work Area is used in the various phases for switches, addresses, counters, and pointers of local significance only (i.e. used exclusively by the operative phase). In the storage maps in Appendix IX-a, these areas are identified as "private work areas". The following tables are constructed by the several phases in the variable part of the Common Work Area. A majority of these is transmitted to at least one or more subsequent phases via the Common Work Area. A few are used locally only. IEXll P.B. No. Table (PBTAB1) scope Table (SPTAB) Group Table (GPTAB) Semicolon Table (SCTAB) -- local use IEX20 Program Block Table II (PBTAB2) IEX30 For Statement Table (FSTAB) IEX40 Address Table (ATAB) -- local use IEX50 Program Block Table III (PBTAB3) IEX51 Program Block Table IV (PBTAB4) Chapter 2: Directory (IEXOO) 25 CHAPTER 3: INITIALIZATION PHASE (IEX10) The logic of the Initialization Phase is outlined in Flowcharts 007-010 in the Flowchart section. The following sections describe the principal functions perforned. PURPOSE OF THE PHASE The Initialization Phase: 1. Saves registers used by the Initial Entry Routine in the Directory, and addresses a save area (by loading register 13) for storing registers when lower-level routines, e.g. in the control program, are invoked by any of the subsequent phases. The save area addressed comprises the first 72 bytes of the Common Work Area. 2. Executes the SPIE macro, specifying the PIROUT routine in the Directory as the program interrupt exit. 3. Reads the options specified for Compiler by the invoking program turns on a set of switches in HCOMPMOD Control Field to reflect options specified. 4. Inserts ddnames (if any are specified by the invoking program) in the corresponding Data Control Blocks. 5. Selects an Area Size Table, according to the machine system capacity indicated by the SIZE option. The Area Size Table specifies the main storage space to be provided in each phase for work areas and buffers, as well as maximum data set block sizes. 6. 7. 26 the and the the Acquires main storage for the Common Area, containing the main Error Pool and Source Buffer 1. Any errors detected before the main Error Pool is acquired are recorded in the Preliminary Error Pool in the Common Work Area. Opens all data sets, after specifying the addresses of Open-Exit routines in the Data Control Blocks of the SYSIN, SYSLIN, SYSPUNCH, and SYSPRINT data sets, and after inserting block sizes in the Data Control Blocks of the SYSUT1 and SYSUT2 data sets (the block size is equal to the length of the Source Text Buffer). Block sizes for SYSIN, SYSLIN, SYSPUNCH, and SYSPRINT are inserted by the particular open~ Exit routine, using the block sizes (if any) specified in the DD statements, or the maximum block size specified in the Area Size Table. The block size for SYSUT3 is included in the assembled Data Control Block. EXECUTION OF TEE SPIE MACRO At entry to the Initialization Phase, after registers used by the Initial Entry routine have been saved, and after Register 13 has been loaded with the address of the general save area in the Ccmmon Work Area, a SPIE macro instruction is executed which specifies the address of the Program Interrupt Exit routine (PIROUT) in the Directory. By virtue of the SPIE macro instruction, the Operating System passes control to PIROUT in the event of a program interrupt. When entered (in the event of a program interrupt), PI ROUT passes control to the routine whose address is stored at the location named ERET in the Common Work Area. ERET is updated in each phase so as to indicate the address of the appropriate closing routine in that phase. Immediately after execution of the SPIE rracro, the address of the Initialization Phase closing routine GOTOTERM is stored at ERET. GO~O TERM transfers control directly to the Termination Phase (IEX51), after releasing main storage and closing data sets. GOTOTERM is subsequently replaced as the program interrupt exit by OPEXERR and GOTOEDIT (the latter exits to IEX21 for output of any recorded errors, before transferring control to IEX51). PROCESSING COMPILER OPTIONS, HEADING INFORMATION DDNA~ES, AND The compiler may be invokedCa) by means of the job control EXEC statement, i.e. using the facilities of the control program, or (b) by a user-made program. The options o~en to the user, as Well as the concomittant obligations, insofar as the execution of the Compiler is concerned, differ under each of these alternatives. Where the Compiler is invoked by the EXEC statement, the options specifiable are limited to the compiler control options listed under "compiler Options" below. Under this alternative, the key-words representing the compiler options specified are assembled by the con~rol program in an option field addressed by a pointer. At entry to the Compiler, the address of the pointer is contained in Register 1. Where the Compiler is invoked by a user-made program, the user may specify (a) any of the compiler options, (b) ddnames for data sets, and (c) heading information" consisting of an opening page number for the printed output of the Compiler. Under this alternative, it is the obligation of the user to assemble the key-words representing the compiler options exercised, ddnames (if any) specified, and the heading information, in three separate fields of main storage (hereafter called, respectively, the option field, the ddname field, and the heading field). Each field must be addressed by a pointer in a three-word address list, and the address of the address list must be contained in Register 1 when control is transf erred to the Compiler. Figure 5 pictures the arrangement of the option" ddname and heading fields, and the related pointers. The arrangement is completely analogous under both invocation alternatives, except that in the case of invocation by EXEC statement, the ddname and heading fields are always vacant (the latter fieldS may also be vacant under the alternative invocation procedure). A vacant field is indicated by the value zero in the corresponding pointers; value zero in Register 1 indicates that all three fields are vacant. A vacant option field indicates that the options exercised are the default options. Register 1 Address List process the ddname and heading fields will be bypassed. The address of the address list is obtained from the Operating system's save area, in which the contents of Register 1 will have been stored after entry to the Coropiler. COMP ILER OPTI ONS The processing of Compiler options consists in reading the key-words listed in the option field and in setting appropriate switches in the HCOMPMOD Control Field (Appendix IV) to reflect the particular options specified. The key-words representing valid options which may be specified for a compilation are as fellows (the first key-word corresponds to the default option): SIZE = [a number ~45056] PROGRAM (PG) or PROCEDURE (PC) SHORT (SP) or LONG (LP) SOURCE (S) or NOSOURCE (NS) LOAD (L) or NOLOAD (NL) NODECK (ND) DECK (D) EBCDIC (EB) or ISO (I) TEST (T) or NOTEST (NT) The letters within parentheses represent tlle alternative (abbreviated) form in which the option may be specified. The key-words are recorded in the option field in EBCDIC code and are separated by commas. Except in the case of the SIZE option" each option is identified by comparing the key-word with a list of 28 possible key-words in a table named PARMLIST. o 1 10 14 r---------~----------------T------------, Il instruction> JI Figure 6. Figure 5. option, DDname and fields, and pointers Heading The first bit of each full-word pointer in the address list functions as a flag, to indicate whether or not the field currently being processed is the last to contain significant data. The bit is tested after each field has been processed, to determine whether the next field is to be processed. Thus, for example, if the flag bit is on in the option field pointer, indicating that the ddname and heading fields are vacant, the DDNAMES and BEAD INFO routines, which PARMLIST Table entry for a piler option key-word Com- In addition to the option key-word and the key-word length (-1), each entry in the PARMLIST Table contains a logical instruction (NI or OIl which, when executed, turns on a specified switch in the HCC~F~CD Control Field (Appendix IV). As soon as a key-word in the PARMLIST Table is found which matches the key-word in the option field, the instruction in the table is EXECUTEd, turning on the appropriate switch in the Control Field and thus recording the option specified. The SIZE option is identified by a CLI instruction. After recognition, the size specified is converted to binary and stored Chapter 3: Initialization Phase (IEX10) 27 at SIZE, provided it is not less than the minimum capacity required. The size is subsequently referenced in selecting the Area Size Table (see below). If an option is incorrectly specified, error No. 200 is recorded in the Preliminary Error Pool in the Common Work Area and the default option is assumed. If the main storage size specified is less than the minimum, error No. 208 is recorded, and the minimum size of 45,056 is assumed. The contents of the Preliminary Error Pool are subsequently moved to the main Error Pool after the Common Area has been acquired. tion Phase (IEX10) acquires a Coromon Area used by all phases (see below). To enable the Compiler to adapt itself flexibly to the available storage capacity, the space allotment for certain work areas is scaled to the capacity of the particular machine system as specified in the SIZE option. Twelve capacity levels are established, beginning at 45,056 bytes and graduated upwards at increasing intervals, up to a maximum of 999,999 bytes. At each capacity level, specific area sizes are defined for all work areas and buffers. Capacity levels and area sizes are defined by twelve Area Size Tables, the first of which is named ARTAB. DDNAMES The processing of ddnames consists in transferring the ddnames (if any) from the ddname field to the relevant Data Control Blocks. Unless a ddname field is provided in a user-written program which invokes the Compiler, the ddname field is vacant (Data control Blocks contain the ddnames required by the Compiler). The ddnames, each consisting of a maximum of eight EBCDIC characters, will have been entered in the ddname field in prescribed positions, according to the physical device involved. Data Control Block addresses are listed, in corresponding order and position, in the Common Work Area, beginning at LINADD. This enables the ddnames to be transferred to the appropriate DCB in sequence. The FNDARSIZ routine selects the appropriate Area Size Table, according to the machine capacity specified in the SIZE option, and moves the table to the Common Work Area at the field beginning at INBLKS. The table thus selected, which specifies the main storage space to be acquired for all work areas, is referenced by the rrain working phases at initialization, before the GETMAn~ instruction for the phase's private area is executed. In addition to work area sizes, the Area Size Table also specifies the maximum blcck sizes for the SYSIN, SYSPRINT, SYSLIN, and SYSPUNCH data sets. The maximum bleck sizes are referenced by the Open-Exit reutines (see below). Appendix VIII shows the increase in the size of work areas, buffers and maxirrurr block sizes as the SIZE option increases. HEADING INFORMATION ACQUISITION OF COMMON AREA The heading information which may be specified, consists solely of a starting page number for the printed output of the Compiler. Where no page number is specified, page numbering begins with the number 1. The page number field is moved to a which is updated PRINT subroutine in (if any) in the heading counter named PAGECNT, and referenced by the the Directory. SELECTION OF AREA SIZE TABLE (FNDARSIZ) With the exception of load modules IEX10, IEX21, IEX31, and IEX51, each phase of the Compiler acquires a private area containing one or more work areas or buffers for the construction, processing, or output of working tables. The Initializa28 The Initialization Phase acquires a Common Area containing Source Buffer No.1 and the Error Pool, in which compile time errors detected in the several phases are recorded. The sizes of the buffer and Error Pool are obtained from the Area Size Table. The use of Source Buffer No. 1 is discussed under "Use of Main Storage" in Chapter 1. After acquisition of the Error Pool, the contents (if any) of the Preliminary Error Pool in the Common Work Area are moved to the newly acquired Error Pool. OPENING OF DATA SETS The Initialization Phase opens all data sets used by the compiler, namely SYSLIN, \ SYSPRINT, SYSIN, SYSPUNCH, SYSUT1, SYSUT2, and SYSUT3. The DCBs of SYSIN and SYSUT1 are contained in the Common Work Area (this facilitates the release of main storage for other uses when the data set is no longer needed after the Scan 1/11 and Scan III Phases, respectively); all other DCBs are contained in Control section IEXOOOOO of the Directory. DCB addresses are listed in the Con®on Work Area, beginning at LINADD. In®ediately before the OPEN macro instruction is executed, the addresses of the Open-Exit routines INEXRT, LINEXRT, PCHEXRT, and PRTEXRT are stored in the SYSIN, SYSLIN, SYSPUNCH, and SYSPRINT DCBs. The Open-Exit routines, which are entered from the Operating System when the OPEN macro instruction is issued, serve to verify that the block size (if any) specified, is a multiple of the record length and does not exceed the maximum s~ecified in the Area Size Table. If the block size is not specified at invocation or if the block size is incorrectly specified, the OpenExit routine inserts the record length as the block size. If the block size is incorrectly specified, an error is recorded, and in the case of SYSIN, the NOGO switch (Appendix IV) is turned on, causing compilation to be subsequently terminated. In the case of the SYSUT1 and SYSUT2 data sets, the block size (equal to the source buffer length specified in the Area Size Table) is inserted directly, before the OPEN macro instruction is issued. In the case of SYSUT3, the block size is sFecified in the DCB at assembly time. When control is recovered from the Operating system OPEN routine, a test is rrade to determine if the SYSPRINT data set bas been opened (in the negative case, Error No. 201 is recorded and the PRTNO and NCGO switches are turned on, causing compilation to be terminated after the error message has been printed out by Load Module IEX21 on the console typewriter). If the data set has been successfully oFened, the date is derived and edited from the systerr clock, and the title "LEVEL 1 JUL 67 OS ALGOL F DATE [date]" is printed on a new page. Tests are then made to determine if the remaining data sets have been opened. If all data sets have been correctly opened, control is passed to the Scan 1/11 Phase (IEX11). If any data set has not been opened, an error is recorded, and in the case of SYSIN, SYSUT1, SYSUT2, or SYSU~3, the NOGO and TERR switches are turned on, causing compilation to be terminated after recorded error messages have teen printed out by Load Module IEX21. Chapter 3: Initialization Phase (IEX10) 29 CHAPTER 4: SCAN I/II PHASE (IEX11) PURPOSE. OF THE PHASE object time storage fields are allocated to all identifiers listed in the table, other than declared label. switch, and procedure identifiers .• The purpose of the Scan I/II Phase is to read the source module and perform the following principal tasks. 1. To tabulate and classify all valid identifiers declared or specified in the source module" in the Identifier Table. Declared identifiers include those designated by such declarators as 'REAL', 'INTEGER', 'ARRAY', or 'PROCEDURE', among others l as well as labels. specified identifiers are formal parameters of procedures, specified in a procedure heading. The Identifier Table is terminated in the Scan III Phase" when all externally represented operands in the source text are replaced by their internal names in the table. 2. The Identifier Table" which is further processed in the two subsequent phases, facilitates the construction of the internal names of identifiers and the replacement of identifiers in the source text by their internal names. An identifier's internal name consists of a five-uxte unit containing a descriptive characteristic, a Program Block Number, and a displacement address. The Program Block Number specifies (indirectly) a Data storage Area, compriSing the object time storage area required for all identifiers declared or specified in the particular block or procedure. The displacement address specifies (in the case of a declared label, switch, or procedure identif"ier) the displacement of an entry in the object time Label Address Table, or (in the case of all other identifiers) the displacement of a storage field in the particular Data storage Area. The entries in the Identifier Table consist of the identifier's external name (represented by a maximum of six characters translated to internal code), followed by the five-byte internal name described above. For declared label, switch, and procedure identifiers, the complete entry, comprising external and internal name, is constructed by the present phase. For all other identifiers, the present phase enters the external name and constructs all except the address part of the internal name. The Data Storage Area displacement address is inserted in the entry by the Identifier Table Manipulation Phase, in which 30 To assign a serial Program Block Number to every block and procedure in the source text. The same Prograw Block Number appears in the internal names of all identifiers declared or specified in the particular block or procedure. At object time" the Program Block Number references an entry in the Program Block Table, containing, among other things, the size of a Data Storage Area. In the Object code generated by the Compilation Phase, an operand is represented by the address of the Data Storage Area (loaded in a base register) and the displacement contained in the operand's internal name. 3. To generate a transformed source text, called Modification Levell. A second transformation of the source text" called Modification Level 2, is generated by the Scan III Phase. ~he changes reflected in the first transformation include an initial one-forone translation of all characters in the source text to the internal code., the replacement of all ALGOL delimiter words by one-byte operators, and the removal of declarations, except procedure" array" and switch declarations, from the source text. These and other changes are described in a later section under the heading "Modification Level 1 Source Text". 4. To store strings enclosed by string quotes, '(' ')'" in the Constant Pool" and to replace the string in the transformed source text by an internal name referencing the location where the string was stored. All constants other than strings are stored in the Constant Pool by the Scan III Phase. 5. To recognize syntactical errors in the source module and to store appropriate error patterns in the Error Pool. The contents of the Error Pool are printed out in the form of diagnostic messages by the Error Message Editing routine in the next module but one (IEX21), after execution of the Identifier Table Manipulation Phase. 6. To print a listing of the source module, if the SOURCE option is specified. 7. To assign a serial Identifier Group Nun,ber to every block, procedure, and for statement in the source module. The Identifier Group Number is used in the Scan III Phase to verify the validity of goto statements, and to facilitate the classification of for statements (see Item S). S. To construct a Group Table listing all Identifier Group Numbers and identifying each for statement represented in the list. The Group Table is used in the Scan III Phase, in classifying the optimizability of for statements containing goto statements which imply a branch out of the for statement. 9. To construct a Scope Table indicating the Program Block Number of the block or procedure enclOSing every for statement. The Scope Table is used in the Scan III Phase to ascertain if all terms of subscript expressions of array identifiers occurring in for statements are valid (i.e. declared) outside the for statement. This is one of several conditions for subscript optimization. 10. To construct the Program Block Number Table, indicating the Program Block Number of the block or procedure imrr~diately enclosing every block and procedure in the source program. The table is constructed for purposes of user-information and is used in the Identifier Manipulation Phase in the print-out of the Identifier Table. ALGOL delimiter words (e.g •., 'BEGIN' or 'STEP'), as well as other multicharacter operators (e.g., := or .,). If a delimiter constitutes a declarator (e.g." 'INTEGER')., or a specificator, entries are made for the immediately following identifiers in the Identifier Table, after each identifier has been checked for validity. Otherwise, a one-byte symbol representing the delimiter is transferred to the output buffer. Other multicharacter operators are similarly replaced by one-byte symbols. Statements, containing externally represented operands (identifiers) and operators are transferred unchanged, except that any delimiter words and multicharacter operators within the statement are replaced by cne-byte symbols. (See "Modification Levell Source Text" in this chapter.) The following provides a general description of the main eperations performed in the Scan 1/11 Phase, illustrated graphically by the diagram in Figure 7. The description is intended to be read in conjunction with the diagram. At the extreme left of the diagram. it will be seen that the' source module (in card or card-image records~ EBCDIC or ISO code) is read from the SYSIN data set into an SO-byte field of the Common Work Area by the CIB subroutine. Immediately after read-in, a copy of the record is moved te a print area (or a dummy print area, if the SOURCE option was not specified)~ and the record in the Work Area is then translated to the internal code (Appendix I-a. Appendix I-b shows the same character set, expanded by ·the characters which replace delimiter words). The untranslated source text in the print area is used in printing a listing of the source module. It is also used to enable character strings to be stored in the Constant Pool in their original EBCDIC or ISO code. The CIB subroutine" first activated at phase initialization, is subsequently called by any routine which detects the record-end operator zeta (the operator is inserted by CIB at the end of each trans lated source record). SCAN 1/11 PHASE OPERATIONS The two primary 1/11 Phase are: functions of the Scan. 1. To tabulate all identifiers declared or specified in the source module, in the Identifier Table. 2. To generate a transformed source (Modification Levell). text In principle, these functions are performed by searching the source text for In the Work Area" the translated source text is scanned by the TESTLOOP routine, which searches for any of 14 different characters. As soon as anyone of these characters is identified., TESTLOOP meves the preceding scanned characters to the Mo'dification Level 1 text in an output buffer, and then activates the appropriate routine. The diagram indicates the reutines activated in the case of 12 of the 14 characters (the remaining two are the Blank and the Invalid Character" which are" in effect, ignored). Chapter 4: Scan 1/11 Phase 3.1 w "" • , <, >, ( <, >, ( , /,) ·,1, SCAN 1/11 PHASE QEX11) ; I / I ...... , . Not, Power Change Input Buffer (CIS) Gets records from SYSIN into a work area, moves them to a print'orea, then trtmslote!tne records to internal code in the work area. CIS is coiled wl'\en the record-end operatOl"Zefo is encountered. - Label Colon 1="' H"','." '0<. SEMCu transfer. llAI..I:a.operotor: I TESTLOO P scons the rranslatea source text for OIly of 14 characters, moves the intervening characters to the output buffer, then aelivates the routine concerned. Chonge Output Buffer (COB) l~ I (Operands, numbel'$ & arithmetic =:fur~ra:,~:f:~ ~~t:=Y:de) I / I I ~ Then, ~, Goto, .!f,~~ DELIMIT identifies the delimiter enclosed by apostrophes and branches to the routine concerned, using the Delimiter Table. = F ~~! ~:!~ o~ Zeta the source texl into the work oreo ond returns control to TESTLOOP, ~,( , NORMAL, TED and GIF ;:~r,:p:~'7i~~ the _._ >, :; ; , ~, I, =, t /1 I delimiter, from the Delimiter Table. 'BEGIN' 'FOR' (FOR -for statement :"~~:r BEGI called (listing is printed by Directory PRINT ~BEGI (Firstdedar- subroutine, on call ~~EGI~t!) framelS) ...... ! I /I I I ( ~~;:~:~:I=I~ ~~lre;!,~~ tines or. recorded in the farm of error pottems in the Error Pool. The pattems are edited and messages printed out by the Error MeSSClge Editing routine in lEX 21. I'n>< I I .TYPE, PROCEDUR, PROCID, ARRAY, SWITCH, SPEC, IDCHECK, SPECENT, IDCHECK1, end VALUE !'OUtines conlNC! entries for identifi8/'$ in the Identifier Table. (DeciaredOlld ~ specified identifier entries) (labels) I=END ~ -END- I I L ,-C=pBLCKEND zr r E ] \ ' "=FOREND W I ITAB ~;:;,~t:;;;:.) \ '==COMPDEND I -(- (Charocterslrings in external axle) -TRUE-FAlSE- Figure 7. Scan I/II Phase. BOLCON trtlnsfers a five-byte intemal name referencing a location in the Constant Pool where binary 1 and 0 are stored. I I .. _... _, '/ I XCTL to IEX20 I (or IEX21, if a t termlnatingenor h..s been detected) Diagram illustrating functions of principal constituent routines (If DECK and/or LOAD options $pecified) For a majority of the characters, the character is simply transferred to the output buffer or replaced by another character, depending on the character which follows. In the case of a colon, the COLON routine may: 1. Transfer a Label Colon and construct an entry in the Identifier Table for the preceding label; 2. Replace a letter string by a Comma; or 3. Transfer the Assign operator. In the case of a semicolon, the SEMCO routine inspects the Scope Handling Stack to determine if the semicolon closes a procedure or a for statement, and if so, activates the appropriate subroutine (PBLCKEND or FOREND). See "Close of Scopes" • If a semicolon terminates a declaration, SEMCO transfers the Delta operator to the Modification Level 1 text; otherwise, the Semicolon operator is transferred. The record-end operator zeta causes TESTLOOP to call the CIB subroutine, which reads in a new record and translates it to the internal code. The apostrophe leads into the Apostrophe routine (APOSTROF). APOSTROF scans the text immediately following the apostrophe, for a digit or +/- sign, a second apostrophe, or one of a set of logical operators. A digit or +/- sign identifies the apostrophe as the Scale Factor. A second apostrophe indicates an ALGOL delimiter word (that is, a string of letters or an operator enclosed by apostrophes). In this case, the Delimiter routine (DELIMIT) is entered. If the scan is terminated by a logical operator (indicating that the closing apostrophe of a delimiter is missing), the Delimiter Error routine (EROUT -- not shown in the diagram) is activated. EROUT differs from DELIMIT, described below, only in point of procedural detail. DELIMIT compares the characters enclosed by apostrophes with a list of 38 delimiter words in the Delimiter Table (WITAB) and branches to the routine specified in the table for the particular delimiter. A majority of delimiters (21) lead into the NORHAL, TED, or GIF routines, which simply transfer the one-byte symbol in the Delimiter Table to the Modification Level 1 text. Declarators and specificators lead into routines which construct entries in the Identifier Table for the immediately following identifiers. OPENING OF SCOPES Whenever the delimiter opening a block, a procedure" a for statement, or a compound statement is encountered" a one-l::yte operator identifying the particular scope is entered in the Scope Handling Stack. The operators Beta (for a l::lock), Proc (for a procedure), For (for a for statement)" and Begin (for a cOITrpound statement), are stacked by the BEG1" PROCEDUR, FOR" and BEGIN routines, respectively. Depending On the structure of the l::ody of a procedure" the operator Proc may subsequently be replaced by the operators Proc* or Proc** in the BEGIN, STATE" or FOR routines. See "scope Handling Stack". At the beginning of every block and procedure, a program block heading entry" containing a new Program Block Number,. is constructed in the Identifier Table. The Program Block Number in the heading entry is copied into the following identifier entries representing identifiers declared or specified in the particular clock or procedure. Similarly" at the opening of every for statement., a for statement heading entry is constructed in the Identifier Table. The for statement heading entry is subsequently deleted unless it is followed by one Or more identifier entries representing a label or lal::els declared inside the particular for statement. In the latter case, a for statement closing entry is made at the end of the for statement. Program block heading entries are constructed by BEGl (for a block) and PROCID (for a procedure); for statement heading and closing entries by FOR and FOREND, respectively. The BEGl subroutine, which stacks the operator Beta and constructs the program block heading entry at the opening of a new block, is entered from any routine processing the first declaration following the delimiter 'BEGIN'. Entry to BEGl is governed by a switch named BEGBIT, which is turned on by the BEGIN routine., entered from DELIMIT on recognition of the delirriter 'BEGIN'. BEGBIT is tested in all declaration-processing routines (immediately after entry from DEI.IMIT)" and if the switch is on, a call is made to BEGl before the particular declaration is processed. BEGl and PROCEDUR also construct entries in the Group Table, Program Block Numter Table, and Semicolon Table. FOR makes entries in the Scope Tatle and Group Tatle. Chapter 4: Scan 1/11 Phase 33 PROCESSING OF DECLARATIONS AND SPECIFICATIONS In the construction of entries in the Identifier Table for declared or specified identifiers, the external name is copied from the translated source text in the Work Area, while the characteristic is inserted by an MVI instruction or, in the case of specified identifiers, copied from the Delimiter Table. Type declarations ('REAL', 'INTEGER' , and 'BOOLEAN') are processed by the TYPE routine. All type declarations are completely removed from the Modification Level 1 source text, whereas procedure., switch and array declarations are represented in the modified source text by a one-byte declarator, followed by the identifier (s) " as well as parameters., components" or dimensionS. Array and switch declarations are processed by the ARRAY, SWITCH, and LIST routines. The main function of the LIST routine, which branches to several subroutines is to count the number of dimensions or components of arrays and switches, and to store this information in the appropriate identifier entries. Entries for declared procedure identifiers are made by the PROCEDUR, PROCID, and IDCliECKl routines. The external names of formai parameters in the parameter list following a procedure identifier are copied into the Identifier Table by the IDCHECKl subroutine on call from PROCID. The characteristics of formal parameters are entered subsequently when the specifications in the procedure heading are processed. The routines which process specifications include, firstly, the TYPE, VALUE, SPEC, ARRAY, SWITCH, and PROCEDUR routines (depending on the particular specificator), and secondly, the SPECENT and IDCHECK routines (SPECENT is a special entry point of IDCHEcK) • To distinguish between declarations and specifications, a switch named PROBIT is used. PROBIT is turned on by PROCEDUR, as soon as a procedure declaration is recognized, to signify that a procedure heading has been entered. If a delimiter (say 'REAL') is subsequently encountered, the condition PROBIT=l signifies that the'delimiter is a specificator rather than a declarator and causes the particular routine activated (TYPE in this case) to branch directly to SPECENT. After copying the appropriate characteristic from the Delimiter Table to a (or standard storage location, SPECENT 34 IDCHECK) compares each identifier following the specificator (' REAL' in this example) with the formal parameters previously copied into the Identifier Table from the parameter list, and when the matching identifier is found, moves the characteristic into the identifier entry. No part of the procedure heading except the procedure identifier and the parameter list is transferred to the Modification Level 1 text. Type-qualified procedure and array declarations are processed by the TYPE, TYPPROC, or TYPARRAY, and PRCCEDUR or ARRAY routines l in that order. CLOSE OF SCOPES When the delimiter' END' is encountered, the END routine inspects the operator at the top of the scope Handling stack and calls an appropriate subroutine (PBLCKEND, FOREND, or COMPDEND) " according to the stack operator detected. PBLCKEND is called if 'END' closes a block or a procedure (indicated by the stack operators Beta, Proc, Proc* or Proc**). PBLCKEND transfers the last block of entries in the Identifier Table representing identifiers declared or specified in the clos ed block cr procedure" to the SYSUT3 data set~ releases the stack operator; and transfers the closing operator Epsilon to the Modification Level 1 text. FOREND and COMPDEND (which are called if the stack operator is For or Begin" respectively), transfer the operators Eta or End to the modified text, and release the stack operator. FOREND may also ccnstruct a for statement closing entry in the Identifier Table, or delete the preceding for statement heading entry. The Scope Handling Stack is also inspected by the SEMCO routine in case a semicolon closes a procedure or a for statement. In the affirmative case" the PBLCKEND or FOREND subroutine is called. END OF PHASE The Termination routine (EODADIN)" which closes the Scan 1/11 Phase, is normally entered as an EOD (End of Data) routine from the Operating System" after the PBLCKEND subroutine has detected the final exit. from the outermost scope of the source module and has initiated a special scan of the closing text, designed to detect possible logical errors. EODADINmay also be entered when a terminating error has been detected in the source module, in which case control is passed directly to Diagnostic Output Module IEX21, rather than to the Identifier Table Manipulation Phase (IEX20). The conditions under which EODADIN is entered are described more fully under "Close of Scan 1/11 Phase". Flowcharts 011 and 012 in the Flowchart Section indicate the logical arrangement of the principal routines in the Scan 1/11 Phase. All of the major routines illustrated in the diagram in Figure 7, namely TESTLOOP, APOSTROF, and DELIMIT, can be readily distinguished in the charts. The various levels of routines entered from each of these routines may be seen in both the chart and the illustrative diagranl. the Program Block Number of the clock or procedure" and the record length are contained in the first (heading) entry. An ESD record for the object module and TXT records of the strings stored in the Constant pool are generated on the SYSLIN and/or SYSPUNCH data sets, provided the options LOAD and/or DECK are specified in the EXEC job control statement. If the source module is a precompiled procedure to be stored on a partitioned data set, the ESD record will contain the procedure name. If the SOURCE option is specified, a listing of the source module is printed out on SYSPRINT. The name of this phase, Scan 1/11, derives from the fact that the source module is twice scanned in the phase, first by the Change Input Buffer subroutine (CIB), when the source text is translated to the internal code, and second by TE8TLOOP, APOSTROF, or some other lower level routine. PHASE INPUT/OUTPUT SYSUTl - Modification level 1 Souree rex' ~ - SYSIN Identifier Table Souree Wcdule SCAN 1/11 Figure 8 pictUres the data input to and output from the Scan 1/11 Phase. The figure also indicates the tables and other data transmitted to the subsequent phases via main storage. PHASE SYSLIN/SYSPUNCH !"- r--- ----, I Input consists of the source module on the SYSIN data set (card reader, disk unit, or magnetic tape unit). Input records, 80 characters in length, are read into the Work Area (WA) by means of a GET macro instruction. The transformed source text (Modification Levell) output by the phase is transferred to the SYSUT1 data set by a WRITE macro instruction from two alternating output buffers in unblocked, fixed length records. At phase termination, the data set is closed by a Type T CLOSE (no repositioning to the beginning of the data set). RecordS are numbered serially from O. In the event the transformed source text occupies less than one full buffer, it is transmitted to the Scan III Phase via main storage. The Identifier Table is transferred to the SYSUT3 data set by means of a WRITE macro instruction, in variable-length records of up to 2000 bytes (181 Identifier Table entries of eleven bytes each). Each record comprises the set of identifiers declared or specified in a block or procedure. The record number, represented by ESD record md TXT record. of Con.tan. Pool I I MalnSto_ Error Pool Group Table I S " " , . Tabl. I II p....... 610d< Number Table [Modification Lev.1 1 Source L __T:,t1 ___ : I I I I I SYSPRINT I Source NadJI. Listing J '--- • Source text tronsmltted in main storage if It occupies lea than a full buffer. Figure 8. Scan 1/11 Phase Input/Output IDENTIFIER TABLE (ITAB) The Identifier Table (ITAB) is a working record in which an internal form of operand representation, facilitating later compilation operations, is constructed for every valid identifier declared or specified in the source module. This internal representation, referred to as an identifier's internal name, replaces all externally represented operands in the source module. The replacement is made in the Scan III Phase after the construction of the Identifier Table has been completed by the Identifier Table Manipulation Phase. Chapter 4: Scan I/II Phase 35 The entry constructed for an identifier, called an identifier entry, is eleven bytes in length. It contains up to six characters of the identifier's external name, translated to internal code, and a fivebyte internal name. For declared procedure and switch identifiers and labels, the complete entry, compr~s~ng external and internal name, is constructed in the Scan LlII Phase. For all other identifiers, the external name and all except the address part of the internal name is constructed in the present phase, the address part being inserted in the Identifier Table Manipulation Phase. Each set of identifier entries representing identifiers declared or specified' in a block or procedure, is headed by a program block heading entry. The heading entry contains the Program Block Number assigned to that block or procedure. At the close of a block or procedure, the block of entries relating to that block or procedure is transferred as a record to the SYSUT3 data set. Within a given block of entries, an entry (or entries) representing a label (or labels) declared inside one or more for statements, is enclosed by one or more for statement heading entries and a for statement closing entry. The Identifier Group Numbers in the for statement heading and closing entries are used, in the Scan III Phase, in detecting illegal branches into for statements. (SWlLA routine in IEX30.) The processing of the Identifier Table is described in further detail in a later section. or procedure identifier is type-qualified, the characteristic is modified by a logical instruction to show the type. The hexadecimal value of the characteristic for each type of identifier is shown in the table in Appendix II. ~he characteristic. which serves to describe the identifier. is inspected in the subsequent phases. Each of the binary positicns in the characteristic identifies (when set = 1) a particular characteristic of the identifier. The significance identified with each position is shown in Figure 9. Bits 5 and 6 of the first byte are designated Special Use Bits because they may be manipulated in the Scan III Phase if the identifier is a critical identifier. that is, if the identifier occurs in a for list. First Byte (Byte 6 in identifier entry) Bit No: ~} 2 3 4 5 6 7 Second Bit No: o I 2 6 7 Figure 10 shows the content of the eleven-byte entry constructed in the Scan I/II Phase for all identifiers except those of declared arrays, procedures, switches, and labels. The identifier's external name, represented by a maximum of six characters in internal code (Appendixes I-a and I-b), is copied from the translated source text in the Work Area, after the full identifier has been checked for validity. If the identifier does not satisfy the specifications of the OS/360 ALGOL Language with respect to validity, no entry is made, and an error is recorded in the Error Pool. The tWO-byte characteristic, in the case of declared identifiers, is provided by the program (i. e. by an MVI instruction). In the case of specified identifiers, the characteristic is copied from the Delimiter Table (see DELIMIT routine). If an array 36 Operand (See use of bits 0-2 in "Operator/Operand Stacks" - Chapter 8) Not used Not used No Assignment Special Use I Special Use 2 String Byte (Byte 7 in identifier entry) 3 4 5 IDENTIFIER ENTRIES Description Figure 9. Description Standard Procedure } Procedure Code Procedure Call by Value } Simple Call by Name Variable Label Array Real } Boolean Integer Identifier Characteristic The Program Block Number (P.B.No.) is copied from the program block heading entry of the block or procedure in which the identifier is declared or specified. With the exceptions already noted ana described more fully below, the last two bytes of the identifier entry as constructed in the Scan I/II Phase, are filled with zeros. They are reserved for a relative address which is inserted by the Identifier Table Manipulation Phase. The address specifies the identifier" s object time storage field within the Data Storage Area provided for the block or procedure in which the identifier was declared or specified .• Figure 11 shews the content of the entry constructed for a declared array identifier. The external name. characteristic, and Program Block Number are entered in the manner described above. The number of subscripts (or dimensions) of the array is entered in the first half of byte 9. The last one-and-a-half bytes, filled with zeros in the Scan I/II Phase, are reserved for the relative address of the array's Storage Napping Function in the particular Data Storage Area. The address is inserted in the Identifier Table Manipulation Phase. The entry constructed for a declared procedure identifier is shown in Figure 12. The external name and characteristic are entered in the manner described earlier. A new Program Block Number is assigned to the procedure. This same Program Block Number appears in the immediately following program block heading entry, which heads the set of entries representing formal parameters specified in the procedure. The number of parameters of the procedure is entered in the first half of byte 9. The last one-and-a-half ~ytes of the entry contain the relative address, referred to as the La~el Number (LN), of a four-byte entry reserved in the object time Label Address Table (LAT). At Object time, the Label Address Table entry contains the absolute o address of the the procedure. In the case of a declared typeprocedure, the heading entry ~hich follows the procedure identifier entry is followed by a second entry for the procedure identifier. The two identifier entries for a type-procedure are identical. except that in the entry which precedes the heading entry, the first ~yte of the characteristic is equal to hexadecimal CA, ~hile in the entry which fcllo~s the heading entry. the first byte of the characteristic is equal to hexadecimal C2. Figure 13 shows the entry constructed for a declared s~itch identifier. ~he entry is identifical ~ith that for a declared procedure identifier, except that the first half of byte 9 contains the number of components of the switch. minus one. The entry constructed for a declared label is shown in Figure 14. The entry differs from that for a procedure identifier only in that the first half of byte 9 is unused and set to zero. 8 6 object code generated for 11 9 r----------------------------------T-----------T-----~----------, I I 1~ ____ No·>1L_ __________ JI <------(Internal Name)------> = (Reserved) : The last one-and-one-half ~ytes are reserved for the relative address of the identifiers's object time storage field -- inserted by the Identifier Table Manipulation Phase Figure 10. Identifier Table entry for all identifiers except declared array, procedure and switch identifiers and labels o 6 8 9 10 11 r----------------------------------T-----------T-----~----------, I I (Re- 1 istic>1 No. _L >1 ___________ served) lI IL__________________________________ I __________ _L ____ ~ <------(Internal Name)------> : (Reserved) = The Figure 11. last one-and-one-half bytes are reserved for the relative address of the array's Storage Mapping Function. inserted by the Identifier Table Manipulation Phase. Identifier Table entry as constructed in the Scan 1/11 Phase for array identifier a declared Chapter 4: Scan I/II Phase 37 o 8 6 10 9 11 r----------------------------------T----------~----~-----------, I I I I I L _L ____ _L __________ -J istic>1 No·>1 I __________________________________ ~ __________ <------(Internal Name)------> = = = Figure 12. Identifier Table entry for a declared procedure identifier o 8 6 10 9 11 r----------------------------------T-----------~----~----------, I I I _L __________ -JI istic>1 ____ No·>1 IL __________________________________ I ___________ ~ ~ <------(Internal Name)------> = = = Figure 13. Identifier Table switch identifier o entry constructed 8 6 in the scan I/II Phase for a declared 9 10 11 r----------------------------------T-----------T-----~----------1 I I I I No·>1 L ______ ----------------------------~-----------L-----~ I __________ I J <------(Internal Name)------> = = Relative address of an entry in Label Address Table> Figure 14. Identifier Table Entry constructed in the Scan label PROGRAM BLOCK HEADING ENTRIES A program block heading entry heads every set of identifier entries representing identifiers declared or specified in a block or procedure. Figure 15 indicates the content of the eleven-byte program block heading entry. The first eight bytes provide two four-byte save areas, in which the contents of the pointers LIGP and LPBP are stored, before these pointers are set to the address of the heading entry itself. The first bit of byte 8 functions as a switch to indicate if the scope is a type-procedure. In this 38 I/II Phase for a declared case, the bit is set = 1; in all other cases, it is set = O. The Identifier Group Number (I.G.NO.) and Program Block Numter (P.B.No.) are copied from two counters (IGN and PBN) '. IGN is incremented for every block, procedure, and for statement, while PBN is incremented for tlocks and procedures only. At the close of a block or procedure, when the set of entries representing identifiers declared or specified in the block or procedure is transferred to a utility data set, the length of the record to be transferred and the semicolon count (copied from the corresponding entry in the Semi co- Ion Table) are inserted in the heading entry, as indicated in Figure 16. 8 9 o 4 10 11 ,r-------------------,---------------------,.-----------,------, 1 I L ___________________ = 1 1< K> <1. G. 1 1i _____ No·>1J ~ <1<> X'8' for a type-procedure; X'O' in all other cases Figure 15. o Program block heading entry 2 5 6 8 10 9 11 r---------,--------------,------T---------~----------~-----, l <1.G·I iI- ____________ iI _____ iI __________ count> No.>1 No·>1J IL_________ iI __________ -L _____ Figure 16. Program block heading entry, as transmitted to the SYSUT3 data set FOR STATEMENT HEADING AND CLOSING ENTRIES the Identifier Group Number of the ing block or procedure. A for statement heading entry is constructed in the Identifier Table as soon as the delimiter FOR is encountered. If no labels are declared inside the for statement (or a nested for statement), the entry is deleted at the close of the for statement. If, however, any labels are declared inside the for statement, a for statement closing entry is constructed at the close of the for statatement. Where a label is declared inside a series of nested for statements, the entry for the declared label is preceded by a heading entry for each enclosing for statement, and is followed by a single closing entry containing o 4 5 6 8 emtrac- The first four bytes of the for statement heading entry are used as a save area in which the contents of the pointer LIGP are stored before that pointer is reset to the address of the heading entry itself. The Identifier Group Numter (I.G.No.) is copied from the counter IGN, which is incremented successively for every tlock, procedure, and for statement in the source module. The Identifier Group Number in the for statement closing entry is copied from the heading entry of the reentered scope. 9 10 11 r-----------------r-----,------T-----------,.-----------,------, IL________________ I I - iI _____iIX'2B'I _____i ___________ I __________ i _ _ ___ J ~ = Figure 17. o For statement heading entry 5 6 7 8 9 10 11 r-----------------------T-----T-----T-----~---------T-----, I _______________________ iIX'2B'IX'FF'I L _ ____ i _____ i Figure 18. I __________ - iI ____ - lI ____ - i For statement closing entry Chapter 4: Scan 1/11 Phase 39 for statement closing entry is constructed following the entry for the label. At the close of a block or ~rocedure, the set of entries representing identifiers declared or specified in the block or procedure are transferred to the SYSUT3 data set. ~he transfer is handled by the PEICKEND subroutine on call from the END or SEMCO routine. PROCESSING OF THE IDENTIFIER TABLE The diagram in Figure 19 illustrates the processing of the Identifier Table in the Scan 1/11 Phase. At entry to every block or procedure, a program block heading entry, containing a new Program Block Number, is constructed. (In the case of a procedure, the heading entry is preceded by an entry containing the procedure identifier.> Program block heading entries are constructed by the BEG1 subroutine, on call from declaration-processing routines, and by the PROCID routine, entered from PROCEDUR. At entry to a for statement, a for statement heading entry is constructed by the FOR routine. At the close of a for statement, the heading entry may be deleted, or if any labels are declared in the for statement, a A pointer named LPBP at all tirres addresses the heading entry of the current (embracing> block or procedure. LPBP is used 1. In copying the Program Block Nurrber into the following identifier entries, 2. In transferring the Program Block Number of a reentered block to the Modification Level 1 text following the operator Epsilon, which closes a tlock Contents of Identifier Tobie Work Area in Scan 1/11 Phore at Varying Points in Soorce IVodule Source Module Block Structure (Letters refer to labelled positions in block diagram at left) c:::=E}-{tf~ 0 -- AITL b) PSl (bJo<.:k or procedure) e\ d) c) b) a) j Proc.Nome Proc.Nome !-{tfgph t----i * rDedaea,;ao.;s,e,;,;,a,;ao, c) L-_-'.__ I I I I AITl PB2 (block) Proc.Name'" ) 1 \ \ \ \ I I I '.B.l P,B.1 2 P.B.2 P.B.2 3 -{ti~~ '.B.2 \ For Hdg. LABEL: Proc.Name 'M4 ('ype-peaced,,, - Mm, '4) I Proc.Nome~' ) I 1 \ \ I I P.B.1 1 1 2 Proc.Name* I 3 m) P.S.3 for Hdg. Lobel J For Close .. - A1Tl , P.B.T P.B.l I I 3 !=-AITL 1------1 I I I I '.B.3 I I '-{tf~p 4 f-----l I P.B.2 2 I I 1'3 : SVSUT3'" 'a SVSUT3 I I '0 AITl I '.B.2 I L ___ J r---- I I ;----11+f--+---.-/ I P.B.l I Proc.Nam ~~ __ -l -{t~~ ;0 '4 SVSUTl P.SA L~~5!.2:......j Label '3 '4 '4 r----1 I \ P.B.2 / , .----2..,·1 ~tr~p f------I.' f---__2,,1 -{ti~p} '3 1 \I I I P.B.2 P3 I Proc.Nome Proc.Nome* ) \\ P,'B.1 P.B.2 n) LlGP AITl lPBP \ t,, EEsilon *< IGN>* Procedure Pi Epsilon * * Typeprocedure Phi Epsilon * * For Statement For Eta * Compound Statement Begin End * PBN or IGN of the reentered scope The Program Block Number (PBN) occupies one byte, the Identifier Group Number (IGN) two bytes. SCOPE HANDLING STACK The action required at the close of every scope depends on whether the scope is a block, a procedure, a for statement, or a compound statement. Thus, at the close of a block or a procedure, the set of entries in the Identifier Table representing the identifiers declared or specified in the block or procedure, is transferred to the SYSUT3 data set, and the operator Epsilon is transferred to the Modification Level 1 text. At the close of a for statement, a closing entry may be made in the Identifier Table and the operator Eta transferred. At the close of a compound statement, the operator End is Simply transferred. Owing to the fact that the same delimiter ( 'BEGIN') opens both a block and compound statement, and owing also to the fact that procedures and for statements may be closed by the delimiters 'END' or a semicolon, depending on their structure, a method of classifying each scope is required, so as to specify both the delimiter to be identified as the closing delimiter and the r---------------T------------------------------------------------~---------T-----------, IStack Opera tor I I 1 I .------~-------~ 1 I 1 I Name 1 Hex. I Significance IStacked bylReleased byl ~------+--------+------------------------------------------------+----------+-----------~ I I I I 1Begin I 08 Designates a compound statement, closed by 1BEGIN 1CO!!PEND I 1 'END'. IBeta 04 I I Proc* Designates a block, closed by 'END' IProc For OC Designates a procedure, closed by a semicolon or by 'END'. 'END' unconditionally closes the embracing scope. The procedure body consists of a procedure statement, a dummy statement or a delimiter 'CODE'. PROCEDURE IPBLCKEND I ~ _______ Figure 20. 42 1 I 1 Designates a for statement, closed by a semiFOR colon or by 'END'. A semicolon may close an embracing procedure or for statement. 'END' unconditionally closes the embracing scope. I I IPBlCKEND IPBLCKEND I 1 1 I I FOREND 1 I 1 1 00 1l ______ I I Designates a procedure, closed by a semicolon STATE or by 'END'. 'END' unconditionally closes the FOR embracing scope. The procedure body consists of a labelled statement or block, or a Single assignment, gato, conditional or for statement. 1 1 1Alpha 1 IPBlCKEND I I PBLCKEND I I BEGIN 18 1--- BEGIN I 1 Designates a procedure, closed by 'END' The procedure body consists of an unlabelled block or compound statement. 14 Proc** 1 10 1 I 1 I ~ 1 Marks the bottom of the stack. ALPHA is stackedlInitiali- 1Termination I only at phase initialization and released only I zation I I at phase termination I __________ I ___________ JI _______________________________________________ Scope Handling Stack operators ~ ~ particular action to be taken at the close. The device used for the classification of scopes is the Scope Handling Stack. The Scope Handling Stack employs a set of six stack operators, each of which identifies a characteristic scope structure. Whenever a delimiter is detected which marks the opening of a new scope, an appropriate operator is placed in the stack. If, subsequently, some feature is detected in the scope which indicates a change in structure, the operator originally placed in the stack is replaced by another operator which correctly reflects the structure of the scope. When the delimiter specified by the stack operator as the closing delimiter is encountered, the operator is released from the stack. In this way, all embracing scopes at every point in the source module are classified by the operators in the stack, the innermost scope being classified by the last stack entry. The list in Figure 20 indicates the stack operators, their significance, and the routines which stack and release the operators. Stack operators are tested in the SEMCO, STATE, BEGIN, CODE, FOR, END, PBLCI lof the fori I ____________________ I statement> L __________ JI Valid labels are transferred, but the colon following a declared label is replaced by the Label Colon. Entry forr---------------------T----------, a block I I zeros>1 d. o 2 3 ~ procedureL--------------------~----------J e. f. Parameter delimiters of the form ) LETTERS: ( are replaced by the Comma. If a parameter delimiter extends across two output buffers, the symbol Rho is inserted at the beginning of the second buffer, indicating to the Scan III Phase that the letters at the end of the preceding record are to be replaced by the Comma. The record-end operator Zeta is inserted at the end of every output record, except the last, in which the character Omega marks the end of the Modification Level 1 text. All operands (identifiers) contained in statements in the source module are transferred unchanged to the Modification Level 1 text, except for the initial translation to the internal code mentioned in item 1 above. Figure 21. Group Table entries for a for statement and for a block or procedure SCOPE TABLE (SPTAB) The Scope Table is constructed in the Scan 1/11 Phase and transmitted to the Scan III Phase in main storage. A one-byte entry is constructed for every for statement, indicating the Program Block Number (P.B.No.) of the enclosing block or procedure. The Scope Table is used in the scan III Phase in determining whether all terms of array subscript expressions occurring in for statements are declared outside the for statement (i.e. nct in a block enclosed by the for statement). Chapter 4: Scan I/II Phase 45 o 1 r-----------------------------------------, I I _________________________________________ L JI Figure 22. One- byte Scope Table entry PROGRAM BLOCK NUMBER TABLE (PBTAB1) The Program Block Number Table is constructed in the Scan 1/11 Phase and transmitted to the Identifier Table Manipulation Phase in main storage. A one-byte entry is constructed for every block and procedure, indicating the Program Block Number of the enclosing block or procedure. The Program Block Number Table is used in connection with the print-out of the Identifier Table listing in the next phase, in which the Program Block Number of the block or procedure embracing each block and procedure is shown. o 1 r-----------------------------------------, I JI Figure 23. One-byte Program Table entry Block Number specifies, in general, that scanning for the appropriate character sequence is to continue. STARTBIT = 1 (on) signifies that the opening delimiter has been found. The chart in Figure 24 shows the logical flow through the routines which process the opening delimiter, and the function of the STARTBIT. In the TESTLOOP routine the condition STARTBIT off has the effect of limiting the character search to an apostrophe (the first of two apostrophes enclosing a delimiter word). When an a~os trophe is found, control is passed to APOSTROF, which searches for the secend apostrophe and then branches to DELIMIT. In DELIMIT, the condition STARTBIT eff causes a branch to a s~ecial-purpose routine, called STARTDEL, whose function is to activate FIRSTBEG, PROCEDUR, or TYPE, according to whether the delimiter is 'BEGIN', 'PROCEDURE' or 'REAL', 'INTEGER', or 'BOOLEAN', respectively, and to return control to TESTLOOP in all other cases. If the source module is a ~rogram and the delimiter is 'BEGIN', STARTBIT is turned on by FIRSTBEG, thus signifying that the correct opening delimiter has been found. If the source module is a ~recompiled procedure and the delimiter is 'PROCEDURE' or ' ' 'PROCEDURE', STARTBIT is turned on by PROCEDUR. In all other cases, an error is stored in the Error Pool, and control returned to the TESTLOOP, which continues to scan for an apostrophe. PROCESSING OF OPENING SOURCE TEXT CLOSE OF SCAN 1/11 PHASE The source module as specified in the EXEC statement may be a program or a precompiled procedure. If the source module is a program, the operative (programming) text in the source module must be opened by the delimiter 'BEGIN'. If the source module is a precompiled procedure, the operative text in the source module must be opened by the delimiter 'PROCEDURE' or by one of the delimiter sequences 'REAL' 'PROCEDURE', 'INTEGER' 'PROCEDURE', or 'BOOLEAN' 'PROCEDURE'. Since the opening delimiter may be preceded by comment, provision is made in the Compiler to assure that, at the start, all text is disregarded until the correct delimiter or delimiter sequence is found. To facilitate the search for the correct opening delimiter, a number of specialpurpose routines, as well as a switch named STARTBIT, are used. STARTB1T = 0 (off) signifies that the opening delimiter has not been found and 46 The EODADIN routine, which closes the Scan 1/11 Phase and which transfers control to the succeeding phase, may be entered under four main conditicns: 1. At the logical close of the source module, when the logical terminal delimiter ('END ' in most cases) has closed the outermost scope of the source module 2. When an unexpected End of Data condition occurs 3. When a terminating syntactical error is detected in the source module 4. When a program interrupt or unrecoverable I/O error occurs. Charts A, B, C and D in Figure 25 show the flow of control through the various routines before EODADIN is finally entered, under the four conditions mentioned. Opening delimiter found AYe, '" , ,/"BraneR", <. accord. to "') ' .... chcr. /"" ",(/ r------t-------, t I I (COLON, POINT, SEMCO, etc. Operator DigitI Invalid character TYPESPEC • Ye, (Normal processing) ~ROCEDURE'~-------------------, Ye, Opening delimiter found Opening delimiter found Ye, /A, t (Normal processing) '" , .,.,"'Branch', acccrd. to " ,~e1imit~/ " <",""Branch accord. to < (Continue scanning for opening delimiter) r---'-----, 'y/ r------t-------, I t (NORMAL, TED, GIF, etc.) 'PROCEDURE' I '.e~imi~ .? y 1"'------+-----, I t t (NORMAL, TED, GIF, etc.) ERRS (Begin normal processing) Figure 24. (Continue scanning for opening delimiter) Chart showing the logical flow in the search for the opening delimiter and showing the function of the STARTBIT In Chart A, the logical close of the source module is detected by the PBLCKEND subroutine signifies that a procedure heading has been entered and specifies to declaration-processing routines that, until turned off, all declarative delimiters such as 'INTEGER', are to be processed as type specifiers of formal parameters, as opposed to type declarators. (turned off by the STATE, BEGIN, FOR, and CODE routines, when a statement, or the delimiter 'BEGIN', indicating the end of a procedure heading, is identified> specifies to declaration-processing routines that, until turned on, all declarative delimiters are to be processed as type declarators, not as specifiers. laration and upon entry to the SWITCH routine> signifies to all routines that, unless turned on, the character being processed forms part of a switch list. LISTBIT: Qg (turned on by the ARRAY routine on recognition of a comma following an array identifier> signifies that the next identifier is a continuation of a list of declared array identifiers with the same dimension list, and specifies that a Comma is to be transferred to the output buffer to separate the last identifier from the next. off has no significance. TERBIT: DELTABIT: on off: (turned on by declaration-processing routines> identifies the fact that a declaration has been detected and specifies to the SEMCO routine that the semicolon immediately following is to be replaced in the output string by the one-byte operator Delta. (turned off by the SEMCO routine> signifies that, unless subsequently turned on, the next semicolon is to be represented by the Semicolon operator. ~ (turned on by the ENDMISS routine after control has been passed to it by the Operating System at End of Data> speoifies to the PBLCKEND subroutine that control is to be returned to ENDMISS. off (turned off at phase initialization> has no significance. ENDBIT: on signifies that the delimiter which logically closes the source module has not yet been reached. IDBIT: on (turned on by the PROCID routine> signifies that the next identifier is the procedure identifier and specifies that a program block heading entry is to be made in the Identifier Table to mark the beginning of a new identifier group. Qff (turned off by the PROCID routine> Signifies that the procedure heading entry has been made in the Identifier Table and specifies that the formal parameter part of the procedure heading is being processed. COBIT: on specifies to the COM routine that the source string up to the next semicolon is to be deleted. The characters deleted may be a segment of the form: ' COMMENT' ;. off specifies that the source text up to the next semicolon or the delimiter "ELSE' or 'END', is to be deleted. This deletes: ARBIT: on off 50 (turned on by the ARRAY routine> signifies that an array declaration has been identified and specifies to all routines that the character being processed forms part of an array list. (turned off upon identification of a semicolon terminating an array dec- 1. Any comment enclosed as follows: 'END' 'ELSE'/'END'/: or 2. An erroneous statement or declaration (or portion thereof). lowing 'END', a branch is to te taken to the COMPEND2 routine. The latter activates the FCREND or PBLCKEND subroutine, depending on whether the stack operator is For or Proc**. STARTBIT: off (turned on by the F1RSTBEG and PROCEDUR routines) signifies that the opening delimiter of the source module has been found. off E11B1T: (turned off at phase termination) signifies that the opening delimiter of the source module has not been found. See "Processing of Opening Source Text". (turned on by ERRS) signifies that error No. 11 has been recorded, and that the error should not te recorded again. off VALBIT: (turned on by the VALUE routine) signifies to the SPEC routine that a value specification is being processed. (turned on by PROCID) signifies that the formal parameter list of a declared procedure is teing processed and that the end of the list has not been reached: and specifies to IER that control is to be returned to PROCID after a defective parameter has been processed. PROBIT: off (turned off at phase has no significance. (turned off by PRCCID when the serricolon following a formal parameter list is found) has no particular signif icance. NOFREE: (turned on in CLOSE2) signifies that main storage for the private area has not been acquired, and specifies to EODAD1N that a FREEMAIN macro instruction is not required. termination> FRSTPUT: (turned on by the GENERATE routine> signifies that the first PUT instruction has been issued, and that the address of an output buffer is available. off off signifies that the first PUT instruction has not been issued. ENDELSEBIT: (turned on by the END routine when, after the delimiter 'END' has closed a block or compound statement, a test shows that the stack operator is For or Proc**> signifies that the embracing scope is a for statement Or a procedure which may be closed by a semicolon, and specifies to the COM routine that, if a semicolon is found to terminate the comment fol- (turned off at phase initialization) signifies that error No. 11 has not previously been recorded. FMBIT: (turned off in the IDCHECK routine) signifies that, unless turned on, a type specification (not a value specification) is being processed. (turned on by EODAD1N in the event the source module is a precompiled procedure) specifies to PBLCKEND that control is to be returned to EODADIN, after Program Block 0 in the Identifier Table has been transferred to the SYSUT3 data set. (turned off by the END, COMPEND2" and TED routines) has no significance. off (turned off at initialization) signifies that no previous output has taken place on SYSUT3 and that, accordingly, a CHECK macro instruction is not required tefore the next output operation. PROCESD: on (turned on in the PROCEDUR routine) Chapter 4: Scan 1/11 Phase 51 signifies that the source module is a precompiled procedure and specifies to the PROCID routine that an ESD record is to be made for the procedure name. off (turned off by the PROCID routine) signifies that the source module is a program, or that the ESD record for a precompiled procedure has been generated. POOL L0 C AKOPOOL r SPCLT I (Space reserved for constants 0 - l5, stored in Constant Pool at phase termination - displacement 64) Constant Pool (4096) SP I t ATOPS TAK AITAB BUFF ScoE;e Handline Stocle (1000) Identifier Table Buffer (2000) CONSTITUENT ROUTINES OF SCAN 1/11 PHASE ADDA RI +4 Source Buffer No.2 The principal constituent routines of the Scan 1/11 Phase are described below. The page on which each routine is described and the flowchart in the Flowchart Section in which the general logic of the routine is set forth may be found with the aid of the Index in Appendix XI. AITAB LlGP LPBP 1 J AITL T I * (Heading entry for P .B.O constructed Identifier Table (ITAB). The position of the major routines in the overall logical organization of the phase may be determined by reference to Flowcharts 011 and 012 in the Flowchart Section. MGESlTL = ITAB length ELI * Area size specified by Area Size Table in Common Work Area. See Appendix VIII for the variation in area sizes as a function of the SIZE option. PHASE INITIALIZATION Figure 26. The Initialization routine gets main storage for the private work area shown in Figure 26; initializes pointers; specifies EOD and program interrupt-I/O error routines; assembles headlines for the source module listing; and activates the Change Input Buffer subroutine (CIB). The routine exits to TESTLOOP. The entry, ENoMISS, in the event of an End of Data (EOD) ccndition on the SYSIN data set is stored at EODIN, the location referenced by the End cf Data Exit routine in the Directory. The entry pOint of the routine activated in the event of a program interrupt or an I/O error (both of which terminate compilation) is stored in ERET, the location referenced by the Program Interrupt routine (PIROUT) and the I/O Error routines (SYNAD and SYNPR) in the Directory. The entry point CLOSE2, specified at entry is changed, after the GETMAIN instruction haS been issued, to EODADIN. Both CLOSE2 and EODADIN close data sets and transfer control to Diagnostic output Module IEX21. EODADIN in addition releases main storage. The GETMAIN instruction for the private work area is executed after the total area required has been computed. The area sizes needed for the Identifier Table and Source Buffer No.2, which depend on the capacity of the system used, are obtained from the Area Size Table entries named ITAB10S and SRCE1S, respectively. The areas allocated to the Constant Pool, Stack, and ITAE buffer are fixed at 4096, 1000 and 2000 bytes, respectively, for all systems. The various pointers initialized are shown in Figure 26. A fuller explanation of the pointers LPBP and LIGP is given under the heading "Processing of the Identifier Table". 52 Private Area acquired by the Scan 1/11 Phase., showing pcinters initialized r--------------------------------, (Source Buffer No.1) Ir----------------->IL ________________________________ JI o ADDARI I 4 8 r----+----~--------, IA(Buff l)IA(Buff 2)1 L ___ -L ___ -L ___ o t EAP (Reg. 3) APE ~----J r--------------------------------, I 1 t L _____ ~->IL ________________________________ (Source Buffer No.2) JI r--------, DISP IL ________ 0 or 4 JI Figure 27. Source text buffers and pointers Source Buffer No. 2 is the second of two buffers used for output of the modified source text generated by the phase. Buffer 'No. 1 is set up in the Common Area by the Initialization Phase, its beginning address being stored at SRCE1ADD and its end address at SRCE1END. The present initialization routine stores the addresses of both buffers in an eight-byte field named AD DARI, and then initializes the pointers EAP (Register 3) and APE for Source Buffer No. 1 (see Figure 27). EAP and APE are updated whenever buffers are exchanged by the Change Output Buffer subroutine (COB). The particular address loaded in EAP from ADDARI is determined with the aid of a control byte named DISP (reset from 0 to 4 and vice versa just before EAP is updated), which specifies the displacement (0 or 4) from ADDARI. A heading entry (Figure 28) for Program Block 0 (an arbitrarily defined block enclosing the source module) is constructed in the Identifier Table. The current entry position AITL is set to point to the next free entry in the Identifier Table. o 3 4 5 6 11 r----------T----~---y_---y_--------------, I __________ I____ FF L_ I ___ L_ I _2B I ______________ JI L _ _ L_ ~ Figure 28. Heading Entry constructed at initialization in Identifier Table for Program Block 0 The following dispositions are made in the Cornmon Work Area, in which the addresses of the various tables and other fields are defined by a dummy control section in IEX11. The address of an 88-byte dummy print area named SAVEPRNT is stored at APRINTAR. If the SOURCE option is not specified, the Change Input Buffer subroutine (CIB) moves each source record to SAVEPRNT, in order that strings may be stored in the Constant Pool in external code. If, however, SOURCE is specified, indicating that a listing of the source module is to be printed, source records are moved instead to a print toffer specified by the PRINT routine in the Directory. In this case, the address in APRINTAR will be replaced by the address of the print buffer. In preparation for the print-out of a source module listing, the headlines ("SOURCE PROGRAM" for the first line and "SC SOURCE STATEMENT" for the second line) are moved to a field named PAGE HEAD in the Common Work Area from the locations HDING1 and HDING2. The headlines are printed out by the Directory PRINT subroutine, on call from CIB, if the SOURCE option is specified. The BITS1 r--, I BEGBIT 01 11.--~IPROBIT BITS2 r--, IENBIT 01 .--i 41 IARB1T 51 I LISTBIT ~--i IE11BIT 11.--~ICOBIT 11 IFMBIT 31.--~IVALBIT 31 J--~ 41 IPBOBIT .-~INot used 51 ~--~ ~--~ ~--i J-~ 61 71 ITERB1T Figure 29. IFRSTPUT J--~ 21.--~I NOFREE .--i IFRSITB .--4IPROCESD 41 .--iI Not used 51 ~--i 61 I Not used 71L __JIENDELSEBIT 71 I Not used INot used 61 L __ J r--, 01 .-~ISTARTBIT 21.--~IDELTABIT 21 31.--~I IDBIT BITS3 .--i L-_J Switches Phase used in Scan 1/11 See "Switches" in this chapter. The Program Block Counter (PBC', Identifier Group Counter (IGC), Semicolon Counter (SC), For Statement Counter (FSN), and output Record Counter (ONC) are initialized at 0, and the first entries (0) for Progra~ Block 0 are made in the Program Block Number Table (PBTAB1), Group Table (GPTAB), and Scope Table (SPTAB). The control Chapter 4: Scan 1/11 Phase 53 switches used in the phase, which are contained in three bytes named BITS1, BITS2, and BITS3, are zero-set. The switches in each byte are shown in Figure 29. Their function and significance is explained elsewhere in this chapter under "Switches" • Hexadecimal Diselacemen t 00-03 04 08 OC 10 14 18 1C 20 24 28 2C 30 34 38 3C 40 44 48 4C 50 54 58 5C 60 64 68 6C 70 74 78 7C 80 84 88 8C 90 OPIN and LAPIN are the names of two special-purpose output buffer pointers. OPIN is always adjusted to point to the character that may precede a label or begin a parameter delimiter. These include Begin, ~, Do, Else, Delta, semicolon, and). At OPIN + 4 is noted the number of the output record (ONC) " in which the character pointed at by OPIN is to be found. LAPIN points to the first byte following that pointed at by OPIN, where the letter string or label may begin. OPIN and LAPIN may be separated by two or more characters. OPIN and LAPIN are used when declared labels are entered in the Identifier Table or when a letter string is replaced by a Coronia. T'eta /\ /\ /\ /\ I I I I I I I I OPIN LAPIN OPIN IAPIN Before exit to the TESTLOOP routine, the Change Input Buffer subroutine (CIB) is called. CIB activates the PRINT subroutine in the Directory (if SOURCE is specified), which, prints out the headlines assembled at PAGE HEAD and returns with the address of the print buffer. CIB then gets the first record in the Wor~ Area (WA), moves it to the print buffer (or a dummy print area), translates the record to internal code, and returns control to Initialization, after having loaded the address of WA in REGI (Register 1). In the TESTLOOP routine, which is now entered, as well as in all routines which scan or ins Fect characters in the translated source text, REGI functions as the Work Area pointer. Figure 30. All zeros Address of Address of Address of Address of Address of Address of Address of Address of Address of Address of Address of Address of Address of Address of Address of Address of Address of Address of Address of Address of Address of Address of Address of Address of Address of Address of Address of Address of Address of Address of Address of Address of Address of Address of Address of Address of The function byte assigned by TES'ITABL to each character, and the routines entered from TESTLOOP, are as follows: Blank * / TESTLOOP scans the translated source text in the Work Area, by means of a Translate and Test instruction, for anyone of 14 characters assigned a nonzero function byte in Translation Table TESTTABL; moves the scanned text to the output buffer; and branches to the routine whose address is specified in an entry of Branch Address Table BPRTAB. The displacement of the entry in BPRTAB is given by the value of the character's function byte. 54 TRANSOP TRANSOP TRANSOP TRANSOP TRANSOP TRANSOP CCLON SEMCO RIGHTPAR BLANK ERR1 POINT APOSTROF CIB ASSIGN DECPOIN'I ERRS BLKAPOS NPAFTAPO SCALE COLONLIST SEMCLST DELIMIT ZETAAPO EROUT LEFTPARL RIGHTPARL PZETA ASSIGN DECPOINT ERR5A COMMALS'I POINLST SLASHLST QUOTE SEMC60 Branch Address Table BPRTAB Character MAIN LOOP (TESTLOOP) Content of Entry ( > < Not ) Point Apostrophe Colon semicolon Invalid Character Zeta Function Byte Routine Entered 28 04 08 OC 10 14 18 24 30 34 1C 90 2C 38 00 BLANK TRANSOP " " " " " RIGHTPAR POINT APOSTROF COLON SEMC60 ERR 1 CIB (No branch, scanning continues) The branching action just described is dependent on the condition that the correct delimiter word opening the source module has been found (STARBIT=l). See "Processing of opening Source Text". The transfer of scanned source text from the Work Area to the output buffer is handled by MSBLOOP (Move Scanned Bytes Loop). Branch Address Table BPRTAB is referenced by most routines which determine a branch on the basis of a Translate and Test instruction. Resultant Current Expected Operator Operator Operator (RO) {CO} (EO) r--------T--------T--------, I * I * I Asterisk I Power Slash I Left Parenthesis Less than Greater than Not ~--------+--------+--------~ ] I / I } I ~--------+--------+--------~ I [ I I ( I I / I I I in TRANSCP ~--------+--------+--------~ I ~ I < I = I ~--------+--------+--------~ I ~ I > I = I ~--------+--------+--------~ IL________ :f: I ________ , I = L-_______ JI ~ Figure 31. BLANK (BLANK) BLANK steps the Work Area pointer REGI to the next nonblank character and returns control to the calling routine (TESTLOOP or LIST). A scan, using Translation Table BTABLE, is initiated if a string of blanks is indicated by a second blank following the first. BTABLE assigns function byte FF to all characters except a blank, which is assigned a zero function byte. KEYTAB keys routine used RIGHTPAR RIGHTPAR transers the ) operator to the output buffer, and sets the pointers CPIN and LAPIN (see "Phase Initialization"). TEST AND TRANSFER OPERATOR (TRANSOP) POINT TRANSOP determines if any of the characters *, /, (, <, >, or Not is associated with an immediately following character, and if so, transfers a one-byte operator representing the two characters in combination. Otherwise, the character is transferred unchanged. The determination is made by comparing the succeeding character with a key, contained in a table named KEYTAB (Figure 31). The key used is specified by the function byte assigned the particular character in the TEST LOOP or LIST routines, from which TRANSOP is entered. Current Operator (CO) represents the character in the source text which activates TRANSOP. The Expected Operator (EO) is the character with which the succeeding character is compared. The Resultant Operator (RO) represents the logical result of CO in combination with EO. RO is transferred to the output buffer, if the succeeding character agrees with EO. CO is transferred if the succeeding character is any character other than EO (excepting blank, which is disregarded, and the record-end operator Zeta, which causes the CIB subroutine to be called). POINT inspects the character which follows a point, using a Translate and Test instruction, and branches to one of six routines according to the value of the function byte assigned the character in Translation Table PTTABLE. The address of the routine entered is obtained from an entry in Branch Address Table (BPRTAE), whose displacement equals the value of the assigned function byte. The function byte assigned by PTTABLE to each character, and the routines entered from POINT, are as follows: Function Character Equal Sign Point Comma Zeta ~ 40 3C 1C 20 44 38 00 Routine Entered DECPOINT ASSIGN COLON SEMCO E~R5 CIB (No branch, scanning continues) Chapter 4: Scan 1/11 Phase 55 DECIMAL POINT (DECPOINT) DECPOINT operator. transfers the Decimal Point ASSIGNMENT (ASSIGN) ASSIGN transfers the Assign operator and passes control to STATE. STATEMENT (STATE) STATE is entered when a statement, identified by an assignment operator or a label, or by the delimiters 'GOTO', 'FOR', or 'IF', has been recognized. It serves to determine if the statement constitutes the body of a procedure, and if so, to stack the operator Proc in place of Proc** (see "Scope Handling Stack"). APOSTROPHE (APOSTROF) APOSTROF has the main function of determining if an apostrophe opens a delimiter or if it represents a scale factor. APOSTROF inspects the characters following the apostrophe by means of a Translate and Test instruction, and branches to one of six routines, determined by the function byte assigned the particular character in Translation Table ATABLE. The branch is made by reference to Branch Address Table (BPRTAB). The function byte assigned to each character in ATABLE, and the routines entered from APOSTROF, are as follows: Character Blank Zeta Invalid Character Apostrophe Not,Or,And,Comma,) or Point , / or ( Function Byte Routine Entered 50 SCALE 48 BLKAPOS ZETAAPO NPAFTAPO DELIMIT EROUT bypassed. The closing apostrophe, however, would terminate the scanning operation, and a branch would be taken to the Delirri ter routine (DELIMIT). The particular action taken by the SCALE, NDAFAPO, DELIMIT, and EROUT routines is governed by a control byte called FBYTE, which may have one of three hexadecimal values: 00, FO, or FF. FBYTE is set to X'OO' in APOSTROF; to X'FO' in TYPE and SPEC; and to X'FF' in COM. The function of FBYTE is to specify whether or not a specific choice of delimiter words is being sought in the source text. Thus, for example, when the TYPE routine determines that an apostrophe immediately follows one of the delimiters 'REAL', 'INTEGER', or 'BOOLEAN', indicating a second delimiter in a sequence ' ' 'PROCEDURE' or ' DC X'041C' On entry to the called subroutine. REGB contains the address of the i~nediately following parameter list, the first byte of which specifies the error pattern length while the second byte specifies the error number. Pool. except in the case of. Error O. ERROR2: Calculates the length of an identifier or delimiter addressed by a pointer named IN and storeS the length in the parameter list of the calling routine. ERR2D: Activates ERROR2 (which computes an identifier's or delimiter's length and stores the length in a pararoeter list), and ERROR! (which stores the length, error number and semicolon count in an error pattern); moves the identifier or delimiter addressed by IN to the Error Pocl entry addressed by REGY; and returns control to the calling routine. ERR2: The typical return to the calling routine from the called subroutine is of the form: BC 15,2(0, REG B) This specifies a return to the instruction following the parameter list in the calling routine. The error recording routines may be divided into service routines and call routines. Service routines are those which actually store message patterns in the Error Pool, or which handle the necessary processing preliminary to the storage of error patterns. Call routines are those which receive calls for the recording of an error and which, in turn, issue calls to the· appropriate service routines. Call routines may also move source text into an error pattern at an address specified by a service routine. The service routines are the following: ERROR1: Stores the first four bytes of every Error Pool entry, containing the entry length, error number, and semicolon count. The entry length and error number are fetched from the parameter list specified by the calling routine. ERROR1 also updates the Error Pool pointer (NEXTERR) in readiness for the next entry, making allowance for any source text to be subsequently inserted. The address of the current Error Pool entry is transmitted in REGY. In the event of an Error Pool overflow, a branch is made to ERRO. ERROR! is activated every time an error pattern is stored in the Error 58 No. Sets the pointer IN to the last entry for an identifier in the Identifier Table" then branches to ERR2D (which stores the error pattern with the aid of ERROR2 and ERRORl). ERR2B: Sets the pointer IN to an entry in the Identifier Table for a procedure identifier, then branches to ERR2D (which stores the error pattern with the aid of ERROR2 and ERROR!). ERR2E: sets the pointer IN to a location called IDBUCKET (see Type specification routine IDCHECK) containing a procedure parameter, then branches to ERR2D (which stores the error pattern with the aid of ERROR2 and ERROR1). ERR2C: Moves six characters of an erroneous delirriter to a location narred BUCKET, sets pointer IN to that location, and branches to ERR2D (which stores the error pattern with the aid of ERROR2 and ERROR1). ERR?: Activates ERRORl (which stores the length error number and semicolon count in an error pattern). ERR? is called where the error pattern ccntains no source text. ERRO: Records a terminating error indicating an overflow of the Error Pool, and transfers control to the terminating routine EODADIN (via COMPFIN, which turns the TERR switch on). The call routines are described below. certain of the routines handle specific errors and, in calling the service routine, specify a parameter list for the particular error. Other routines handle more than cne error. the parameter list being specified by the calling routine in which the error is detected. ERR1: Calls ERR7, specifying a parameter list for Error No.l. ERR3: Calls ERROR1, specifying a parameter list for Error No.3, then moves the characters previously stored at BUCKET by the Colon routine into the error pattern set up by ERROR1. ERR4: Calls ERROR1 and passes control (via COMPFIN) to the EODADIN routine. ERR4 is called by numerous routines on detection of any terminating error. (See also "Close of Scan 1/11 Phase"). ERRSA: Calls ERROR1, specifying a parameter list for Error No. 35. ERRS: Calls ERROR1, specifying a parameter list for Error No.2. Exits to TESTLOOP or LIST. ERR6: Depending on two switches (which may cause a branch to other routines), calls ERROR1 and moves six characters of a delimiter from the Work Area into the error pattern set up by ERROR1. ERR8: made to the PRINT subroutine in the Directory, which prints out the record previously moved to a print buffer, and transn:its the address of a new print buffer, to which the newly obtained source record will be moved. CIB is called by all routines which scan the source text, on recognition of the recorded operator Zeta. The latter is inserted by CIB at the end of each translated record in the Work Area. In the event the source module is in ISO code, each record is first translated to EBCDIC code by searching for the characters (, ), =, + and the apostrophe (the only characters whose representation differs between the EBCDIC and ISO codes) and replacing these characters by their EBCDIC combinations. This conversion simplifies the subsequent translation to internal code and facilitates printing the source text on the printer. in Which the code implen:ented is EBCDIC. The translation to internal code is made with the aid of translation table TRLTAE~E, and produces the character set shown in Appendix I-a. Depending on a switch~ calls ERROR1, specifying a parameter list for Error No.11. Exits to TESTLOOP or LIST. IDENTIFIER TEST (IDCHECK1) ERR18: Calls ERROR1, specifying a parameter list for Error No. 18. ERR9: Calls ERR7, then transfers control to EODADIN (see also "Close of Scan 1/11 Phase"). ERROR10: Calls ERR2B, specifying a parameter list for Error No. 10 (which indicates that certain parameters of a procedure have not been specified). On return, ERROR10 inserts an allpurpose internal name in the Identifier Table entries representing the unspecified parameters. ERR21: stores the length of a declarative delimiter in a parameter list for Error No.21; calls ERROR1, specifying the parameter list; and then moves the delimiter from the Delimiter Table into the error pattern set up by ERRORl. CHANGE INPUT BUFFER (CIB) CIB gets an SO-character record of the source text from the SYSIN data set into the Work Area (WA); copies the record into a print buffer or a dummy print area; and translates the record in the Work Area to the internal code (Appendix I-a). If the SOURCE option is specified, a branch is IDCHECK1 is entered from the PROCID, ARRYID, and SWITCH routines, after a test has determined that the first character of a procedure, array, or switch identifier is a letter. IDCHECKl transfers the letter to an entry in the Identifier Table and to the output buffer; inspects the following characters of the identifier, similarly transferring the next five characters. provided they are letters or digits; and returns control on detection of any character other than a letter or digit. CHANGE OUTPUT BUFFER (COB AND COBSPEC) See also "Phase Initialization". COB determines if the last byte but one in the current output buffer has been filled (by comparing pointer EAP (register 3) with buffer-end pointer APE), and if so., transfers the buffer-end indicator Zeta to the last byte pointed to by EAP; writes out the current buffer (whose address is stored at WADDARI); and resets pointers EAP and APE to an alternate buffer, addressed by ADDARI + DISP storing the address of the new buffer at WADDARI. If the current buffer has not been filled. COB returns control to the calling routine. COB is Chapter 4: Scan 1/11 Phase 59 called in advance of every transfer of one or more characters to the output buffer. ters, or if the comparison described above produces no corresponding Delimiter Table entry, control is passed to the Delimiter Error routine (EROUT). COBSPEC, a special entry point of COB, includes a test as to whether a variable number of unfilled bytes (two or more) remain in the current buffer. The test consists in comparing REGO (instead of EAP) with APE, where REGO, preset by the calling routine, indicates the current address value of EAP, incremented by the required number of bytes. COB SPEC is called when a unit of data may not be split between records (e.g. the three-byte unit transferred by SEMCO, containing the Semicolon (or Delta) and the semicolon count). After a delimiter has been correctly identified, a test is made of the STARTEIT to determine if the correct delimiter opening the source module has teen found (indicated by STARTBIT=l). If not. control is passed to STARTDEL (see "Processing of Opening Source Text"). Otherwise. the routine corresponding to the delimiter identified is entered. DELIMITER (DELIMIT) Before the comparison described above is initiated, a test is made of the switch named FBYTE. FBYTE=X'FO' signifies that one of the delimiters 'PRCCEDURE' or 'ARRAY' is being sought: while FBYTE=X'FF' signifies that one of the delimiters 'ELSE' or 'END' is being sought. In either of these cases, control is passed to TYFESPEC or COMSPEC (See also APOSTROF). otherwise (FBYTE=X'OO'), a normal comparison is initiated. DELIMIT is entered from APOSTROF when the second of two apostrophes enclosing a delimiter word has neen identified. DELIMIT compares the characters enclosed by apostrophes with a set of delimiter words in the Delimiter Table (W1TAB -- Figure 32), and when the corresponding word has been located, branches to the routine whose address is specified in an entry of the Branch Address Table (DELPRGTB). The displacement of the entry in the Branch Address Table is indicated opposite the delimiter in the Delimiter Table. The delimiter in the source text is compared with the group of words in the Delimiter Table having the same number of characters. The length of the delimiter in the source text is contained in REGL. The particular word group in the Delimiter Table, with Which the comparison is to be made, is found with the aid of a look-up table (L1TAB) consisting of ten four-byte entries each containing the address of the particular word group. Thus, the address of a given word group comprising words of the same length (REGL) as the source delimiter, is contained in the entry specified by L1TAB + 4*C(REGL). Within a given word group, the entries for all words are uniform in length, being equal to the number of characters in the word, plus three (a two-byte characteristic or operator and a one-byte displacement - the displacement of the corresponding entry in the Branch Address Table, DELPRGTAB). The number of entries in the word group is indicated in the byte preceding the word group (loaded in REGY). If the apostrophes enclose no characters, Error No. 12 is recorded. I f the apostrophes enclose more than ten charac60 DELIMITER ERROR ROUTINE (EROUT) EROUT is entered from APOSTROF, when the closing apostrophe of a delimiter word is mlsslng, and frorr, DELIMIT, when a misspelling is detected in a delimiter word. EROUT compares the characters following the opening apostrophe with each of the words in the Delimiter Table (W1TAB), moving dOwnward through the table, and if a matching word is found, branches to the routine specified. (See DELIMIT routine). If no matching delimiter is found., Error No.14 is recorded, the apostrophe is disregarded, and control is returned to TESTLOOP. The comparison proceeds by comparing (1) the first character of the defective delimiter with each of the entries in the first word group of the Delimiter Table., (2) the first two characters with the entries in the second word group, (3) the first three characters with the entries of the third word group, and so on, until a matching delimiter word is found, or until the last word group has been compared. The comparison is conditional on the switch FBYTE=X'OO'. If FBYTE=X"FO' or X' FF' , control is passed to TYPESPEC or COMERR directly (see below). After identification of a delimiter. the same test of the STARTBIT is made as that described under DELIMIT. DEL I MI TE R TABLE Hexadecimal 1 Word Group No. 2 3 4 No. of Entries in Delimiter Word One-byte Operator Notation used in this Manual (see column 6) I I 1 02 '(' 2 3 PI ::l ~~ GIF 'OR' 'END' Or 4E 51 22 00 00 NORMAL 44 4D 43 00 00 10 END 45 4E 51 00 00 14 FOR NORMAL 2) 04 3) 'AND' And 40 4D 43 23 00 'NOT' Nat 4D 4E 53 20 00 00 00 44 40 4B C2 12 18 09 H " Notes: ~ 52 53 44 4F 19 00 00 NORMAL Then 53 47 44 4D 1E 00 08 TED TED , ELSE' Else 44 4B 52 44 1F 00 08 'GOTO' Goto 46 4E 53 4E 17 00 OC GIF 53 51 54 44 07 00 1C BOLCON 4B 44 52 52 42 4E 43 44 11 00 00 NORMAL 00 00 20 CODE NORMAL < 3) ~ 2) OA Until 3) 21 00 00 41 44 46 48 4D 00 00 24 BEGIN 54 4D 53 48 4B 40 51 51 4058 lA CA 00 16 00 28 NORMAL 55 40 4B 54 44 00 18 2C 44 4B 00 CA 56 47 48 4B 44 1B 00 45 40 4B 52 44 00 00 05 10 4B 40 41 While 'POWER' Power , EQUAL' = 4F 4E 56 44 51 44 50 54 40 48 , EQUIV' ~ 44 50 54 48 55 3) 02 ' INTEGER' 05 4) 48 4C 4F 48 'WHILE' , FALSE' 30 00 4) BOLCON 00 00 00 NORMAL 00 NORMAL 24 00 00 NORMAL 52 56 48 53 42 47 52 53 51 48 4D 46 CA lC 34 SWITCH CB 10 30 SPEC 48 4D 53 44 46 44 51 C2 11 18 TYPE 41 4E 4E 4B 44 40 40 C2 13 18 TYPE 'COMMENT' 42 4E 4C 4C 44 40 53 00 00 38 COM ~ 4D 4E 53 4B 44 52 52 15 00 00 NORMAL I , GREATER' > 46 51 12 00 00 NORMAL I 13 00 00 NORMAL 9 ' PROCEDURE' ' NOTGREATER' 01 'f 3) ~ 44 40 53 44 51 40 4E 53 44 50 54 40 4B 51 4E 42 44 43 54 51 01 4F 01 40 4E 53 46 51 -- 44 44 40 53 44 51 -_._._- CA _ 14 .. __. - DO 3C PROCEDUR 00 00 NORMAL ----- I For the specifi-cators .. REAL", .. ARRAY", .. LABEL", .. SWITCH", "STRING', , INTEGER', .. BOOLEAN'" and" PROCEDURE', the two-byte cha'octeristic is copied into the Identifier Table entries of specified formal parameters. In the case of all other del imiter words (except for ~ TRUE~ and ~ FALSE~ ond all delimiters for which both bytes in the column representing the delimiter. The notation in column 3 indicates the nome by--w'hich the operator is identified in the text. = X ~ 00"), the first byte is transferred to the Mldification Levell text as a one-byte operator Oelimi"ter vcriously represented in t-he M:>dification Levelland 2 versions of source text by two or more one-byte operators, supplied by program. See "Scope Identification", "Iv\odification Levell Source Text"and Appendix I-b. PI CIl 3. Delimiter represented in the IVIodification Levell text by one-byte operator supplied by program. See Appendix I-b and "Iv\odification Level- 1 Source Text". 4. First byte specifies the displacement of the constant 0 {False} or 1 (True) in Constant Pool No. O. 0.... I , NOTLESS' 'U CD NORMAL lC 2. P" I ARRAY VALUE SPEC 'BOOLEAN' ' NOTEQUAL' H H NORMAL TYPE , THEN' 8 1. 51 ' REAL' , STEP' ' SWITCH' 10 TED OC 'STRING' en o STRING 08 , LABEL' ., NORMAL 04 00 03 , VALUE' rt 00 00 00 , ARRAY' ~ 04 00 00 06 03 lC ' BEGIN' , UNTIL' 7 Nome of Routine Entered 10 'IMPL' i '0 I 43 4E 48 45 LESS' 6 Delimiter Word Displacement of Full-Word Entry in lIranch Adcre.. Table DELPRGTAB, containing Entry Point of Routine Entered 8 If 'CODE' ("l 7 Do 'TRUE' 5 6 One-byte Operator (second byte = X' 00') Q[ Two-byte Characteristic for Specificators 9£ Null Operator {both bytes = X' 00') 'DO' , IF' 'FOR' 4 5 Word Group (F irst byte in Word Group) (WI TAB) Reoresentation Figure 32. Delimiter Table (WITAB) TYPE SPECIFICATION (TYPESPEC) TYPESPEC is entered from DELIMIT and EROUT by virtue of the switch FBYTE=X'FO'. FBYTE is set to X'FO' by the TYPE routine when a test shows that a type declarator ('REAL', 'INTEGER', or 'BOOLEAN') is immediately followed by another apostrophe, indicating a further delimiter. (Unless the latter delimi ter is 'PROCEDURE' or 'ARRAY', the source text is in error). TYPE passes control to ENTRAPR (an entry point of APOSTROF). which scans to the next apostrophe and branches to DELIMIT or EROUT, which branch in turn to TYPESPEC on finding FBYTE=X'FO'. TYPESPEC inspects the delimiter and passes control to TYPPROC or TYPEARRY, if the delimiter is 'PROCEDURE' or 'ARRAY', respectively. If any other delimiter is identified, control is passed to the Identifier Error routine IERSPEC. The latter serves to bypass the defective declaration and to record an error. COMMENT (COMSPEC) COMSPEC is entered from DELIMIT by virtue of the switch FBYTE=X'FF'. FBYTE is set to X'FF' by the COM routine when an apostrophe is found in a sequence of comment following 'END', indicating that the comment is terminated by a delimiter word. The, latter should be 'END' or 'ELSE'. COM passes control to ENTRAPR (an entry point of APOSTROF), which scans to the next apostrophe and branches to DELIMIT, which branches in turn to COMSPEC on finding FBY'I'E=X' FF'. COMSPEC inspects the delimiter and passes control to END or TED, if the delimiter is 'END' or 'ELSE'. If any other delimiter is identified, control is passed to COMCED2 (an entry point of the COM routine). The latter continues to scan to the next semicolon or apostrophe, disregarding the delimiter. OPENING DELIMITER transfers the operator Begin to the Modification Level 1 text. stacks Begin. and turns the BEGBIT switch on. If the stack operator is Proc. indicating that the delimiter 'BEGIN' opens the body of a procedure Closed ty 'END'. the stack operator Proc is replaced by Proc* and the PROBIT switch turned off. STRING (STRING) STRING is entered from DELIMIT and ERCOT on recognition of the first of two string quote signs' (' ••• ')' enclosing a character string. STRING stores the enclosed character string in the Constant Pool and transfers a five-byte internal name. referencing the location where the string is stored, to the Modification Levell text. The internal name (see Appendix II) is preceded by the Apostrophe operator. The string is stored in the Constant Pool in the external code (EBCDIC or ISO) of the source module -- it is copied from the print area (or dummy print area) to which each source module record is moved ty CIB, before the record is translated to the internal code. see Figure 7. NORMAL ACTION (NORMAL) NORMAL is entered from DELIMIT or ERCUT when any cne of the following delimiters is identified: "/", 'OR'. 'AND', 'NC'I', 'STEP', 'LESS', 'UNTIL', 'NOTLESS', 'EQUAL', 'EQUIV', 'IMPL', 'WHILE' , 'GREATER', 'NOTEQUAL', and 'NOTGREATER'. NORMAL transfers the corresponding one-byte operator in the Delimiter Tatle (Figure 32) to the output buffer and returns control to TESTLOOP or LIST. (ST&~TDEL) BOOLEAN CONSTANT (BOLCON) See "Processing of Source Module Opening Text" • BEGIN (BEGIN) BEGIN is entered from DELIMIT and EROOT on reCOgnition of the delimiter 'BEGIN'. BEGIN inspects the Scope Handling stack and, unless the stack operator is Proc, BOLCON is entered from DELIMIT or ERCUT when the boolean constant 'TRUE' or 'FALSE' is encountered. A five-byte internal name (Figure 33) is transferred to the output buffer, indicating the character of the boolean constant, and referencing a location in the Constant Pool where the constant 0 (False) or 1 (True) is stored. The internal name is preceded by the Apostrophe (X'2E'), which signals the Scan III Phase that an internal name follows. (Character istic) o 1 (Constant (Displacement) Pool> 2 3 4 5 output text and in the Scope Handling Stack. It also constructs entries in the Group Table, Program Block Number Table and Semicolon Table. r------,-----~------T------T------, , TRUE' IL______ C8 L-_____ I 03 L-_____ I 00 I ______ 00 I ______ 07 JI ~ ~ r------,------.------T------T------l END (END) Figure 33. END is entered from DELIMIT or EROUT when the delimiter 'END' is recognized. Its function is to inspect the operator in the Scope Handling Stack and to activate the appropriate closing sutroutine, according to the stack operator detected: ~ , FALSE' IL______ C8 L-_____ I 0 3 L-_____ I 00 LI ______ 00 I ______ 00 JI Internal Names of boolean constants 'TRUE' and 'FALSE' GOTO-IF (GIF) GIF is entered from DELIMIT or EROUT on recognition of the delimiters 'GOTO' and 'IF'. The one-byte operator given in the Delimiter Table (Figure 32) is transferred to the output buffer and control passed to STATE. Stack operator Subroutine Activated Beta, Proc Proc*, --pr;jc** PBLCKEND COMPDEND FOREND THEN-ELSE-DO (TED) ERR8 (see "Close of Scan I/II Phase") The subroutines are described below. TED is entered from DELIMIT or EROUT on recogni tion of the delimiters 'THEN " 'ELSE', or 'DO'. A one-byte symbol representing the delimiter in the Delimiter Table (Figure 32) is transferred to the output buffer. Before control is returned to TESTLOOP or LIST, pointers OPIN and LAPIN are set to point, respectively, to the delimiter symbol transferred and to the next byte in the output buffer (see "Phase Initialization"). COMPOUND END (COMPDEND) COMPDEND releases the stack operator Begin and transfers the operator End to the output text, marking the close of a compound statement. See END. FIRST BEGIN (FIRSTBEG) See "Processing of Source Module Opening Text" • PROGRAM BLOCK (BEGl SUBROUTINE) BEGl is activated as soon as a new block has been identified. It is entered from all declaration-handling routines (e.g. TYPE, PROCEDUR, ARRAY) processing the first declaration following the delimiter 'BEGIN' (indicated by the switch BEGBIT=l). BEGl constructs a program block heading entry in the Identifier Table, containing a new Program Block Number; resets the pointers LPBP and LIGP to the new heading entry; and replaces the operator Begin by Beta in the FOR STATEMENT END (FOREND) FOREND, which is entered from END and SEMCO on detection of the delimiter 'END' or a semicolon closing a for statement, constructs a for statement closing entry in the Identifier Table, if the closed for statement contained a declared lacel. If the closed for statement contained no declared labels, the for statement heading entry is deleted. FOR END also transfers the operator~, followed Cy the Identifier Group Number., to the output text, and releases the stack operator For. Pointer LIGP is reset to point to the heading entry of the reentered for statement, if any, or to the heading entry of the enClosing clock or procedure. Chapter 4: Scan I/I1 Phase 63 PROGRAM BLOCK END (PBLCKEND SUBROUTINE) PBLCKEND, which is called by END and SEMCO on detection of the delimiter 'END' or a semicolon closing a block or procedure, transfers the set of entries in the Identifier Table representing identifiers declared or specified in the block or procedure to the SYSUT3 data set. The program block heading entry which heads this set of identifiers is indicated by the pointer LPBP. Before the transfer is executed, pointers LPBPand LIGP are reset to the address of the heading entry corresponding to the enclosing block or procedure (see "Processing of Identifier Table"). PBLCKEND also transfers the operator Epsilon to th~ output text, followed by the Program Block and Identifier Group Number of the enclosing block, procedure or for sta tement, and releases the stack operator. ning continues until a semicolon is found. This deletes all source text beginning with the declarator and extending up to (but not including) the next semicolon. When the semicolon is found, SEMCO is entered. FOR STATEMENT (FOR) FOR is entered from DELIMIT and EROUT on recognition of the delimiter 'FOR'. A for statement heading entry is constructed in the Identifier Table and entries are made in the Scope and Group Tables. If the stack operator is Proc, it is replaced by Proc**. The operator For is stacked and transferred to the output text, followed 1:;y a new Identifier Group Number. TYPE DECLARATION (TYPE) COMMENT (COM) COM has two main fUnctions: to bypass comments, and to delete (or bypass) erroneous declarations. The routine scans the source text (using translation table COMTABLE) for a semicolon, an apostrophe, a blank, or Zeta. The function 1:;ytes assigned these characters specify displacements to subprograms of the COM routine. There are three entry points: COM, COMMEND, and COMERR. COM is entered from DELIMIT and EROUT when the delimiter 'COMMENT' has been encountered. scanning continues until a semicolon is found. This deletes (or bypasses) all source text beginning Hith , COMMENT' and extendl.ng up to and including the semicolon. COMMEND is entered from END when a comment of the following form is to be eliminated: 'END' 'END'/;/ 'EI.SE'. scanning terminates when a semicolon or an apostrophe is found, deleting the preceding comment. In case a semicolon is found, SEMCO is entered. If an apostrophe is found, the switch FBYTE is set to X'FF' and control passed to ENTRAPR (an entry point of APOSTROF). APOSTROF scans to the next apostrophe, branches to DELIM!'l' (or EROUT). which branches to COMSPEC on finding FBYTE=FF. COMSPEC inspects the delimiter and branches to END or TED if the delimiter is 'END' or' ELSE', respectively. In all other cases, CO~illRR is entered. COMERR is entered from several declaration-processing routines when an erroneous declaration is identified. Scah64 TYPE is entered from DEI.I~IT and ERCUT on recognition of any of the declarators 'REAL', 'INTEGER', or 'BOOLEAN'. The rcutine makes an entry in the Identifier Tatle for each of the identifiers following the declarator, provided the identifier is valid. If any invalid character is fcund in the identifier, control is passed to the Identifier Error routine (IER), which deletes the entry made in the Identifier Table and records Error No. 5 or 16. If the declarator is immediately followed ty another apostrophe, indicating a furthe·r delimiter, the switch FBYTE is set"" X'FO' and ENTRAPR (an entry point of APCSTROF) is entered. At entry, the switchesPROBIT and BEGEIT are tested, in that order. If PROBIT=l, indicating that the delimiter specifies a formal parameter in a procedure heading, control is passed to the SPECENT routine. If BEGBIT=l, indicating that the declarator represents the first declaration following 'BEGIN' and that, accordingly, a new tlock has been entered, a call is made to the BEGl subroutine (which assigns a new Program Block Number) before entries for the declared identifier(s) are made in the Identifier Table. IOENTIFIERERROR (IER) IER is entered from declaration- processing detection of a defect in a declared ident.ifier. The routine deletes all or part of an entry for the identifier in the Identifier Table and reCords .Error No. S or 16, depending on the entry point HER or Form Y33-8000-0, Page Revised by TNL Y33-8001, 12/15/67 IERSPEC). It also skips over the source text up the next comma, semicolon, or ri'Jht parenthesis, in the case of a formal parameter list. CODE PROCEDUHE (CODE) CODr; is entered from 1)ELDUT or EROUT on recoqnition of the delimiter 'CODE', representinIJ the body of a code procedure. The routine verifies that 'CODE' follm-1s a procedure heading; modifies the characteristic in the entry previously made (by the PROCEDUR and PROCID routines) for the p~ocedure identifier in the Identifier Table, so as to designate a code procedure, and transfers up to six characters of the procedure identifier, follo"Ted by t,'lO nlanks, to the output text, preceded by the operator Gamma. After finding the semicolon ';>1hi~hould follo"1' CODE' , the PI3LCKEHD subroutine is called and control tl1cn passed to SEliCO. At entry, the s,,1itches PROI3IT and BEGm~ are tested, in that order. If PROBIT=l indicating that the delimiter specifi:es a formal parameter in a procedure: heading, control is passed to the SPECENT routine. If 3EGBIT=1, indicating thatthe declarator represents the first delimiter follo,,1ing 'BEGIN', and that, accordingly, a new block has been entered, a call is made to the BEGl subroutine ("1hich assigns a ne," Program Block Number) before processing continues. SPECIFICATION (SPEC) SPEC is entered from DELIMIT or EROUT on recognition of the specificators 'LABEL' and 'STRING'. Its function is to verify that the specificators occur in a procedure heRding. If they do, control is passed to the Type Specification routines (SPECENT and IDCHECK). If not, Error No.25 is recorded, and the declaration is skipped by branching to COMERR. VALUE (VALUE) VALUE is entered from DELIMIT or EROUT on recognition of the delimiter 'VALUE' After testing the s';>1i tch PROBIT to insure that the delimiter occurs in a procedure heading (signified by PROBIT=l), the switch VALBIT is turned on and control is passed to IDCHECK. The latter locates the Identifier Table entry corresponding to each formal parameter which follows'VALUE', and, by virtue of VALBIT=l, sets the value bit in the identifier characteristic (Figure 9) so as to designate a value-called parameter. PAIU\:lE'rER SPECIFICATION (SPECENT and IDClIECK) SPECEu'r is entered from TYPE, ARRAY, S';nTCH and PROCEDUR, when a specificator is ~ncountered in a procedure heading (indicatecl by PROBIT=l). SPECENT moves the corresponding two-byte characteristic contained in the Delimiter 'I'able (Figure 32) to a field named 1m and then enters IDCHECI<. IDCHECK is entered from SPECENT Rnd from VALUE. IDCHECK~s function is to locate the appropriate entry (entries) in the Identifier Table and a) to insert the characteristic and Program Block ::~umber, or b) to set the value hit in the characteristic. (Before the value or specification parts of a procedure heading are processed, the external names of all formal parameters are copied into a sequence of Identifier Table entries, from the parameter list "lhich follmls the procedure identifier. The first of these entries is addressed by the pointer PRIlvlPAR). The characteristic is inserted by ORing the relevant bytes of the Identifier Table entry \'lith the contents of the location KB. TYPE ARRAY (TYPEARRY) TYPEARRY is entered from TYPE SPEC when a delimiter sequence of the type ' ' 'ARRAY' has been identified. If PROBIT=l (indicating the delimiter sequence occurs in a procedure heading) control is passed to IDCHECK which proceeds to complete the Identifier Table entry for a type-array parameter of a procedure. If BEGnIT=l (indicating the delimiter sequence represents the first declaration following 'BEGIN', and that accordingly 'BEGIN' opens a block), the BEGl subroutine is called. Thereafter, control is passed to the ARRAY routine (by way of ARRYDaEl), which constructs an entry for a type-array identifier in the Identifier Table. ARRAY DECLARATION (ARRAY) ARRAY is entered from DELI~UT and EROUT on recognition of the delimiter 'ARRAY'. The routine constructs an entry in the Identifier Table for each array identifier following the declarator (by call to the IDCHECKl subroutine); and transfers the operator Afray to the output text, followed by up to s~x characters of each identifier. On recognition of the left bracket, (/, marking the beginning of the dimension list, the operator [ is transferred to the output text and control passed to the LIST routine. The LIST routine analyzes the dimension list, records a count of the number of dimensions in the corresponding Identifier Table entries, transfers the dimension list to the output text, and returns control to ARRAY if the dimension list is followed by a further identifier. Chapter 4: Scan I/II Phase 65 At entry, the switches PEOBIT and BF.GBIT are tested, in that order. If PROBIT=1, indicating that the delimiter specifies a formal parameter in a procedure headins, control is passed to the SPECENT routine. If BEGBIT=1, indicating that the declarator represents the first declaration following 'BEGIN' and that a new block has teen entered, a call is made to the BEG1 subroutine (which aSSigns a new Program Block Number), before entries for the declared array(s) are made in the Identifier Table. cOITponent list; and record the dimension count or component count in the correspcnding Identifier Table entries made by the ARRAY or SWITCH routines for the array or switch identifiers. The actual dimensions in a dimension list or the components in a component list are transferred to the cutput text by the LIST routine before branching to the routine concerned. The switch ARBIT=1 specifies an array dimension list, while ARBIT=O specifies a switch component list. ARRAY/SWITCH LIST (LIST) POINT IN LIST (PONTLST) The LIST routine is entered frOI,] the ARRAY and SWITCH routines upon recognition of a din,ension list in an array declaration or a component. list in a switch declaration. LIST scans the source text (beginning with the first character following the left bracket in an array declaration or the first character following the assignment operator in a switch declaration) for anYone of 15 characters assigned a non-zero functior, byte in Translation Table (ARTABLE); moves the scanned text to the output buffer; and branches to the routine whose address is specified in a full-word entry of Branch Address Table (BPRTAB) given by the value of the character's function byte. PONTLST inspects the character following tbe point and passes control to CCLONLST or SEMCLST or transfers a Decimal Point. The fUnction bytes assigned by ARTABLE to the chal:acter set and the routines entered from LIST are as follows: Character Apostrophe >* < Not Zeta Blank Invalid Character' Comma / ) ( Point Colon Semicolon Function Byt 5E Routine Entered 34 04 14 10 18 38 28 2C APOSTROF TRANSOP 80 88 6C 68 84 54 58 00 COMVlALST SLASHLST RIGHTPARL LEFTPARL PONTLST COLONLST SEMCLST (No branch, scanning continues) " " " CIB BLANK ERR1 The latter seven routines recognize separators in a dimension on component list; transfer re~resentative operators to the output Luffer; count the number of dir,lensions or components in a dimension or 66 RIGHT PARENTHESIS IN LIST (RIGHTPARL) RIGHTPARL transfers a right parenthesis and deorements the bracket count. LEFT PARENTHESIS IN LIST (lEFTPARl) LEFTPARL transfers a left parenthesis or a left bracket, [ , representing (/, and increments the bracket ccunt. CO~MA IN LIST (COMMALST) CONll,ALST increl~ents the dirrension and transfers the Comma operator. ccunt COLON IN LIST (COLONLST) Transfers a colon, provided it occurs in an array dimension list. If it occurs in a switch component list, the colon is disregarded and Error No.3 is recorded. SEMICOLON IN LIST (SEMCLST) SEtJiCLST stores the component count in the Identifier Table entry specified by a pointer named DIM, and transfers control tc SJ:::MCO, after specifying the return address of TESTLOOP. If the semicolon occurs in an array dirrension list, Error No.32 is recorded, deleted. and the identifier entry is Block Number for the procedure identifier, followed by a program block heading entry., and copies the external names of the formal parameters in the parameter list into the following entries. SLASH IN LIST (SLASHLST) SLASHLST inspects the character following the slash and transfers the slash or a right bracket, 1; enters the dimension count for a declared array in the Identifier Table entry indicated ~' pointer DIM; and transfers control to ARRAY, SEMCO, or COMERR, according to whether the character following is a comma, a semicolon., or any other character, excepting Zeta or a blank. Initially., the PROBIT and BEGBIT switches are tested, in that order. If PROBIT=l (indicating that the delimiter 'PROCEDURE' specifies a formal parameter in a procedure heading), control is passed directly tc SPECENT. If BEGBIT=l (indicating that the delimiter represents the first declaration following 'BEGIN' and that., accordingly" 'BEGIN' opens a new block), a call is made to the BEG1 SUbroutine. PROCEDURE IDENTIFIER (PRCCID) SWITCH DECLARATION (SWITCH) At entry to the routine, the switches PROBIT and BEG BIT are tested, in that order. If PROBIT=l (indicating that the delimiter specifies a formal parameter in a procedure heading), control is passed to the SPECENT program. If BEGBIT=l (indicating that the declarator represents the first declaration following 'BEGIN' and that., accordingly, a new block has teen entered), the subroutine BEG1 is called before entries for the declared switches are made in the Identifier Table. PROCID is entered from PROCEDUR when a procedure declaration has teen encountered. PROCID first constructs an entry in the Identifier Table for the procedure identifier. The external name (up to six characters) is copied into the entry and transferred to the output text ty call to IDCHECK1. The characteristic for the procedure identifier will have been stored in the entry by PROCEDUR. When a left parenthesis (opening a parameter list) or a semicolon (following the identifier of a parameterless procedure) is encountered., a program block beading entry is constructed. If the procedure is a type-procedure., a second identifier entry for the procedure identifier is made immediately after the heading entry. The external names of the formal parameters, represented by a maximum of six characters, are now copied into the following entries of the Identifier Table and the output text. The two-tyte characteristics of these parameters are inserted immediately after, by the SPECENT routine when the specifications in the procedure heading are processed. Control is passed to SEMCO as soon as a semicolon following the closing right parenthesis of the parameter is encountered. PROCEDURE DECLARATION (PROCEDUR) TERMINATION (EODADIN) SWITCH is entered from DELIMIT and EROUT on recognition of the declarator 'SWITCH'. SWITCH constructs an entry in the Identifier Table for the identifier following the declarator, and transfers up to six characters of the identifier to the output text, preceded by the operator Switch. On detection of the assignment operator marking the beginning of the component list, the Assign operator is transferred and control passed to the LIST routine. LIST transfers the component list to the output text, counts the number of components in the list, and enters the component count in the Identifier Table entry for the switch identifier. PROCEDUR is entered from the DELIMIT and EROUT routines on recognition of the delimiter 'PROCEDURE'. PROCEDUR makes entries in the Group, Semicolon, and Program Block Tables; transfers the operator Pi to the output text and the Stack; inserts the characteristic for a declared procedure identifier into the next entry of the Identifier Table; and passes control to PROCID, which constructs an entry in the Identifier Table, containing a new Program EODADIN is entered from: 1. PBLCKEND (via CO~MEND and READRCUT) when the stack operator Alpha (marking the bottom of the Scope Handling Stack) indicates that the outermost scope of the source module has been closed; 2. ENDMISS when an unexpected End of Data condition occurs; Chapter 4: Scan 1/11 Phase 67 3. PI ROUT (in the Directory) when a program interrupt or unrecoverable I/O error occurs; and 4. ERR 4 when a terminating error detected in the source module. is See also "Close of Scan I/ II Phas e". EODADIN transfers the closing operator Omega to the Modification Level 1 text; writes out the last record of the modified source text (by calling COB), except when the entire text occupies less than a full buffer (in which case it is transmitted to the Scan III Phase in the Common Area buffer): generates TXT records of the character strings in the Constant Pool (ty calling the GENERATE - GENTXT5 subroutine) on the SYSPUNCH and/or SYSLIN data sets, provided the DECK and/or LOAD options have been specified; closes the SYSIN., SYSUT1, and SYSUT3 data sets; releases main stor- 68 age; and transfers control to the Identifier Table Manipulation Phase (IEX20), or, if a terminating error has occurred, to Diagnostic Output Module IEX21. If the source module is a precompiled procedure, Prcgrarr Block No. 0 in the Identifier Table, containing an entry for the procedure narre, is transferred to the SYSUT3 data set (by call to PBLCKEND) and an ESD record for the procedure narre is generated (by calling GENERATE-GENESD). The precompiled procedure name will have been stored in external code at the location named ESDPARAM by the PROCID routine. GENERATE SUBROUTINE See Chapter 8. CHAPTER 5: IDENTIFIER TABLE MANIPULATION PHASE (IEX20) PURPOSE OF THE PHASE contents of the Identifier Table, if the SOURCE option has been specified. The main purpose of the Identifier Table Manipulation Phase is to complete the construction of the internal names of all identifiers listed by the Scan 1/11 Phase in the Identifier Table. Except in the case of entries for declared procedure and switch identifiers and labels, the last two bytes of the internal name provide space for the relative address of the identifier's object time storage field (Figure 36). The Identifier Table Manipulation Phase assigns an object time storage field to each identifier, and stores the corresponding relative address in the space provided in the identifier's internal name. The processing of the Identifier Table, which forms the main input to the Identifier Table Manipulation Phase, may be divided into the following functions. 1. To search each group of identifiers in the Identifier Table for repeated declarations of the same identifier, and to record appropriate error patterns in the Error Pool. IDENTIFIER TABLE MANIPULATION PHASE OPERATIONS The diagram in Figure 34 illustrates the principal operations performed in the Identifier Table Manipulation Phase. The bracketed numbers in the following text refer to the numbered positions in the diagram. IDENTIFIER TABLE MANIPULATION PHASE (lEX20) 1. Identifier Scan (READBlK) Reads on IT AB record into the work oroa and stores the record '$ work (lists addresses of ITAB records in oscending Program Block Number order) IIT~B) Outputs IT AS when all records have been processed. Records ore output in ascending Program Block Number sequence, with the aid of AlAB. Posses control to ITABPRNT if the SOURCE option is specified; otherwise, to CLOSE. orea address in AlAB. Scans the record for multiple declarations and records errors in the Error Pool. Posses control to AllOSTOR. SYSUT3 Identifier 3. Write ITAB ('NRITITAB) SYSUT3 Identifier Work Areo f - -........_-+L.-I ___ _ f---....l.--~ rIT~B) (Records not in Progrom Block Number order) (Records in Progrom Block Number order) om {Records in Program Block Number order} SySPRINT 2. 3. To allocate object time storage fields to the identifiers listed in the Identifier Table, and to record the relative address of each identifier's assigned storage field in the identifier's internal name. The relative address represents a displacement from the beginning of a Data Storage Area, comprising the total number of bytes assigned to identifiers declared or specified in the particular block or procedure. To construct Program Block Table II (PBTAB2), indicating the size of the Data Storage Area required at object time for every block and procedure in the source module. Program Block Table II is transmitted in main storage to the Compilation Phase, in which the space requirements recorded in the table are augmented by additional space allocations for the storage of intermediate results. 4. To transmit the completed Identifier Table (via SYSUT3) to the Scan III Phase according to ascending Program Block Number sequence. 5. To generate a printed listing of the Allocotes (I storage field in on object time Doto Storage Area for each identifier in on ITAB record, and records the relative address in !~: !~:t~:i~:~!i;Bf~~tJI' i~::t~~ fiers, in PBTAB2. Retums to Identifier Scan, unless the lost record has been read, in which case control is passed to WRITITAB. Identifier L-_---' 4. Print ITAB (tTABPRNT) If~~ Prints a listing of ITAB, if the SOURCE option is t~S~~~d, exits fo end 5. Termination (CLOSE) ~r~:sf:~ ~:~~~;~~ar~o~nd Module IEX21 (for output of diagnostic meS50ges reflecting errors recorded in Error Pool). I (XCTl to IEX21) t Figure 34. Identifier Table Manipulation Phase. Diagram illustrating the functions of the principal constituent routines. Identifier Table records (1) are read into a work area an~ processed, one at a time, in the order ~n which they were stored on the SYSUT3 data set by the Scan 1/11 Phase, that is, according to the sequence in which the blocks and procedures were closed in the source module. To enable the records to be output in ascending Program Block Number sequence, the address of each record is stored ~n the Address Table (ATAB), in an entry determined by the record's Program Block Nureber. Initially, each record is scanned by the Identifier Scan routine to determine if multiple declarations were made for the same identifier. Chapter 5: Identifier Table Manipulation Phase 69 After the record has been scanned and appropriate errors recorded in the Error Pool, the Storage Allocation routine (2) allocates an object time storage field to each identifier, and records the address of the allocated bytes (relative to the beginning of the Data storage Area comprising the total allocation for the block or procedure) in the corresponding identifier entry. The Identifier Table listing is compiled by the lTABPRNT routine and printed on SYSPRINT, line by line, by call to PRINT in the Directory. Phase Input/Output IDENTIFIER TABLE (ITAB) When all records of the Identifier Table have been read in and processed in this manner, the Identifier Table is (3) retransferred to the SYSUT3 data set, records being output in ascending Program Block Number sequence. If the SOURCE option was specified, (4) a listing of the Identifier Table is printed; otherwise, (5) the termination routine (CLOSE) is entered. CLOSE transfers control to the next phase. PHASE INPUT/OUTPUT Figure 35 pictures the data input to and output from the Identifier Table Manipulation Phase. The figure also shows the tables transmitted to and from the phase in main storage. Figure 36 shows the space provided (last one-and-one-half bytes) in the typical identifier entry for the relative address of an identifier's storage field in the particular block's or procedure's object time Data Storage Area. The figure is not representative of identifier entries for declared labels and declared procedure and switch identifiers, in which the last 1 1/2 bytes contain a displacement address in the object time Label Address Table, inserted by the Scan 1/11 Phase. o 6 8 9 10 11 r------------T---------T-----T------------, I I I I ____________ Name> L I _________ teristic> I _____ I ____________ JI ~ ~ ~ <--------Inserted by Scan-------> VII Phase r-~~;o:9:--1 II I ~:b~~m ~f:Tc~B~)umber Error Pool I SYSUT2 - Identifier Table (ITA') SYSUT3 Identifier Table (lTAB) I IDENTIFIER TABLE I f----~-tl MANIPUlATION J-1f------t PHASE r--- ----, I Main Storage in the block's or procedure's Data Storage Area> II I L_-T-_J I = I _________________________________________ L lI Figure 37. Two-byte entry in Program Block Table II (PBTAB2) PBTAB2 is constructed by the ALLOSTOR routine. The total storage allocation for a particular block or procedure is stored in the entry corresponding to the particular Program Block Number. CONSTITUENT ROUTINES OF IDENTIFIER TABLE MANIPULATION PHASE The principal constituent routines of the Identifier Table Manipulation Phase are described below. The index in Appendix XI indicates the page on which each routine is described and the flowchart in the Flowchart Section in which the general logic of the routine is set forth. PHASE INITIALIZATION The Initialization routine gets main storage for the private work area shown in Figure 38; initializes pointers and switches; specifies EOD and program interrupt-I/O error routines; calls the PRINT subroutine in the Directory, after assembling headlines for the Identifier Table listing, provided the SOURCE option is specified, and exits to READBLK (which reads in Identifier Table records from the SYSUT3 data set). The program interrupt-I/O error exit, CLOSE2, is stored at ERET, a location in the Common Work Area referenced by the PI ROUT routine in the Directory. The exit is changed, after the GETMAIN instruction, to CLOSE. CLOSE releases main storage and transfers control to Diagnostic Module IEX21, while CLOSE2 simply transfers control to IEX21. The GETMAIN instruction for the private work area is issued after the total area required for the Identifier Table (ITAB) and the Address Table (ATAB) has been computed. The area allotted to the Identifier Table is fetched from the ITAB20S entry in the Area Size Table in the Common Work Area. The area provided for the Address Table is fixed at 1024. SAVEPB, SAVE, and BITS1 are three Common Work Area locations defined by a dummy control section in Load Module IEX20 (ITAE Manipulation). SAVEPB is the name of the Program Block Counter which is incremented by 1 in the Lastrec routine for every Identifier Table record processed. SAVEPE is compared with PBN (the program tlock count transmitted by the Scan 1/11 Phase in the Con:mon Work Area)., and if the count is identical (indicating that all Identifier Table records have been read in from SYSUT3 and processed), control is passed to WRI'IITAB, which outputs the table on SYSUT3. SAVE is a location used (ty the ITABPRNT routine) in converting numerical data, in connection with the print-out of the Identifier Table. BITS1 contains a switch, named PROCEIT. PROCBIT=l (turned on in the ITABPRNT routine on recognition of a procedure identifier) signifies that the Identifier Table entry being processed is that of a procedure identifier, and that the parameter count in the internal name is the actual count and should net te increased ty 1 when the entry is printed out. PROCBIT=O signifies that the Identifier Tatle entry teing processed is that of an array or switch identifier, and that the dimension count or component count in the internal name represents the actual count" less one., and should be increased by 1 when the entry is printed out. I f the SOURCE option is specified., the headlines "IDENTIFIER TABLE" for the first line, "PBN SC PBN NAME TYPE DM DSP NAME TYPE DM DSP NAME TYPE DM DSP" for the second, and "SURR PR LN PR LN PR LN" for the third line, are moved to a field named PAGE HEAD in the Common Work Area. A call is then made (via PRINTITB) to the PRINT subroutine in the Directory, which prints out the headings on a new page.. Resetting to a new page is governed by presetting the line count to 128 (in LINCNT) tefore calling PRINT. If short prec~s~on has been specified (determined by testing the LNG switch in the HCOMPMOD Control Field), the value 4 is stored in the half-word named C, displacing the defined constant 8, and specifying t.c the ALLOSTOR routine that arithmetic identifiers are to be allocated four bytes each. If short prec~s~on has not been specified, C rereains unchanged at 8, and real (or floating point) identifiers will accordingly be assigned eight tytes each. Chapter 5: Identifier Table Manipulation Phase 71 (at initializatian) AITAB Notes: Identifier Table (ITAB) Work Area READBLK Routine ALLOSTOR Routine AlB (reg. 8) AlB (reg. 8) (An ITAB record) RAID (reg.7) -~-AKOM (reg.9) RAID (reg. 9) I I ll _________ _ AI TAB AI TAB 2. In the ALLOSTOR routine, AlB and AI TAB point to the beginning and end of the record. RAID addr.esses successive identifier entries in the record. -----------==== (An ITAB record) REGY (reg. 10) -+---11-- 1. In the READBLK routine AITAB initially addresses the lacation in the Identifier Table Work Area to which the next record is read from SYSUT3. After read-in of the record is cO'IIPlete, AI B is set equot. to AITAB, and AITAB is then incremented by the length of the record (in the heading entty), so that AlB and AITAB now point to the beginn ing and end of the record. RAI D addresses successive identifier entries in the record, maving progressively through the record, while AKOM addresses each of the entries following RAID, with which the identifier addressed by RAID is compared. RAID (reg. 9) AITAB (at initialization!.,.)-If--------------f ATABAD AddreS5 Table (ATAB) (r024) 3. In the ITABPRNT routine, AlB arid AITAB point to the beginn.ing and end of the record currently being processed. For each record processed, AlB and AITAB are set by loading AlB with the address contained in the Address Table entry corresponding to the next sequential Program Block Number, and then setting AITAB = AlB + (the length of the ITAB record addressed by AlB, the length being contained in the heading entry). Identifiers are printed out in alphabetical order, three on each line of printed text. To find the next identifier in alphabetical order, RAID and REGY are initializedat the first identifier entry in the record. REGY then addresses the following identifiers in tum, each identifier being compared with the identifier addressed by RAID. When REGY addresses an identifier of higher alphabetical order than RAID, RAID is reset to REGY. This procedure is repeated until the end of the record is reached, so that RAID now addresses the next identifier in alphabetical order. After the identifier has been processed, it is deleted, by shifting the identifier en tri es at the bottom af the record upward by the entry length. * Area size specified by Area Size Table- in Common Work Area. See Appendix VIII for the variation in area sizes Figure 38. -procedures, for which the area reserved is 32 bytes). Object time storage space is allocated with the aid of a set of displacement pointers named DP (Double Word Pointer). WP (Word Pointer), HP (Half Word Pointer), and BP (Byte Pointer). These pointers are zero-set at the beginning of every Identifier Table record. DP reflects the total displacement at any point in terms of double- words. It is incremented at double and full-word boundaries by 4 or 8 bytes, depending on the precision specified. Where the allocation to be made for an identifier is less th~n a double word, pointer BP, BP, or WP may be set equal to DP and incremented by one, two, or four bytes, so as to minimize the number of unused bytes. See Note 2 in Figure 38. WRITE IDENTIFIER TABLE (WRITITAB) WRITITAB is entered from AllOSTOR when all Identifier Table reccrds have been reao into main storage and processed. After repositioning SYSUT3 by a Type T CLOSE, WRITITAB transfers the Identifier Table records in the work area to the SYSUT3 data set, in ascending Program Block Nurrber sequence.. The address cf the record corresponding to the next sequential Program Block Number (in REGZ) is determined by reference to the Address Table (ATAB) entry for that Program Block Number. Control is passed to the ITABPRNT routine when the Program Block Number in REGZ equals the program block count stored in PBN by the Scan 1/11 Phase. PRINT IDENTIFIER TABLE (ITABPRNT) ITABPRNT generates a listing of the contents of the Identifier Table, containing the external name of each identifier and indicating (by means of a system of coded symbols) the characteristics of the identifier. Output of the listing, whose format is described in the OS ALGOL Programmer's Guide, is dependent on the SOURCE option being specified. The identifier groufs are listed in ascending Program Block Number sequence, and within each group the identifiers are listed in alphabetical order. See note in Figure 38. TERMINATION (CLOSE) CLOSE releases the main storage area occupied by the Identifier Table and the Address Table, and transfers control to Diagnostic Output Module IEX21 (see Chapter 9) • Chapter 5: Identifier Table Manipulation Phase 73 CHAPTER 6: SCAN III PHASE (lEX30) PURPOSE OF THE PHASE The subscript Table is transmitted (on the SYSUT3 data set) to the Subscript Handling Phase" in which optimizable subscript expressicns are identified and copied into the Oftimization Tatle (OPTAB) for transmission to the CORpilation Phase. To be optimizable, no assignment may be made in the for statement to the factor F or the addend A in the subscript expression. The test for oftimizability is performed in the Subscript Handling Phase by comparing the faotor and addend with the variables listed in the Left Variable Table (see next item). The purpose of the Scan III Phase is to read the Modification Level 1 source text output by the Scan 1/11 Phase and to perform the following princifal tasks: 1. To replace the external names of all identifiers in the modified source text by their corresponding internal names in the Identifier Table (see Chapter 4). 2. To store constants in the source text in the Constant Pool, and to replace each constant by a five-byte internal name, referencing the location where the constant is stored. A constant is stored in the Constant Pool in fixed or floating point representation, depending on whether the constant is an integer number or a real number. TXT records of the constants stored in the Constant Pool are generated on the SYSLIN and/or SYSPUNCH data sets, according to the Compiler options specified (see Item 5. To construct the Left Variable Table (LVTAB) , listing" under each for statement" the integer left variables in the iterated fart of the for statement. The Left Variable Table is transmitted (on the SYSOT3 data set) to the subscript Handling Phase. It is used in identifying subscript expressions listed in the Subscript Table which are not optimizable (see preceding item). 6. To generate a transformed sourc~ text (called Modification Level 2). 'Ihe principal change made in this version of the source text consists in the replacement of externally represented identifiers and constants by five-byte internal names (see items 1 and 2). Other changes are set forth under "Modification Level 2 Source Text". 7. To replace the external names of standard mathematical functions and input/outpu~ procedures by five-byte internal designators. The internal designators are stored in the Identifier Table work area by the Initialization routine" before the first record of the Identifier Table is read into main storage from the SYSUT3 data set. 8. To recognize syntactical errors in the source text and to store appropriate error patterns in the Error Pool. The contents of the Error Pool are printed out in the form of diagnostic messages by the Error Message Editing Routine in the immediately following Diagnostic Output Module (IEX31). 9. To generate TXT records of the Constant Pool on the SYSLIN and SYSPONCH data sets, if the LOAD and/or DECK options have been specified. 9) • 3. 4. 74 To construct the For Statement Table (FSTAB), indicating the critical features of every for statement in the source text. The For Statement Table., which is transmitted to the two subsequent phases via main storage, serves to determine the structure of the loop generated in the object code for each for statement. Among other things" the For Statement Table assigns each for statement to one of three loop classifications (Normal Loop, Elementary Loop, or Counting Loop) and indicates the character of the for list (e.g. if the for list contains a step or while element). It also indicates if subscript optimization is to be performed for optimizable array subscripts in a for statement. To construct the subscript Table (SUTAB) listing~ under each for statement, all subscript expressions of a defined character occurring in the iterated part of the for statement. The expression must be of the type ±F*V±A, where V is the contrOlled variable, and the factor F and addend A must be integer variables or constants. ( SCAN III PHASE OPERATIONS The primary Phase are: functions of the Scan III 1. To replace externally represented operands in the Modification Level 1 text by their corresponding internal names in the Identifier Table; 2. To store constants found in the Modification Level 1 text in the Constant Pool and to replace the constants ty internal names; and 3. To detect critical logical features of all for statements and record these in the For Statement Table. A closely related function is to list integer left variables and linear subscripts of arrays in for statements, in the Left Variable and Subscript Tables. The diagram in Figure 39 illustrates the main operations performed in the Scan III Phase (the overall logic of the phase is indicated in Flowcharts 044 and 045 in the Flowchart Section). The following description provides a brief comment on the diagram. The modified source text is scanned, in the first instance, by the GENTEST routine, which branches to approximately 30 other routines, according to the character identified in the source text. Control is in every case returned to GENTEST after the required processing has been completed. Modification Level 1 text records are read from the SYSUT1 data set by the ICBA subroutine, which is called by all routines on detection of the record-end operator Zeta. The Modification Level 2 text records are output on SYSUT2 by the OUCHA subroutine on call from all routines which transfer operators and internal names to the modified text. OPENING AND CLOSE OF BLOCKS AND PROCEDURES At the opening of a block or procedure (indicated by the operators Beta, Pi or Phi), the next sequential Identifier Table record is read into the work area provided. Records are read from the SYSUT3 data set by the ITABMOVE subroutine, on call from BETA or PIPHI. When the end of the current (embracing) block or procedure is reached (indicated by the operator Epsilon), the corresponding Identifier Table record in the work area is deleted by EPSILON. This procedure insures that the Identifier Table work area at all times contains those identifiers which have been validly declared or specified in the current block or procedure, as well as in all enclosing blocks or procedures. The handling of the Identifier Table is described more specifically in a later section. IDENTIFIER HANDLING A letter indicateS the beginning of an externally represented identifier. The LETTER routine scans the following characters, and when the end of the identifier has been found, branches to IDENT. IDENT initiates a comparison (between the identifier in the source text and the external names contained in the entries in the Identifier Table work area)., designed to locate an entry for the same identifier declared or specified in the current (or an enclosing) block or procedure. If no matching identifier is found in the Identifier Table, the identifier in the source text is undefined: an error is recorded in the Error Pool, the Compiler enters Syntax Check Mode (Chapter 9), and, after an all-purpose internal name has been transferred to the Modification Level 2 text, control is returned to GENTEST. If, however, a matching identifier is found in the Identifier Table (indicating that the identifier was duly declared or specified) control is passed to FOLI, which branches to one of four routines (NOCRI. PROFU, SWILA, and CRITI), according to the character of the identifier, indicated by the characteristic in the Identifier Table entry. The main function of the NOCRI. PROFU, SWlLA, and CRITI routines is to determine if the identifier in the source text is contained in an embracing for staterrent (that is, in the for list or in the iterated part of an embracing for statement); and if so, to make entries in the Left Variable and/or critical Identifier Tables; and to classify the embracing for statement(s) in the For Statement Table, according to whether the presence of the particular type of identifier in the for statement affects the logical structure of the code to be generated for the for statement(s) in the Compilation Phase. ~he processing of for statements is discussed in more specific detail in a later secticn. The SWILA routine, entered if the identifier is a label or a switch, serves to verify the validity of a branch. Chapter 6: Scan III Phase 75 ...fk SCANmPHASE (lEX30) ITABNOVE .... .,d.lo ldeolili., T"bl ..... a>rlIl",,,, LETAAf hubro<.oti ... of C~IMtI _..,. NOC~I f--_ _ _-+_---1f--_-=;ond CRITII CRlTlde,.,,,,I" •• if 'ho Id.",m., l,eo""'lnod in Ih. I", 1i,I Or In :~.i:.:~:~6:r~ !,~: ~"'lrCR:j'.g ~~;;o~i':-;I~"~~i~:~h';:!~'1 ~-- r---.,._,. ::":;;.~P:':'::;;jt:g ""ho".. Tobl. 1_ 110.' .. "",' G "", •••,",,,. '"' in ~. " '"'~'''''"''.", '".,_~""'_'""."'~""."'." """"'-I~"" I f~'1 - --",",,,,,'U - ,. . ,."._..-. wth.hoodollhoGroupTablo,ola",I,e. r:;;tof;~~~ ::::::~:(:~!!~:.o;tb::n dificatiorit.,,,,,, n 2 OUCHA .. lehar<><- t~i.~;l~;:~~f~;~ F= !!r'?S~E:~Ci:l:f~i~~~~~:t{~~!;I~~ M>dlflcollon level I Sourcer..1 alor, -tJJ ,"0," .- bracingfor."" ...."I(.) 0) N" .... al Loap(.), Ilafor 11."idontifi.,otho, Ih.", ,ho..,n'rall.d va,Iobl. oc~v"o. variabl. th.for "alemon' (•• g. ". ,hotantrolleclvoriablool o oe.lod lor ,1"le_ ",ont) or;! tho dificalio" ~~!:TW F=FOR ""dOOen.r..y itoh,e - ~========t=========t=================~~=il l .....1I t .. t,anca!l lramoll routln., which d .. ' .. e. COMM/\ ",,<:ICLQBRACK). .. ,oriobt.ofon •• 'ecI for ltolemonl, a,if theoonlraHed, _ _ vo,lobl. occv" in 0 n""-al'timl~al>le ",b,c,ipt .. ",... i"n. ~ =phe F=~::~~a~n~IS~I!;~y'::::::~~o~:;'~::i:o.::r:hlb" =================================",'&=","",=","","",'=0;/ !t~dgC·~~·~Rtcrc."ing 1 F=~~~o:"'Q~bTt,h~~~~~~",,~~~.o~tae~~ra<_ ==",============================r:"~!o~:~d,,,~!:",~~m=Q:~=~~=":ha=-b;=o'C<-=i1 '.x'k>I~e 1 ,.r,,';ng, ImmthelYladifkoHon L.."ol I M>di/ieolio"LoveI2te~'. the F ~e~~f; ,:,;,~,re" lox'.'nal ""me' 01 cod. by QPeRACK, COMMtI opero'or 10 .h& M,dTfi'oHon ================================,, 0 toll f"'m INTHAN, REALHAN and OMEGA. OUCHA, "",in ,'o,~e: "rid (XCTl to IEX31) Scan III Phase. Diagram illustrating the functions of the principal constituent routines NOCRI, PROFU, SWlLA, and CRITI all return control to LETTER (directly if the identifier is not contained in a for statement). LE.'TTER thereafter transfers the identifier's five-byte internal name to the Modification Level 2 text, replacing the external name in the Modification Level 1 text, and returns control to GENTEST. The internal name is obtained from the Identi'fier Table entry previously located by IDENT. An overall survey of the identifier-handling routines Can be found in the Flowchart Section with the aid of the Index of Routines in Appendix XI. optimizable, that is, if the expression is a linear expression satisfying certain constraints (defined in a later section). If the sutscript expression is optimizable, the terms of the expression, together with their signs and a serial number identifying the for staterrent, are entered in the Sul::script Table. HANDLING OF OTHER OPERATORS NUMBER HANDLING Constants in the Modification Level 1 text are handled, in the first instance, by the DIGIT19, DIGITO, DECPOIN, and SCAFACT routines. The function of these routines, in the case of real constants (e.g. 457.725 or 0.0095'86), is to represent the constant as the product of a mantissa (with the decimal point immediately to the left of the first significant digit) and a power of ten. Thus the constants in the illustrations above would be represented as 0.457725 x 10 3 and 0.95 x 10 84 • When this transformation is complete, control is passed to the REALCON routine, the mantissa being transmitted in a storage location and the exponent in a register. REALCON converts the constant, represented by the mantissa and exponent, to floating point representation in a register. Thereafter, control is passed to the REAL HAN routine, which stores the constant in the Constant Pool and transfers a five-byte internal name, referencing the constant's storage location, to the Modification Level 2 text. Integer oonstants are handled by the DIGIT19 and/or DIG ITO routines. When the last digit in the constant has been located, control is passed to the INTCON routine. INTCON oonverts the constant to fixed point notation in a register, and exits to INTrlAN, which stores the constant in the Constant Pool and transfers a fivebyte internal name to the Nodification Level 2 text. For a majority of the operators in the Modification Level 1 text, the processing is limited to the transfer of the operator to the Modification Level 2 text (l::y OTHOP). In the case of the operators For and Do, a switch is turned on to indicate, respectively, entry to and exit from a for list, while the appearance of the operators Step, While, Power, or / in a for list is recorded in the appropriate entry of the For Statement Table. The Apostrophe operator indicates that the internal name of a character string or a logical value follows, and in this case the internal name alone is simply transferred to the Modification Level 2 text. PHASE TERMINATION The Scan III Phase is terminated on recognition of the closing operator Omega. The OMEGA routine writes out the last records of the Sul::script and Left Variatle Tables, releases main storage,. and transfers control (XCTL) to Diagnostic Output Module IEX31 (Chapter 9). PHASE INPUT/OUTPUT ARRAY SUBSCRIPT HANDLING Subscript expressions, identified by the operators [, Cmnma and], are handled by the OPBRACK, COMMA, and CLOBRACK routines. If a subscript expression relates to an array in a for statement, an analysis of the subscript expression is initiated to determine if the subscript expression is Figure 40 pictures the data input to and output from the Scan III Phase. The figure also indicates the tables transmitted via main storage. Chapter 6: Scan III Phase 77 ~ r---- Constant Pool TXT records (if LOAD specified) r---------, J I I I I SYSUTI L__ Modification Level 1 Source Text I I Identifier Table (lTAB) I--- I I I I Main Storage Scope Table (SPTAB) Group Tobie (GPTAB) [loAodificotion level I Source Text *] -r_J SCAN III PHASE I I Main Storage SVSUT3 Source Text*] (lVT AB) Subscript Table (SUTAB) I I L _______ -1I I r--- left Variable Tobie , ~ST~B)ement Tobie I ~;::~i~:~tion level - I I r---L--l I SY$UT2 Ncdificotlon level 2 Source Tex' 2 SY$PUNCH Constant Pool TXT records (if DeCK ______ specified) '" Source text transmitted in main storoge if it occupies less thon a full buffer. Figure 40. Scan III Phase input/output The Modification Level 1 source text is input from the SYSUT1 data set, unless the text occupies less than a full buffer. In the latter case the modified source text will have been transmitted from the Scan 1/11 Phase in main storage. Similarly, the Modification Level 2 source text is output on SYSUT2 or transmitted via main storage, depending on whether the text occupies more than or less than a full buffer. Input of the Identifier Table (ITAB) proceeds in parallel with output of the Subscript Table (SUTAB) and the Left Variable Table (LVTAB) on the same data set (SYSUT3). ITAB input is handled by the ITABMOVE subroutine, while SUTAB and LVTAB output is handled by the WRITE subroutine. SUTAB and LVTAB records (fixed length = buffer size) are output in random order, accordingly as the respective buffer is filled, starting at the SYSUT3 data set address immediately following the last ITAB record output by the Scan 1/11 Phase. The data set address is saved at initialization and transmitted to the Subscript Handling Phase in readiness for input of the first SUTAB/LVTAB record. To enable the records to be differentiated in the Subscript Handling phase, each output record contains a leading four-byte key (SUTB in SUTAB records, LVTB in LVTAB records). Before every input and output operation on SYSUT3, a test is made in both the I TAB MOVE and 78 WRITE SUbroutines, to determine if the operation to be performed differs from the last operation (i. e. input of I TAB or output of SUTAB/LVTAB). If the operation to be performed is the same as the last performed operaticn, input/output is initiated directly from or to the current data set position. If, however, the operation to be performed differs from the last performed operation, the data set position of the last transferred record is saved (with the aid of a NOTE macro) in one of the pointers NOTER or NOTEW (see Figure 41); the data set is then repositioned (by a POINT macro) to the address previously saved in NOTER/NOTEW; and input/output is started at the data set address to which SYSUT3 is positioned. NOTER (data set address of next ITAB record to be read) SYSUT3 - --- fo----- NOTEW (data set address for next output operation) Figure 41. -ITAB-- ----SUTAB LVTAB SUTAB Notes: NOTER is updated by the WRITE subroutine when the data set must be repositioned from an ITAB record to the next free record, for output of a SUT AB or LVTAB record. NOTEW is updated by the ITABIvIOVE subroutine when the data set must be repositioned from the end of the last written LVTAB or SUBTAB record, to the beginning of the next ITAB record to be read into main storage. Function of pointers NOTER and NOTEW in input/output operations on the SYSUT3 data set PROCESSING OF THE IDENTIFIER TABLE A descripticn of the entries in the Identifier Table (ITAB) is given in Chapter 4. See also Appendix II. In the Scan III resented operands in replaced by their names constructed in Phase, externally repthe source text are corresponding internal the Identifier Tatle. The processing of the Identifier Tatle is approximately as follows. A new I TAB record is read into a wcrk area from the SYSUT3 data set, as soon as a new block or procedure is encountered in the ~odifica tion Level 1 source text. When the end of a block or procedure is reached, the corresponding record in main storage is erased. In this way, the work area at all times contains those identifiers which have been duly declared I IL _________ I _______________________________ JI ~ = Figure 43. 82 Entry in Left Variable Table (LVTAB) CRITICAL IDENTIFIER TABLE (CRIDTAB) The critical Identifier Table provides a temporary record of the critical identifiers in the embracing for statement(s), that is, the nonarray identifiers found in the for list(s) of the embracing for statement(s}. It is used primarily in determining if an identifier in the iterated part of a for statement also occurs as the controlled variable in the for list. It also provides a means of identifying the for statement, in whose for list a critical identifier occurs. The latter function assumes importance in the case of a series of nested for statements, where an assignment is made to a critical identifier which occurs in the for list(s) of one or more enclosing for statements. This condition affects the lcgic of the enclosing for statement(s), and must be reflected in the For Statement Table. o 4 1 7 10 12 11 14 r-----T------------------T---------------r---------------y---T----T------------~ I I I I 1 factor> 1 addend> 1 1 1 of left I I I 1 1 1 1 1 cracket in 1 o/p buffer> JI I _____ 1__________________ 1_______________ 1_____________ __i1___ I ____ i1_____________ L ~ ~ ~ Bit 0 1 2 = o = -> = -> (used only in Subscript Handling Phase) = 3 Figure 44. ~ Fourteen-byte subscript Table entry for an optimizable array sucscript expression in a for statement 1 4 5 7 9 r------T-----------------------T------T-----------T-----------, I I ll1 critical identifier> i I ______ iI ___________ L1 __________ JI IL ______iI _______________________ = : Bit 0 on = Identifier is controlled variable Bit 1 on CRIDTAB contains a preceding entry for same identifier Bit 1 off = This entry is the first or only entry for the identifier Bit 2 on = CRIDTAE contains a succeeding entry for the same identifier Bit 2 off This entry is the last (or only) entry for the identifier First or only entry: Second or subsequent entry: = Any entry except the last: Last or only entry: (Not used) Figure 45. Entry in Critical Identifier Table (CRIDTAB) Chapter 6: Scan III Phase 83 An entry is made in CRIDTAB by the CRIMA subroutine as soon as it is determined that an identifier is contained in a for list. At exit from a for statement, all entries for identifiers in the for list are deleted. If the same identifier occurs in the for lists of a series of nested for statements, each entry for that identifier is flagged to show that there is a preceding and/or succeeding entry for the same identifier. If a for statement is classified a Normal Loop, all CRIDTAB entries for identifiers in the for list are deleted (by the DELCRIV subroutine). In the event of CRIDTAB overflow, the entries for the outermost for statement are deleted (by the CRIFLOW subroutine) • As indicated above, CRIDTAB lists the identifiers in the for list(s) of the embracing for statement(s), each entry indicating, first, if the identifier is the controlled variable, and second" if the identifier occurs in any other embracing for statement(s). As soon as it is detected (by NOCRI) that an identifier occurs in a for list, the Special Use Bits (see Figure 9) in the corresponding Identifier Table (ITAB) entry for the identifier are set to binary 11, to indicate that the identifier is a critical identifier, and an entry is made for the identifier in CRIDTAB. The Special Use Bits remain set to binary 11 until exit from the for statement" or until the for statement is classified a Normal Loop, at which time they are reset to their original value by the CRIFODEL routine. When an operand is encountered in the iterated statement (or in the same for list) whose corresponding ITAB entry shows that the identifier is a critical identifier, control is passed by FOLI to the CRITI routine. CRITI locates the corresponding entry in CRIDTAB, and then proceeds to modify the classification byte (in FSTAB) of the for statement(s) corresponding to each entry for the identifier, according to the particular circumstances surrounding the identifier in the iterated statement and in the for list. These may show, for example, that the identifier occurs as the controlled variable or as some other variable in the for list; that the identifier appears to the left of, or to the right of, an assignment operator in the iterated statement; or that the identifier appears only in a subscript expression. Depending on the circumstances identified, the corresponding for statement's classification byte may be modified to change the loop classification, or to specify that subscript optimization is or is not possible. 84 ARRAY IDENTIFIER STACK (ARIDSTAB) An entry is made in the Array Identifier Stack for an array identifier in a for statement when the opening bracket following the identifier is encountered. The entry is deleted when the bracket which closes the array list is found. In a series of nested arrays {as, for example: (ARRAYl [K, ARRAY2 [L, ARRAY 3 [M, N]] ] ) , an entry is made for each array, as soon as the opening bracket for the particular array is recognized. The stack entries are released as the relevant closing bracket is identified, the last entry for the innermost nested array being released first" the entry for the embracing array being released second., and so cn. o 3 4 5 7 r------------------y-----T------T---------, I , ,1 I __________________ array identifier>1 _____ , ______ I_________ JI L ~ Figure 46. ~ ~ = = (set to X'OO· if the array does not occur in an embracing array list) =