• Aucun résultat trouvé

ALGUL-to-PL/I Language Conversion Program for IBM Systlem/3S0 Operating System

N/A
N/A
Protected

Academic year: 2022

Partager "ALGUL-to-PL/I Language Conversion Program for IBM Systlem/3S0 Operating System "

Copied!
89
0
0

Texte intégral

(1)

IBM System/3S0 Conversion Aids:

File No. 5360-29 Form Y33 -7006-0

Program Logic

ALGUL-to-PL/I Language Conversion Program for IBM Systlem/3S0 Operating System

Program Numbeir 360C-CV-711

This documen-t describes the internal logic of the ALGOL-to-PL/I Language Conversion Program for the IBM System/360 Operating System.

Program logic manuals are intended for use by IBM system and customer engineers involved in program main- tenance, and by system programmers involved in altering the program design. Program logic information is not necessary for program operation and use. Therefore, distribution of this manual is limited to persons with program maintenance or modification responsibilities.

Restricted Distribution

(2)

This document describes the structure and functions of the ALGOL-to-PL/I Language Conversion Program: its components, their functions, and the control flow among them.

The detailed organization of each component and the instructions used to implement its functions are given in the program listing.

The object of this manual is to help the user to find any portion of the listing he requires.

In this manual, the IBM System/360 Operating System ALGOL language is referred to as ALGOL and the IBM System/360 Operat- ing System PL/I (F) language is referred to as PL/I.

The manual consists of six sections.

Section 1 is an introduction to the Lan- guage Conversion Program. Section 2 describes the Control Phase of the program.

Sections 3, 4, 5, and 6 describe the phases into which the program is divided.

The reader must have a working knowledge of tae ALGOL and PL/I languages and the System/360 Op€rating System.

The reader should have some familiarity with the contents of the following publica tions:

~~n_~Y§~~!LJ2Q_QEg~~!ing_2Y§!~!L_AL~Q~

Language, Form C28-66t5 1

!~~_~y§!gmLJ2~~Eg£~!ill~_~y§!gmL_R~LJ 1~L_E£Qg£~~~gf~§_2Yigg, Form C28-6591

!~~Q1=!Q=E~L!_~~n~Yagg_£Qn!~f§i2n_~fQ=

g£am_!Qf_!~~_2y§!gillLJ§Q_QEg££!illg

System, Form C33-20002

In addition, the reader will find i t useful to be acquainted with the

publica t ions:

1Referred to in the text as "the ALGOL lan- guage manual"

2Referred to in the text as "the ALGOL-to- PLII language conversion manual"

Specifications contained herein are subject to change from time to time.

Any such changes will be reported in subsequent revisions or Technical Newletters.

Request for copies of IBM publications should be made to your IBM representative or to the IBM branch office serving your locality.

A form for reader's comments is provided at the back of this publica- tion. If the form has been removed, comments may be addressed to IBM France, Centre d'Etudes et Recherches, Programming Publications, Depart- ment 843, 06 - La Gaude, France.

<e> Copyright International Business Machines Corporation 1969

2

I

(3)

INTRODUCTION •••••.••••••••••••••••..••• 7

Tables •••••••••••••.•••••••••••••••••.• 7 Overall Logic of the LCP ••••••••••••••• 8 CONTROL PHASE •••••••••••••••••..•.••••• 10

Initialization Procedure •••..•.••••.••• 10

Return Procedure ••••••••••••••...•..••• 10

PHASE 10 ••••••••••••••••••••.•••.•.•••• 12 Preprocessing •••••••••••••.•••.••.• 12 Detection of Block Structure •..•.•• 12

Construction of Dictionary •••..•••• 12

Phase 10 Routines ..•••••••••.••••..•••• 13

Input/Output Routines ••••.•••••.•.•.• 13 Processing Routines •••••••••••.••.••• 13 ARRAYS ••.••••••••••••.•••••..•..••• 13

COMENT .•••••••••••••••••••••••... 13

DECLAR ••••••••••••••••.•.•.••..••.• 14

DEPOIN •••••••••••••••••••••••.•••.• 14 DESPEC ..•••••.••..••.•.••.•••.••••• 14

GLABEL ••••••••••••••••••••••••••••• 14 tEND ••••••••••...•.•.••.••••.•..•.. 14

LETR • • • • . . • • • • • . • • • • • • • • . • • . • • . • • . • PAREN ••••••••••••••••.••••.•••... PROCED ••••••.•••.•••••..••..•••.... PVIRGU •.••••••••••.•••.••••••.•.... QUOT ••.•••••••.•.•••.•••.•••.••.•.. SCAN ••••••••••••••••••••••••••••••• SPEC IF SWITCH UNPOIN VNSPEC 15 15 15 15 15 16 16 16 16 17 PHASE 20 •••••••••••••••.•••.•.•...•...• 39

Phase 20 Routines .••.•.•.••.•••••.••••. 39 BEGPRO .••••••..•.••••••••.••••.••.• 39

PDCPRO ••••••.••..••••••••.••.•••.•. 39

PENPRO •..••.•.••••.••••••.••...•.•. 40

SDCID •••••••••••••••••••••••.•...•. 40

PHASES 25 AND 30 •••..•••••••••••••••• 50

Phase 25 •....••..•.••••••••••.••... 50

Phase 30 ...••.•••.•.••.••••••.••....• 50

Phase 30 Routines ...•••••.•.•••.•.... 50

