A Concurrent PASCAL Compiler for Minicomputers
Total Page:16
File Type:pdf, Size:1020Kb
512 Appendix A DIFFERENCES BETWEEN UCSD'S PASCAL AND STANDARD PASCAL The PASCAL language used in this book contains most of the features described by K. Jensen and N. Wirth in PASCAL User Manual and Report, Springer Verlag, 1975. We refer to the PASCAL defined by Jensen and Wirth as "Standard" PASCAL, because of its widespread acceptance even though no international standard for the language has yet been established. The PASCAL used in this book has been implemented at University of California San Diego (UCSD) in a complete software system for use on a variety of small stand-alone microcomputers. This will be referred to as "UCSD PASCAL", which differs from the standard by a small number of omissions, a very small number of alterations, and several extensions. This appendix provides a very brief summary Of these differences. Only the PASCAL constructs used within this book will be mentioned herein. Documents are available from the author's group at UCSD describing UCSD PASCAL in detail. 1. CASE Statements Jensen & Wirth state that if there is no label equal to the value of the case statement selector, then the result of the case statement is undefined. UCSD PASCAL treats this situation by leaving the case statement normally with no action being taken. 2. Comments In UCSD PASCAL, a comment appears between the delimiting symbols "(*" and "*)". If the opening delimiter is followed immediately by a dollar sign, as in "(*$", then the remainder of the comment is treated as a directive to the compiler. The only compiler directive mentioned in this book is (*$G+*), which tells the compiler to allow the use of GOTO statements. The UCSD compiler does not 513 handle nested comments correctly. 3. EOF(F) To set EOF to TRUE for a textfile F, including the standard INPUT file, the user must press the <ETX> or <ENTER> key (CONTROL-C on a keyboard lacking an explicit key for that purpose). The specific code used for this purpose may be altered from <ETX> if desired. If the file F is closed, then EOF returns TRUE. If EOF is TRUE, and the file is of <type> TEXT, then EOLN is also true for the same file. Following RESET(F), EOF will return FALSE if the file is present. The system automatically performs a RESET on the files INPUT, OUTPUT, and KEYBOARD when a program is initialized. 4. EOLN(F) EOLN(F) is defined only if F is a file of <type> TEXT. EOLN becomes TRUE only following a READ during which the end-of-line character «RET> by default) is received, and before the next READ. 5. GOTO and EXIT(P) statements UCSD PASCAL only allows a GOTO within the same <block> that contains the declaration of the target label. EXIT provides a limited capability equivalent to GOTO with a target label immediately following the point where the procedure P was called most recently. See Appendix C for further discussion of E) :T. GOTO is disabled by default in UCSD PASCAL when the system is initialized for student use. It can be enabled using the compiler directive (*$G+*). 514 6. Packed Variables UCSD PASCAL supports packed arrays of characters, and packed RECORD <type)'s. Characters are packed two to a 16-bit word. Within a record, packing and unpacking are performed automatically within groups of fields that are at most 16-bits wide. UCSD PASCAL has no equivalent of the built-in procedures PACK and UNPACK described by Jensen & Wirth. 7. Procedures and Functions as Formal Parameters UCSD PASCAL does not support the use of Procedure or Function identifiers as parameters. One exception is the EXIT built-in procedure. 8. Program Headings In the early releases of UCSD PASCAL, the list of standard file names in the PROGRAM line must not be included as pseudo parameters. Later releases will include this mechanism on an optional basis for use with the X(ecute) command of the operating system. 9. READ and READLN Jensen & Wirth define READ(F, CH) to be equivalent to the sequence CH := FAj GET(F)j In UCSD PASCAL this sequence is reversed when F is either of the standard console input files INPUT or KEYBOARD. Without this change, it would be extremely awkward to write programs which interact closely with the user. 515 10. RESET(F) In UCSD PASCAL, RESET(F) points the file window to the start of a file, but does not load the window variable FA. Thus the UCSD equivalent to the standard definition is: RESET(F)j GET(F)j 11. REWRITE(F) UCSD PASCAL does not support the standard procedure REWRITE. OPENNEW provides similar facilities. 12. Sets In UCSD PASCAL a set may have a maximum of 255*16 elements, i.e. a set may be up to 255 16-bit words in size. All of the set operations described by Jensen & Wirth are supported. 13. STRING variables UCSD PASCAL has a predeclared <type) STRING. A variable of <type) STRING is essentially a PACKED ARRAY[1 •• 80] OF CHAR, with an associated length attribute of <type> INTEGER. The default length of 80 characters may be overridden by a declaration which specifies the desired maximum length within square brackets, as in: TITLE: STRING[30]j where the absolute maximum length supported is 255 characters. The use of STRING variables is described extensively in this book. 14. WRITE and WRITELN UCSD PASCAL differs from the standard in not supporting parameters of <type) BOOLEAN for WRITE and WRITELN statements. Parameters of <type) STRING produce the results described in the body of 516 this book. 15. Turtle Graphics The Turtle graphics facilities described in this book and supported in UCSD PASCAL have no counterpart in the standard language. 517 Appendix B GLOSSARY OF COMPUTER JARGON This glossary presents a list of words and terms used in this book with meanings different from everyday usage. With each term is a very brief reminder about its meaning. For a more extensive discussion of the term, see the «chapter> • <section» referred to with each term. For example, (11.5) refers to Chapter 11 Section 5. Activate (11.5) A procedure or function is said to be activated when it is called and begins executing. It is no longer active after it terminates normally, or via use of the EXIT statement. A recursive procedure or function may activate several "copies" of itself concurrently. Actual Parameter (2.5) An actual parameter is a <variable> or <expression> supplied as part of a call to a procedure or function, thus replacing the formal parameter which appeared as part of the procedure or function declaration. Address (5.4) The address of a word in the computer's memory can be thought of as the number of the register containing the word. Algorithm (0.2) A statement describing a sequence of actions needed to perform a specific task. Analog Computer (5.2) Term applying to a class of machines that use electrical signals, mechanical levers, pneumatic pressure, or other similar means to simulate the behavior of other systems. 518 Argument (4.9) A data value to be used as an actual parameter. Arithmetic Expression (2.9) The PASCAL means of combining operands with numeric values to perform the arithmetic operations of addition, subtraction, multiplication and/or division. Array (8.2) A data structure which may contain many items (called "elements") of the same <type>. ASCII (5.2) The American national Standard Code for Information Interchange. An arbitrary assignment of numeric values to 96 displayable characters, and 32 control signals. Assembler Language (5.3) A method of programming a computer similar to using machine language, except that the user refers to each operation using an abbreviated descriptive identifier, rather than with numeric codes directly. Assembler language is translated into machine language by a program called an "assembler". Assertion (6.5) A statement of fact, the truth or falsehood of which will be tested within an algorithm. Assign (2.7), Assignment Operator (2.8), Assignment Statement (2.7) Assignment of a value to a variable causes that value to replace whatever value, if any, was previously stored in the memory location named by the variable. The assignment operator (":=") is the PASCAL symbol identifying an assignment statement which calls for the variable on the left of the operator to be assigned a new value. 519 Backspace (7.4) A key found on most keyboards. Generally used to indicate that the cursor pointing at the current text location should be backed up one space. Not all hard copy output devices support this feature. If the key is missing, <control-H> usually has the same effect. Batch (7.3) Term used to describe the manner in which programs are executed on a computer system (generally large) which accepts its input in the form of a deck of punched cards, and gives output to users in printed form on paper. Binary Search (13.5) A searching process in which the set of data items is cut roughly in half, then the half containing the item sought is cut in half, then the quarter containing the item sought is cut in half, and so on. Bit (5.2) A binary digit, whose value may be either 0 or 1. Bit Map (12.6) Term used to describe a graphic display device which creates images by providing a large number of positions where a program may turn a bright spot on or off. Bug (1.10) A logical error in a program, which causes the program to stop abnormally or to give incorrect results. Built-In (2.11) Adjective referring to pre-declared procedures and functions which are supplied as part of a software system.