vffl m m mm IBS MH ■ill HlSi BniliHinnnHDl Wuhm LIBRARY OF THE UNIVERSITY OF ILLINOIS AT URBANA-CHAMPAIGN 510. 8+ IKS, Kio. G6I-6G6 cop. Z CENTRAL CIRCULATION BOOKSTACKS The person charging this material is re- -ui„» f^r it<; renewal or its return to tKbrar^ °rom which it was borrowed on or belore the Latest Date stamped Sow You may be bargee. «m.n,mum fee of $75.00 for each lost book. for dlKlpHnory attlon mnd may ■*»«•" £ W^EW^U TELEPHONE CENTER, M3-8400 AUG 1 4 1996 AMR 8 1956 When renewing by Phone, write new due date bdow previous due date. UIUCDCS-R-71+-66U 'Mm ftlAyL^ coo-2383-0010 The PLW Compiler by William Vanmelle and Lawrence Lopez July, 197^ DEPARTMENT OF COMPUTER SCIENCE UNIVERSITY OF ILLINOIS AT URBANA-CHAMPAIGN URBANA, ILLINOIS JHE LIBRARY OF THE AUG- nc tl 1 INOiS UIUCDCS-R-T 1 +-66U COO-2383-0010 The PLW Compiler by William Vanmelle and Lawrence Lopez July, 19lh DEPARTMENT OF COMPUTER SCIENCE UNIVERSITY OF ILLINOIS AT URBAN A -CHAMPAIGN URBANA, ILLINOIS 6l801 * Supported in part by the Atomic Energy Commission under contract US AEC AT(ll-l)2383. Digitized by the Internet Archive in 2013 http://archive.org/details/plwcompiler664vanm TABLE OF CONTENTS The PLW Language 1 Translating Into FORTRAN 7 Procedures 7 Allocation 8 Global Variables 9 Character Strings 10 SCAN 13 Operation of the SCAN Routine 15 Automatic Alignment of the Source Program 17 The Symbol Table 18 The Expression Analyzer 35 The Command Processor 59 The PLW Language PLW was designed to provide a systems programming language to be used on many different computers. The language has greater facility than. a simple language like FORTRAN, hut is nowhere near the general monster PL/I. Our compiler achieves installation independence by converting PLW source into FORTRAN, to be further processed by the particular FORTRAN compiler in use at an installation. Along the way, we get convenient linkage compatability with existing FORTRAN modules . The features of the language as described in this document follow: Identifiers- these consist of 1 to 31 characters, the first of which is a letter and the remainder are letters, digits, or the underscore character. Constants- Integer and real constants are as in FORTRAN. A real constant followed by the letter I denotes an imaginary constant. Character string constants consist of any string of zero or more characters enclosed by single quotes, with internal quotes represented by two consecutive quotes. The logical constants are IB and OB, representing TRUE and FALSE. The null pointer constant is the word NULL. Constants and identifiers may not extend over card boundaries . Program variables- these are identifiers defined in a DECLARE or PROCEDURE statement. A variable must be declared before it is used in any way. The following attributes, abbreviations and alternates may be used: BINARY, BIN- numerical variables FIXED, FIX, INTEGER- integer variables, i.e. no fractional part FLOAT, FLT- floating-point variables. A BINARY variable is either FIXED or FLOAT, and the following attributes all imply FLOAT . SINGLE, SGL.- single-precision (default) DOUBLE, DBL, LONG- double precision COMPLEX, CMP LX- complex( single-precision by default) FLAG, LOGICAL, BOOLEAN- logical variables, which may take on the values IB or OB (true or false) CHARACTER , CHAR- character string, This attribute may be followed by a parenthesized integer constant expression giving the length of the string; otherwise it has length 1. VARYING, VARY- indicates the string has varying length. Length given above is then the maximum length . POINTER, PTR- pointer variable, which is used to qualify members of a DSECT. Variables of the above types may also be arrays, declared by giving dimension information on the dimensions. Currently this is restricted to upper bounds given by unsigned integers, e.g. DECLARE A(lO) FIXED, B(2,2,2) FLOAT. AREA- a block of storage used' to contain one or more DSECT's. This attribute is followed by a parenthesized constant giving the number of words (an integer occupies one word) in the area. DSECT- describes a section of storage. Each copy of a dsect is allocated in an area and qualified by a pointer. The declaration takes the form : DECLARE name DSECT( ) BASED( ) IN(). PROC- this names an external procedure. The declaration also permits the specification of parameter types and the type of value returned by the procedure. The general form of this declaration is DECLARE name PROC [ ( ) ] [RETURNS ()] The model parmlist consists of a series of attributes, separated by commas, e.g. PROC(FIXED BIN, FLOAT, CHAR, FLAG). External names are limited to six characters, In addition, the language permits symbolic constants, which are identifiers declared to have a given integer value. Whenever such an identifier appears in the program, it is replaced by its integer value. An expression containing only integer and symbolic constants is simplified to a single integer at compile time. The declaration is DECLARE CON STANT(< value > ) ; where is an expression involving only integers and previously declared symbolic constants. Alternates to CONSTANT are CON and EQU. Procedures- these are defined by the PROCEDUEE (PROC) statement of the form : PROCEDURE [ ( )] [ RETURNS ( )] ; Internal procedures must appear before any reference to them. The parameter list may supply attributes, or these may be given in a separate DECLARE statement. X: PROC (I FIXED, (A,B) FLOAT); is equivalent to X: PROC (I,A,B) ; DECLARE I FIXED, A FLOAT, B FLOAT; Nesting is permitted in PROCEDURE parmlists, DECLARE statements, and in the list of elements for a DSECT. Further, the PROC statement can also serve as a DECLARE statement simply by replacing the final semi-colon with a comma and follow it with declaration, e.g. X: PROC (A,B FIX) RETURNS (FIX) ONE CON (1), (I,J,K) FIXED; Following are the executable statements. DO and CASE may be preceded by a label (identifier followed by colon); labels are otherwise ignored. "Variable term" means simple variable or array name with subscripts, which are any integer expressions; "clause" is a DO block or a single executable statement other than END. Optional operands are enclosed in brackets. Assignment statement: = ; The expression is assigned to the variable or array element indicated. Both must be of the same basic type (BINARY, FLAG, CHAR, etc.). DO statement: DO [ = [TO ][BY ] [WHILE ] ; The control variable must be numeric. If the increment is omitted, it is assumed to be 1. If the upper limit is omitted, it is the largest integer. The range of the DO block is all statements up to the corresponding END statement. The range is executed zero or more times until the control variable exceeds the upper limit or the WHILE expression is false. If neither operand is present, the range is executed once. The increment must be positive or else a negative integer constant, in which case the range is executed until the control variable falls below the upper limit . The limits and increment are calculated once, before the loop begins. The control variable should not be changed within the range. CASE statement: CASE ; [OTHER < alternate clause>] END ; The case expression is evaluated, vith value i. If 1< i THEN [ELSE ] The then clause is executed if the expression is true; otherwise the else clause, if present, is executed. END statement: END [