Download O - Defense Technical Information Center
Transcript
ESD-TR-70-256 MASSACHUSETTS INSTITUTE OF TECHNOLOGY LINCOLN LABORATORY THE LEAP USER'S MANUAL LINCOLN MANUAL 93 ESD ACCESSION LIST Call No. ^7/ 23*3 Copy .No. f of I cys. P.D. ROVNER Group 23 11 September 1970 The work reported in this document was performed at Lincoln Laboratory, a center for research operated by Massachusetts Institute of Technology. This work was sponsored by the Advanced Research Projects Agency of the Department of Defense under Air Force Contract AF 19(628>5167 (ARPA Order 691). This report may be reproduced to satisfy needs of U.S. Government agencies. This document has been approved for public release and sale; its distribution is unlimited. LEXINGTON MASSACHUSETTS A1>} YV&i ABSTRACT This document is a user's manual for the LEAP language. LEAP is an extended algebraic programming language which is similar in form 8 to ALGOL. Extensions include language forms for display output and interactive input and facilities for building and manipulating associative information structures. The basic algebraic language is described in Sections I through LX; the extensions to LEAP are presented in the Appendices Accepted for the Air Force Joseph R. Waterman, Lt. Col., USAF Chief, Lincoln Laboratory Project Office ii CONTENTS I. II. III. IV. V. VI. VII. VIII. IX. VARIABLES 1 A. Declarations 1 CONSTANTS DYNAMIC VARIABLES 2 4 A. Arrays 4 B. Textarrays 4 C. Matrices EXPRESSIONS A. Arithmetic Operators B. Boolean Operators C. Matrix Operators D. Miscellaneous Matrix Expressions 5 6 7 10 11 12 E. F. Array and Textarray Expressions Textarray Operators 13 13 G. Conditional Expression 14 STATEMENTS A. Assignment Statement 14 14 B. Transfer-of-Control Statements 1. Unconditional Go 2. Conditional Go 3. Switch 16 16 16 17 C. D. If Statements Iteration Statements 17 18 E. Compound Statement 19 F. Blocks COMMENTS 19 19 PROCEDURES RETURN STATEMENTS PROGRAM LAYOUT 19 21 22 in Append:Lees III. Primitives for Interactive Input 23 29 31 IV. V. Text and Numerical I/O 39 Sub-Program Linkage Facility 52 VI. VII. Error Detection in LEAP Miscellany Synonyms NOKBBF 56 I. II. Primitives for Display Output Assembly Code Option 64 External Procedures GETFROMKB Compilation Mode Options Miscellaneous Reserved Functions and Procedures VIII. IX. Primitives for Data-Structuring: the Associative Sublanguage Primitives for Text and File Manipulation iv 74 90 I. VARIABLES One may declare and use VARIABLES in LEAP. A variable is an entity which has a NAME, a DATATYPE, and a VALUE. The NAME of a variable must consist only of alphanumeric characters and must start with a letter. The number of characters allowed in a name is unlimited. The DATA TYPE of a variable must be one of the following data types: REAL INTEGER BOOLEAN FIXED (i.e. fixed point fraction) MATRIX TEXTARRAY REAL INTEGER ARRAY BOOLEAN FIXED The VALUE of a variable is an algebraic quantity having the specified data type. For example, if X were an INTEGER variable, it might have 46 as its value. If Y were a BOOLEAN ARRAY, it would have an array of BOOLEAN numbers as its value. A. DECLARATIONS All variables must be declared. The declaration of a variable may occur either at the beginning of the LEAP program or at the beginning of the outermost COMPOUND STATEMENT within which the variable is used (see the discussion of COMPOUND STATEMENTS in Section V.E). A typical declaration has a data type specification , a list of names, and a semicolon. Examples: REALX, Y, Z; INTEGER ARRAY A, B; A dynamic variable (a MATRIX, ARRAY or TEXTARRAY) may be declared with information about its dimensions; for a complete discussion of dynamic variables, see Section III. II. CONSTANTS Integer constants are converted to either radix 8 or 10, depending on their form. Including sign, integer constants consist of 36 bits, float- ing point constants of 27 bits of mantissa and 9 bits of characteristic, and fractions of 36 bits. Omission of a preceding sign indicates a positive number. 1. Decimal INTEGER constants are expressed by 1 to 11 digits written without a decimal point. Examples: 3 527 -321 923 2. Octal INTEGER constants are expressed by 1 to 12 octal digits and are written with a terminal decimal point. Examples: 5. 7. 770770770777. 3. REAL (i.e. , floating point) constants are expressed in two ways, either by digits both before and after the decimal point (for example, 3 .5 or -0. 3), or by the exponential designation with an optional decimal point: Examples: 4. -2E-3 equals -0.002 .2E7 equals 2,000,000.0 2.E10 equals 20,000,000,000.0 FIXED (i.e., decimal fraction) constants are expressed by a decimal point followed by 1 to 10 digits: Examples: .2 .37 .002 5. There is no facility for octal fraction constants in LEAP. 6. BOOLEAN constants are expressed as either "TRUE" or "FALSE" (Note: this is not valid for typed input to a READ statement). THUS: . 35.0 is REAL 35 is decimal INTEGER 35. is octal INTEGER is FIXED is BOOLEAN .35 TRUE III. DYNAMIC VARIABLES A. ARRAYS An ARRAY is an ordered collection of ELEMENTS. A particular array element is indicated by specifying a unique subscript for the element, as illustrated below: (1) ^1, E2, E3 En In (1), the "Ei" are any INTEGER expressions, "n" is the number of dimensions of the array, and A is the name of the array. Each array element has a value. The data type of the elements of an array is specified when the array is declared (e.g. , REAL ARRAY A;). An array may be declared with size and dimension information; if this information is specified, then storage will be allocated at program execution time for the array elements. If this information is not specified, then no storage will be allocated until a statement is executed which explicitly assigns storage to the array for its elements (see the discussion of the assignment statement in section V-A.). The following is the form for an array declaration with size and dimension information: (2) (type) ARRAY (name) fa to a , b to b , . . . , z to z }; In (2), (type) is either REAL, INTEGER, BOOLEAN, or FIXED. The (name) is the name of the array. The other parameters are explained below; a is the lower bound on the first dimension (if there is to be only one dimension, then a must equal 1) a is the upper bound on the first dimension b is the lower bound on the second dimension b is the upper bound on the second dimension, etc. There is no limit on the number of dimensions, and the bounds may be any INTEGER expressions. B. TEXTARRAYS A TEXTARRAY is a single dimensional array of characters, each represented by its integer character code. Like the ARRAY, a TEXTARRAY may be declared with information about its size (the maximum number of characters in the TEXTARRAY, including the 777. character); (3) TEXTARRAY (name) AE ; If no size information is given, then no storage will be allocated for the TEXTARRAY elements by the declaration. This storage will be allocated only by a subsequent assignment statement. In (3), (name) is the name of the TEXTARRAY, and AE is an INTEGER expression specifying the size of the TEXTARRAY. A TEXTARRAY element is indicated by specifying its subscript: Examples: IF TAj = 777. THEN .. . 777. -T C. V MATRICES The MATRIX in LEAP is a highly specialized entity. It always has two dimensions, and its elements are always REAL numbers. Only one exponent is kept for all the elements; the elements are scaled appropriately. Thus, information is lost if the values of elements differ by too many orders of magnitude. Matrices may be declared with no information about the number of rows and columns (e.g., MATRIX (name);), or with such information given: (4) MATRIX (name) aj BY b ; If no dimension information is specified, then no storage will be allocated for the matrix elements by the matrix declaration. As in the case of the array, this storage will be allocated only when an assignment statement explicitly assigns storage to the matrix. If, as in (4), dimension information is specified, then appropriate storage is allocated for the matrix, and all elements are initialized to zero. In (4), a-, and b-, are INTEGER expressions. The declared matrix will have a^ rows and b^ columns. A matrix element is indicated by specifying the name of the matrix, the row index, and the column index. These indexes may be any INTEGER expressions between 1 and 256. M (1,2) M (K, J + 1) Examples follow: row 1, column 2 element of M row K, column J + 1 element of M Matrices were introduced into LEAP to implement the parametric homogeneous matrix representation for points, lines, and conies which is described in Reference 9. LEAP has facilities for multiplying, inverting, and adjoining matrices . A complete presentation of the operations which apply to matrices is given in Section IV. C. LEAP also has a facility for generating the appropriate display instructions from a parametric homogeneous matrix description of a point, line, or conic (see Appendix I). Note: The word USELEAP must follow START in every LEAP program in which MATRICES are used. IV. EXPRESSIONS Variables, constants, elements of dynamic variables, and/or EXPRESSIONS may be combined by OPERATORS (e.g. + and -) to form EXPRESSIONS • An expression has a data-type, and a value. The value is computed by performing the indicated operation. For example, if X is a REAL variable having 3.6 as its value, and Y is a REAL variable having 1.0 as its value, then X + 4.2 x Y is a REAL expression with 7.8 as its value. Note that we would expect the multiplication to be done before the addition when the above expression is evaluated. In LEAP, the multiplication operator (x) is said to have "higher precedence" than the addition operator (+). We can classify the operators in LEAP by specifying their relative precedence, or "binding power." The remainder of this section is a tabulation of the operators in LEAP, organized in groups by operand type, and arranged within groups in order of decreasing precedence. Note that the expression scan is done from left to right. When operators of equal precedence are adjacent, e.g. , A + B + C, then the evaluation is performed from left to right, e.g., (A + B) + C. When operators of different precedence are adjacent, the operator of higher precedence is treated first. When in doubt about precedence, parenthesize. In what follows, A, Al, A2, etc. will represent ARRAY's A. TA, TA1, TA2 , " " " TEXTARRAY1 s M, Ml, M2, " " " MATRIX EXPRESSION'S AE,AE1,AE2," " " ARITHMETIC EXPRESSION'S B, Bl, B2, " " BOOLEAN EXPRESSION'S " ARITHMETIC OPERATORS The operands for arithmetic operators are of REAL, INTEGER, or FIXED types, and may be mixed indiscriminately in expressions. The result of mixed arithmetic is always REAL. os w OS w O w D os DC < CD w H 3 u co 2 OS < SI S3 o CQ H 13 CQ < CO os u 0 w OS 2 2 hH w CO u H 5 H a [•"- S! S3 Sj < w < w < ID U3 W CO w U u P CO to to ID si 3 3 gg S3 -<• *" CO CO O to OS 0- OS co ^-s C U n (0 W it < Si CO <; os o - -H FH CO CO «a; < a) o S < (0 ro S 1 53 < g 9u o o X! c E i-, CO c c o O 2 co c a (D 3) E a c a c o E c Q) E 3 a) < ro CO CO *3 w 53 S o v? H CD U <0 en o E ^J cu -a c o CD CD ^ (0 "£-? O > *•> o I—I H O u co co u CO co -^ "E« P CD , co (0 T3 CO 0) 2 eg 3 3 C cu 0 3 <D > c o o 3 O i-5 PL, < + c (0 C o ^ ~ OS o ^ ~ DS u M s> wo E w a3 O > co C H C H to Q u 53 O 53 as H OS (0 a •—t c o u ro E E o u 5C •a z: -c u CO -Q fO X} CD CD Q. u rn OS to Cu o o a 3 CO a '~ •PH U co X 3 to to .1) C •«-< r 0) !f) a a CO CO OJ CD o U] CO CO CD XI 4-1 C CD CD -C 0) (0 a £ c CD k, tO a ro o z 2 -+ ± C o u ra 53 4-> o a (L, > o 73 CO ro CD CD co (1) CD 3 p-H CD si Q < 1 > co CO co 3 3 a £ fc ro c (0 3 & c 3 en « OS w U w CJ O w H H D CO w >—i OS < LO LO CJ >, -Q H 2 w < XI CJ 0 4-> id *-> CD -^H X! < c ••-t a o Si 52 62 en SI S3 62 in CO CM u CJ P CJ CJ u PS Q, w <D C o CM CJ < CO CJ < CNj CM CJ < 2 CJ O < CJ < •I-I IS CO CO C •—* +J i—i "3. •—1 CJ 2 3 £ —i X ro 0 --* Uj O X X 0 G o CD X! 4-J c o CO > -a x CO 4-> x IN >c CO co X •f-> (0 c HH X 2 •—< CJ < Xen O CD 3 •—t ro > CM CM CM 62 62 62 CM <M 3 62 8i S2 -V- + I ii i—I r—I r-4 .—< < > © i-H to S2 62 S2 62 62 62 62 •>-> •—I I—t CD T3 0) j3 CM co •H •*-> 2 I OH CJ O 2 o 2 1_ 0) (D X X •!-> 03 o ra i o CO • £2 c CO (D 3 •—i CD u. ro > c o 0 o ^-*, C CJ H OJ CO X w C X o a X CO +-> *-> CD CD -a -a CO (0 •<-• o ro +-> X 3 CO o *-" o RJ CD —i CO CD 1-. O aCD E x OS u > c co 3 CD C C —< (O u «~4 Oi (O O o -.-4 o O 1 CD * CD CD C —* X 0 3 X (D •—t •—i B O c ro O •^ D> O ro -~H o> O (0 E 0 —i a B o o CD C o ro co CM < CJ OH o -V-+ I o || XV A VI Al CJ H < > © O 2 10 B. OPERATOR BOOLEAN OPERATORS PRECEDENCE MEANING FORM RESULT /-^/ "NOT" ~B 3 B A "AND" Bl A B2 2 B V "OR" Bl V B2 1 B © "exclusive OR" B1©B2 1 B 11 CC OS UJ UJ H H u O w an w O ~ i-4 < 5 S g 2222223332220QCO W O u a 10 m io i/> (M CO CM CO CM CO i-H rH CM CM CN CM U w a. 2 2 2 2X \ _ 2 ^ 2 DC o |5 c o u t—1 2 H < l-H W 2 + I II X i—I f—I >—I t-H c O CO X 10 en 0 a a o z § 2 2 ~2 3 S 2 2 *§ S = . 2 2 2 2 *rH -t-J w »v O < K u O 2 2 2 2 oj to > C o CO o a to c 9 4a 3 3 6 o •—< o I T3 10 c £ o o X >• —I c o **—I XI (0 CD XI £ c u 0) X C o a. C c X c o t—I X to a) T3 3 6 9 ra X s 6 •!-> (0 C X) CO 2 I + o 2 o C OS w a- C ,-, ^ X X \ c o c = CO 12 D. MISCELLANEOUS MATRIX EXPRESSIONS FORM AE1# ^ MEANING AE2 BY AE3 A MATRIX having AE2 rows and AE3 columns, where all elements have value AE1. AE2 BY AE3 A MATRIX having AE2 rows and AE3 columns, where all off-diagonal elements have value 0.0, and all diagonal elements have value AE1. A M (AE1 AE2) AE3 BY AE4 Submatrix of M, starting at row AE1 and column AE2, for AE3 rows and AE4 columns. 13 a O) CO DS PJ o w -^-1 ra U -a c Q) X W-H o 5es 3 c HJ u 3 i—. rO 2 2 > co +-» •*H CO (0 co IB J3 c o o IM 0) N O ~J CO N -—4 *-» c CJ u (3 to c o S o .—1 a ;g ra a a c o co ca o a X c CO sH „ CO C 0 CO c o £ -—i •a 3^ , o co H XI !=) co cu OS c pG CJ •#H -5 c £ §H .*-» CO X XI 1 3: co ei D» w H 13 x •*-< o o •4-1 2 to -~-4 4-1 o o -~H CO 3 < • (0 1—1 CD 0 •—i 4-J 1—1 ra a cr o _ u < o > (3 x *-» CO 1—I 1—1 1—I c o H-J 0 a CO 00 § 5 ca 3 ra a) N *J . ra C •4-* c 0 -^H CO c o CO -<-H CO CO CO x u X CD co CD u a ra X B. CD ra c o CO CO o a X CO CO --H < O 4-» X CQ N > CO 03 u IH co -^H H 2 r—t 5 «4-4 o X u ra CD » w U w 2 i—i c ra CD X 3H X u H XI 10 C •0 co S 3 0 X CO •(-> a) 0) x •—t H CD w 2 as O OH 3H 3H II r-H < X .—i < < H X H CO IH !_ CD CD +y o " rO CO «-, 2 x; 2 C i—i 6° o£ CO CO' r x es a. x rx CO O 2 < cs < OH X w H H £ >. 3 (0 3 cr II \ cr w X H Q CD C Ia 3 73 H-l c +-• o 2 o CM O CO O DS o OH § OH OH O O o c = 14 G, CONDITIONAL EXPRESSION General form: (B=>E1,E2). This expression has either El or E2 as its value, depending on whether the BOOLEAN expression B has value TRUE or FALSE, respectively. El and E2 are expressions which must have the same data type. This may be any allowed data type, including MATRIX and ARRAY, for example. V. STATEMENTS There are a number of imperatives (called STATEMENTS) in the. LEAP language. These are used to modify the values of the program variables and the flow of control through the program. All statements in LEAP must be terminated by one of the following, depending on context: END ELSE A. ASSIGNMENT STATEMENT General Form: <expression> - <variable or element of a dynamic variable>; This statement causes the value of the indicated variable to be reset to the value of the expression. Examples: REAL X, Y; MATRIX M; 4. 0 -+ X; X x 2 .0 - Y; °-0#3by3^M; 1.0- M (3, 3); Data type conversions take place where required and allowed. The following table shows the allowed and resulting conversions. conversion is not allowed. Blanks indicate that the 15 V \>^ VARIABLE >v TYPE EXPRESSION^V. TYPE \ REAL FIXED INTEGER REAL Real Fixed Integer (rounded) FIXED Real Fixed — INTEGER Real — — — * BOOL. BOOL. * — Integer — — Bool. The assignment statement may in fact be an expression if it is nested. This facilitates multiple or intermediate stores. For example, 1 - A - B; assigns the value 1 to both A and B. The subword form may be used as a variable in an assignment statement. Example: INTEGER X; • 3 - X (1 "• 4); A special case of the assignment statement is the sub-matrix store command. Example: M x N - M (3,5); The matrix expression on the left will replace the sub-matrix of M whose upper left-hand element is in row 3, column 5. If the new sub-matrix will not fit into the indicated space, an error will be indicated at run-time. No check is made for overflow: strange things may occur if a REAL number larger than or equal to 1.0 is converted to a FIXED. 16 B. TRANSFER-OF-CONTROL STATEMENTS Bl . General Form: Unconditional Go GO GOTO <statement label>; GO TO The GO statement causes a transfer of control to the statement indicated by the "STATEMENT LABEL. " A STATEMENT LABEL is a sequence of alphanumeric characters, starting with a letter, which is assigned to a statement by prefacing the statement with <statement label> "" . Example: 1.0-»X; LI w x+ 1.0-X; GO TO LI; B2 . General Form: Conditional GO Statement GO GOTO <B> => <label 1>,< label 2> ; GO TO This statement causes control to go to either statement label 1 or statement label 2, depending on whether the BOOLEAN expression is true or false. 17 B3. General Form: Switch Statement SWITCH VIA <INTEGER expression> TO <list of statement labels>; This statement causes a transfer of control to the statement label indicated by the value of the INTEGER expression. If this value is out of bounds , an error message will be given. Example: INTEGER I; SWITCH VIA I TO LI , L2 , L3; If I = 1, then control will go to Ll. If I = 2 , then control will go to L2 . If I = 3, then control will go to L3. C. IF STATEMENTS General Forms: (1) IF <B>THEN <statement 1> ELSE <statement 2>-, If the BOOLEAN expression is true, <statement 1> is executed; if it is false, <statement 2> is executed. If there is a "dangling ELSE" clause, it is associated with the innermost IF clause. la. Example (la and lb are equivalent): IF <B1>THEN IF <B2> THEN < statement 1-* ELSE Statement 2>; lb. IF<B1>THEN BEGIN IF <B2>THEN <statement 1> ELSE + + , 'statement 2> END; (2) the IF <B>THEN <statement>; < statement> is executed only if the BOOLEAN expression is true. The word IFNOT may be used instead of IF in the above forms; in this case, the BOOLEAN expression is complemented, and then examined. 18 D. ITERATION STATEMENTS General Forms: (1) FOR Ei - P STEP E2 1 THRU ! E DO S; 3 where E\, E2 , E3 are arithmetic expressions, P is a non-dynamic variable or an array element, and S is a statement. This statement causes statement S to be executed once for each new value of P, the iteration variable. The statement is executed as if it were written as: El -P; LI" IF || P> || E3 S; P + E2 - P; GOTO LI THEN GOTO L2; (see note 1 below) L2' (2) FOR El - P STEP E2 I UNTIL ! B DO S; where E\ , E2 , E3 , P and S are as above, and B is any Boolean expression Execution of this statement is analogous to the previous statement. Ex- ecutions of statement S continue as long as: (a) (b) B is true (WHILE) B is false (UNTIL) • "»"!-' |T£| — where E^ , P, B, and S are as above. This statement behaves as indicated in (2) above, except that the iteration variable is not incremented. where B and S are as above. This statement behaves as type (3), but has no iteration variable. CONTINUE STATEMENT This is a statement which causes a jump to either the incrementing or testing part of the FOR statement when execution of the remaining body is not desired. Example: FOR 1 - P STEP 1 TO 10 DO BEGIN IF P = 7 THEN CONTINUE: END; would cause execution for values of P = 1 through 6, 8 and 9. Note 1: For TO, this operator is s; for THRU, the operator is >. If the iteration variable changes sign or ever equals zero, then another form of the FOR statement should be used. 19 E. COMPOUND STATEMENT It is often desirable to have a number of statements act as a single statement. A group of statements which is preceded by the word BEGIN and followed by the word END is called a COMPOUND STATEMENT. Note that compound statements may be nested. Compound statements may have "local" declarations of non-dynamic variables (of types REAL, INTEGER, BOOLEAN, and FLXED) immediately following the word BEGIN. These variables are "local" in the sense that they may not be referenced from outside of the compound statement, but they may be referenced anywhere between the current BEGIN-END parentheses. The NAMEs of these variables may have been used in an outer compound statement or in the main program declarations. In this case, a NAME always refers to the variable declared in the current innermost compound statement. Note that one may GO into the middle of a compound statement. F. BLOCKS A compound statement in which dynamic variables are declared is called a BLOCK. Iteration statements, [AJ . . . [EJ statements (see appendix 2), and PROCEDURES (see section VII) are also BLOCKS. One may not GO into the middle of a BLOCK. VI. COMMENTS Comments may occur anywhere in a program where a statement or declaration may occur. Comments begin with the word COMMENT, and end with a semi-colon. Any string of characters (excluding semi-colon) may appear in between. VII. PROCEDURES A PROCEDURE is a subroutine which may or may not expect input parameters and may or may not return a result. A PROCEDURE must be declared before it is called. A PROCEDURE declaration must occur in a declaration portion of the LEAP program (see section IX) in one of the 20 following forms; (1) <REAL, INTEGER, BOOLEAN, or FIXED> PROCEDURE <name of procedurexplist>; <statement>; (2) PROCEDURE <name of procedure><plist>; statement^ In the above, the <jiame>is any string of alphanumeric characters, starting with a letter. The <plist>is a list of "parameter declarations," separated by semi-colons, preceded by {, and followed by }. If the procedure takes no parameters, the <plist> is absent. A "parameter declaration" consists of a data type specification, followed by a list of names which are separated by commas. For example, the declaration of a PROCEDURE to find the largest number in an array and store it in a specified cell would look like this: PROCEDURE BIG {INTEGER ARRAY A; INTEGER AM, AB}; BEGIN INTEGER I; Aj -AB; FOR 2 -I STEP 1 UNTIL I>AM DO IF A > AB THEN A -* AB; END; In this procedure, A, AM, and AB are procedure parameters. They represent the true arguments given the procedure when the procedure is "called." Two additional declarations are allowed in a procedure declaration to describe arguments. They are: and LABEL L,,L, . ..Ll 12 n (type) PROCEDURE P , ?2> P^ (Again, type is optional) Examples: REAL PROCEDURE PYTHAG [REAL A, B] ; INTEGER PROCEDURE AVG [INTEGER I, J] PROCEDURE TEST [REAL PROCEDURE P; LABEL TAG!; A procedure "call" may occur as a statement or an expression depend- ing on whether a data type precedes the word PROCEDURE in the procedure 21 declaration. A procedure which is to be used as an expression is called a FUNCTION. The procedure call has the following general form: <procedure name> <-a list> The <a list>is a list of expressions, variables and elements of dynamic variables, separated by commas, preceded by {, and followed by }. If the procedure takes no parameters, the <a list>is absent. The data type of each element in the <a list>is compared with the declared data type of the corresponding element in the <p list>, and an error is given if these do not match. For example, the following is a statement calling the procedure declared above: BIG [LIST, 100, LARGLST]; where LIST is the name of the array, 100 is the maximum size, and LARGLST will contain the largest element after the procedure is called. Note that there are two kinds of parameters in the above example: (1) parameters which are not changed by the action of the procedure, but whose values are used (VALUE parameters: LIST and 100, for example) (2) parameters whose values are changed by the action of the procedure (REFERENCE parameters: LARGLST, in this case). In LEAP all variables and dynamic variables may be passed to pro- cedures as REFERENCE parameters; also, elements of ARRAYS may be passed as REFERENCE parameters. However, TEXTARRAY elements, subword expressions, and MATRIX elements may NOT be passed as REFERENCE parameters to procedures. VIII. RETURN STATEMENTS Normally, procedures and functions return to the calling statement at completion. However, an additional statement is provided to cause the procedure or function to return from anywhere within the procedure body. General Form: RETURN E; where E is required for functions and not allowed for other procedures. 22 E must be of the same data type as the function. This statement causes the procedure to return to the calling statement. If the procedure is a function, then the function value is E. Example: FUNCTION REAL PROCEDURE LARGEST {REALX, Y\; DECLARATION IF X >Y THEN RETURN X ELSE RETURN Y; FUNCTION LARGEST {4. 0/A, 2 . 0/B1 + 5 . 0 - A; CALL IX. PROGRAM LAYOUT Each LEAP program must start with the word START and finish with the word FINISH. parts: The remainder of the program consists of two separate a sequence of declarations, followed by a sequence of statements. Example: START REAL X, Y, Z; ARRAY A |l to 40[; L^X+ 3.0 -Y; GOTO ' L; FINISH 23 APPENDIX I PRIMITIVES FOR DISPLAY OUTPUT The display output facility in LEAP consists entirely of a collection of library procedures for constructing and modifying a "picture data structure". The picture on the screen at the console is generated by a display processor * which accesses and interprets picture-drawing commands from this picture data structure. Typical commands to the display processor are: ** 1) Place a dot at a specified position on the screen. 2) Draw a line or conic segment from a specified screen position with a specified slope and length. 3) Display specified text starting at a specified screen position. 4) Call a "display subroutine", to be centered at a specified position relative to the current frame of reference. The "picture data structure" is simply a collection of display subroutines (called GROUPS), each having a unique 16-bit integer identifier (ID). Each display sub- routine (GROUP) consists of a collection of display ITEMS, each having a 16-bit integer identifier (ID) which is unique within that collection of items. There are two kinds of display items: 1) A linear sequence of commands for drawing simple picture fragments and moving the beam, and Effectively a separate, special purpose computer (see reference 1). All positions are REAL expressions, ranging from -1.0 to +1.0. 24 2) a "use" of a display subroutine, which causes the indicated picture to be displayed as a subpicture of the group. The library of procedures for constructing and modifying display groups and items is tabulated below. Note the facilities for blanking items, drawing dotted lines, moving the unintensified beam, deleting groups and items, and creating uses. Groups are created automatically when required: e.g. when a use is made of a non-existent group; when an item is "put" into a non-existent group. When a group is deleted, all uses of it are automatically deleted. Display subroutines (groups) are not re-entrant: the "structure" of the picture resembles a tree. One creates the first kind of display item as follows: 1) Declare the ID of the display item (a 16-bit integer) with a "SETITEM" call, 2) Put points, lines, conies, and/or text into the display item via PUTPNT, PUTLINE, 3) PUTMAT , and PUTTEXT calls, and Put the display item into a group via the PUTITEM call. (If the display item is put into group zero, it will be displayed.) * The line will be drawn from the last position of the beam. The PUTMAT routine expects as input the parametric homogeneous matrix representation of a point, a line, or a conic. For further information about matrix representations of picture parts, see Reference 9. 25 As an example of a LEAP program which uses the display output facility, we have written down a program to display the scope diagonals: START CLEARS COPE; SETITEM {if; LOADPNT {-1.0, -1.0} ; PUTLINE {2.0, 2.0}; PUTITEM {o|; SETITEM {2J; LOADPNT {1.0, -1.0 } ; PUTLINE {-2.0, 2.0 }; PUTITEM { 0 } ; FINISH 26 >, ?s 1—1 co C CO U 3 u c co c a) c '~* o •a CO XI •—i a -*-• "d o -a X to c o rrj 0) X —i co X CD IH a 4-> a X 0) N —i -—i c o (posit <D H eg, C B (0 to CO P •M o •M > o "a? c -.H • 1 T5 co 4-* 4-J o (0 o c o o 0) 1 1 o -a fO 1—1 1—1 1—1 * Q w cu Si 5 u u CD 2. 3 10 a) P O a) c , u, u a) Q. ro CO -a i-, 3 XI E 0) 4-> o 7J 0) o ,2 •4-J 3 -<-l IH CO -»-< T> +-• Q.^ -4-J CO +-> 0) c c 0) c/; o •*H "O ETITE1 VI, exce is not cleared 3 *-< •-H (simila item b 0) -*-» 0) i—4 ex to 0) 4-1 <<-l 3 displa y item b ge tub e) •PN j. to c O fcj w u •a +J e c 01 b +-• CD 3 O (the cu to the I4H -ACO S-i O co w O a o Cu co w es Q O A Q A c c o u O O cu o co O A Q a w > i—i OS w u U CO U o o 2 2 E Q) (0 -H A a c o co O Q. v co co >H c o "H < V W A C O ••H CO CO V a) u a x A z CD 1* 2g *ft <ft 0) X •—4 O, X CD y A/ • P a 3 O <-, §H 6 •—I E CD Di X < •a ©• A w o w H w Z o fO a CO 5 5 Jt £ s s 3 .v. a Xi CO CD •a v oo V w W < w W U O i—i S3 w U o a. u CO O 2 PJ H i—i u P H H H w CO u < 1-1 H H cu CU ib P P 0u 1 b Bu cu as l-H 9 9O O •-I h-l -1 H 5 H O Q H O Q Cu Cu P Q O P Q l-H 2 M H w H w cu w 00 i—i H W 00 w a: Q i—i sw H O Cu H 00 P 27 13 (1) C & CD c CD +-" C X5 CD O 0) & CD o c c ~ s CD +-> a o S-, A CD •(-> C ro -^H CJi CD U ain >, ro .—i ft >, ro •—i V CO CO a 3 O .—i ca a —i 73 XS G ro ro CD +J CD 0) CD <D 0) J3 15 3 3 o, 3 o u £ 0" Cn >, ro .—) ro i—i w to ft Cfl CO 2 w H w 2 a 1 V Q 3 O* >i 3 O S-, & >, a. ,5 w i—i .V. .V. ft o CD a V CD +-> Q X o Q i—i V 5 CD C V ro % u c ro m c -—< C -—< a 3 4-1 IH O Di i—i I >—1 o t-i „, C CD O ft* o V - /\ CD O O V T3 T3 V A C 4-» CO o A~ Q i—i C7> Q i—i v ro •—i -F-H Q i—i V CD 4-" 4-1 Q a CD 4. 4-1 o ro •—i CD r-*-» J5 +-> i-, Di CD +-> C CO O 0 c 3 O V A J3 CD OH U >H O A~ i—i CD CO V a c 6 1 ft & O) u. E a; 0) -M •—( >, .—i a to -a v CD a. o •y ro ain .—i T3 V ro ft W -a . v. I-. Di ft o -y ro X3 V CD w X3 CD B ro £ ro i—i ft co -^ A CD i—i a C CD X! Cfl p .V a V y. CD U C o CD >, ro "a 10 • --I w o < W H W O • i Q w O O CU w U O w S3 en w H S3 cu S3 3 DQ ^* W Cu oi 3CQ B|j O 25 pq _1 H S3 Q Q CU aj O Oi oi O CO w w CO D & CD U w CO S3 s C ro ca C 4-< CD x: H 28 NOTES (1) The X and Y coordinates of the display run from -1.0 to +1.0 (2) All ID'S are INTEGER expressions (3) All positions are REAL expressions (4) The PUTITEM procedure does not re-initialize the display item buffer. This implies that one may build a display item and copy it into more than one group. Also, one may build a display item, copy it into a group, then add more to the display item, copy it into a group and so forth. 29 APPENDIX II THE ASSEMBLY CODE OPTION A. General Description A brief version of TX-2 assembly code has been implemented in LEAP allowing the assembly and execution of machine code in LEAP programs. The current implementation has no macro facility. Format To begin assembly coding, the user types j~A~| . This character causes the compiler to look for MARK S*information. fE~[ marks the end of the assembly information and the compiler returns to normal LEAP processing. The form QT) [1] ; is equivalent to a statement in LEAP. C. Restrictions and Notes 1. Equalities are permissible, but all symexes used in forming the equality must be defined. 2. The special symexes A, B, C, D, E are not automatically available, although they may be defined as equalities by the user. 3. Configs, hold bits, bit instructions, double indexing, and RC's are allowed. When defining a bit, however, it is necessary to separate the quarter-bit number by a comma (not a period). Example: SKN. _ YB Configs and subscripts must also be single symexes. 4. When reference is made to a LEAP variable, the address of the variable is used. This means that in the normal case LDA 0 will put the value of Q (a LEAP variable) in A. 5. All MARK 5 equalities and instructions must end with semicolons, except for the last where (T) 6. is used. Forward references are allowed in restricted cases. These are: * MARK5 is the assembler for TX-2 . 30 a) No operation is performed on the symex. b) The symex is defined later by a •*•' in LEAP or a '•»•' or '-' in MARK 5 . 7. Tags are assigned by use of a '--, or '-' followed by a MARK 5 instruction, constant, etc. 8. of LEAP. There is no comma convention and constants follow the rules Octal integers must therefore be followed by a decimal point. Example: 9. in [A| JED 56- and LDA X One may not refer to a label or equality which has been defined . . . [E] statement from anywhere outside that statement (e.g., equalities are "local" to the [Aj . . . [EJ statement in which they are defined. 31 APPENDIX III PRIMITIVES FOR INTERACTIVE INPUT The facility for non-typewritten interactive input to a LEAP program has two parts: (A) a set of reserved variables and functions which directly indicate the current state of the indicated input device (see Table IIIA), and (B) a simple sublanguage for communicating with the part of the time-sharing system which handles input interrupts. The interrupt sublanguage allows LEAP programs to "activate" the 2 11 various input devices at a TX-2 console, ' thereby asking the time-sharing executive to gather relevant information at the exact time that an input event occurs, and report this information to the user when he is next active. The user may ask for certain status information to be recorded along with the specified input event. For example, he may ask that the real-time clock reading be recorded whenever a knob changes state: (1) ACTIVATE 0KNOBS REPORTING 0RTC*; The time-sharing executive reports input information to the user by maintaining a list of events, each with appropriate cause and status information. The user may ask for information about the next event; an entry will be removed from the list of events, and the cause and status information will be reported to him. If the list is empty, he will be notified. The user calls a reserved procedure to get information about the next event: GETNEXTINT; This procedure stores the appropriate cause code (an INTEGER) into the reserved variable aCAUSE, and device status information into appropriate reserved variables (e.g. if the event were a knob change, the state of the four knobs would be copied into the reserved variables «KNOB 1, «KNOB 2, «KNOB 3, and "KNOB 4). If a request to report the real time clock reading accompanied the knob activation statement (as in (1)), the reading taken at the time of the event would be stored into the reserved variable oRTC. 'reserved words in the language are in CAPITALS. If the list of events 32 is empty, the GETNEXTINT procedure would store zero into aCAUSE and then return. The input sublanguage consists of three special statement forms, and a number of reserved variables, procedures, and functions. (1) Statements in the input sublanguage: (a) ACTIVATE < input device name> ; (b) ACTIVATE < input device name>REPORTING< report list>; (c) DEACTIVATE < input device name> ; The "input device names" are listed in Table III B. Note that there are four interval timer device names, each of which may be activated with a unique interval time, in milliseconds. The minimum interval time is 64 milliseconds; the maximum is 2 milliseconds. The "report list" consists of one or more "report specifications," separated by commas (see Table III C). (2) Reserved variables in the input sublanguage are presented in Table III D. Reserved functions are presented in Table III E, and reserved procedures are shown in Table III F. 33 DATA TYPE NAME NOTES RTC INTEGER real time clock register KNOBS INTEGER knob register TOGS INTEGER reg. 3776210 EIR INTEGER reg. 377621 COR INTEGER reg. 3776220 KNOB1 FIXED quarter 1 of knob reg. KNOB2 FIXED quarter 2 of knob reg. KNOB3 FIXED quarter 3 of knob reg. KNOB4 FIXED quarter 4 of knob reg. TBLTX FIXED x-coordinate of tablet 12 stylus TBLTY FIXED y-coordinate of tablet stylus TBLTSW1 BOOLEAN TBLTSW2 BOOLEAN TBLTSW3 BOOLEAN switches which become TRUE as the tablet stylus moves toward the tablet surface. TOG1 BOOLEAN TOG 2 BOOLEAN TOG9 BOOLEAN META • • o BITS 1.1 thru 1.9 of reg. 3776218- if the bit is a 1, value is TRUE 0 => FALSE. BOOLEAN META bit on knob register TABLE III A: RESERVED VARIABLES AND FUNCTIONS FOR INTERACTIVE INPUT. 34 DEVICE NAMES VALUE OF aCAUSE (in octal) AUTOMATIC REPORT (in addition to o-CAUSE) 6TARGET 1 c/ITEMSEEN, aGRPSEEN 3TRACKSTART 2 aTBLTX,oTBLTY 3TRACKEND 3 <*TBLTX,aTBLTY pSWCHANGE 4 o-TBLTX,crTBLTY 3INTMI {<# millisecs>} 5 3INTM2 {<# millisec:s>} 6 3INTM3 (<# 7 miHisecs>1 3INTM4 {<# millisec:s>l 10 3INTMS 11 3KNOBS 12 aKNOBl, aKNOB2 , Q-KNOB3 , <yKNOB4 3EIR 13 a-EIR 3KEYBOARD 14 3INKING 17 o-NUMSTROKES 3 TRACKING TABLE III B: INPUT DEVICE NAMES AND THEIR OCTAL CODES, AND RESERVED VARIABLES AUTOMATICALLY REPORTED. NOTES REPORT SPECIFICATIONS 0KNOBS causes Q-KNOBI 3EIR causes aEIR gRTC causes Q-RTC g TBLTPOS causes aTBLTX TABLE III C: REPORT SPECIFICATIONS thru c^KNOB4 to be set up. to be set up. to be set up. and aTBLTY to be set up, 35 DATA TYPE RESERVED VARIABLES FIXED QKNOBI <>KNOB2 Q-KNOB3 aKNOB4 aTBLTX aTBLTY aEIR INTEGER aRTC alTEMSEEN aCAUSE aGRPSEEN aNUMSTROKES TABLE III D: RESERVED VARIABLES FOR THE INTERACTIVE INPUT SUBLANGUAGE. FUNCTION AND PARAMETERS NUMPOINTS {<stroke number>} DATA TYPE INTEGER INKX {<stroke number>,<point number>} FIXED NOTES value is the numbar of ink points in the indicated stroke X and Y coordinates of the indicated ink point INKY {<stroke number> ,<point number>} TABLE III E: RESERVED FUNCTIONS WHICH ARE RELATED TO THE INKING EVENT. 36 NOTES PROCEDURE NAME CLEARINK (no parameters) This causes the ink to be removed from the display, and the inking machinery to be re-armed. TURNOFFINTS (no parameters) Turn off all interrupt devices. CLEARINTS (no parameters) Clear out the list of input events. SETPENMODE {<display group ID>, <pen mode: 0,1,2, or 3>} See Note 5 below. GETNEXTINT (no parameters) The GETNEXTINT reserved procedure reports the next occurrence of an input event by setting up aCAUSE with the appropriate code and setting up the appropriate reserved variables. If there is no event recorded, aCAUSE will be set to zero. TABLE III F: RESERVED PROCEDURES FOR THE INTERACTIVE INPUT SUBLANGUAGE. 37 SAMPLE PROGRAM This program displays a smooth line for every line drawn in with the tablet stylus. START INTEGER ITEMNUM; ACTIVATE p INKING; 0 -ITEMNUM; CLEARINK; GETNEXTINT; TAGl- IFaCAUSE = 0 THEN BEGIN SHADE; GOTO TAG1 END; IFaCAUSE ?* 17. THEN HELP; IF aNUMSTROKES ? 1 THEN GOTO TAG2; SETITEM {ITEMNUM + 1 -ITEMNUM}; LOADPNT { +INKX [1,1], flNKY {1,1 } }; PUTLINE ftlNKX {l, NUMPOINTS {1 }}- INKX {1, 1 }, t INKY f 1, NUMPOINTS { 1} }- INKY {1,1}}; PUTITEM {0}; CLEARINK; TAG 2* GOTO TAG1 FINISH MISCELLANEOUS NOTES l) One can optionally specify an "inking wait duration" (i.e. time delay between lifting the pen from the tablet surface and receiving the inking interrupt) by specifying an integer value between 0 and 100 when activating inking: ACTIVATE SINKING {<INTEGER >] e.g. ACTIVATE PINKING {40} REPORTING 0EIR; The increment is 5 ms; the default (normal) delay is 500 ms (1/2 second). 38 2) -1 <coordinate value <1 3) "ACTIVATE ^TRACKING" simply renders the tracking dot visible; no input event is associated with this input device. 4) CLEARINK must be executed (after activating inking) before inking will occur. 5) The "pen mode" attribute of a display group specifies the relationship between the picture indicated by the group and information to be reported to the user when a target is "seen" by the pen. In the case where a target has subpictures (uses) as parts, the user must specify which item in which group is to be reported when a target is seen. He does this by specifying a "pen mode" for each display group; this indicates which group is the "working level": item ID's from this group are reported when a target is seen. There are four pen modes: 0) Normal (default) mode: look above here for the working level. 1) Picture parts here and below are invisible to the pen. 2) (Unused). 3) Working level: this group contains a group of targets; report the ID of this group and the ID of the item seen by the pen. 6) a) 'a' prefixes denote reserved variables which are stuffed by GETNEXTINT (e.g. o-KNOBl). b) "0" prefixes denote device names (e.g. pKNOBS). c) No prefix (see TABLE III A) denotes a reserved variable or function whose value is a direct reading of the indicated device status when the reference is made (e.g. KNOBl). 39 APPENDIX IV TEXT AND NUMERICAL I/O CONTENTS: A. TEXT AND NUMERICAL INPUT TABLE TABLE TABLE TABLE B. Al . A2 . A3 . A4. RESERVED VARIABLES AND PROCEDURES DATA TYPE CODES ALLOWED DATA TYPE CONVERSIONS FOR THE READ STATEMENT READ ERROR CODES TEXT AND NUMERICAL OUTPUT 1. TEXTARRAY OUTPUT STATEMENTS a. PRINT b. XEROX c. SHOWTEXT d. S TO RET EXT 2. FORMAT STATEMENTS 3. FORMATTED OUTPUT STATEMENTS a. PRINT FORMAT b. XEROX FORMAT c. GATHER FORMAT 4. THE OUTPUT LIST 40 IV. A. TEXT AND NUMERICAL INPUT The facility for typewritten input to a LEAP program is line-oriented and format-free. Normally (see SETSMACKER procedure), a line which is being typed in is not processed until a read-in key or carriage return key is pushed. Five special function keys are allowed: a) The DELETE key: deletes the previous character typed, unless there is no previous character on this line. b) the WORD EXAM key: delete the previous input word on this line, and any trailing spaces or tabs. c) the NO key: delete all previous characters on this line. d) the YES key: types a clean version of the input line so far. e) the READ-IN key: terminates the line, using it as a text file name, and pushes the contents of that text file onto the source of input characters. An input line consists of a sequence of input words, separated by spaces and/or tabs. The READ statement takes a list of variables as its argument, and attempts to read one input word into each variable, working from left to right, until the argument list is exhausted. If there are not enough input words to satisfy the argument list, the system will wait for sufficient input from completed input lines to be typed. As each input word is read into a variable, allowed data-type conversions are made (see Table A3). The data-type of the input word is determined from its format (see the discussion of constants in Section I. A), and the data-type of the variable is known from its declaration. Only variables of the following types may be arguments to a READ statement: REAL INTEGER BOOLEAN FIXED TEXTARRAY If a TEXT ARRAY variable is the argument, an input word will be copied character by character into the indicated textarray, starting with the first element in the textarray. The value of each textarray element will be the integer character code for the indicated character. The next available 41 element in the textarray will have the value 777g to indicate end-of-word. The reserved INTEGER variable o-CHARCNT will contain the number of characters read into the TEXTARRAY (not including the 777g character). There are two general forms for the READ statement: a) READ <list of variables separated by commas>; (example: READ X, Y, I, IBA;) b) READ {<TD: an integer expression^ <list of variables>; (example: READ {37} X, Y, I, IBA;) The second of the above forms is used to indicate an identifying integer for the READ statement; in case of a read error, this integer is reported to the user along with the appropriate read error code (see Table A4.). The READ statement reads input words; there is another statement for reading input characters: a) READCHAR <list of INTEGER variables>; b) READCHAR {ID} <list of INTEGER variables>; This statement takes a list of INTEGER variables as its argument, and attempts to read one input character into each variable, going from left to right, until the argument list is exhausted. The indicated integer character code is stored into each variable. Spaces, tabs, and carriage returns ARE treated as input characters. If there are not enough input characters to satisfy the argument list, the system will wait for sufficient input from completed input lines to be typed. The second READCHAR statement form is similar to the second READ statement form; in case of a read error, the indicated ID is reported to the user along with the appropriate read error code (see Table A4.). The user may disable the built-in facilities for reporting a read error by executing a statement of the following form: SETRDERLBL <label> This causes the system to note the indicated label, and transfer control to it instead of printing an error message when the next read error occurs. Appropriate information is stored into reserved variables when a read 42 error occurs (see Table Al.). The user may cause his program to take its input from a text file rather than from the keyboard. At execution time, he may type the name of a text file, and then hit the READ-IN key. This causes the indicated text to be read in exactly as if it were typed in. When the text file is exhausted, a message will be printed out, and input will again be taken from the keyboard. Note that no change need be made to the user program. The user may re-read an input word or input character on the current input line by storing away and later resetting the system's input pointer. * This pointer is kept in the reserved variable INPTR (see Table Al .). TABLE Al. (1) RESERVED VARIABLES AND PROCEDURES FOR THE LEAP INPUT FACILITY READNUM (INTEGER) The value of this variable is set to the ID of the offending statement (if specified) when a read error occurs. (2) RDERRCODE (INTEGER) The value of this variable is set to the read error code number (see Table A4.) when a read error occurs. (3) RDTATYPE (INTEGER) The value of this variable is set to the data type code of the input word if an illegal mode conversion is requested. (4) ENDOFLINE (BOOLEAN) This variable is set to FALSE at the beginning of each READ and READCHAR statement execution, and set to TRUE at the end of the execution if there is no more input on the current line. (5) INPTR (INTEGER) The value of this variable is a pointer to the next character on the current input line. (6) LASTINPTR (INTEGER) This is an integer reserved variable which is used to store the previous value of INPTR. Each time an input character or input word is to be read from the current input line, the value Note that INPTR may not be reset to point into a previous input line 43 of INPTR is assigned to LASTINPTR. If a new input line must be fetched, LASTINPTR is reset to the beginning of the new line. The system uses the value of INPTR as its pointer into the current input line; the user may save LASTINPTR or INPTR, and reset INPTR if desired. Note that INPTR may not be reset to point into a previous input line. (7) ISCHARINPUT (BOOLEAN PROCEDURE; no parameters) This returns the value TRUE if there are any characters left on the current input line, or if there is another completed input line available; the value FALSE is returned otherwise. (8) ISWORDINPUT (BOOLEAN PROCEDURE; no parameters) This returns the value TRUE if there are any input words left on the current input line, or if there are input words on any new, completed input line; the value FALSE is returned otherwise. (9) CLEARKBDLINE (PROCEDURE; no parameters) This removes all input from the current input line. (10) CLEARKBD (PROCEDURE; no parameters) This removes all completed input lines from the source of typed input. (11) READINTEXTFILE (PROCEDURE; Textarray parameter) This procedure pushes the textfile whose file name is given onto the stack of input character sources. If the parameter is not a correct textfile name, a READ ERROR #12 will result. Example: (12) READINTEXTFILE { ' STANDARDTEXT' }; SETSMACKER (PROCEDURE; boolean parameter) This procedure allows the user to access single characters typed on the keyboard before a carriage return is typed. tions READCHAR Only the func- and ISCHARINPUT are changed. After a call of the form SETSMACKER {FALSE }, READCHAR will return any character typed, 44 including the five function keys which, obviously, have no effect when accessed in such a manner. This is a special mode of operation, primarily for those who wish to use the keyboard as a set of control keys, rather than as a source of input text lines or words. Under this mode, READ acts as it always does, but INPTR, LINPTR, and ISWORDINPUT should not be used. The normal mode for the read package is restored by executing a SETSM ACKER {TRUE}; statement. 45 DATA TYPE CODE BOOLEAN INTEGER 1 2 FIXED (FRACTION) 3 REAL 4 5 ALPHANUMERIC TABLE A2 . DATA TYPE CODES ,if fractional part ^ 0 =*> error if s 1 = > error 0 => FALSE *> TRUE any other => ERROR TABLE A3. ALLOWED DATA TYPE CONVERSIONS FOR THE READ STATEMENT 46 TABLE A4. READ ERROR CODES CODE (in OCTAL) 1 ERROR illegal mode conversion - example: you tried to read an INTEGER into a FIXED (fraction) variable. 2 too many characters on this line 3 used ISWORDINPUT while SMACKER was off 4 you tried to do a READCHAR into a variable of different type then INTEGER 12 tried to read-in a nonexistent text file 47 B. TEXT AND NUMERICAL OUTPUT 1. Statements which output a text array: a) PRINT <text array>; b) XEROX <text array>; This statement causes the indicated text to be appended to the XEROX buffer. This buffer is maintained by the APEX executive. The following statement causes the XEROX buffer to be printed and then cleared: DUMP XEROX; c) SHOWTEXT [<text array>, <display item ID>, <display group ID>, <X position>, <Y position> ]; This is a reserved procedure which causes the indicated text to be added as a display item to the current display structure. The indicated position coordinates specify the position of the lower left comer of the first character. d) STORETEXT [<text array> , <X position> , <Y position>]; This is a reserved procedure which causes the indicated text to be displayed on the storaqe tube at the indicated DOSition. 2. FORMAT Statements The FORMAT statement is used to define a format descriptor, and associate it with a format description. A format description is used to specify the manner in which printed output is to be formatted. For example, a format description may indicate the number of digits to be printed after the decimal point of a real number, or the number of spaces between fields on an output line, or whether to print or suppress leading zeros. The FORMAT statement has the following general form: FORMAT <name of format descriptor> (<format description>); A FORMAT statement should appear as a declaration in a declaration portion of a LEAP program. In general, a format description consists of several data descriptors which are separated by vertical bar or slash. In addition to separating data descriptors, a slash causes a carriage return to be inserted on the 48 output line when the format description is applied to data to be output. Data descriptors in a format specification are matched to data arguments on a one-to-one basis. A full discussion of the format scan and list matching follows this section. In general, a data descriptor consists of a combination of designators to specify the different portions of the data argument which is to be printed. Nesting of data descriptors is accomplished by parentheses preceded by an optional replicator (see the examples). The general form for a number specification is: [SIGN] [ WHOLE DESIGNATOR] [POINT] [FRACTIONAL DESIGNATOR] [CONVERSION] [MODIFIER]. Some of these fields are optional (see the examples). Numbers are converted to characters according to the conversion designator. These are: K for octal integer. I for decimal integer, F for fraction, E for mixed plus exponent of 10, R for mixed number, and A for alphanumeric The modifier is an integer constant specifying the power of ten (or eight for octal integers) which multiplies the number before it is placed for output. For example, T 2, would cause the integer to be mul2 tiplied by 100 (10 ) before processing. The sign of a number is specified by an optional portion of the specification. The sign may have either a fixed or floating position. A fixed sign is declared by having only a single + or - sign. A floating sign is declared by preceding the sign with a replicator larger than 1. This defines the sign field. The + causes the sign to be printed regardless of its value; the - causes only negative signs to be printed. A fixed sign is printed in the specified position at the left of the field. A floating sign is printed either at the left of the first significant 49 digit or at the right of the sign field. A decimal point is indicated by a comma. Both the whole and fractional parts of a number are used to describe the digit positions before and after the decimal point. The two digit designators are: D Print digits, but suppress leading or trailing zeros Z Print digits with leading or trailing zeros. These designators must be ordered if both are used to describe either whole or fractional parts. For the whole part of a number, (D) must precede (Z), and for the fractional part, (Z) must precede (D). There are two special output descriptors which may be used in a format description: (a) S (insert a space character) (b) T (insert a tab character) Examples of the FORMAT statement follow: (a) FORMAT Fl (6 D I); Specifies a six digit decimal integer with leading zeros supressed, If a sign is not specified, + is assumed. (b) FORMAT F2 (- 7 D, 3 Z R); Specifies a real number having seven integer digits, and three fractional digits, with trailing zeros. A sign will be printed only if the number is negative. (c) FORMAT F3 (7 A); Specifies seven integer numbers, which will be treated as character codes, and printed as the indicated characters. (d) FORMAT F4 (3 (4DII-5D, 6DE) I 2 A); Specifies three pairs of numbers (the first of each pair an integer, the second a real) followed by two character codes. 3. Statements for Formatted Output There are three statements which generate formatted output: (a) PRINT FORMAT <format descriptor , <output list>; This causes the indicated output to be printed on the Lincoln 50 writer (see the discussion of the output list below). (b) XEROX FORMAT <format descriptor , < output list>; This causes the indicated output characters to be put into the APEX Xerox buffer. The user program must force this buffer to be dumped by executing a DUMP XEROX; statement. (c) GATHER FORMAT <format descriptor ,< output list>; This causes the indicated output characters to be appended to a special reserved textarray named OUTPUT. This textarray may be used as a parameter to the statements described in section B of this appendix, for example. The following special statement clears and reinitializes the OUTPUT reserved textarray: CLEAROUTPUT; There are several restrictions on the use of this textarray: (i) Storage for the elements of OUTPUT is automatically allocated, and is of a fixed length (500 characters). Do not attempt to re-declare or assign storage to OUTPUT. (ii) References may be made to the elements of OUTPUT, but do not attempt to move the 777. character if subsequent GATHER statements are to be executed before a CLEAROUTPUT is done. 4. The Output List The output argument list in a formatted output statement consists of arithmetic expressions and braced FOR statements. The comma is used to separate list elements. The braced (f }) FOR statement is an iterative output argument. This means that several elements of the argument list may be indicated by one FOR statement. The braced FOR statement has the same form as the regular FOR except that the DO clause is an arithmetic expression or another braced FOR statement. Examples: IFOR 1 -I STEP 1 THRU 10 DO A^ would be equivalent to listing arguments Ai . . . Aio{FOR 1 - I STEP 1 UNTIL I> 10 DO fFOR 1 -J STEP 1 UNTIL J> 10 DO AIf j, Bj( ^ 1 would be equivalent to listing elements A\ ( \ , Bi i, A^ 2 • ^2 ,1. . 51 A 10,10' B io,io[FOR 1 -1 STEP 1 UNTIL I > J DO {FOR 1 -KSTEP 1 UNTIL K> 3 DOAI)KD would cause the variables A]_ \ , A\ 2 ' ^1, 3 ' ^2 1 > etc • to ] e use ° d• The processing for formatted output is controlled by the output list. The format description is scanned and processed until a data descriptor is found. The next output argument is then fetched and processed; the format scan is continued until there are no more arguments. If the end of the format description is reached before the output list is exhausted, a carriage return is automatically inserted, and the scan restarts from the beginning. Examples: FORMAT F (5 D I) PRINT FORMAT F, A, B, C; causes A, B and C to be printed as 5-digit integers on separate lines. FORMAT F (5(5 D I); XEROX FORMAT F, X, Y; cause X and Y to be placed in Xerox buffer as 5-digit integers on one line. FORMAT F (2(5D, 3D E)) PRINT FORMAT F, fFOR 1 - I STEP 1 UNTIL I > 6 DO {FOR 1 - J STEP 1 UNTIL J > 2 DO A^ }}; causes array elements A . , A^ ?, A? , A_?, . . . At.? to be printed as real numbers, two to a line. 52 APPENDIX V * SUBPROGRAM LINKAGE FACILITY A. GOUPTO AND PEELBACK There is a facility for going up to a LEAP program from a LEAP pro- gram with input parameters and output parameters . The calling program executes a statement of the form: GOUPTO <TEXTARRAY expression> <argument list>; where the TEXTARRAY contains the name of the LEAP program to be called, and the argument list may be: a. null, if there are no parameters. b. {<INPUT parameter list>} , if there are only input parameters. c [; <OUTPUT parameter list>|, if there are only output parameters, and d. [<INPUT parameter list>; <OUTPUT parameter list>], if there are both. Input parameters may be variables or expressions; output parameters must be variables . In the called program, if there are any input parameters, a declaration of the form INPUT tdeclaration list> 1; must appear immediately after USELEAP, or after START if there is no USELEAP. The declaration list is similar to the declaration list for a PROCEDURE declaration, with the exceptions that LABEL and PROCEDURE parameters are not allowed, and a program may use the "FILE" declaration to pass the name of a file (or any name) in the public or private directory as a parameter in the GOUPTO statement. A "directory item" parameter is put into the connector, and the INPUT declaration on the upper map causes the text of the file name to be made available. The "FILE" declaration is used on both maps as follows: Examples: lower map: GOUPTO 'BLOP' (FILE 'SAM', . . . }; For an introduction to the APEX time-sharing executive and features of the time-shared virtual machine, see references 6 and 11. 53 upper map (in the program BLOP): START INPUT [FILE X, . . . 1; After the INPUT declaration on the upper map x behaves like a declared TEXTARRAY variable, having the FILE NAME as its value. When the called program finishes, it may execute a PEELBACK statement: PEELBACK [output parameter list}; or simply execute the FINISH statement. B. OVERLAYS A LEAP program may be segmented into one main program and several subprograms (called OVERLAYS). At execution time , the main program is set up on the user's map, and remains set up until execution terminates. Overlays may be set up and dropped from the map under program control. Only one overlay at a time may be set up. The main program must be no larger than one book of code, and each overlay is 7 similarly restricted. At compile time, the user must use the BBIN command to compile his program if overlays are declared within. The overlay facility was implemented for three reasons; (1) to help reduce the maximum core requirement both at compile-time and at run-time, (2) to provide an alternative to the GOUPTO facility, which may cause large inefficiencies if much information is passed between maps, and (3) to get around the requirement (imposed by the VITAL 7 system) that the total code compiled for any one program not exceed two books. Overlay declarations should appear immediately before FINISH in a LEAP program. Overlay declarations may not be nested. A LEAP 54 program in which overlays are declared should have the following general form: START < entire main program > DEFINE OVERLAY '<character string >'; < statement >; DEFINE OVERLAY '<character string >' ; < statement >; FINISH Example: START REAL X, Y; 3.0 _X; DEFINE OVERLAY 'OVL1'; BEGIN END FINISH There are three statements in LEAP which are related to the overlay feature: (1) CALL < textarray expression >; This statement causes the overlay with the indicated name to be set up, and control to be transferred to the first statement in the overlay. If a different overlay is already set up when this statement is executed, it will be dropped from the map. (2) OVERLAYRETURN; This statement causes control to return from an overlay to the statement following the CALL statement last executed. Note that one overlay may call another overlay; the calling 55 overlay is re-set up before control is returned. A GOTO statement which transfers control to a label in the main program may be executed from within an overlay (if the label is not within a block). Note that labels declared within an overlay may not be referenced from outside the overlay. (3) DROPOVERLAY; This statement causes the current overlay (if any) to be dropped from the current map. 56 APPENDIX VI ERROR DETECTION IN LEAP A. PRODUCTION ERRORS * These errors appear in the syntax phase of compiling. They are noted by the following comment: PERRXXXX EDITARG (line in error) where, XXXX is the error number, EDITARG is a standard argument defining the line in error, and asterisks mark the current scan pointer at the occurrance of the error. HINT: If the error occurs on the first word of the line, then the error may be caused by an incorrect end to the preceeding line. B. SEMANTIC ERRORS These errors are caused by the VITAL mechanisms and may in- dicate an error in the compiler. SERR XXXX They are noted by the comment: EDITARG (line in error) where XXXX and EDITARG are as previously defined. If these errors occur, the user should consult the staff. C. SEMANTIC FAULTS These faults occur in the semantics of the language and are noted by the comment: FAULT XXXX EDITARG (line in error) where XXXX and EDITARG are as defined for production errors. A complete tabulation of both compile-time and run-time errors and probable causes is presented below. *The LEAP compiler was written using the VITAL compiler-compiler, and is housed in the VITAL system. For information about VITAL, see reference 7 57 or o o Q- CO Q O Z Ul co •—> O- to o 3 0 UJ >- CO O _1 z o Ul X V1— Ul a. z o t— H-X i-*t u| M M a or -i _i CKI o UJ ru Ul z o »—. O f- 04 -tt VJ toi o or or o Q- U- to o _l o 3 u. IK UJ a UJ _l CO <t I— OT UJ col _1 Ul a. o a: a_ >z <. Z: o_ X o o u| ru d o o V- z »—• zx. o 01 _l Z t— _l -X •— to a 'i _i o a UJ M to O •H Ul Q o z to to —• z: to _1 <t z o •—• UJ t— it z <c <c o o t— «t _1 tJ UJ -1 a: o >- <t _i •to z o Ul CO \- z or zz> »— UJ OT u. o 13 z: Ul to - 1 o -1 _l Zl -I <t UJ 3 U4 o z o -a ori o o UJ Ul o ca o oi H- O <t CD z <t tJ _) ~ -I >- t— u. Ul I— 0 QL ul z; Ul 0 Ul 1— Ul -1 0 0 0 Ul z: Ul X ^ or ul 1— t— tO 3 U| arl - 1 1 -t 'I to u. 0 1— CD «t UL Ul Zl -3 Ol -=t -1 z? Ul Z- OJ Zl z: 3 •-1 t-> ^t or M 0 z <c _l *t 1— «* a Ul _1 a. <!. z> o tj Ul ZL> tO •— o o Q -1 _l —1 »— Ul <c t— a. a. <c a; <t _i tj Ul _i z A UJ <t t-> _i Ul CO <t _l <t tO Ul <L Q_ CO Ul <t Ul -I CO a. z; o; z •— <t i: 0 a. z: >- 0 0 0 _i z z <c z •— •^> •— 0 t— 0 Ul z > ul -1 X t— to CK Ul >- <c _1 CO z •—• *— OIL to tO z OIL to Ul ct to Ul 0 <t t— Q; a. a. X UJ X Ul -1 _1 •— <c oc <t X Ul 0- I— >- -J •-• <c <t »-• (£ «1 oc <c 0 0 0 0 0 0 QL -t z z z •— •—• »-• > o Ul Ul ul <c <t X X > ;> ^> X <c to •—' Ul V— Ul z; <t _1 ct <c a_ tO to to z z z 0 0 0 — •—• •—• to to tO tO Ul Oi to Ul OL to UJ OX a. Ul X Ul on o_ X ul n n ^ *» Ul z: 0 0 Qi -et. >• =• (Kl z 0 Ul C£ 3C X V- >—t I— t— 1— 0 Ul O <c <t z cc cc z O Qi Ul 1- <t 0 SI _J _l _J <c <c 0 Ul <t 0 Ul <t 0 Ul Zl 0 Ul _1 _l _J _1 _l _1 _1 _l Zl —• " — •— •^00-^0000 0 0 X t- --> to t- 0 Ul -t \z> Ul CO •— z C( •—• -1 to UJ 0 •— 0 O Ul »-« •—• 0 u. Ul X I— ^Jl Ul a. t•2 *t 1tO Ul a: ul l~ Ul -X 0 ul or 0 0 0 u. u_ 0 0 -» M M ^ tJI to *-« 0 z <u Ul z <t or -I _1 «1 <-> >" z: O- Q Ul CO •— or Ul to 0 z 1- a 0 co «« >- Ul 0 0 to ZD z *^ •o z =3 0 Ul CX 'J3 Ul z 0 _l CO <t Zl ac Ul z \- z i: _l CO •a. •—• Ul _1 t— <t a. z: -I Ul Ul ru z: a: •—• Ul <t •—• OX Ul t- <c o_ z: •—• z 0 Ul ZJ Ml a a •—' \— *—• ^ to CO •—i l~ OL to •-• Ul _l t— X <t X 0 Ul 0 CO ^t X K-. 0 t— *<* •— :> 0 O- V- _l I— 0 z o_ X 1— to to to u_ Ul ul 3- z ul ul Ul to to Ul Ul •—• 1— <t <J~> >- >- >»— Q «t 0 UJ Q UJ >- •—• _1 I— X 2: z o QT t— z o o Ol Ul •— a. t— z; 0 0; <t to 0_ ¥- C£ <I to «t n_ Ul or o to a. en ul •—• >- >- z >- I— -I to CO z o to Ul to l— <t -I Ul Q Ul »—• z z o or o XI t-A 0 -I < li: Ul 1— _1 UJ _l i— to z »—1 z •—• z o >- »-« co z Ul Ql O t- UJ i— VJ 2: a; z z <c o tj •>- to ul Q- to <H 14 Z5 IX t— or -4 <c or CO UJ Q UJ Q UJ —• z: O «* ^ — ;> —. o -1 ^H o fM Q UJ QT <t _l CJ Ul 1 .^ X t— 0 CO tO X <t <£ £ z. o z o Ul 1 ul ^ ul «t a Z z: z U. Q rj U Ul z z 0 r— t- X 1- ul or ZZ> _^ or o_ <J X ut »— z <C <n z <~> »-« to 1— z: 0 *-• CO X 0 0 Ul u- u. S3 U| V- z 1— z ul Ul U| Q Ul QL -I I— oa 0( 0 OL H 1— tO zz> z; — X Ul a z •-• ai H a. -1 z; z: z; z z 3 •>i 0 oa tO <t 0 ul X -I _l 0 0 _l or I— ZD a. cc QC =) Q: a. <l 0 ul a. 0 «a tOl >- ul to > «a tni to Ul 0; CO «I —1 CJ 0 ^H 1— 0 <t Ul UJ =•( z z Ul _l Q; u| to _) -I 0 0 <t 0 Ul <c oc 0 Ul <t -<t _l _1 Q <t —• CD 0 •a CO uJ —• ^ »— —• >—• -51 tOI _l -1 ZD 0 or _i «t 0 Ul -I _| «—< 58 co UJ CK n- X UJ 23 UJ n 10 <s -I 3 o 3 LK CK «i -I u. o u_ o IK UJ IK CO £ 3 Z •- o CO z o CO s— -t 1— :£ z UJ a. IK 3 1^ X UJ 7£. UJ 21 UJ 3: a UJ CO UJ <t 2: UJ CO 3 _J -I I— <t ^1 3 o CO _) «— o z t— Q UJ X UJ X o z .—i CO CO UJ a. UJ X 1— 2 i— »— CO UJ IK <t Si Z •— Wl CO CO ^ •— •—• Z UJ <I X -1 X •—1 CK or <t 3 3 o 3 X 3 Q UJ O UJ •— i— - V— • UJ LKI <u M H CKJ uj O-l o ot I— IKI o-l M z «x CO <t Zl IKI o< 31 CK a. _i *t Z o •—• >- l-t a 3 <i XX U4 31 or u_ Zl 31 uj. «t c* oa a-l UJ X t— UJ CO 3 3 o CK IK z _l a. O- UJ <t co 2. 3 1— UJ - t- CO - • _1 _l z <x Z <t z 3 3 — — z 2 <t 3 <t 3 3 3 o o 3 O >- >- >- •—• ~- X 1— X t— O CK -I o ~ o v; «i V— z o CJ «* u: CO •X X CO CO h- l- a: o (K O CO CO -1 3 CO -1 .—. 'lK iUJ *— "-• X X t— t—• UJ CO •-« a: o t— <t X '_il UJ -1 LK UJ e> * z <i t— CO z o CJ 'I (XL '3 cn o t— <£ <J <t CJ t— Z ~X I— CO V- t- z z Q CK Id O UJ t - z z X •- >— z o z o *—• *— <\- >3 -=l <t UJ -1 OUJ IK a; VO -i «i u_ o OL O \— O- 1— z o z CO CO -i u_ o •—« UJ UJ or o CQ t~ t" 3 CD «4 a. CO 3 i: CK -i CO »—t •—• o; (K <3 CO UJ CJ CO UJ a a — or UJ 3 UJ t— t—• UJ 13 Z UJ UJ CO UJ CO z z UJ UJ -3) »— 3 3 UJ 3 3 z o o_ UJ -i z o a. ^ 3 3 3 3 3 o <c o «i o X UJ X UJ <t O UJ <t O UJ «I O UJ <I O UJ <t O UJ UJ X i— UJ 3 3 3 3 3 3 3 3 3 3 OL O —• •—« _i 3 UJ UJ a_ <t Q_ UJ 3 3 3 3 c-i CK oc UJ UJ UJ UJ UJ OL U. CK •— •— —1 *— 1— X t— CO «I •— -I > O z CO <t X u. o z CO <t X S- H H <a -a za i3 ccl u:l u: CO —1 O 3 UJ ^rl -i o: o; u_ <t Q. UJ UJ J OJ "i cw H UJ 3 Q_ •-• \— OL UJ -J IKI Q: "— — •— —* —• Q Z -I CO z C3t <3 O >- -t X I— X t— CK UJ X I— PC UJ X UJ UJ ^— •—• »-» • J 3 a z X <t <I 'X UJ » <-> — t— in 3 «£ >3 Q UJ UJ CD H uj tO CJ z IM O 3 UJ IK CO OL -i 3 CK UJ CJ UJ I— UJ a za en 3 -1 •3 n_ O 3 M UJ <t 1 <c *—• IK CK <t x z o <« CO tK 1 X z o •— -I o z 3 3 UJ <I <i O UJ i— =•: «1 O UJ •—• o o 3 3 3 3 UJ i— —I t— z «I cj X t- o co ~\ — 1— 0. M •ZL -3. 3 <t CK <t ca 3 CO *l aa ij UJ •— <l X - t~ CO 3 O f- i: o •-. UJ 3 fO i: >- CO 3 z 1—• V— —• 3: Q: X —• »- i: CK «i •—1 UJ 3 CO UJ > «t —• *— •^ > > *— =» <t UJ -i UJ CO X CK 3 UJ CO *— CO •— <c UJ O CK n_ :> CO CO co; m t— o z <^1 UJ >3 UJ <c il ~- CO •— — t- CO <c o <£ o >- •-- X u. o O- 3 3 IK 3 VI 3 IK UJ -« -fl *t. <t «i CO UJ 3 OJ M •—' «t •3 i— t— o z >31 0( 3, UJ t- UJ <J 1— _ »UJ >- — — <t UJ UJ CO 3 <t •— CO z o »— l- z V— UJ -1 Q UJ CO 3 »t O Z u. o __ CO -i o IK 3 i 3 X IK <t t— Z <c z <t uj H Zl i-1 CO CO UJ CK QX UJ «I >— in 2 CO _l CD 5» •—1 »i 3 UJ M >— •—< *£ •—. <t to 3 3 «i UJ CJ, UJ :E _1 3 3 <t CK •—• 3 od IE t—. o 3 3 CK X t— o o -I CKI H UJ X t- >- co 3E _5 z o z o O CO 2 UJ o Z >3I o< o UJ ct z o ^i UJ «t UJ <t. UJ r~> CK (K CK O a t— i— t— h- z z z UJ UJ UJ at a. i: 3 O i; 3 1c 3 z LK «t IK <t (K -t -i 21 a Q 1 CD Q 1 UJ X 1— z 3 CK UJ f- V- i: CJ l- CO O t— Z *l IK UJ UJ X >- -X UJ u. o t— t- o X 3 C3 <c Z <t o (K U_ Q — «* *— t—> CO o a z f- »•—• • r3 UJ >- z o •— z >^X CO -i CO o !•- o CD <t 3 IK UJ cO •--• :> "JL UJ -t z: CK O O z z >- -1 -t <t 3 CK UJ >• o o <l CO o 3 3 <* O •- - Z -4 3 59 UJ 1 Q Q UJ CO -i z o to UJ UJ ix CO UJ o 1— . • • _l o Z o a_ z o o 3 rj UJ z -1 •—i i— V- r> O © o a- ir o Z _, SL _. •"• ~ Q.|- z z —• O UJ CD <n - z ac 4 Z O —• I— <t en Z O —• »<t m O O u: J CJ u J U u en CO CO 4 CO o a: a: Z —• co Of CK QO en 3 Qi O en en CO IX o en a: en o <M X x •-• CJ Ul CO a o en a. LJ 4 <c a: <c -I O UJ o x <x •— K t— < 0_ Q Q 3E 1-3 UJ z en >_> O en II- x UJ z O •— »— << ac 4 (K -i 4 -I _l VJ <J uj UJ Q Q CO CO UJ in 3 z o 4 en 4 _l CJ UJ O 4 ot 4 QX Ul z o 4 (K -I ..J CJ Ul ro o o z z z I— Qi < »— to t— C£ < *— CO OL •>4 4 i- a co m 4 -1 o o o o z ___-,»_,_oz 444 < ul ui to a: a: a: a: 2: £ co UJ CO H 4 I V_> U a 4 I U U Q 4 I CJ Ul CO -4. _i VJ Ul Q UJ t4 1CO UJ t-4 ICO UJ a: Q_ X UJ z —• z o »— X. *3 UJ •—• in 1— 4 ZcL CO CO UJ <n ex. CO 3 CO 3 o 3 ul X UJ a 4 :U ~t UJ •— -I 4 4 4 Ul CO o Ul CO 3 1- _l -i Ul _) U| • -{ in > 3 z 4 u. u_ o o iO Ul CO z z 3 m z o •— •— •- _/ «i CJ UJ DC 3 a Ul Ul Of c_> o o m Z ul a. :c o o a> O o 't VJ ».—• fO 4 z 4 CJ _J -i >a —• ul »x CJ CO X UJ u. u. o o 3 u; rc. Ul _l CO 4 =) CO CO X u. o Ul CO CO CO Ul (i_ >• o o en z en z o z •—• o —• r-3 IK (i; Q: O O 4 u. i- u. 1— -1 ^1 n_ t— -t >: •i en o o u. u. U- »— o fK Ul c* ex 1U r±: CO o o CO o o u. u. 3 u. t— -1 CK O U. _l_l_J_J_l_l_l_l_l_J_l_l_l_l_l_l_l_l_l_l_l_l_l_llOcO_l_J_J_l_l_J_l -4'<<t<£«*<t«!«l'«t-<t«t«t«*'<l-4«t«*«t<X-l<*«t-<«*—'—i «Z «X <t 4 4 <I 4 OOOOUOOOOOOOOOOOOOOOOOOO OOOOOOO I.I lit i.i UJ i»i lit !•! !•! i.i ill i.t I.I I.I 1.1 I.I i.i iii ill i.i I.I I.I I.I I.I I.I m tn I.I i.i I.I I.I I.I iii ill _l I I —» • I I _l I • • I I I. I I I I I _» I • I 1^— —• _l _l _l _l _l _l _l _J_I_I-J_I_1_1_1_J_I_J_I_I_I_J_I_I_J_I_I_I_I_1_JIX_J_I_J_I.-I_1_I 60 a u_l o z —• z o o a: o a o> >- uJ UJ _l z <t CO co ca it o o o —I to tO UJ Oi ai CC o_ O o •4 «4 *4 -4 -4 -4 -4 <C o. >- UJ UJ M v- huj -4 z z _1 (t o I OOOOOOOO UJ i; UJ -4 Ctl -4 -4 Vto r_3 oj. tto q J -i <t q q -s -s -i -i N -1 _!• <t O u _i _i — CkU OL\ H tnt >i t/» -J «1 O u _i _l — fto »- "4 I— to _l <t O u _i _i ~ *n UJ. Z •- H •- Z >« -I ui u» i2: M to UJ •— «t •to ac o u_ o q u *s cm -i <9 u to O <I o «4 o Z -4 o «n X Z »n X Z m £ »n «•> t/> *n 2£ E Z X z: «4«t<t«j:«t<l«4«i « Gf « ii: o; a: K o it u_ it o: -i a: <c ix UJ to —. ad it -t Z z_i_i_i_j_i_i_i_ia: to it UJOUUUVJOOOQ; UJUIUIUJUJUJUJUJUJ <J O a: <t >i a: oooooooo <a z oa ui oa s: Q o X UJ <J 3 a: <J 3 o: u 13 tj 3 u 3 o 3 a o: K K o t— 00000000 z •UJ t- I— t— t— t— I— I— t-<t 2:«4«I-I«4«4-4«4-i2: -4 o o u o y o o o o >-> •4 o UJ o UJ o UJ O -4 v-> -4 v~> •— 0£ QC Q£ It o: Q: [j; •40000000 to -4 _) •4 O UJ o o o o o •4 co Q£ o u. «I O UJ •< O UJ «t O UJ •< O UJ "4 O UJ "4 O UJ -4 o UJ _1 -J O u. *4 Ol <4 CQ J UI U| aj CKI It] Od _i •4 VJ 1 oa _J «t VJ i «t O i -4 <J oa oa oa to) >i »q </i >i tq It It UJ ca a a a u. aj ru aj ixi o tOtOtOtOtOtOtOtOt/) uixxzxxxxxct o u Qfl m >n w> m o 1 •"• i: UJ to -t z UI _l -4 O UJ _l _l — a 83 y a tq >i tq tq >i tq .2 O to 3 •— •o z> _1 <t o UJ -I _1 a o (t a. —• •4 m z o _i o </> tO 3 uj H Ol o z •—• V1— UJ o on o 61 UJ o 3 o CO UJ z o at -I o o u_ -i •—« »< »- UJ X CK h- cu i3 c>1 r-3 o ai X »— © • -1 lCO UJ C3 CO. . -1 Z •-• z 3 o _l 3 O u_ 3 CK t— .—• i— 3 o z o CO X o —1 z V— t—. 1- -I IK a "i «1 3 3 Q UJ Z -1 s: >- o cc> — o X UUJ «t •—» a z CK o_ *— o a: z o UJ UJ CK UJ UJ >— ^ :> i— 3 m o o a. UJ -i _J X CO CK ~ <M >n • 3 o Q UJ u_ ru t— •—• >• z •— UJ o •—• UJ _) *t <c Z co a; o IK UJ V- CK CK UJ >- . CO CK Ul CD •3. UJ _l -e- UJ CO CK O a. z X =x ad 14 <* -» U4 o <t _l CK UJ O o 1— CO — UJ o CK 3 •3 3 CK UJ _i u_ > o UJ (K 3 »- CJ 3 IK k— CO >H Z3 -4 UJ cj u_ o CK UJ UJ CO t— CO Q Z o UJ o -t o UJ I— < »r a. CO LJ CK INI IK I- rj a. IK O -t CO 3 CJ «-> n UJ M z CK <t -1 "i UJ UJ 2; UJ O UJ rj UJ IK U_ < »t a a -< -1 <a *a -» J C-^l CJl UJ UJ aa IK] o O 1— H UJ CO) -X CO 3 UJ H H u. o UJ CO o V- »— z <i -3. r^ 2: o UJ UJ O _1 _J CK UJ CK 1— yj K •—« >v~ o_ i: UJ >• _l <c O •- CD z 3 •—• »—• V— -i 1— CO _l CO •—• o> >- U- UJ >• •— »- 3 z o o _1 _I 1— i: o »— CK U_ z IK 2C -i i; 3 j h- z --> UJ o H o UJ ca •4 CO *v* *t Ol UJ 1H CK ai »— 3), ^ Q UJ •—• IK V- CO UJ z -i IX K- >- <£ UJ cj O (K o en -=t u. o z o CK CK 3 O O t- Ol Q UJ CO >- CK CK UJ 1 *o >z •— a :> >— < v: o o 3 C3 <3 UJ O CO CO O o «t z Z «t CO -I p—i »I fr - CO •—• X X UJ UJ --J a_ — CK t— 3 en l3 UJ t— CO UJ 3 3 v- <J> UJ 3 > —> O O 13 u_ o UJ UJ IK (K UJ UJ cj 3 X •> -X X CO >- a. UJ 3 < .—. •X 3 Q_ IK <t IK LU i: 3 Q V- > t— CK t— <t z. a z o (3 IK 13 -£• O 3 CO t~ <t s: C3 3 •~ 3 CO O IK IK O UJ CK 3 CQ If. CJ >: IK <C 3 3 -31 i: <_l CO z z a_ Z o LJ UJ CO »- ~ 3 O 3 O CO 3 a z t- X >• 5- CO 3 <t t— •o w> 1 n « ^^ *» a UJ X i— IK O IK IK UJ 3 3 3 u. 3 CK H- UJ <C 3 O UJ z O CQ l-I i. rn >- O CO CK -i CO 1— 3 x (K CJ CO •— -I z o »—i •3 z UJ —• z CO C3 3 '-• CO CQ O o t— H z o o z 3 U- C3 UJ t-CO IK O a z O o ^ CK O O I— 3 UJ 3 3 -i o o UJ •—. CO CO V- > -* >- UJ o ^ X 3 O z IK O U- U- •I 3 —-* O f—• CO UJ o U- o o -3 t— CO ^d CJ »—• o CK o o> LKI -i o X c^ <c UJ z XI cj 3 Z CD t- z o IK O t— CO u. aa rj UJ IK o < < UJ t -«£ VcO UJ CK -i -t U. O LJ CO o o Q o •— \— -t CK «1 -t z —• CK O CK O IK O IK CK UJ CK CK UJ IK CK UJ > ClCO Z <t CK c- z IK -I O z •—• UJ f— i: CK CJ CK Id Z X 3 CO —• ^- > II UJ CO IO 3 Z CO 3 :s UJ O IK Z >—• UJ UJ _J _l >-i CK «i iCO o -t • -• ij O —• -a tl >• CK UJ a W UJ LICK UJ t- a-» CO) O CO 1 11 3: 0( n 3: _1 CKI 3 H a. X V— CKI 9 =>( IKI •t cOl -~ t CJl CO CO -I OJ v: H UJ Z 3 o z a a or _i IK UJ n_ o z c— to i >3 UJ UJ UJ iil UJ UJ X UJ Z t- 1~ h- 1— o o z 1 o a UJ C3 UJ (0 ii 3 Z o CO • t— CO CO IK CK »- g ^ X Of UJ a IK o 3 h- ii CO 3 3 z I— ^- > •— c«* >—• *— , i CO •—1 X UJ UJ -. <-N* *o Q ~« «** ^ -< <-^ -^ ^» M Q -< r* •n -V to w »0 »o »n u"> *i Irt »n 62 IV o t- CJ UJ a: •—• o <v o z •- >3 LJ o U —• O. iT> ri UJ •u. o o u. •—• >—• CJ CO z ir> —• -1 id z. U- a. o llJ „ a; o i-t IV UJ n. o (- -X IV 3L id id >- UJ v- CO -t cv -t IV UJ iv •-L z o u. u_ vx a) 3 CQ • - •—• iv UJ r> Z IV O Z o IV rv CV UJ r> v— v^ x UJ CO o O UJ h- CO —• \— -- iv UJ 1*4 u_ u_ CO © cv UJ CJ cD iv Z 3 cv CO i— X —• -i id 3 UJ tv o t- t- Z -t id o CO 3 o —• —» «i x •— iv t-I id ca VCO in CO 3 CO »—i CO IV _•£ IV •— *— UJ tv -i 3 3 CV UJ a. o UJ 1— UJ IV ".£ iv h- o z •—• t- cv icUJ — >- ti t— Z J z o u_ X t— X UJ t CO i z —< u. hX UJ t— l/> UJ z o o z Q -1 CQ »- 3 o >- z —« >C3 CO -X CQ •— _) ~- <t U- CJ UJ -t cv Z -X X o »— Z UJ iZ U_ IV UJ h- o IV o o ca o o o u. h- UJ UJ _1 r^i IV O <c t—« o o _1 CJ IV UJ V IV IV UJ <t IV z z •—1 o s: _) —• i; z X t— CO X 1— o z o a i: i—• I 1 1 1 i i 1 I UJ _) UJ UJ _l IX. u_ a. u_ o_ UJ ZiL UJ 21 UJ n_ Z) a_ o UJ hUJ _J CO u_ o o id -=t t— h- o o z z O- >- i: o X z £ UJ UJ •- ** -I >- >~ •w; CO «-• u. IV t— -s ~U- —* IV t- ^ fr— >— CO UJ _l •— _J UJ <i: -i —• UJ IV UJ -J 1— CO _l *— ru J y— UJ CO u. a. z UJ _i o u_ u_ ^- UJ IV C o CO 3 ILJ 1CJ UJ -£ z> CO i— o z ^-» CO UJ ^1 <t LiJ Id <C z 1 i-^ IV UJ CQ »— o z CO •—• d) d: UJ _l »—. U- i; UJ ^ »— o o >~ CO CQ UJ CQ co >>\— UJ UJ -I _l CO -1 CQ —• CO cO UJ O n_ id Z 1 1 1 .—. 1— o CO z 1 -X z llJ IV *-* o — Q V IV UJ IV 3 Z CO id 3 «c o -I _1 1— UJ UJ CO 3 X IIV UJ 3 Z I— t— <c -i L3 o z UJ IV UJ 3 t— UJ o CO CO •—• UJ 3 •— UJ 1U. 3 CQ -t IJ- t— 3 o o CO X O UJ X UJ y~ UJ UJ i 1 UJ id X ^- c3 —. CO CO o Qid Z UJ 3 1 1 I 1 UJ 3 U_ UJ -t o cv co UJ X t~~ z cv UJ 3 •-• UJ CO o z UJ 3 1 1 1 1 1 1 1 1 UJ 3 UJ 3 UJ 3 LU 3 UJ 3 U_ UJ U. UJ UUJ U_ UJ U_ UJ id id -I -i id <C z Q Z U- ' 1 1 UJ UJ UJ UJ UJ _1 _J _l -1 —-1 _l •—1 _1 •— •— z z o Q z Z u. u. 0_ u_ n. u_ a. 3 n. ru o_ 3 3 I— UJ i~ UJ 3 kUJ z z z Q C5 Q Z Z z -i -a -t n. CL Q. 3 3 3 UJ •— UJ cO cO CO CO cO —• — •— U0. "3 u_ a. o 1— UJ t~ LU CO U- n_ Ci o hUJ UJ V— UJ 0d> •— UJ CO CO CO CO \- '3 t~ IJJ cO 1 UJ 3 -I <t <l »— »— »— UJ CO ^: id t 1 i n_ «x UJ rM UJ 1 z •— ^-« <L s: UJ CO n> id 3 Z rv -i id UJ •-^ u. —. •- CO 1- — o u- •-* u_ o_ Z CO ^ 1 1 o O -1 CO 1 1 3 UJ U_ CO CO 1 1 z z cO t CO •- <t X _£ X a; — —. «I 1— X UJ V--t V - o z CO CJ lO o UJ 3 3 K-. 13 id -i —* o o o t— UJ UJ --• «i t—• o o UJ 3 Q 3 UJ t - z UJ o z 3 z u. •— o z V- o z CO cO ~- UJ o z 3 CO UJ UJ UJ «I id •X Z i; -t id -I U_ z z UJ 3 UJ 3 UJ UJ 3 UJ 3 — •—• — — •— t 1 u_ U, U- u_ o o <t t— CO 1 1 t 1 1 1 1 1 o lIV u_ o UJ 3 U 3 t- U. o z UJ IV o z CO CO — UJ id UJ IV UJ X z —• -t UJ 3 f-i *- u. 1 , 1 1 U-« u_ hUJ CO V— UJ CO u_ U- 1 - 1— o a «x o <x »~ \— o <c z o CO UJ CO Ul o UJ 3 3 IV IV cv <t CJ CJ UJ -X UJ cv IV u_ o 3 «X UJ z *-• — —' O- •—» — i^ CO z UJ UJ i"_ <t id -X Z UJ 3 cs cv 3 «i o u_ o o CV IV 3 1— o o_ *— >- »— o "X o z id <I o UJ IV UJ CO z •— u. o 13 >IV CJ UJ IV O UJ o rr> 3 »-H <t o <t U_ U- 1— ^ >- z ca o cv ru £ 3 UJ t~ z n_ o z I— -i CD UJ UJ 13 i-t -- CV ^ id IU IV 3 «i ^» O *c CJ UJ X 1 rv. UJ Zt_ >- z o CO ~z .-c z H ru o CO < •UJ t/> <t i: £ UJ M o z ru i; IV UJ CO —. z CQ UJ Ul 1- o a_ 1—i o_ >- or o •— ri UJ UJ _l UJ UJ o a_ o_ o UJ 3 UJ X UJ t— CO UJ -i LJ CV in a rv >—i «x •-• —• --c a_ K- iUJ cO UJ _l 1— —« •— ^ 1 CO UJ z o UJ CO 1— Q n_ 1/) »— -X '3 > —• UJ u. UJ id ~i iv •— or "« UJ z o >- o »-i u. _l Z UJ Q -X >- 1— —1 3 ** a. Z >- id UJ »-* z. o o X l~ _J UJ UJ LiJ UJ id >— UJ •— •—' i"i u Z iIJ uo ~x cv o o r— UJ -X UJ IV _1 -I CQ Q il z UJ fO rv z rv Z a. 3 U- >- Q •— UJ tIV '3 t- z UJ UJ UJ n. a_ r* o o o IV z n_ IV UJ v—i Q >- ^~ >- <L O •u. o o ca > cv o ^ o w: o o <a o t— •—' o 63 CK UJ Z Q. >- >- 2 -t X UJ o o z *i LU o i: •X •—• _l u I— -1 O UJ -I U- o UJ CK o X LK UJ _1 -i o z UJ _l CK >—• o *— UJ £ o cj UJ •*i U_ -1 z —i y~ t— © U- o »- 1— rz> 2 CK o 1/) co *— UJ •— o_ CO UJ IK UJ _1 IK UJ h_l «I Q UJ z o z u_ o UJ -X _1 CO z. CK UJ Q UJ UJ o _l _l •—1 UJ •—' 3 *•*• UJ o z t— u_ o 2 t— _) • »— > > •—1 o • CK «t UJ o CK CJ IK cj z _l o <c o t 1 1 1 I 1 1 1 1 1 t 1 1 CO u_ o u_ o u_ o u_ o u_ o u_ o CO 3 y— CO 3 I— CO 3 •- CO CO •- -I VcO <£ yCO 1 u_ o U- 1 »•—• 1 2 Ut— IK Z CO 3 I— CO u_ CO 3 V- -X yCO CO 'I VCO CO CO o t— *t 1— CO t— «i UJ CO -t X O UJ t— UJ yUJ •UJ UJ 1— UJ y— UJ X UJ CO CO CO CO CO CO CO CO _l CJ o ru — «i V- V3 cu o »— 3 \h- »- r> => ^<c <c ^- >— 1- *M "^ UJ t— <t -3. -t z y- o *— ZD CO CK UJ y~ t> X 1— «t X 5. z o ^ <J UJ o UJ o o_ -I LI- >- •— y— UJ i y-3. a o <t t— _) a >• o CK UJ CK UJ U. UJ »— U_ Z) -1 _1 o CQ •"" Z -• r«* •o _i oa <x CO CK UJ CJ o_ •X <c o -« »-• o »—• o Q <c UJ CO CK UJ »- <J -=t CK •a X cj >- 3 o h- y- ^— CO o o z> o aH »—• z LU LU o z z o z o CO —• <t CK X t— z CK O Lc z o Lc U. O U_ U_ 3 -u u HCO CO a o> X X <J z z 3 ZL o ^ CK O CK O o o o o I— •- CK CK UJ CK CK LU z <-> -i CK «t X «; o -1 — >LU M •—• 1 -3. UJ IK O I— o z •—t o _) _i <t LU —i CK Q UJ — QC 1- CW CKJ •a a LU 1— —1 OS M "~• <a a CK Cfi( CKI O) CKJ X! 1— u. CKl 31 2: UJ X LU 1— UJ >- #—• 1— CO y— -1 UJ —1 CK y- UJ _l X •—• o -=t il Z LU X LU 1 o Z V- y— •X UJ •—• -1 -J _l •— •-. CK UJ 1— o o CO X LU u. <t UJ s: 1— UJ _J CK -J o CK UJ »— CK Z o •— CO U. o CO •— z o Z «t UJ z z 1—t o o ^• -J z o o_ 3 z »- CK :> «\ -. UJ i— t— s: ^ >u. co <t 2: UJ t— t— a. i. o CK UJ z CK t— n. _1 CK UJ U_ *— z o X t I u_ 1 o> >_) _) <t UJ -I 2 1 1 •<; 0- z^ 1 1 CK UJ X t— CK a. z 1— -i lcO UJ Q z u_ ru UJ V UJ CO 3 UJ 1— X •-« — UJ X LU _l <c d •3cj u_ CO 1 M u. o o _l ^- <I U- UJ »— o s; CK UJ 2 «I 2 —• _1 UJ ^ Q£ *— UJ -I 2 UJ X UJ CO 1C LLJ -i »- CO *~* •""' •""' ^i z 2 o z 2 CO «x u_ o z o V o UJ _J z o o UJ X h- •— UJ ii- 1 o IK o _1 a_ a. t— <t IT u_ o »£ z IK tcO LU C3 J o <t 1-U CK UJ 2 UJ UJ >- -1 o_ Z o 1U _J >- u_ u_ o > >— z UJ <t LU _l 2 (K UJ CJ CO *t 2 «t •—• 2 UJ _l U- o u_ o -1 •—• cO UJ —• X y— UJ cJI cq O Ll_ o Lu c0| M ai -I ZJ »— -* •—• « U4 t—• APPENDIX VII 64 MISCELLANY A. OTHER RESERVED FUNCTIONS DATA TYPE FUNCTION NAME FIXED B. SIN ARGUMENTS NOTES FIXED; part of IT; i.e. , .5 = 90° SINE REAL SINR REAL number in radians SINE FIXED COS FIXED; same as SIN COSINE REAL COSR REAL number in radians COSINE FIXED ATAN (AX, AY} both FIXED ARC TANGENT REAL ATANR REAL number ARC TANGENT FIXED SQRT FIXED SQUARE ROOT REAL SQRTR REAL SQUARE ROOT FIXED PYTHAG {X, Yj both FIXED computes SQR {X2 + Y2] REAL LOG REAL LOG10 REAL LOGE REAL LOGe REAL EXP REAL ex LEAP. BIN MODES The "bin" command to VITAL may be followed by a vertical bar, and an octal number. 1. I 1 causes the LABEL table to be Xeroxed 2. \ 2 causes the SYMBOL table to be Xeroxed 3. | 4 causes a formatted listing to be Xeroxed 4. | 10 disables the compilation of code to check subscript bounds and SWITCH bounds. 5. 120 disables the compilation of code to check the data type of LEAP items when y is used. These mode numbers may be combined: e.g. C. I 7 causes all three listings to be Xeroxed SYNONYM FEATURE One may define a synonym to a declared variable or to a procedure in LEAP; for example, if XYZ is a declared variable or a procedure, then W =XYZ: 65 is a DECLARATION which will assign the "semantics" of XYZ to W. Subsequent reference to either XYZ or W will have identical meaning. D. NO KEYBOARD BUFFER OPTION The following declaration, occurring anywhere in a declaration portion of a LEAP program, will suppress the assignment of a keyboard buffer at run time: NOKBBF; E. SEGMENTING A LEAP PROGRAM DIRECTIVE There is a feature in LEAP which allows the compilation of a LEAP program from text files rather than from a VITAL directive. This is useful if the directive is larger than two books, or if core space at compile time is at a premium. Only one text file is set up at a time during compilation. Note that: (1) The user cannot ask VITAL for a program listing, or for a formatted listing. (2) Compile-time error messages will usually be garbled. The use of this feature is described below; The user deals with his program in text file form. He may direct the compiler to take its input from the keyboard, and proceed to specify the text files which are to be read in. The compilation is then performed. The user directs the compiler's attention to the keyboard by asking to compile a program consisting of one special word: GETFROMKB He specifies that a text file be read in by typing the name of 66 the text file followed by the READ-IN key. For example, if BLOP is a large program, having TAG as a label about halfway through, then the following sequence of events in VITAL will compile BLOP: TYPED BY SYSTEM CLEAN USER ^L 5LEAP USER r>*C BLOP ~DIR F|| #-TAG ^DIR FF|| TAG- ? USER USER USER AFRESH SYSTEM FRESH USER -INS USER # GETFROMKB USER m USER •"-BBIN USER F USER FFH) ® SYSTEM F. OTHER RESERVED PROCEDURES 1. SHADE; This causes the user to go into the shade. HELP; This causes a HELP call. 3 . ASSIGNRECOGNEER ( <TEXTARRAY >); The TEXTARRAY parameter indicates the name of the file which is to be used henceforth as the character recognizer. 4. There is a reserved procedure which calls the character recognizer:* RECOGNIZE; When this procedure is called, a full inking buffer should be available, and the ASSIGNRECOGNEER procedure should previously have been called. c For information on the TX-2 drawn character recognition facility, see r<=>forvsn<-p 3_ 67 The following reserved variables will be set up by the procedure: aCHAR aXMAX aXMIN aYMAX aYMIN o-XCEN aYCEN (INTEGER) (FIXED) (FIXED) (FIXED) (FIXED) (FIXED) (FIXED) character code (-1 if no recognition) maximum X coordinate minimum X coordinate maximum Y coordinate minimum Y coordinate X coordinate of center Y coordinate of center EXAMPLE: (reserved words are underlined) START INPUT (FILERECI; ASSIGNRECOGNIZER {REC}; GETNEXTINT; IF aCAUSE = 17. THEN BEGIN RECOGNIZE; IF aCHAR = -1 THEN HELP; END; FINISH 5. A reserved procedure for "going up to" the character-recognition trainer (5TRAIN). This procedure expects the ASSIGNRECOGNIZER procedure to have previously been called. TRAIN; 6. A procedure which takes a TEXTARRAY as a parameter, and "goes up to" the scope editor EDIT { < TEXTARRAY >}; 68 7. Two reserved procedures for allocating and emptying books at run time: (a) FREEBOOK - an INTEGER function which requires no parameters, and returns the number of an empty book (1 thru 17) as its value. Book 0 is automatically free for use; allocation of other free books must be done through FREEBOOK. (b) EMPTYBOOK f<INTEGER quantity > }; A procedure which causes the indicated book to be emptied (JED 123). 8. KEYBOARDEDIT {<TEXTARRAY> ] ; This calls the keyboard editor, with the indicated TEXTARRAY as input. It works just like the EDIT procedure. 9. BASICTRANSLATE [<TEXTARRAY >} ; This passes the indicated text up to 5BTF. 69 G. EXTERNAL PROCEDURES This is a facility for defining a procedure or function that during run-time will exist outside the LEAP system. The experienced user will find this useful in linking MARK 5 and LEAP programs. The following is the external procedure declaration form: EXTERNAL <LOC>, <normal procedure definition header>; where LOC should be an octal integer constant defining the absolute location of the procedure and a regular procedure definition follows. Example: EXTERNAL 411. ,REAL PROCEDURE SUMSQ {REAL Al, A2}; defines the real function SUMSQ at location 411 o with two real arguments. The calling sequence generated by LEAP is JES1Q LOC address of argument 1 address of argument 2 * address of argument n expected return point - H. LIST OF RESERVED WORDS AND SYMBOLS Note that all Mark 5 op-codes are also reserved words in LEAP. 70 a s, £ b a * —• i- O 2 UJ of a: 4 ddssssac 2r 3 >- Q <x <i o n. HUl cJuJco_ioa.ri.x a. fc s a: — 9 fi £ o G -t X A St • w t ^ Of •- o O -I 3 X !*s _i 55 fcj UJ o en i8 o co & £ 3S5l2553g8(fi?2ii:^yi«!H!liSSef UJ 3i« UJ a. o UJ w 00 z £ Uj O? d a Q o O _l co cj UJ IK o i- w ul CO 0£ UJ cj t— a: o cj y UJ a * 5 t~ UJ CO cO o a; Q o UJ IX. < ?y & s 3 M < UJ 15 35 a: UJ i z o CO z u u_ E 5 5 X CJ I— 3 Q. •— -J »3 Q. a 5 o_ u: to ii; u: u: & «T OT 01 €0 «/} lO UJ < 1J 6 3 o y d OUJUJUJ-iUJUJ—.t-CD co x o o o; z IL £ t— i- t- f- 3 UJ cO *- 3 < — < > 3 o 3 UJ :> a B£ ct o z § UJ s & UJ 3 « Z UJ o 2 % •£ P s UJ UJ 3 3 O UJ co CJ UJ a: y- UJ S ^ 1— z z CO O Z co UJ ct i—• CJ t— vj e. a _ x .5 u 2 ^ o a: o <x CJ Q: 2 £ ts y & - S 5 y % ssy t^aa^ygc: UJ o: •— Q O UJ s ^ 3 5* sayy £ i *£ 47 £ 3 Z~OUJU-ZC0UJZOUJ3O333QUJLL1I- ujuJu-u-O"— •—•-• i^^_is;za-Q_a-o_a:a;a:a< Q «X »- »- o <t _i x o o «t n. UJ —• uj ui x *- co UJ o o O! >• 3) « CO CO </> to »— »— 1-1-3 3 CO 3 &5 z o •—• 2 » «i <i z •— 3 a. 0H 1i- 3 CO o z Ct -i t UJ b z Ul "Z. a y y s a CO CJ <_> VJ Q z 1- o Q _1 u. O ui CO >2 5 % II z 0? ^ Q. V I £ ^ z CO Q 32^ {5ujdz:«£z';§ UJ Ul u. u_ o x •— —• "-• i^_i X a: li: u. Z > >- 0. 0. CJ % CJ Ui 3 Z 3< O O O UJ ul u. 15 o S & 5 O z cO s 9 3 y S >•• Z K O -1 0. a: V- Ul ^ ^2 »— UJ !4? — •! S o Ul cO UJ Z (t a: o z E a. Ul «I UJ »- s^u^s cjOZQfc0<3 a t- QiZOOitZO. UJ > o OUJUIUJUJUJUJOt_> B936El!2t6 o_ OCOiOiCiiUJcOcOcOtO o; ct 3 0_ a% Ul X CO »- z ffi % ° s ID n « u 3 15 S a. CO 8 t- a: ^ Ul " ci? co CO CJ CJ ss»- W Q u. £ y Sr ?£ UJ UJ UJ «»» j ac <t —i X z UJ 4 h t- ui n: CJ >1/J > •— «/> o t— S3r^ a •— -too 5 ^W!S5 5 o a UJ UJ ul Ei £ % 3 BJ Q_ CO CO CO CO CO CO Z (2 UJ 1 5 n_ co UJ t«t > — tyj s *— z b. U. X a 5 CO X 3, 3 o o t- 1— Q. o o; C -J t- UJ CO 3 x to X 3 cE UJ x 71 y CO 1 UJ ai z •I Ui t— ul x o 3 £ ts s< o UJ n_ •- t— PzzSigays xi— ujt-caua-ZZ'5*tz UI-JKV-X>--~ZHD . t^ O U UJ _l CO UJ _J UJ <t hi 2 fc 6 i/) 9 3 CO h- h h X X -X ^ <aK&23riE-2&z-5*a? "UJOV<lQit-^>-UJ>CO 3 a as S3 w ai I- Z "> y-> UJ </) X 9 »- 2 •— X iS 9 » & !j Vrd a 5 a £ 2 o y •t'-'zaccoxvjxzuji— a: ill _1 O* »/> o a: rt ui «M UJ CO vc >- g o — io: 3 Z ^ 05 S CO »- O Z, Z_IOZ_ICJ— O£ _i Z <>* co o 3E CO O t- o <* z UJ *£ CJ < 3 £ £ 2 Pfc^SSSy^ -I co £ S CJZ— £<I>- UJ a UJ -i £l-~.OUJQ.UJ •£ & 8 9 a: < Q zt-x<t2:co»-t->2 .fe 2 Si 5 *o2~t£uj°iA£ <jD u»^i:io »-xo— ^ a. i- s Q O n rj Q Q OQ CQ <X} CQ CQ CQ 72 o en zc >~ a UJ to UJ K — - -wDUii.^ t* K m >- t> N a c asa w tO «x </> ft. Z ft 1 = *• 73 HVAV|AI<>I"»K/W,-,0 III . - d) - >- « O 74 APPENDIX VIII PRIMITIVES FOR DATA-STRUCTURING This appendix presents a user's-eye view of the data-structuring facilities in LEAP. The first part of the appendix is a condensation of * a paper on this topic, and is included here as a user's introduction to these facilities. The remainder of the appendix is an annotated tabula- tion of the language forms for data structuring. Part I. Introduction to the Associative Sub-language The basic data-structure entity used in LEAP is an associative TRIPLE of the form ATTRIBUTE of OBJECT is VALUE (e.g. , FATHER of JOE is PETE). The data structure is a store of facts in this form. The hash-coded nature of the data-structure makes it amenable to paging techniques. Programming constructs are available for creating, deleting, and searching for elements in the data store. Of particular importance is the uniformity of the single data form used. A LEAP user does not have to consider the details of a complex structure in computer memory; he can concentrate on what he wishes to represent and not how to represent it. The programming facilities available include set-theoretic operations, a powerful fact search and retrieval facility, and the ability to use a TRIPLE itself as a component of another TRIPLE. In the discussion below, reserved words in the language are underlined. A. COMPONENTS OF A LEAP DATA STRUCTURE Conceptually, a LEAP data structure consists of a universe of •kic ITEMS, a universe of TRIPLES, and a number of SETS. 1. ITEMS An ITEM is an entity whose "internal identifier" (name) is manipulated by the LEAP system. An ITEM may have an associated "datum", this must be specified to have one of the data types of the base language, * For further details, see references 4, 5, and 10 **Not to be confused with "display items". 75 which wo will refer to as "algebraic types." Some allowed algebraic types are listed below real * integer boolean fixed (real, integer, boolean, or fixed) array For example, the declaration real array item. LINE4 ; would specify an entity, LINE4 , whose datum was an array of real numbers, perhaps containing end-point coordinates. The LEAP language contains elements which are used only as algebraic quantities, only as names (ITEMs without algebraic type), and in both ways (ITEMs with algebraic type). The LEAP language has various statements for creating ITEMs and entering them into the initially empty universe of ITEMs. Declaring an ITEM will enter it at compile-time; the facilities for dynamically entering a new ITEM at execution time are presented in Section B. 2. TRIPLES The TRIPLE is an ordered collection of three ITEMs and is used to represent a fact in the relational structure. A TRIPLE is created and entered into the initially empty universe of TRIPLES via the MAKE statement. For example, if FATHER, JOHN, and PETE are ITEMs, then execution of (1) make FATHER- JOHN s PETE; (read "FATHER of JOHN is PETE") will add the indicated TRIPLE to the universe of TRIPLES. In (1), and "=" are reserved symbols. A TRIPLE may be removed from the universe of TRIPLES via the ERASE statement; (2) erase FATHER • JOHN = PETE ; 3. SETS A SET is an unordered collection of ITEMs. SETs are created by a SET declaration, (e.g. , set SONS;). *In this appendix, reserved words are underlined. 76 initially, a SET is empty (has no ITEMs). An ITEM may be added to a SET via the PUT statement: (3) out JOE in SONS; An ITEM may be removed from a SET via the REMOVE statement; (4) remove JOE from SONS; 4. ITEMVARs (ITEM variables) An ITEMVAR has an ITEM as its value. An ITEM (e.g. , JOE) may be assigned to an ITEMVAR (e.g. , X) via the assignment statement: (5) JOE - X; X now "represents" the ITEM JOE in the sense that the following two statements have the same meaning: (5) make FATHER• TOE s PETE; (7) make FATHER.X = PETE; ITEMVARs may be declared with or without an algebraic type (example: real itemvar X;). The algebraic type specification is necessary in case it is ever desirable to retrieve the datum of the ITEM that is currently represented by the ITEMVAR. In such a case, the system assumes that the algebraic type of the ITEM represented is the same as the algebraic type of the ITEMVAR. An ITEMVAR may always be used in place of an ITEM. 5. LOCALS A LOCAL also has an ITEM as its value. The LOCAL is used as the iteration variable in the FOREACH statement. It is used as a "local ITEMVAR" within the scope of this statement, hence its name. A discussion of the FOREACH statement and the use of LOCALS is presented in Section G. 11 B. DYNAMIC CREATION AND DELETION OF ITEMs 1. DYNAMIC ITEM CREATION There are two ways to create new ITEMs dynamically (at execu- tion time): (a) via the statement (3) new it em -. X; where "X" is an ITEMVAR. This statement causes a new ITEM to be gener- ated and assigned to the ITEMVAR and space allocated for its datum (unless this is an array). The algebraic type of this datum is assumed to be the same as the algebraic type of the ITEMVAR. If the ITEMVAR was not declared with an algebraic type, then no space is allocated, and the new ITEM is assumed to have no datum. (b) via the unary operator, "n ". This operates on an arbitrary algebraic expression and yields a new ITEM having the evaluated expression as its datum. 2. DYNAMIC ITEM DELETION The following statement removes the ITEM represented by X from the universe of ITEMs. (9) reclaim X; Execution of this statement causes the internal identifier of the indicated ITEM to be placed on a list of available internal identifiers, and the storage allocated for the datum of the ITEM (if any) to be returned to free storage. ITEMs which were declared via an ITEM declaration may not be deleted. It is the user's responsibility to make sure that an ITEM is not a member of any SET nor a part of any TRIPLE when it is deleted. C. THE ITEM EXPRESSION Thus far, we have mentioned three ways to represent an ITEM: (a) by a declared ITEM identifier (b) by an ITEMVAR which has been assigned an ITEM (c) by "n" applied to an algebraic expression. 78 Wc will classify these as "ITEM expressions." An ITEM expression /nav always be used in place of an ITEM. In addition, a TRIPLE form can be an ITEM expression. ture allows the use of a TRIPLE as part of another TRIPLE. This fea- For example, the following statement creates a TRIPLE which expresses the idea that "the number of lines in a square is four": (10) make NUMBER-(PART-SQUARES LINE) s n 4; In (10), "NUMBER," "PART, ""SQUARE ", and "LINE" are ITEMs. The TRIPLE PART• SQUARED LINE should exist in the universe of TRIPLES before (10) is executed. The ITEM "NUMBER" is meant to represent an attribute which applies to all part-whole relationships. D. SET EXPRESSIONS A declared SET is a SET expression. <P is a SET expression (the empty SET). A list of ITEM expressions separated by commas, all enclosed in brackets "{" and ")", is a SET expression (example: [PETE, JOE"!). Two ITEM expressions combined by one of the binary association operators (. , ', *) is a SET expression. The evaluation of these SET expressions requires extracting information from the universe of triples, as follows: If A and B are the two specified ITEM expressions, then (a) A-B is the SET of all X such that A.B=X (b) A'B is the SET of all X such that A-X = B (c) A*B is the SET of all X such that X'AS B The special reserved word ANY may De used in place of an ITEM expression in a binary association operation, implying that any ITEM in the indicated position will match. 79 Example: (11) FATHER-ANY is the SET of all fathers. E. SET STATEMENTS The SET ASSIGNMENT statement may be used to assign an ar- bitrary SET expression to a declared SET, (e.g. , (12) SONS U BROTHERS - SONS) There is a special statement in LEAP for performing a task for each ITEM in a SET. For example, if SONS is a SET and X is a LOCAL, (13) foreach X in SONS do <STATEMENT> ; will cause the <STATEMENT> to be executed once for each ITEM in the SET. Before each iteration, the next ITEM in the SET is assigned to the LOCAL. Within the scope of the FOREACH statement, the LOCAL behaves like an ITEMVAR. A complete discussion of the FOREACH statement is presented in Section G. F. LEAP OPERATORS WHICH YIELD ALGEBRAIC RESULTS The binary operators "e", "c" , and "=" and the unary operators istriple , "Jj", and "y" yield algebraic results. Four of these operators deal with SET expressions: (a) <dTEM expression> e <SET expression> is a Boolean expression which has the value TRUE if the indicated ITEM is a member of the indicated SET, and FALSE otherwise. (b) |! <SET expression> is an INTEGER expression whose value is the number of ITEMs in the indicated SET. (c) <SET expression> c <SET expression> is a Boolean expression which has the value TRUE if the left operand is a subset of the right operand, and FALSE otherwise. (d) <SET expression> = <SET expression> is a Boolean expression which has the value TRUE if the left operand equals the right operand (i.e., the left SET is a subset of the right SET, and vice versa), and FALSE otherwise. 80 The unary operator "y" (GAMMA) operates on an ITEM expression to yield the datum of the indicated ITEM. For example, if PETE is an INTEGER ITEM, then the following statement assigns 40 as the datum of PETE: (14) 40 -y PETE; The unary operator istriple operates on a TRIPLE form to yield a Boolean result. This result has the value TRUE if the indicated TRIPLE exists in the store. G. ASSOCIATIVE FOREACH STATEMENT There is a special statement for retrieving information from the universe of TRIPLES. It allows one to specify the context in which the information of interest is to be found rather than a procedure for finding that information. For example, the following finds PETE'S sons: (15) foreach FATHER-X= PETE and SEX.X= MALE do <STATEMENT>; In (15), X is a LOCAL. There are two "context specifications" in (15): (a) SEX-X= MALE (b) FATHER. X = PETE These serve to determine the collection of ITEMs represented by the LOCAL X. An ITEM will be in this collection if and only if it satisfies all "context specifications." In general, there may be many "context specifications" in a FOREACH statement. At execution time, a collection of ITEMs is calculated for the LOCAL from the context specifications. The <STATEMENT> is then executed once for each ITEM in this collection. Before each iteration, the next ITEM is assigned to the LOCAL. Within the limits of the <STATEMENT> , the LOCAL is treated like an ITEMVAR. The difference between an ITEMVAR and a LOCAL is only that the LOCAL has special meaning within the FOREACH state- 81 ment and no meaning outside of this statement. An ITEM may be assigned to a LOCAL only by the internal action of the FOREACH statement. This action is said to "bind" the LOCAL. Within the FOREACH statement, the LOCAL is termed "bound." Outside the FOREACH statement, the LOCAL is undefined. FOREACH statements may be nested; a LOCAL which has been "bound" by a FOREACH statement is treated like an ITEMVAR everywhere within the scope of that statement. More than one LOCAL may be "bound" by a FOREACH statement. In this case, if there are N LOCALS, then a collection of N-tuples of ITEMs is calculated when the context specifications are processed. The <STATEMENT> is executed once for each N-tuple in this collection; the appropriate ITEMs are assigned to the appropriate LOCALS before each iteration. For example, the following statement would create all paternal grandfather relationships: foreach FATHER-X = Y and FATHER-Y = Z do make PGRFATHER-X = Z; Usually, the three operands of a "context specification" of the TRIPLE form may be any ITEM expressions. There are cases which are ill-defined; the compiler makes the following restrictions; (a) At least one operand must be a LOCAL which is being "bound" by this statement. (b) The three operands cannot all be LOCALS which are being "bound." (c) The item expression n_<algebraic expression> is not allowed. The following constructs (specified in BNF) are other allowed operands for a "context specification" of the TRIPLE form: <other allowed operand> : : = <ITEM expression> <binary association operator> <LOCAL> | 82 <LOCAL> <binary association operatorxlTEM expression> I <ITEM expression> <binary association operator> <other allowed operand> An example of the use of these constructs follows. In this example there are TRIPLES having the following forms: ABOVE-SQUARE s [OBJECT] PART-[OBJECT] = [LINE] "ABOVE," "SQUARE," and "PART" are ITEMs, and "OBJECT" and "LINE" represent the meaning of ITEMs found in the indicated context. The following statement will display all objects above the square; (16) foreach ABOVE.SQUARE = PART ' Z do DISPLAY {YZ}; In (16), "Z" is a LOCAL with declared data-type REAL ARRAY, the DISPLAY procedure expects a REAL ARRAY (representing a line) as a parameter, and an ITEM which represents a line has a REAL ARRAY as its datum. The statement (16) may be expressed another way: (17) foreach PART-Y =Z and ABOVE • S QUARE = Y do DISPLAY fYZ]; In addition to the TRIPLE form the following construct is allowed as a "context specification" in the associative FOREACH statement: <LOCAL> in <SET expression> This "context specification" restricts the collection of ITEMs represented by the LOCAL by requiring that each such ITEM be an element in the SET expression. NOTE: Do not attempt to terminate a foreach statememt by a GOTO to a label outside the scope of the statement. 83 tn C -—< 3 0 —J U —I CO l 0 •a CO g - c c A en a In a) O l-H c C 0) c ro A uw -a -a o o w 03 iH —H V V c > £ c "N >. ca a, o u a ro £ > g 0) 0) •*-> c rO ,_, 0) ro U O CD ro 0 CD •*-» •w 3 — ra H -c c — —^ c •—i o o XI o •—4 >> >1 ro u ro •a r0 10 ^ X CD +-* 1_ CD Or CD CD •4-J c •<-4 0) S-, CD t! <—t ro CD u a C (0 1) CD +•> c •r4 T3 CD X Ja *4H b4 CO •»-> co XI (D CO U a eu 4-J ID O CD X" r. --4 1-. CD CD -C 4-J CO 13 X! XI o CO w H O S 5 2 w H i—i 4-1 •~4 4-J C 0) X> --4 • 1 it) C CD 4-1 c --4 4-1 --4 CO CD 0 i- co ID X C ca 2 H H 5 CD C 4-1 0 CO i—i XI G tfl --4 CO 0 to C i_ 0 Oi 0 •*-> C ca CO CD J-J CO S-H CD C CO CD —4 a x: 5 CD P H 4-1 c 0 CD —i 1-4 4-1 CO co •—1 co "a E >-. CD' CO 4-J •~4 T3 CO CD C O --4 o XI --4 CO (D x: l-i ca x: CD x: x; w (X 8 £O X CD (A +-> ID 3 ca > H t—t c <a -<—* o -—< E 4-1 O c CD 4-> --4 CO +-> >-4 +-> 3 4-J fD CO E 3 J-> C CD co CD (13 X CD —i £ 4-> CD !-, a O XI CO 4-1 CD x: 4J CD 4-J C ID CD Cn --4 CO 4-4 -—1 CO X C 1-1 —4 4-1 CO CD CD C CD —4 x: +-> CD XI 4-J 4-1 X 0 x; 4-J CO -~i x: 5 CD E CD 4-J a E t-. +J —4 c -a CD -—i 4-> 4-> CD x: CD 4-J Co CD 1-. 4-> •^4 4-J 0> u £ O x: E 3 -M x: x: 4-J -a --H --4 x: o *^4 CO --H CO XI U CO —4 1-1 4-1 2 £ 4-> CO ^-^ 4-J E ID o CD —4 4-J —i x c X --4 x: -a 4-J C £ CD 4-J C CD o x: u 4-J CD CO CD x: 4-4 CO 4-J 4-4 O E a 4-J X x: E 4-J CO 4-J CD C CD XI 4-J CD CO 1-1 a 1-4 U CD CD CD CD IH IH 1-4 1-1 Ao A a A C --4 ra , , CO W CO CD i-i CC Cu o a X w —4 CO CO X CD • :> w £ 4-J —4 X CD 4-J CD co o a o --4 O !-• a X CD 1-4 CD CD 4-J CO CO CD 1-4 a X CO !-• A HJ < £ CO V 4-" o -r-1 c ID > £ 0 —4 > £ CO Io 0 -^4 1-1 CO a X 0 fO 0 V 0 +J V T T A C o o 0 IH a X 0 £ 0 4-> --4 V A o c o —4 —1 CO CO CO co 0 i-i CO CO 0 0 1-4 a •H do —4 Q. X 0 S-H -•-4 CO CO co en 0 CO CO 0 1-4 £ E E 0 !-• a (X X 0 4-> £ X 0 X 0 4-J -~4 4-J --4 £ £ V V V CO 0 IH a X 0 o o CD CQ 4-J --4 T3 V V V (0 4-J c (D i-i n CO !-• CO A 4-> -^4 H H i—i H CO 0 a> 2 w C O --4 X 0 V 0 V 0 1-1 2 A i-i o o o III CO CO Q, X3 CD c V ••-* CD U 0 o 1-1 U CD 0 *. a CO X V A C i-. 2 CX u 4-1 o CO CO CD CO 0 CD A C 0 E 0 4-» 0 0 X 0 0 0 0 3 0 0 CO 4-J —4 4-J -—1 V V V Fl 1 1—1 1 CNI O CD o i—i C/Q CD 4-1 4-J GO O •-4 x; 4-> X a —4 X C 1-4 •^4 CD CD CD +-> ID O x: c CO CD 4-J --4 CD [co 3 4-J CO x CD x: 4-J 4-J 4-1 51 CD xj 4-J E o 85 _Q X C c ---< l— X X III III 111 X X • CO (0 IU X J* J* X • c o "H -*—' o co CD w O c o c 2 +-> o CO CO IH o c -*-» o co c o 4-J o ra o i« 0 CO (1) +-* CD C o >, CD IH CD . H-t o > i-, >> u o c o X c III 3 •i—i co CD CD x X CD X to CO co G o 3 ••H >. rO CD CD Ui £ o c c o -—* c 3 0 c 3 CD X X CO CO CD 3 <D a <—i -t-i > CO r0 CD > > CO XI X a X * X X CO rO "rO > CO "3 > •<-t 1~i CD > u. •—( ra 1- ' > O 3 (0 co ••< co 3 •a X CO 4—» •—I CO 0) o .a -4-> c ""' •~i 1— X 4-< X III X rO j* rO co ~x 3 •*-» •—i CD rO CO > X * ro •»H CO 0 i—i CO CO X W H W co ca X CD *J O co V A i— IH co C O A X co a a A IH X CO a CD 2 S CD OS 0 d* £ 13 o 4-J w -—1 V 1—1 a ra 1—1 X o X CD -a ••H c •M CD f 0 n o CO CO CO CO V V cr. V 1 V 1 X A u A A A <D IH u, s- X X G (0 a CD o o V IH -r-> C CD 4-> CD CD CO A CD 4-J o A a CD a X o •4-J CD a X o +-> CD CD +-> CD CO CO CO CO V V V V A A a X o £ CD •—i o o A CD CD e CD "H a X A A IH a X a X B CD CD +J *•> 4-J CD CD CO CD A a X CD CD CO V * <5 • - * A A A A A A (-. IH IH !-• IH u, X X X X X X CD CD CD a CD V V Q. a o CD S S CD CQ V IH - V • CD A u a X •rH V V V a S o a 6 III CD X a CO K V a £ +J CD CD •!-> -4-J V V V X CO •*—* o CO 86 CD CD CD XJ 4-1 O c 4-> CO CD CD +-> c CD X o S-i E CD CD c --H X 0 CD x; 10 4-> CO w H o o -.-1 2 CD 3 "TO • > -a c -—I E 3 C CD -i-> "Jo > a CD x; +-> en ro in 4-> CD Cn -a CD -M 03 O X CD 3 u CO CD XJ ex o cn c 1-1 fO CD c CD -C +-• 4-4 .—1 C CD en E •*-> t 0 x: —< 4-1 --H X o X) c 1-4 c •—1 • —i CD —i x: J-J 4-1 CD x: CD +-> i-i CO CD x: E .—i E CD +-> 0 CD CD 4-1 4-> E o ro 0 -C +-> 4-1 •—1 w o p a; £> H H M BJ • CO CD i—i a i-i CD X! +-> <+-< -^ w & OS H CD E ro 0 x: •—I U 4-1 E 0 ro o o en 4-> X 0 +-> 0 X CD 4J o c XJ CD -C CD 0 u ro +-> CD +-> (0 ro c —1 -(-> 4-1 o £ 3 +-> (0 X CD X +3 en •—1 CD _3 ro > c l-i ro ro c o 0 en E CD 0 +-> +-> 0 o O +-> •1-1 0 4-> CD xj 4-> 4-1 —1 u S5 Qi H 0 x: •M 4-4 —4 w 1= a; H 0 O X! •M o 1-1 C 3 CO o CO ro 3 +-> to ii en E —1 4-1 CO ca --* o 0 x: CO CO 0 CO CO cn E 0 s 0 J3 +-' 4-1 w p tt H E ro en +-> +-> 4-1 . a 0 1 0 -C •(-> 0 4-1 -—4 •M w x: ro 0 ro E o X ro +-' 0 +-> 0 en :=> OS H 0 en 4_J 3 0 i-i 0 X en ro ro o -i-i -—4 4-4 •^1 ---1 1-1 -a W ^> a! H -a 0 en 3 x: CO c o —i CO en 0 i-i a x0 E E 0 0 co 0 O XI i—i CO CO c^ w w O w H 2 Di W o w H s H i-l O o CQ < w 2 < w o o CQ O O < 0 >1 CQ < § a a a o o O o o o CQ CQ CQ 2 < ^ o o CQ 0 -C < a O O o 5 CQ O en O CQ W ro O 1- iX X 0 0 o ro E 0 +-> a. —H V c III x A 0 i-, a X 0 0 E A • 1-4 X 0 +-> 0 ca V A IH 2 as O a X 0 E 0 —1 A ii a. A 1-4 0 •^H V A • ii 0, E -S3I 0 .V, -i-i 0 0 0 en E ^4 0 1-1 V V 4-> --H " ~ V o u a V cx X t 0 a X 0 X 0 A +-> en A i-i a X 0 E 0 A A i-i a x 0 u a x £ E 0 v A S-i a X 0 B 0 -t-> 0 V A i-i a x 0 u <x a x0 0 en V V +-> 0 CO V 0 £ 0 A A 1-4 1-4 0 X 0 a x 0 CO V X 0 U i-i 0 A i-i 0 A a x A V V 0 en V ro b ro I x i-i o X 0 -t-J V 0 i-i 3 •M u 2 en w X 0 0 eo 0 1-4 0 X! H 6 CJi ro c •a *-> H3 u 1H T3 -r-l C 0 1-4 is. CD c ••-4 (0 o 1_ 0 c 0) • 4-" CO 3 IM CJ .—* a •a c 3 CJ IM t3 a 3 5 CJ 3 cu 4-» CQ 3 4-4 u -•-> 3 u (0 4-< T3 3 >-, (0 4-» c CJ 00 u 4-1 O 2 "cD CJ " 0) CO 03 CO .—1 a 4-» O o X) 0) 3 co IM 0 X) • CD CD > *-• -4 -1 03 .£ co 4-1 (0 -a c §•0 CO C CD IM 4-» •*-* CD i- co m u 3ro.H 4-< C CD CO 1-4 +-» CD TJ •a .-o xs > (0 to CD -X) fO c .CO-—. •*-> •—4 CD u CO U CJ 3 CO •M -o IM 3 u CO CJ s: +-> iO a, to 0 u X! 0 -D C en C A 0 .C •~4 ^4 u. p E 'ro U x o 4-» X 0 O 4-4 IM A X o 4-J u A £ 4W c CO CO IM IM X CJ 0 (0 a CJ —4 CJ CO i- E C X 0 0 E o 4-J -«-H X c 4-> CJ CO u JS 4-4 44H v ox; O > 4-> 03 CD CJ O CJ > 3 X o 0 4 ' CO a N ---4 i 1 0 X 10 c 4-4 CD CO C 1 a (0 CD W-. CD C U 0 X 0 E c 4^ 0 to c & 03 0 •si 5 o o »—4 C2 A 03 U CD C • •* V _0 U O % X! v r—1 X C c £ rD U CD C CD DI D> CD CO CO —c 03 A co co (0 W A ~u A •03 a x o £ o a X o X 0 6 o Q) 4-> V o| *-• A >. 4-i S-, C o a o V c Di /•H X to r0 •^4 o "O tu 03 V U CD E T3 0 V u, HH c A >. a o a V CD •*-> o 1—I o T3 A V X c 03 4—I -.—I co A CD i-. i-> 10 i-H o CD -a V £ o A. g. oo T3 V co CO 4-> CD 0 CO eCO 10 CD *-» 03 CD CD a) 3 O 3 CD u 3 U 3 i-. •t-> (0 E A X -t-i 03 (0 V *J a x CJ a x u a x £ E 0 0 0 0 CO CO u 3 o 3 s CO CD T3 (0 0 X) CD E 0 CD B 2 V o 5 +-• w C (0 CD f-H o T E 0 5 CD C V E -w V T A u a x CD E o CD CD X 0 S-. (0 .—i CJ 0 -v V T A i-. £ 0 a x a x +-> 0 (0 4-> V V 0 V 0 0 CO 0 E 0 V O X a. X U m s II fO II V :: ^ ii CO v © a x IM 4-J -*M CO > A A IM 0 £ 0 X > S co > o (0 V 6c V V V A IM <T3 E o V A X b03 -t-1 A -r-4 a x E CO -^ V 03 O ^-^ +•> a, x o —— —i 0) "O O V A IM V HI A 03 CJ H01 60 V •—i 10 EH W V V X u w 0 t! A X u fO V J=. u 03 0 u o •a 0 5 10 V IM 03 V IM m V 03 .a V 88 NOTES: (1) Items, properties, and locals may be declared only at the beginning of a LEAP program. (2) The word useleap must follow start in every LEAP program in which the associative sublanguage is used. (3) When a procedure is declared, one can specify either an item or an itemvar as a parameter; the first specifies a value parameter, the second a reference parameter. One can pass any item expression as an item parameter; only an itemvar may be passed as an itemvar parameter. (4) There is a facility for binding locals with an arbitrary Boolean expression in the upper part of the foreach statement. A Boolean expression in this context must be preceded by andb. Example: foreach X in S andb y X<6do. . . (5) There is a facility for declaring and using up to six "properties' in LEAP. A property may be assigned to or removed from an item, if the item has a datum. Also, one may ask if a specified item has a specified property. Examples: begin real itemvar X; set S; property A, B; real local Y; newitem - X; assign A _to X; foreach Y _in S do if Y is A then delete A from X; end 89 (6) When using writostructure and road structure, the user should be careful that the program in which a structure is written should be "compatible" with the program in which the structure is read. This simply means that the item declarations in the two programs should correspond. Since there is no symbolic communication between LEAP programs, only the order of declaration of items, the data-type of the corresponding items, and the total number of declared items should match. (7) The merge structure statement allows the user to merge "compatible" LEAP data structures. Example: mergestructure 'ABC; when this statement is executed, the structure named 'ABC will be appended to the current structure in the following way: (a) All items in 'ABC except those declared with no datatype will be added as new items to the store of items, and (b) All triples in 'ABC will be adjusted to preserve the relations between these new items and then will be added to the store of triples. Note that both the current structure and the structure to be merged should have no items which were declared with a data type. (8) itemvars are treated as simple variables (e.g. real) in declar- ations (i.e. the existence of an itemvar declaration in a compound statement does not make the compound statement a BLOCK). (9) sets are treated as dynamic variables in declarations. 90 APPENDIX DC PRIMITIVES FOR TEXT AND FILE MANIPULATION This appendix describes a set of reserved procedures for manipulating textarrays and APEX files. The names of files are textarrays containing the text of the name. Procedures are provided for setting up files, reporting which files are set up, setting and reporting file status information, reading and writing text files, and combining textarrays. A flexible error handling facility has been implemented to allow for the variety of errors that can occur. Should an error occur, a jump to the label at the top of a stack will be executed after the reserved variables aROUTINECODE and aFILEERRORCODE have been set to indicate the cause of the error. Initially, the stack contains a jump to an internal routine which prints a "canned" message regarding the source of the error and then calls help. The user, however, may push and pop this stack of error labels to set his own handling of errors in various parts of his program. 91 A description of the routines and reserved variables follows: SETUPTEMPFILE {LENGTH, BOOK}; This routine sets up a non-executable, auto-expandable, ephemeral file of LENGTH pages in the specified book. The reserved textarray variable a FILENAME is set to the name of the file (e.g., '43E201763'). SETUPFILE (NAME, BOOK"*; This routine sets up the indicated file in the specified book using the status information in the directory. If the file doesn't exist, an error is signalled. SETUPANDNAMEFILE {NAME, LENGTH, BOOKV, This routine sets up a new file with the indicated name, status nonexecutable, auto-expandable, of LENGTH pages, in the specified book. Any previous uses of the name are dropped. WHATSIN fBOOK, MAP, NAM El; This routine sets NAME to the name of the file in the specified book and map. If that slot is empty, NAME is set to the null textarray (i.e., ' '). SETSTATUSOF {NAME, WHICH 1; The status of the file NAME is set to be the status specified by the integer WHICH; typically this is an "OR'ing" of the following reserved variables: ^EXECUTABLE ^NONEXECUTABLE PWRITEABLE ^READONLY PUNPROTECT pPROTECT ^EXPANDABLE 3NONEXPANDABLE 3LENGTH (Set length to aLENGTH pages). ^DATATYPE (Set datatype to a DATATYPE). examples: Set the status of file RR to be Read-Only and 10 pages in length. Leave other status information unchanged. 10- aLENGTH; SETSTATUSOF {'RR', pREADONLYv 3LENGTH}; REPORTSTATUSOF fNAME}; The status of the file NAME is used to set the values of the following reserved variables: 92 ^SUMMARY INTEGER aLENGTH INTEGER No. of PAGES ^DATATYPE INTEGER DATATYPE, VALUES HAVE THE FOLLOWING MEANINGS: 1 LEGAL DEFINED FILE 0 LEGAL DIRECTORY NAME, BUT NOT DEFINED -1 NOT LEGAL DIRECTORY NAME 0 1 2 3 4 5 6 - UNSPECIFIED (BINARY) LINCOLNWRITER TEXT PROCESS ARRAY LIBRARY FILE MK4/5 DIRECTIVE USER DIRECTORY TABLET RECOGNIZER DICTIONARY EXTENDED LINCOLNWRITER TEXT FILE 9 - RELOCATABLE BINARY 10 - TAP ASSEMBLER DICTIONARY 11 - COMPILED REGULAR EXPRESSION aWHICH This, if supplied in a SETSTATUSQF would set status identical to this file. e.g., To set file RR to identical status with file RA, except that RR is one page longer, the following code would be written: INTEGER REPORTSTATUSOF {'RA'}; ^LENGTH + 1 - ^LENGTH; SETSTATUSOF {'RR', aWHICH}; ^EXECUTABLE BOOLEAN aWRITEABLE BOOLEAN ^PROTECT BOOLEAN- ^EXPANDABLE BOOLEAN READTF (NAME, TAl; The contents of the textarrav' TA is set to oe the contents of the text file NAME. OPENTF; Prepares to ouild a new text file. (i.e., open) at one time. Onl one text file may be under construction 93 CLOSETF {NAME} ; Close the current text file and name it NAME. PUTCHARINTF {iNTGRl; Puts the character INTGR into the next character location in the open text file. PUTTAINTF {TA} ; Appends the indicated text to the open text file. APPEND (A, B, C] ; The textarray B is appended to the textarray A and the result is put into textarray C. Any two or all three may be the same textarray or the null textarray. PUSHFILEERRORLABEL {LABEL}; If an error is discovered in the file package, or a DOFILEERROR is executed, control will be passed to the last LABEL pushed. The reserved variables o'ROUTINECODE and aFILEERRORCODE will be set to indicate the cause of the error. These variables are volatile over any reserved procedure and should thus be saved quickly. If no error is detected in a reserved procedure, the values of aROUTINECODE and aFILEERRORCODE are not defined. aROUTINECODE and aFILEERRORCODE are safe over the following reserved procedures: PUSHFILEERRORLABEL, POPFILEERRORLABEL. POPFILEERRORLABEL; Cancels the last PUSHFILEERRORLABEL executed. If you try to POP too far, the top of the stack will contain its initial value, namely a label of routine which types the cause of the error and then calls help. DOFILEERROR {ROUTINECODE, FILEERRORCODE"'; Sets the reserved variables aROUTINECODE and aFILEERRORCODE to the specified values and then jumps to the last label pushed onto the file error label stack. 94 TYPEERROR; This routine takes the values in aROUTINECODE and aFILEERRORCODE and uses them to print a canned message as to the cause of the error. RESERVED VARIABLE DATA TYPE COMMENTS YTFCOUNT INTEGER contains number of characters inserted into currently open text file. Contains -1 if no text file currently open. c*ROUTINECODE INTEGER aFILEERRORCODE INTEGER See discussion at PUSHFILEERRORLABEL and listing of errors. Set to the name of the file set up by the last SETUPTEMPFILE. ^FILENAME TEXTARRAY ^DATATYPE INTEGER ^LENGTH INTEGER ^SUMMARY INTEGER aWHICH INTEGER ^EXECUTABLE BOOLEAN ^EXPANDABLE BOOLEAN aWRITEABLE BOOLEAN aPROTECT BOOLEAN otMAP INTEGER Set at initialization to the number of the map the user is running on. ^CONSOLE INTEGER Set at initialization to the number of the console on which the user is running. See REPORTSTATUSOF 95 REFERENCES 1) Blatt, H. , "Conic Display Generator Using Multiple Digital-Analog Decoders:" PROC FJCC (1967). 2) Clark, W. A. et. al., "The Lincoln TX-2 Computer", Proc. Western JCC (February 1957). 3) Curry, J. E. , "A Tablet Input Facility for an Interactive Graphics System", PROC of International Conference on Artificial Intelligence, Washington, D. C. (May 1969). 4) Feldman, J. A. and Rovner, P. D., "An ALGOL-Based Associative Language", CACM (August 19 69). 5) Feldman, J. A., "Aspects of Associative Processing", Technical Note 1965-13, Lincoln Laboratory, M.I.T. (21 April 1965), DDC AD-614634 6) Forgie, J. W. , "A Time and Memory Sharing Executive Program for Quick-Response on-line Applications", PROC. FJCC (1965). 7) Mondshein, L. F. , "VITAL Compiler-Compiler System Reference Manual", Technical Note 1967-12, Lincoln Laboratory, M.I.T. (8 February 1967), DDC AD-649140. 8) Naur, P. et. al. , "Revised Report on the Algorithmic Language ALGOL-60. CACM (January 1963). 9) Roberts, L. G., "Homogeneous Matrix Representation and Manipulation of N-Dimensional Constructs", The Computer Display Review, published by Keydata Associates, Bedford, Massachusetts . 10) Rovner, P. D. and Feldman, J. A. , "The LEAP Language and Data Structure", IFIP Congress 1968 (August 1968). 11) Sutherland, W. R. et. al. , "Graphics in Time-Sharing: A Summary of the TX-2 Experience" PROC SJCC (1969). 12) Teixera, J. F. and Sallen, R. P., "The Sylvania Data Tablet", Proc. SJCC (1968). UNCLASSIFIED Security Classification 9b DOCUMENT CONTROL DATA - R&D (Security classification of title, body of abstract and indexing annotation-must be entered when the overall report is classified) I. ORIGINATING ACTIVITY (Corporate author) 2a. REPORT SECURITY CLASSIFICATION Unclassified Lincoln Laboratory, M.I.T. 2b. GROUP None 3. REPORT TITLE The LEAP User's Manual 4. DESCRIPTIVE NOTES (Type of report and inclusive dates) S. AUTHORISI (Last namp, first name, initial) Lincoln Manual Rovner, Paul D. 6. 7a. REPORT DATE 11 September 1970 100 9a. Ba. CONTRACT OR GRANT NO. 7b. NO. OF REFS TOTAL NO. OF PAGES AF 19(628)"5167 12 ORIGINATOR'S REPORT NUMBER(S) Lincoln Manual 93 b. PROJECT NO. ARPA Order 691 96. OTHER REPORT NOISI (Any other numbers that may be assigned this report) ESD-TR-70-256 10. AVAILABILITY/LIMITATION NOTICES This document has been approved for public release and sale; its distribution is unlimited. II. 12. SUPPLEMENTARY NOTES None 13. SPONSORING MILITARY ACTIVITY Advanced Research Projects Agency, Department of Defense ABSTRACT This document is a user's manual for the LEAP language. LEAP is an extended algebraic programming language which is similar in form to ALGOL.8 Extensions include language forms for display output and interactive input and facilities for building and manipulating associative information structures. The basic algebraic language is described in Sections I through IX; the extensions to LEAP are presented in the Appendices. 14. KEY WORDS computer language LEAP language extended algebraic language UNCLASSIFIED Security Classification