PRPRO •.••.•...•.•.•••.••••..•.. 51

PALGEN ••••••••....•.••••..•••.... 51

RTNGEN ••••••..••.••.•.•...•••..•. 51

PHASE 40 . • . . • • . . . • • . . . • • • . . . • . 58

Phase 40 Routines ...••••••••.••••.. 58

Statement Processing Routines •.••.. 58

ARPRO •.••...••••..••••..•.••... 58

ASPRO . . . • . • . . . • • . . • • • . • • • . . • . 59

FORPRO .•..•.•.•....•••••.••••.•.. 59

GOTOPRO •.••.••.••.••..•••.•••..•. 59

IFPRO •...•.•..•••••.•.•...• 59

IOPRO . . . • • . . . • • • . . • . . • • . . . 59

PRPRO . . . • . . . • . . • . • • . • . . . 60

Expression Processing Routine • . . . 60

EXPRO • • • . . . . • • • • . . . • . . . • . . . 60

Utility Routines . . • . • • • • . • . . • . . . 61

APPENDIX A: TABLES • • . . . • • . . . • . . . 76

BUFFER . . . • . . . • • . • • . • . . • . . . • . . . 76

The Dictionary . • . . • . . • • . . . 76

DICEXT . . . • . • . . • . . . . • • • • . . . • . . . 37

DICPRO . . . . • • . • • . . . . • . . • . . . 18

Table PCT (Procedure Call Table) . . . 79

Comarea . . . • • • . . . • • . . . • . . . 79

APPENDIX B: FILES ••••••..••••.•... 81

File SYSUTI . • • . . . • • . • . . . 81

File SYSUT2 .•••••.•••.•..•.••... 81

File SYSIN •••••••••••.••...••.•... 81

File SYSPRNT . . • • . • • . . . • . . . 81

File SYSPCH ••.•.•••.•.••...•.•.... 81

APPENDIX C: STORAGE MAP ....•.•.••••.. 82

INDEX ..•••••••.••..••••••••••.•....•• 83

3

(4)

Chart 001. Overall Logic of Chart 027. SDCID Ro utine, Part 1

Control Phase

· · · ·

11 of 4

· · · · · · · · · ·

46

Chart 002. Overa 11 logic of Phase Chart 028. SDCID Rout ine, Part 2

10

. · · · · · · · · · · · · ·

18 of 4

· · · · · · · · · · ·

47

I

Chart 003. ARRAYS Routine, Part 1 Chart 029. SDCID Routine, Part 3

of 2

· · · · · · · · · · · · · ·

19 of 4

· · · · · · · · · · ·

48

Chart 004. ARRAYS Routine, Part 2 Chart 030. SDCID Routine, Part 4

of 2

· · · · · · · · · · · · · · · ·

20 of 4

· · · . . . · ·

49

Chart 005. COMENT Routine

· · · · ·

21 Chart 031. Overall Logic of Phase

Chart 006. DECLAR Routine, Part 1 25, Part 1 of 2

· · · · · . . ·

52

of 2

· · · · · · · · · · · · · ·

22 Chart 032. Overall Logic of Phase Chart 007. DECLAR Routine, Part 2 25, Part 2 of 2

· · · · ·

53

of 2

· · · · · · · · · · · ·

23 Chart 033. PRPRO Routine, Part

Chart 008. DEPOIN Routine

·

24 of 2

· · · · · · · · ·

54

Chart 009. DESPEC Routine

· · · · ·

25 Chart 034. PRPRO Rou tine, Part 2

Chart Chart 011. 010. GLABEL Rou tine LEND Routine

· · · · · ·

26 27 of Chart 2

·

035.

· ·

PALGEN Routine.

· · · · · · · · · ·

55 56

Chart Chart 012. 013. LETR Routine PAREN Rout ine

· · · · · · · · · ·

29 28 Chart Chart 037. 036. Overall Logic of Phase RTNGEN Routine

·

57

Chart 014. PROCED Routine

· · · · ·

30 40

. · · · · · · ·

63

Chart Chart 016. 015. PVIRG U Routine QUaT Routine

· · · · · ·

31 32 Chart Chart 038. 039. ARPRO Routine AS PRO Routine

· · · · · · ·

64 65

Chart 017. SCAN Routine

·

33 Chart 040. FORPFO Routine

·

66

Chart 018. SPECIF Routine, Part 1 Chart 041. GOTOPRO Routine

· ·

67

of Chart 2

·

019.

· . ·

SPECIF Routine, Part

. · · · · · · · · · · ·

