Version I.5, September 1978
The UCSD Pascal compiler, a one-pass recursive descent based on the P2 portable compiler from Zurich, is invoked by using the C(ompile or R(un command of the outermost level of the UCSD Pascal system. If a workfile exists, it compiles that. Otherwise, it prompts the user for a source file name. It generates codefiles to run directly on the Pascal interpretive machine.
Unless the HAS SLOW TERMINAL boolean inside the system communication area (see section 4.3) is true, the compiler, during the course of compilation, will display on the CONSOLE device output detailing the progress of the compilation. This output can be suppressed with the Q+ compiler option (see section on compiler options below). Below is an example of the output which appears on the CONSOLE device:
PASCAL compiler [I.5 unit compiler] < 0> ................... P1 [7050] < 19> .......................................... P2 [3040] < 61> .................................................. < 111> ........ TEST [3003] < 119> ..............................................
The identifiers appearing on the screen are the identifiers of the program and its procedures. The identifier for a procedure is displayed at the moment when compilation of the procedure body is started. The numbers within [ ] indicate the number of (16 bit) words available for symbol table storage at that point in the compilation. The numbers enclosed within < > are the current line numbers. Each dot on the screen represents one source line compiled.
If the compilation is successful, that is, no compilation errors were detected, the compiler writes a codefile to the disk called *SYSTEM.WRK.CODE This is the codefile which is executed if the user types the R(un command. See Section 1.1. Introduction and Overview for a global description of the system commands.
Should the compiler detect a syntax error, the text surrounding the error and an error number together with the marker ‘(<<< ’ will point to the symbol in the source where the error was detected. In the event that both the Q and L options are set, the compilation will continue, with the syntax error going to the listing file, and the console remaining undisturbed. Otherwise the compiler will the give the user the option of typing a space, an <esc> or ‘E’. Typing a space instructs the compiler to continue the compilation, while escape causes termination of the compilation, and “E” results in a call to the editor, which automatically places the cursor at the symbol where the error was detected.
The syntax errors detected by the UCSD Pascal compiler are listed in Table 5. All error numbers will be accompanied by a textual message upon entry to the editor if the file *SYSTEM.SYNTAX is available.
Default value: D-
Default value: G-
The G- option has been used at UCSD to restrict novice programmers from excessive uses of the GOTO statement in situations where more structured constructs such as FOR, WHILE or REPEAT statements would be more appropriate.
Iocheck Option
Default value: I+
The I- option is useful for programs which do many I/O operations and also check the IORESULT function after each I/O operation. The program can then detect and report the 110 errors, without being terminated abnormally with a run time error. However this option is set at the expense of the possibility that I/O errors, (and possibly severe program bugs), will go undetected.
Include File Mechanism
The syntax for instructing the compiler to include another source file into the compilation is as follows:
(*$I filename *)
The characters between ‘I’ and ‘*)’ are taken as the filename of the source file to be included. The comment must be closed at the end of the filename, therefore no other options, such as G+, or L+, etc can follow the filename. Note that if a file name starts with ‘+’ or ‘-’ as the first character of the filename, a blank must be inserted between ‘(*$I’ and ‘filename’. For example, the comment
(*$ITURTLE.TEXT*)would cause the file TURTLE.TEXT to be compiled into the program at that point in the compilation.
(*$I +FARKLE.STUFF*)would cause the source file +FARKLE.STUFF to be included into the compilation. If the initial attempt to open the include file fails, the compiler concatenates a “.TEXT” to the filename and tries again. If this second attempt fails, or some I/O error occurs at some point while reading the include file, the compiler responds with a fatal syntax error.
The compiler accepts include files which contain CONST, TYPE, VAR, PROCEDURE, and FUNCTION declarations even though the original program has previously completed its declarations. To do so, the include compiler control comment must appear between the original program's last VAR declaration and the first of the original program's PROCEDURE or FUNCTION declarations. Note that an include file may be inserted into the original program at any point desired, provided the rules governing the normal ordering of Pascal declarations will not be violated. Only when these rules are violated does the above procedure apply.
The compiler cannot keep track of nested include comments, i.e. an include file may not have an include file control comment. This results in a fatal syntax error.
The include file option was added to the compiler at UCSD in order to make it easier to compile large programs without having to have the entire source in one very large file which in many cases would be too large to edit in the existing editor's buffer.
(*$L DEMO1.TEXT*)To specify a file-name inside a control comment, see the section describing the include file mechanism.
Note that listing files which are sent to the disk may be edited as any other text file provided the filename which is specified contains the suffix “.TEXT”. Without the “.TEXT” suffix the file will be treated by the system as a datafile rather than as a text file.
The compiler outputs next to each source line the line number, segment procedure number, procedure number, and the number of bytes or words (bytes for code, words for data) required by that procedure's declarations or code to that point. The compiler also indicates whether the line lies within the actual code to be executed or is a part of the declarations for that procedure by outputting a “D” for declaration and an integer 0..9 to designate the lexical level of statement nesting within the code part. If the D+ option is set then the listing file will include an asterisk on each line where it is appropriate for a user to specify a breakpoint while in the interactive Debugger. This information can be very valuable for debugging a large program since a run time error message will indicate the procedure number, and the offset where the error occurred.
Default value: is set equal to current value of the SLOWTERM attribute of the system communication record SYSCOM (actually SYSCOM.MISCINFO.SLOWTERM)
Default value: R+
This option sets the boolean variable SYSCOMP in the compiler which is used by the compiler to determine whether this compilation is a user program compilation, or a compilation of a system program.
Default value: U+
Use Library Option
In this version of the ‘U’ option, the U is followed by a file name. The named file becomes the library file in which subsequent USEed UNITs are sought. The default file for the library is *SYSTEM.LIBRARY (see section 3.3.2 for more details on UNITs)
Following is an example of a valid USES clause using the ‘U’ option:
USES UNIT1, UNIT2, { Found in *SYSTEM.LIBRARY } {$U A.CODE} UNIT3, {$U B.LIBRARY} UNIT4, UNIT5;