1.6. Pascal Compiler

Version I.5, September 1978

page077 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 page078 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.

1.6.1. Compile Time Options

Compile time options in the UCSD Pascal compiler are set according to a convention described on pages 100-102 of Jensen and Wirth, where compile time options are set by means of special “dollar sign” comments inside the Pascal program text. The syntax used in UCSD's compiler control comments is essentially as described in Jensen and Wirth. The actual options and the letters associated with those options bear little resemblance to the options listed on pages 101 and 102 of Jensen and Wirth. Following is a description the various options currently available to the user of the UCSD Pascal compiler.
B
Byte-flip. Causes the compiler to generate code for a machine which is byte-flipped from the one upon which it is running.

C
Places the line following the C character for character somewhere in the codefile. The purpose of this is to have a copyright notice imbedded in codefiles.

D
This option causes the compiler to issue breakpoint instructions into the codefile during the course of the compilation in order that the interactive Debugger can be used more effectively. See Section 3.2 “Debugger” for details.

Default value: D-

D-
causes the compiler to omit breakpoint instructions during the course of the compilation.
D+
causes the compiler to emit breakpoint instructions.

page079 G
Affects the boolean variable GOTOOK in the compiler. This boolean is used by the compiler to determine whether it should allow the use of the Pascal GOTO statement within the program.

Default value: G-

G+
allows the use of the GOTO statement.

G-
causes the compiler to generate a syntax error upon encountering a GOTO statement.

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.

I
When an ‘I’ is followed immediately by a ‘+’ or ‘-’, the control comment will affect the boolean variable IOCHECK within the compiler. An alternative use of ‘I’ in a compiler control comment causes the compiler to include a different source file into the compilation at that point. See Include File Mechanism, below, for syntax.

Iocheck Option

Default value: I+

I+
instructs the compiler to generate code after each statement which performs any I/O, in order to check to see if the I/O operation was accomplished successfully. In the case of an unsuccessful I/O operation the program will be terminated with a run time error.
I-
instructs the compiler not to generate any I/O checking code. In the case of an unsuccessful I/O operation the program is not terminated with a run time error.

page080 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.

page081 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
Controls whether the compiler will generate a program listing of the source text to a given file. The default value of this option is L-, which implies that no compiled listing will be made. If the character following “L” is “+”, then the compiled listing will be sent to a disk file with the title ‘*SYSTEM.LST.TEXT’. The user may override this default destination for the compiled listing by specifying a filename following “L”. For example the following control comment will cause the compiled listing to be sent to a disk file called “DEMO1.TEXT”:
(*$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.

page082

P
Page. Pages listing file.

Q
The Q compiler option is the “quiet compile” option which can be used to suppress the output to the CONSOLE device of procedure names and line numbers detailing the progress of the compilation.

Default value: is set equal to current value of the SLOWTERM attribute of the system communication record SYSCOM (actually SYSCOM.MISCINFO.SLOWTERM)

Q+
causes the compiler to suppress output to CONSOLE device.

Q-
causes the compiler to send procedure name and line number output to the CONSOLE device.

R
Thus option affects the value of the boolean variable RANGECHECK in the compiler. If RANGECHECK is true, the compiler will output code to perform checking on array subscripts and assignments to variables of subrange types.

Default value: R+

R+
turns range checking on.

R-
turns range checking off.

Note: programs compiled with the R- option set will run slightly faster; however if an invalid index occurs or a invalid assignment is made, the program will not be terminated with a run time error. Until a program has been completely tested and known to be correct, it is strongly advised to compile with the R option left on.

S
This option determines whether the compiler operates in “swapping” mode. There are two main parts of the compiler: one processes declarations; the other handles statements. In swapping mode, only one of these parts is in main memory at a time. This makes about 2500 additional words available for symbol table storage at the cost of slower compilation speed due to the overhead of swapping the compiler segment in from disk. On full size, single density floppy disks this amounts to a factor of two reduction in compile speed. This option must occur prior the the compiler encountering any Pascal syntax.

page083
Default value: S-

S+
puts compiler in swapping mode.
S-
puts compiler in non-swapping mode.

U
User Program Option

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+

U+
informs the compiler that this compilation is to take place on the user program lex level.

U-
informs the compiler to compile the program at the system lex level. This setting of the U compile time option also causes the following options to be set: R-, G+, I-.

Note: This option will generate programs that will not behave as expected. Not recommended for non-systems work without knowing its method of operation.

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;

page084
This page last regenerated Sun Jul 25 01:09:11 2010.