2 34 Chart Chart 043. (H"2. IFPRO Routine IOPRO Rout ine

· · · ·

68 69

of 2

· · . · . · · · · · · ·

35 Chart 044. PRPRO Routine

· ·

70

Chart 020. SWITCH Routine

· · · · ·

36 Chart 045. EXPRO Routine, Part

Chart 021. UNPOIN Rou tine

· · · · ·

37 of 5

· · · · · · · · · · ·

71

Chart 022. VNSPEC Routine

· · · · ·

38 Chart 046. EXPRO Routine, Part 2

Chart 20

. · . · . · · ·

023. Overall logic of Phase

· · ·

42 Chart of 5

·

047.

· ·

EXPRO Routine, Part

· · · · · · ·

3

.

72 Chart 024. BEGPRO Routine

· · ·

43 of 5

· · · · · · · · · · .

73

Chart 025. PDCPRO Routine

· · · · ·

44 Chart 048. EXPRO Routine, Part 4

Chart 026. PENPRO Routine

· · · · ·

45 of Chart 5

· · ·

049. EXPRO Routine, Part

· · · · · · ·

5

·

74 of 5

· · · · · · · · · · ·

75

4

(5)

Figure 1. Overall Logic of the LCP 9

5

(6)

I

(7)

The ALGOL-to-PL/I Language Conversion Pro- gram, henceforth referred to in this publi- cation as "the LCP", helps the user to transfer to PL/I by convertingSystem/360 Operating System ALGOL source programs into PL/I (F) programs. In this publication, the donverted PL/I programs are referred to as "target" programs. The LCP itself is wri tten in PL/I (F) language. I t is dis- tributed in object module form for inclu- sion in the user's library.

The Job Control Cards used to call the program from the library are desdribed in the ALGOL-to-PL/I language conversion man ual.

The ALGOL source program must be free from errors; i.e., i t must meet the follow- ing requirements:

• It has been successfully compiled, without producing error messages, into a System/360 machine code version tha t

produces the results exp~cted by the user.

• It consists of statements that are in strict conformity with the synt~ctic

and semantic rules laid down in the ALGOL language manual.

Since these requirements are assume1, the LCP makes no attempt to detect errors, nor to continue scanning after an error has appeared, nor to' give precise diagnostics.

The LCP may, however, attempt to process an ALGOL program containing an error (where, for example, a card has been modified after compila tion) • In thi s ca se, con ve rsion may stop altoget her or, if ca rried out, rna y result in a PL/I program of dubious meaning and validity. In addition, note th~t:

• If the ALGOL program contains function designators that produce side~effects,

the converted program may produ=edif- ferent and un'Predictable side-effects •

• If, for any reason, a source statement cannot be converted (see Appendix D of the language conversion manual), a mes- sage to that effect is printed in the output listing.

The LCP is divided into the following six phases:

1. Control Phase

2. Phase 10, which performs the following functions:

• Converts the "hardware representa- tions" used in ALGOL in to in tel:'nal form

• Builds a dictionary of identifiers

• Detects the block structure of the progra m

• Converts the elements of the pro- gram that do not require reference to the diction~ry, e.g., comments, strings, and certain declarations.

3. Phase 20, which searches in the dic- tionary created during Phase 10, for the types of the identifiers

4. Phase 25 (option~l), which completes the dictionary if necessary

5. Phase 30 (optional), which generates procedure declarations, using the dic- tionary created by Phase 10 and, if necessary, completed by Phase 25 6. Phase 40, which generates the PL/T

statements, and all comments. Phase 40 converts all the elements not con- verted by Phases 10 and 30, statement by statement, using, when necessary, the dictionary of identifiers built by Phase 10, and the identifier descrip- tions added by Ph~se 20.

The LCP uses a number of tanles. The way in which these tables are used by the indi- vidual routines is des:ribed in the rele- vant sections. Appendix A contains a full description of the most important tables.

Introduction 7

(8)

Figure 1 illustrates the overall internal logic of the LCP and shows the relationship among the phases of the program.

The Initializati,on Procedure of the Con- trol Phase receives control from the

System/360 operating System ~nd then calls Pha se 10.

Phase 10 takes the AL30L source program from SYSIN as its input. It scans the source program, placing the intermediate text on SYSUT1, and builds the dictionary, which is placed on SYSUT2. optionally, Phase 10 can list the source program on SYSPRNT. It finally gives control back to the Control Phase, which calls Phase 20.

Phase 20 takes the intermediate text and the dictionary as its input. It inserts the identifier types in the intermediate text, and, in certain c~ ses, builds a table which is placed on SYSUT1. Control again returns to the Control Phase.

The Control Phase now tests for the pre- sence of procedure decl~rations in the source program. If the re.5ult of this test is positive, and if, in ~ddition, cert~in

conditions are present, the Control Phase

8

calls Phase 25 to complete the dictionary, using the table create:! by Phase 20. (For details of the requisite conditions, see the section describing Phase 25.) Control returns to the Control Phase.

The Control Phase then calls Phase 30 which generates the PLII PROCEDURE state- men ts. Note tha t:

1. Phase 30 may be c~lled directly after Phase 20 if Phase 25 is not required.

2. If the source program contains no pro- cedure declarations, neither Phase 25 nor Phase 30 are required.

Phase 40, the last phase of the program, is therefore called, via the Control Phase, either after Phase 30 or directly after Phase 20. Phase 40 generates the PL/T sta- tements and comments, t~king the modified intermediate text on SYSUTl as its input.

On completion of Phase 40, control returns for the last time to the Control Phase which uses the Return Procedure to generate error messages if necessary. (An error message may have been issued during a pre- vious phase if a synt~ctic error was detected in the program.)

Control finally returns to the Operating System.

I

(9)

OS/360

+--

MESSAGES

I

I

8 I

COMPLETED TEXT

I

(

FigQre 1. Overall Logic of the LCP

SYSIN

I

I

I

COMPLETED

+

TEXT

QO'

SYSPCH

Introduction 9

(10)

The LCP Control Phase (see Chart 001) receives control from the System/360 Operating System by means of an EXEC con-

trol card. This phase controls the flow of the program, using two procedures:

1. Initialization Procedure 2. Return Procedure

The actions performed by these proce- dures are described below.

Initi~lization Procedure

The Initialization Procedure initializes the settings of the switches in the LCP communication area. These are set either to a standard status, or to the status indicated by the user in his EXEC control invokes Phase 10.

10

The Return Procedure, which is entered on completion of each phase of the program, calls the following phase. On completion of Phase 40, the Return Procedure generates error messages where necessary and restores control to the System/360 3perating System.

Should the program stop at any time during execution because an error has been

detected, the Return Procedure automatical- ly regains control and issues an appropri- ate message. Control then returns to the Operating System.

I

(11)

Chart 001. Overall Logic of control Phase

****Al*********

* ENT RY FROM *

INIT

***A2************

* OS/360 *---)

* * A *

READ NEXT OPTION

*************** '

*********1******* ,

.

,

. *.

v

B 2 *. *****B3**********

• * *. * *

.* SIZE *. YES * *

*. OPTION .*---)*INITIALIZE SIZE*---X

