LIBRARY OF THE UNIVERSITY OF ILLINOIS AT URBANA-CHAMPAICN 510.84 no.708-7H dop. 2 Digitized by the Internet Archive in 2013 http://archive.org/details/plwusersmanual711lope ' / hJ uiuuuuo- n— | ;>— | _l_l IK y it «- — — -■ PLW User's Manual by Lawrence D. Lopez WU-iiouj-uutiu i IHE LIBRARY OF THE AUG1 1975 UNIVERSITY OF ILLINO! May, 1975 UIUCDCS-R-75-711 COO-2383-0020 PL¥ User's Manual by Lawrence D. Lopez May, 1975 DEPARTMENT OF COMPUTER SCIENCE UNIVERSITY OF ILLINOIS AT URBAN A- CHAMPAIGN URBANA, ILLINOIS 6l801 * This work was supported in part by the Atomic Energy Commission under grant US AEC AT (11-1) 2383. Section Page 1 General Information 1 2 Gross Input Features 2 2.1 Identifiers 2 2.2 Constants 2 2.3 Comments 3 3 Program Form * 3.1 Invocation of Procedures ^ 3.2 Procedure Definition ^ h Declarations o 5 The Assignment Statement 8 6 DO Groups . ., 9 T IF Statement 10 8 CASE Statement 11 9 List Processing 12 9.1 Areas 12 9.2 DSECT 12 9.3 SET Statement 13 10 I/O 15 10.1 READ 15 10.2 WRITE 15 11 TRACE Facility 16" 12 Listing Control IT 1 1. GENERAL INFORMATION The PLW compiler translates the PLW language into FORTRAN for porta- bility. The PLW language resembles PL/I in many respects. This was done in order to ease the transition for users who already know PL/I. The present PLW compiler supports character, fixed, floating, complex, double precision and boolean data types. Procedures, LXD loops, IF, and CASE statements are also provided. List processing facilities and dynamic alloca- tion of list elements are also provided although this facility is somewhat limited and is subject to some change in future versions of the compiler. 2 2. GROSS INPUT FEATURES Input to the compiler consists of card images. Columns 73 through 80 are ignored, and may contain information relevant to the programmer only. As such they are printed but otherwise ignored. Columns 1 through 72 contain the source program. 2.1 Identifiers ! Identifiers are composed of a letter followed by or more letters and digits. Column 73 of the card or a character which is neither a letter nor a digit terminates the identifier. Identifiers may be up to 31 characters in length. 2.2 Constants Constants are of several types: 1) FLAG constants: OB for false IB for true 2) INTEGER constants which are simply a series of digits. 3) REAL constants, for example: 32. .32 3.32 32. E 2 .32 E 2 3.32 E 2 3 E 2 These are translated into single precision unless the context 3 requires a double precision number. k) LITERAL constants - or character strings are the same as in PL/I. That is : 'XXX' is XXX »XX"X' is XX'X It should be noted that all constants must be complete on one card. 5) IMAGINARY constants are real constants followed by the letter I. Example: k.O - 2E - II is the complex number (U, -.2i) 6) The pointer constant NULL is a pointer to no specific dsect. 2.3 Comments Comments are indicated by the percent sign %. % causes all information to the right up to the next % or column 73 to be ignored. k 3. PROGRAM FORM The input to the compiler is one or more procedures. The body of a procedure may contain any number of declarations, procedures or executable statements . Statements will be executed in the order that they appear in the body of the procedure. Procedures and declarations should appear before they are referenced. 3.1 Invocation of Procedures Procedures which return no value are invoked by the CALL statement. Procedures which return values are invoked by a function reference to that procedure in an expression. Procedures may return values of type real, integer, double, complex, pointer, character and flag. A procedure should be defined before it is used. If it is not, then it is assumed external and no warning is given. External procedures which return non-standard types should be declared. For example: DECLARE PS PROC (INTEGER) RETURNS (CHAR(3)); 3.2 Procedure Definitions Procedure definitions have several forms l) Parameterless ABLE: PROC; END ABLE ; PROC is an abbreviation of the word PROCEDURE. In "END ABLE" the word ABLE is presently optional. is a series of declarations, statements, and procedure declarations. 5 2) Procedure with parameters but no value: ABLE2: PROC() ; END ABLE2; The has the same form as the body of a declaration (this will be discussed later). The type, dimensionality, etc. of the parameters may be specified in parameter list or may be specified in subsequent declare statements. Hence, P: PROC(Q POINTER) ; is equivalent to P: PROC(Q); DCL Q POINTER; The second form, although not as elegant as the first, is provided to allow compatibility with PL/I. 3) Procedures which return values: ABLE3: PROC() RETURNS ( CHARACTER (32)) ; The RETURN statement is provided to return the actual value. A procedure to compute the square of a number would be, SQUARE: PROC( VALUE REAL) RETURNS (REAL) ; RETURN ( VALUE *VALLE ) ; END; Note that no parentheses should be used for returned character strings. Hence RETURN('32') is invalid and should be RETURN '32'. The outermost procedure should be called MAIN in order that the proper run time support linkages be made. h. DECLARATIONS The general form of the declare statement is the same as in PL/I. Examples of it are: DCL I INTEGER, (B,C,D) REAL; In this example I, B, C and D are the variahles declared, INTEGER and REAL are the attributes specified for these identifiers. In the following list of attributes is an integer constant expression. It may use "variables" declared as constants, for example, DCL N EQU(lOO); Attribute Defines CHAR() CHARACTER() VARYING VAR BINARY BIN FIXED FIX INTEGER FLOAT FLT REAL DOUBLE DBL LONG COMPLEX CMPLX IMAGINARY IMAG SGL POINTER PTR Character string A varying character string A binary variable An integer variable A floating point variable A double precision variable A complex variable Single precision variable A pointer variable to a dsect FILE A file definition Attribute Defines AREA PROC BIT FLAG BOOLEAN EQU() CON() CONSTANT() BASED() DSECT IN() INIT() An area of storage definition (where DSECTs* are allocated). An external procedure A boolean variable A constant definition Defines the pointer associated with a DSECT* when no other is mentioned. Defines a DSECT* Defines the area in which this DSECT is allocated. The initial value of a variable All variables may have dimensions specified. Up to three may be specified. All must be constant. The lower bound is 1 and cannot be specified. Example: DCL ABLE (100) FLOAT; or equivalently DCL N EQU(99), ABLE (N+l) FLOAT; A variable whose type is not specified in a declare statement assumes a default type of integer if the first character of the variable is I, J, K, L, M or N. Otherwise a type of FLOAT is assumed. * Definition of DSECTs will be given in section 8. 8 5. THE ASSIGNMENT STATEMENT Only variables may be assigned values. Type conversion exist only between integers and floating point. Hence, DCL A INTEGER; A = '1' ||l; is invalid. A summary of the operators for each data type is given below. Type Operators BINARY +, -, *, /, **, unary + - FLAG ^, &, | CHARACTER || , SUBSTR (left and right) POINTER = — i = The general form for the assignment statement is: = ; Parentheses may be used in non-character expressions . 9 6. DO GROUPS DO groups have the from: DO ; statements > ; END; The word DO may be prefixed by a label, in which case the DO group is known as a labeled DO group. A labeled DO group may have its name appearing after the END of the group. has two forms. In one form the word WHILE followed by a boolean expression controls looping of the DO group. In another form an indexed variable is incremented: DO I = 1 TO 10 BY 3; The BY part is optional. The indexed variable may be subscripted. The increment may be negative only if it is a constant. EXIT and LOOP are statements which exit a DO group or loop within a DO group respectively. LOOP causes the incrementing of the index variable or reevaluation of the boolean expression of a WHILE part. Both LOOP and EXIT may take labels . A DO group is considered as one statement. Hence I = 2; IF I > 1 THEN DO; J = 1; I = 3; END; Results in I being set to 3 and J being set to 1. 10 T. IF STATEMENT The form is : IF oolean expression> THEN ; An ELSE clause may optionally follow. It has the form: ELSE ; 11 8. CASE STATEMENT The form of the CASE statement is: CASE ; ; : ; END; The CASE statement exaluates the integer expression and then uses the value to select a case to execute. If the value is < 1 or > n then nothing is executed. The case statement may be given a label. The label may appear on the END of the CASE statement. The cases of a CASE statement may be given labels also. Each case consists of one statement (which may of course be a DO group) 12 9. LIST PROCESSING 9.1 AEEA The AEEA attribute defines an area of storage in which DSECTs may be allocated. The attribute is used as: DCL CORE AREA( 10000 ) ; This defines an area of storage called CORE that is 10000 words long. 9.2 DSECT A DSECT is a collection of variables which may occur zero or more times in an area. It is essentially a template of storage. The general form for the DSECT declaration is: DCL () • BASED () IN () ; For example : DCL NODE DSECT((LL,RL) POINTER, C CHAR (6U) VARYING, LAST) BASED(P) IN (CORE); This defines a DSECT called NODE which contains four elements (LL, RL, C and LAST). This DSECT may appear in area CORE and is implicitly qualified by pointer P. Pointers point to DSECTs. To reference an element of a par- ticular instance of a DSECT one qualifies the element by the pointer to that DSECT. Hence if Q is a pointer to an instance of DSECT NODE one might reference the variable C by using Q ■> C. If no explicit qualification is made then the implicit qualifier is used by default, thus C and P -> C are equivalent. 13 9.3 SET STATEMENT No built in allocation routines exist in PLW. DSECTs are allocated stackwise by the user by executing SET statements. Suppose we declare TOP as a pointer and use it for the top of a stack in area COPE. Initially one would set the top of stack pointer to the bottom of the stack. This is accomplished by using the first form of the SET statement: SET TOP TO COPE; The execution of this statement SETs the pointer TOP to the base of stack in area CORE. TOP always points to free part of the stack not the top element allocated on the stack. If one wishes to allocate a DSECT on the top of stack one needs to adjust TOP so that it points after the DSECT. Hence to allocate a new copy of DSECT NODE one might execute the following code: P = TOP; SET TOP TO P + LAST; P is then left pointing to the new instance of NODE. TOP is set to the first double word boundary at or after P ■*■ LAST. During the execution of this form of the SET statement a check is made to determine if the pointer generated is outside the range of the area. If such is the case then a terminal error is generated. Hence an allocation past the end of an area terminates execution. It should be noted that the variable LAST has had no space allocated for its use. Any character strings in a dsect must be initialized after the dsect is allocated. This is accomplished by calling the subroutine SLEN passing the character variable followed by two parameters which specify the length of the string. Hence to initialize string C one could lU CALL SLEN(P -> C, 0, 6k) The first parameter of SLEN is the character variable to be initialized. The second is a for varying length strings and a -1 for fixed length strings. The last is the maximum length of the string. The third form of the SET statement sets a pointer to the first double word after a character string. The form is, SET TOP TO C TRUNCATE; This is most useful when varying character strings have only a small part of the allocated space used and the recovery of the unused space is desired. 15 10. I/O • Files Files are declared as follows: DCL F FILE UNIT() INPUT STRING; is the FORTRAN unit number. The word OUTPUT may be used instead of INPUT. 10.1 READ The read statement has the following form: READ FILE(F) STRING(S) EOF(FL) ; Flag FL is set if an end of file condition exists. The EOF part is optional. S is a character string expression. 10.2 WRITE The write statement has the following format: WRITE FILE(F) SKIP STRING(S); The word PAGE may be substituted for SKIP. The number of lines to be skipped may be specified after the word SKIP, hence SKIP(O) or SKIP(lO) might be coded. The file declaration should have the word OUTPUT substituted for INPUT. 16 11. TRACE FACILITIES The following statements control the generation of trace code TRACEON; Generate trace code. TRACEOFF; Do not generate trace code (default state) . The following statements control the execution of trace code: CALL TRON; Print trace information (default state). CALL TROFF; Do not print trace information. IT 12. LISTING CONTROL If a decimal point appears in column 1 of a card then that card is a compiler control card. The following are valid control cards: .SPACE Space one line. .SPACE n Space n lines. .EJECT Page skip. .LIST Turn list on (default). .NOLIST Turn list off. .TEXT List FORTRAN text. .NOTEXT Do not list FORTRAN text (default). Form AEC-427 (6/68) AECM 3201 U.S. ATOMIC ENERGY COMMISSION UNIVERSITY-TYPE CONTRACTOR'S RECOMMENDATION FOR DISPOSITION OF SCIENTIFIC AND TECHNICAL DOCUMENT I See Instructions on Reverse Side ) 1. AEC REPORT NO. COO-2383-0020 2. TITLE PLW User's Manual 3. TYPE OF DOCUMENT (Check one): Pm a. Scientific and technical report l~l b. Conference paper not to be published in a journal: Title of conference Date of conference Exact location of conference Sponsoring organization □ c. Other (Specify) 4. RECOMMENDED ANNOUNCEMENT AND DISTRIBUTION (Check one): Pm a. AEC's normal announcement and distribution procedures may be followed. I | b. Make available only within AEC and to AEC contractors and other U.S. Government agencies and their contractors. i ] c. Make no announcement or distribution 5. REASON FOR RECOMMENDED RESTRICTIONS: 6. SUBMITTED BY: NAME AND POSITION (Please print or type) C. W. Gear Professor & Principal Investigator Organization Department of Computer Science University of Illinois at Urban a- Champaign Urbana, IL, 6l801 Signature ,-^fc^b * 1 Date June 23, 1975 FOR AEC USE ONLY . AECvTfONTRACT ADMINISTRATOR'S COMMENTS, IF ANY, ON ABOVE ANNOUNCEMENT AND DISTRIBUTION RECOMMENDATION: 8. PATENT CLEARANCE: I I a. AEC patent clearance has been granted by responsible AEC patent group. I I b. Report has been sent to responsible AEC patent group for clearance. I I c. Patent clearance not required. BIBLIOGRAPHIC DATA SHEET 1. Report No. UIUCDCS-R-75-711 2. 3. Recipient's Accession No. 1. Title and Subtitle 5. Report Date Mav r 197 5 6. '. Author(s) Lawrence D. Lopez 8. Performing Organization Rept. N °' UIUCDCS-R-75-711 I. Performing Organization Name and Address Department of Computer Science 10. Project/Task/Work Unit No. University of Illinois at Urban a- Champaign Urbana, IL 6l801 11. Contract /Grant No. US AEC AT(ll-l) 2383 2. Sponsoring Organization Name and Address US AEC Chicago Operations Office 9800 South Cass Avenue 13. Type of Report & Period Covered Argonne, Illinois 60^39 14. 5. Supplementary Notes UIUCDCS-R-7U-66U The PLW Compiler 6. Abstracts This PLW language and information helpful in using the present PLW compiler is detailed herein. The PLW language is in many respects like PL/I. The object language of the compiler is FORTRAN. Hence the compiled code is, to a great extent, portable. y. Key Words and Document Analysis. 17a. Descriptors PLW language compiler FORTRAN OBJECT PORTABLE b. Identifiers /Open-Ended Terms i s. C OSA I I Fie Id/Group ', A\ ailability Statement 19. Security (lass (This Report) UNCLASSIFIED 21. No. of Pages 22 Unlimited 20. Security (.lass (This Page UNCLASSIFIED 22. Price ' 'M 11 11 I iv 1 |,,. 70) USCOMM-QC 40329-P7 1 V * :