*. . * * * I

* . . * * *

* •• * t NO *****************

C2 .*. *. *****C3**********

.* LiB *. * *

.* CHARACTER *. YES *INITIALIZE CHAR* V

*. SET .*---)* LiB *---X

*. OPTION .* * *

*. • * * *

* •• * t

.

NO *****'************

. *. v

D2 *. *****D3**********

.* *. * *

• * I SO *. YES * * V

*. OPTION .*---)*INITIALIZE ISO *---X

*. . * * * I

* . . * * *

* •• * t NO *****************

.*. 'i

E2 *. *****E3**********

.*SOURCE *. * *

.* CARD *. YES * INITIALIZE * V

*. LISTING .*---)* SOURCE *---X

*. OPTION .* * *

*. • * * *

* •• * *****************

: NO

V

*****F2**********

* *

* *

*INITIALIZE DECK*

* *

* *

********1********

.

v

'(---X

.*. CONTRr.

G2 *. *****G3********** *****GLi**********

.* *. *PH10 002A2* *PH20 023A2*

NO.* OPTIONS *. YES *----~---* *---*

x---*. COMPLETED .*---)* SCAN SOURCE *---)* SEARCH *

*. .* * PROGRAM BUILD * *DICTIONARY FOR *

* . . * * DICTIONARY * * IDENTIFIERS *

* •• * ***************** *****************

* '

. *.

HLi * •

• * *.

YES.* IS *.

X---*. TABLE PCT .*

, *. EMPTY • *

*. * . . * . * r NO

.*. v V

*****J2********** .J3 *. *****J4**********

*PHLiO 037Al* .* *. *PH25 031Al*

*---* NO .* PROCEDURE *. *---*

* GENERATE PL/I *(---*.DECLARATIONS .*(---* COMPLETE *

* PROGRAM * A *. .* * DICTIONARY *

* * ' * " . * * *

***************** , * • . * rYES *****************

'i

*****K2**********

****Kl********* RETURN TO * * * GENERATE * *

OS/J60 *(---* MESSAGE *

* * * *

*************** * *

*****************

V

*****K3**********

*PRPR030 033Al*

x---*

*---*

PROCESS *

* PROCEDURE *

* DECLARATION *

*****************

Control Phase 11

(12)

Phase 10 performs three main functions:

1. It acts as a preprocessor by convert- ing into internal form the ALGOL

"hardware representations" (see Chapt- er 1 and Appendix 2 of the ALGOL lan- guage manual) and by converting into PL/I certain basic elements of the source program.

2. It detects the block structure of the program.

3. I t builds a dictionary of declared or specified identifiers. This dic- tionary serves for the conversion of assignment statements, subscript ex- pressions (other than constants), and actual parameters (called by value).

The overall logic of this phase is illu- strated in Chart 002.

££~E!:.Q~~§§i!!.9.

The input to Phase 10 is the ALGOL source program on SYSIN. After initializing i t s internal parameters and tables, Phase 10 scans the ALGOL program to perform the fol- lowing actions:

12

• ALGOL basic symbols with a hardware representation that contains more than one character are recognized and con- verted into fixed-length internal form.

• Blanks outside strings and comments are elimina ted.

• Strings and various forms of comments are converted into their PL/I equiva- lents. When the sequence *1 appears within the text of a comment, i t is con verted in to

*-.

In an open str ing, a single quotation mark is replaced by double quotation marks.

• Identifiers over six characters in length are truncated to six characters.

(Identifiers in the intermediate text always contain six characters; blanks

are added if necessa ry.)

• Certain delimiters (e.g. 'END', semi- colon, and 'DO') are recognized and used for delimiting essential com- ponents of the ALGOL program, such as declarations and statements. An internal reference number is added to each of these elements.

Detection of Block Structure

The-nested-program-structure

is detected by placing the appropriate delimiters in a stack, and by setting an indicator in the intermediate text. Th~ blo::;k structure of the source program defines the scope of the identifiers. This procedure is used also to recognize the end of 'FOR' statements and of procedure declarations.

The LCP handles a procedure declaration seperately from the rest of the block in which i t occurs, and considers i t as a new block. l number is assignej to each block and to each procedure declaration. The

dictionary (see Appen::tix A), is thus divided into two sections:

1. DICEXT, which cont ains ent ries re la- tive to blocks.

2. DICPRO, which contains entries rela- ti ve to procedure declarations.

At the end of a program-block, the corresponding section is placed on SYSUT2, using a key to identify the section. (See Appendixes A and B for further details.)

~Q!!.§i£~£i~Qrr_Q!_]igi12n~£~

Phase 10 builds the dictionary using the source program declarations and

specifications.

Identifiers are checked, before being entered in the dictionary, to prevent con- flict with built-in PLII function-names or with relational operators when the 48- character set is being used. In the event of a possible conflict, an appropriate flaq is entered in the dictionary.

In the case of a procedure declaration, the description of the formal parameters is completed using the specifications. The declaration processing routine attempts to convert as much as possibl~ of the declara- tion. If a switch-declaration canr~ot be converted, a flag to that effect is placed in the intermediate text.

The output from Phase 10 is an inter~e­

diate text, placed on SYSUT1, using the internal reference number as a key.

I

(13)

To perform its various functions, Phase 10 uses a number of routines. These fall into the following two categories:

1. Input/output routines

2. Processing routines

INPUT/OUTPUT ROUl'INES

These are used by Phase 10 to perform various simple and frequently recurring functions, as described below:

BUFPUT

!)ICPUT

GENER

GETCAR

GQUOT

PRINT

PROPUT

PUTCAR

FINPG

places the contents of the out- put buffer on SYSUT1.

places dictionary DICEXT on S YSUl' 2.

places in the output buffer characters that have been stored in the intermediate area.

places in the word TCHAR the character in the input buffer, positions a pointer to the next char,acter, and if necessary, reads the next card.

reads the ALGOL keyword enc- losed by quotes, converts i t into internal code, and enters the converted keyword in

CODCAR. Determines the type of the keyword (oeclarator, speci- ficator, etc.) and enters the information obtained in LUC.

lists the ALGOL source program on SYSPRNT.

places dictionary DICPRO on SYSUT2.

places in the output buffer the character contained in CODCAR and positions a pointer to the next character.

End-of-phase routine, which closes the files, places the contents of the last output buffer on SYSUr1, and returns control to the 20ntrol Phase.

PROCESSING ROUTINES

This section contains detailed descriptions of the routines used by Phase 10 to process various elements of the ALGOL source pro- gram. The informa tion gi ven about each routine is set out as follows:

• Purpose of the routine

• Calling phase or routine (s'

• Process in g

• Routine(s, called

• Exit from the routine

In order to simplify reference, the rou- tines are described in alphabetical order.

tach routine is illustrated in a separate flowchart.

E~££Q§~: To process the text following the ALGOL decla ra tor 'ARRAY'.

~£~£g~~in~: Generates the list of array- names, converts the bound-pair-list into internal code and, depending on the type of the list, generates ona of the following:

• FLOAT(16)

• FIXED BINARY(31)

• BIT (1)

Enters in DICEXT the information concerning each identifier of the array-name list.

li~~t1~g~_£~11~g: BUFPOT, GLABEL, GENER, GETCA B, PUTC AR.

.f11£1t:

DECLAR.

Eg££Q~g: To process comments.

~£2£g§§ing: Places any text between 'COM- MENT' and a semicolon into BUFFER, enclos- ing this text between the delimiters /* and

*/. Replaces the sequence */, when i t occurs in the ALGOL program, by

*-.

BQ~t1~g§_£~11gg: BUFPOT, GENER, GETCAR, PVIRGU.

~1£1t: SCAN.

Phase 10 13

(14)

To process ALGOL declarators.

££Q£g§§i~g: Detects the type of the declarator(s), places in area TYPCAL the information pertaining to the declaration.

If one of the declarators is 'ARRAY', 'PRO- CEDURE', or 'SWITCH', goes to the routine ARRAYS, PROCED, or SWITCH respectively. If not, enters identifiers of a same type, together with the type, in dictionary DICEXT. Depending on the 1ec la ra tor, generates one of the followinq:

• DECLARE... FLOAT

• FIXED BINAFY (31)

• BIT ( 1)

If necessary, updates the stack.

RQg1i~s§_££11~Q: DICPUT, ~ENER, GETCAR, GLABEL, GQUOT.

IK.ii: ARRAYS, PRO::'SD, SCAN, SPE1, SWTTCH.

E~I£Q§~: To process thp followinq characters: :=

SCA N •

~I2f~§§ing: Detects whether the character spquence to be processed is a colon , an equal sign, or a combination of the two.

Converts the character into internal c01e and places i t into BUFfER.

SCAN or SeA 1.

E~IQQ2~: To process a sequence of two spe- ci d I c ha rae terse

RIQ~§§§i~g: If the first character is a spmicolon, calls routine PVIRGU to process it. If the first character is a period, qoes to routine UNPOIN. If i t is neither of these:

14

a. If the combination of the two charac- ters constitute an ALGOL symbol, con- verts the sy mb 01 into in te rnal co de and places i t into BUFFER.

b. If the two characters do not consti- tute an ALGOL symbol, converts the first character only and places i t into BUFFER.

RQY1in~§_££11~Q: PUTCAR, PVIRGU, SCAN, UNPOIN.

~K~i: SCAN or SCA2.

E~~EQ§g: To place the current identifier in areas IDENT1 and IDEXT6.

~£ll~Q_QY: ARRAYS, DECLAR, LETR, PROCED, SPECIF, SWITCH.

~fQ£~§§1llg: Ignoring blanks, fetches the characters making up the identifier, and truncates the latter to six characters.

Tests whether or not a $ sign should be added as suffix to the identifier, and adds

$ if required. Calculates length of the identifier.

None.

~Ki1: Calling routine.

E~£~Q~g: To process the ALGOL word 'END' and the comments, which, in certain cases, follow it.

E£Q£~~~i~g: Tests the contents of the stack. If i t finds tha t the last symbol in the stack indicates the beginning of a loop, it generates END. If i t finds that

the last symbol indica tes a block, i t places DICEXT on SYSUT2 and generates END.

Tests for the beginning of a comment; if a comment is found, places i t into BUFFER, enclosing it between the delimiters 1* and

*/. If t he comment is followed by:

• 'ELSE', generates a ;ELSE sequence, and returns to SCAN.

• A semicolon, ge ne ra te s a semicolon, processes it using routine PVIRGU, and returns to SCAN.

I

(15)

• IENDI, generates a semicolon and returns to LEN1.

~Q~iing§_£gll~g: BUFPUT, DICPUT, GENER, GETCAR, PVIRGU, QUaT.

I~il: LEN1, SCAN.

E!!R~Q

____________________________

fh~£i_Ql~

Eg£~Q[~: To generate an end-of-loop, an end-of-procedure, or an end-of-function, depending on the contents of the stack.

£g!l~g_h~: DESPEC, LEND, UNPOIN, VNSPEC.

~fQ£~§§ing: Tests the last item in the stack. Then, if the last item in the stack

1~!B

______________________________

~h~£1_~!£ is:

gg£EQ§g: To process identifiers.

SCAN.

gfQ£g§§i~g: Reads the identifier, using routine GLABEL, and places it into BUFFER.

BUFPUT, GLABEL, SCAN.

SCA2.

~!R~N.

_____________________________

~h~f1_Ql.J

R~£EQ§g: To generate letter-strings that occur 1n procedure or function 1e~larations

or in procedure or function calls.

EfQ£g§§irrg: Generates the letter-string, enclosing i t between the delimiters

1*

and

*1.

~~i1: Calling routine.

~gf.EQ§~: <To process proced ure decla ra tions.

~£Q£~§§ing: Detects whether or not the procedure contains parameters, and up1ates the stack accordingly. If parameters are found, processes them. Enters information relating (a) to procedure identifiers in dictionary DICEXT, (b) to parameter ide:1ti- fiers in dictionary DICPRO. Generates pro- cedure declarations.

BQ~1irrg§_£~11gg: DECLAR, GENEP, GETCAR, GLAB·EL, PAREN.

];~i1.:... DECLAR.

• DO, generates an END; sequence. Goes on to test the pre~2jinq item, and so forth.

• A non-type procedure cO:1taining parame- ters, places DICPRO on SYSUT2, and generates: END;

• A type procedure cO:1taining parameters, places DICPRO on SYSUT2, and genera- tes: RETURN(~RTUFN); END;

• A non-type procedure with no ?arame- ters, generates: END;

• A type procedure with no parameters, generates: RETURN ($ PTURN) ; END;

If the program is an ALGOL procedure, enters the name and type. of the procedure in PGPROL and PGPROT respectively for tran- smission to Pha se 20.

~!i1: Calling routine.

~Y~EQ§§: To process th~ followina c~a~'~­

ters or groups of characters: cuote separatoL (exFonent paLt"

'I', •

(~ f'ol-

1 0 we d by a:1 A L GO L s t Lin g, A L G J L k p Y W 0 [ ."1

enclosed by auotes.

LEND, SCAN.

EI~£~[[1rrg: Recoq:1izes aroups of charac- teLs beqin:1inq with a quotatio~ maLk.

• If it fi:1ds the quote separator ( e x po n e n t pa L t), con ve r t s i t i n to inteLnal form, and places i t on SYSUT1.

• If it finds

'I',

converts i t into in t e r :1 a 1 for m, and p 1 aces i t o n S Y S U l' 1 .

• If it finds ' ( I , places the string that follows, up to the 13. st

f, "

in to BU F'F- ER, c0twEen quotes.

Phase 10 15

(16)

• If i t recognizes the group of charac- ters as an ALGOL keyword, ~nd if:

a. It finds specifiers or the word 'CODE', goes to routine SPECI?

b. It finds any declarator except 'CODE', goes to routine DECLAR.

c. It finds 'COMMENT', goes to routine COMENT.

d. I t finds 'END', goes to routine LEND.

e • It fin d s 'D

a "

I THE

N',

0 riEL S E' , processes the m.

f. It finds any other ALGOL keyword, converts i t into internal form and places i t into BUFFER.

R2g1in~§_f211~Q: BUFPUT, COMENT, DICLAR, GENER, GETCAR, GQUOT, LEND, PROPUT, PU~CAF,

SCAN, SPECIF.

£;~!:.1: COMENT, DECLAR, LEND, SCAN, SCA1, SPECIF.

R'y!:£Q§f: "1"0 call the a ppropria te routine required to process a Character.

~211~Q_QY: All routines except ARRAYS, FINPG, PROCED, SHITCH.

R£Q£~§§in~: Reads and tests the charact~r.

• If i t is a letter, goes to routinp LETR.

• If i t is a digit or a left parenthesis, processes i t .

• If i t is a colon 1r an rou tine DE POI N.

sign, goes to

• If i t is a q uotat ion mar k, goes to rou- tine QUOT.

• If i t is any other special character, tests whether i t is the first of a group of two special characters; if so, qoes to routine DESPEC, if not, goes to

cou tine UN SPEC.

RQ~1in~§_£~1!~Q: DEPOIN, DESPEC, GENIR, GETCAR, PAREN, PUTCAR, QUOT, VNSPEC.

~!.i!: DEPOIN, DESPEC, LTF, QUOT, SCAN, SCA2, VNSPEC.

16

RgfEQ§~: To process the followinq:

• 'CODE'

• Text following specifier

• Value part

ffQ£~§§i~g: There are two entry-points to this routine: SPEC IF and SPE1. At entry- point SPECIF, processes a specificator or the word 'CODE'. Generates the appropriate PL/I declaration and enters the relevant information in DICPRO.

At entry-point SPE1, processes the keywords used as. specifiers whi:::::h are also used as declarators. Partially computes TYPCAL and enters the information obtained in DICPRO and in DICEXT, which already contains the procedure type.

EQ~!i~~~_£2!!~g: GENER, GETCAR, GLABEL, GQUOT, PROPUT, SCAN.

SCA N.

gg~£Q§~: To process the text following the declarator 'SWITCH'.

~~Q£~§§ing: Ascertains which identifiers follow the declarator 'SWITCH', and

generates the declaration LABEL INIT-IAL.

If necessary, places number of error mes- sage in RMES.

BQ~ti~~~_£211~Q: GLABEL, GENER, GETCAR, SCAN.

SCA N.

~Y~£Q§~: To process groups of special characters beginning with a period.

~IQs~§§ing: Ascertains whether or not the period is the first of a group of two characters representing an ALGOL symbol.

I

(17)

• If not, i.e., if the period appears on its own, converts i t into internal code and places i t into BUFFER.

• If so, and if the period is followed by another period ( •• ), converts the group into internal code and places it on SYSUT1.

• If so, and if the period is followed by a comma (.,), calls the routine PVIRGU to process the group

EQgiin~§_£All~~: GETCAR, PUTCAR, PVIRGU, SCA N.

]]!;.t!:: SCAN, SCA 1, SCA2.

~g££~~~: To process isolated special characters.

g£~£g~~i~~: If the character is a semico- lon, calls routine PVIRGU to process it.

In all other cases, converts the character into internal code and places i t into BU FFER.

.§:!i! :

S CA6.

Phase 10 17

(18)

Chart 002. Overall logic of Phase 10

PH10

****A2*********

* ENTRY FROM *

* CONTROL PHASE *

* *******:******* *

·

x--->:<---X

i

",**82************ SCAN 01183

*---*

READ A CHAR.

OR GROUP OF * CHAR

*********t*******

.*. v C2 * •

• * *. ****C3*********

.* END OF *. YES * RETURN TO *

*. FILE .*--->* CONTROL PHASE *

*. .* * *

* . . * ***************

* •• * : NO

· *. v

*****D1********** 02 *.

* *CODE GROUP AND *

*

NO • * .* ALGOL

*.

*.

X---* PLACE INTO *<---*. KEYWORD .*

A * BUFFER * .*

• * * * . . *

***************** *. • * t YES

. ·

·

v

· *.

*****E1********** E2 *.

I *COMENT 005A1* .* *.

I *---* YES .* *.

X---* GENERATE *(---*. COMMENT .*

A * CCMMENT * *. • *

* * * . . *

***************** * •• * t NO

· *. v

F2 *. *** **F 3**********

.* *. *

• * *. YES * GENERATE *

*. DECLARATION .*--->* DECLARATION *

*. * . . . . * * * *

*'!'~O ********!********

. i

·

*****G1********** G2

.*.

*. *****G3********** V

* * .*KEYWORD*.

x---! ~~~~O~5G~~D !<-_____ ~~*:Sp~~~2tR~~g-*:*

*PLACE ON SYSUT1* *. CESSING .*

* *

***************** *. * •. *

..*

t YES

~---x V

*****H1**********

* *

I * PROCESS THIS * X--- * KE YWORD *

* *

* ***************** *

18

* * * *

*ENTRY IN DICEXT*

* *

* *

********t********

H3 .*. *.

. * *.

.* *. NO

*. PROCEDURE .*---X

*. •. .* .* ' A

* •. * ! YES

V

*****J3**********

*PROCED *

*---* •

* *---x

*ENTRY IN DICPRO*

* *

*****************

I

(19)

Chart 003. ARRAYS Routine, Part 1 of 2

***** *003*

* A3*

* * t

·

ARRAYS ''I

*****A3**********

* *

* SET NAME *

* COUNTER TO 1 *

* *

* *

********t********

· ·

V

*****83**********

* *

* *

* GENERATE ( *

* *

* *

********t********

.*. ARR1 .*.

*****C1********** C2 *. C3 *.

* * • * *. .*DELIMTR*.

* * NO.* NAME *. NO .* FOLLOWING *. YES

* GENERATE ( *(---*. COUNTER: 1 .*(---*.IDENTIF LEFT .*---X

* * *. .* *. 8RACKET .*

* * * . . * * . . *

***************** , * •• * * YES * •• * *

• t

. .

~(---X V

*****D1**********

* *

*INCREMENT NAME *

* COUNTER *

* * * *

********t********

.

V

*****E1**********

* * GENERATE * *

*IDENTIFIER WITH*

* ~OMMA *

* ********:******** , *

****

*003*

* F1 *-)'

* * •

**** q

ARR2 .*.

F1 *.

.* *.

.* OTHER *. NO

*. IDENTIFIER .*---X

*. . * v

*. • * *****

* •• * *004*

: YES **A~*

,

'I

*****G1**********

* *

* ENTER *

* IDENTIFIER IN *

* DICEXT *

* *

********t********

V

*****H1**********

* *

*

* ENTER TYPE OF *

* IDENTIFIER IN *---1

* DICEXT *

* ***************** *

,

·

V

*****D4**********

* *

* GENERATE *

* IDENTIFIER *

* *

* *

********t********

·

V I

. *.

E4 *. *****E5**********

. * *. * *

.* NAME *. NO * *

*. COUNTER = 1 .*---)* G~NERATE ( *

*. . * * *

*. • * * *

*·t·tES ********:********

I

I I

~(---X V

*****F4**********

* *

* *

* GENERATE ( *

* *

* *

********t*******~

V

*****34**********

* *

* SET DIMENSION *

* COUNTER TO 0 *

* *

* *

********t********

·

V I

*****H4**********

* *

* SET BRACKET *

* COUNTER TO 1 *

* *

* *

********t********

'I

*****J4**********

* *

* *

* SET SW2 TO 1 *

* *

* *

********t********

·

v

*****

*011*

* B3*

* * *

Phase 10 19

(20)

Chart 004. ARRAYS Routine, Pa rt 2 of 2

·

ABRIl v

••••• Al ••••••• ~ ••

• •

SEARCH FOR ~

• RIGH! BRACKET •

• • • •

.

~

... : ... .

·

••••• B1 •••••••••• V

DECREftENT

• BBlCKET COUNTER.

• •

• ••••••••••••••••• · •

C1

.•.

•• • •••• C2 ••••••••••

.... . .

•• BBACKET •• N O .

•• COURTER - 0 ••

..

* . . *

.. --->. .

GEURU. /1

.

•• ••

: YES

• ••••••••••••••••

:

· ·

.

.,

••••• Dl ••••••••••

• •

• EHTER NUftBER OF.

• DIKENS IONS IN •

DICE IT

• •

... : ... .

· ·

V

••••• E1 ••••••••••

• •

: ~ff~E/~N~~D :

BUPFER

• •

... : ... . ... ·

v :~H:

• C3 •

• • •

P l . . • •••• '2 ••••••••••

.... . .

• : . DELIMITER .:.!!~--->: cog~~EI1'~ 1 :

•• COKKA ••

111..*

•• ••

: NO

• ••••••••••••••••

·

V

••••• Gl ••••••••••

• •

• •

GENERATE)

• •

• •

... : ... .

·

••••• H1 •••••••••• 'I

• •

• •

• SET SII2 TO 0

• •

• •

••••••• *: ••••••••

20

· ·

•••••

v

• 007 •

• H,.

• • •

· ·

V

••••• G2 ••••••••••

• •

• •

.GENERATE COK"A •

• •

• •

. ... : ... .

·

'I

•••••

• 003 •

• ' h

• • •

I

(21)

Chart 005. COMENT Routine

:M!:

• 11.

• • :

· ·

COIlENT V

••••• A1 ••••••••••

• •

: PLA~8F~~RINTO :

• • ...

~

... . • •

COll3

..

V

.**B1****** •••• **

READ NEXT CHARACTER

***.* •• *.: •• ** •••

.

'COll2 Cl

... ·

, v ••

. * * .

• * *. YES

*. SEIIICOLON .*---1

X---

*. . *

*. .*

* ..

T * NO

.*.

v Dl *.

.* *.

.* *. YES

*. *1 .*---X

*. .• II

*. .*

* •• * T NO

·

,

V

***E 1 ************

" ,

V

*****E2**.*******

* *

PLACE _ * *

CHARACTER <---* REPLACE BY .- *

INTO BUFFER * * *

* *

COM1

.

V

*****D3********.*

* *

: PLA~fiF~~RINTO :

* *

* .*

********t********

V

*****E3**********

* *

* SKIP TO NEXT ~

* BUFFER *

* *

* *

***************** ************.***** ********t********

''1

*****F3***.******

*PVIRGU 015A2*

*---7---*

* PROCESS *

* SE IIICOLON *

* *

**,******t**·*****

.

,

v

****.

*017*

* B3*

* * *

Phase 10 21

Références

Documents relatifs

Job file control block (JFCB) extension blocks are used to record volume serial num- bers in excess of the five recorded in the JFCBVOLS field of a

Diagram.. Phase ME Overall Logic Chart PA. Phase MG Overall Logic Chart PD. Phase MI Overall Logic Chart PH. Phase MK Overall Logic Chart PL. Phase ML Overall

decla~ed in the ENVIRONMENT attribute. ~rhis control block is. generated during program execution when a file is opened. Dynamic allocation of the FCB storage is

In the following report is discussed the coating formulation, orientation pro- cedure, magnetic hysteresis measurements and magnetic recording results for the disk

System Action: Null statement inserted. SOURCE PROGRAM CONTAINS TOO MANY BLOCKS. §Lstem Action: compilation is terminated. User Response: Re~rite program with fewer

string for each parameter, the parameter count is incremented and the address of the Polish string is inserted in the phrase list. When all parameters have

Entry point names identify points within a module to which control is passed when the module is called by another library module or by compiled code.. with

Whenever the matching record indicator MR is on and indicator 02 is on, the contents of the field AMT are added to the MASBAL. The result is stored