.\" Copyright (c) 1980 Regents of the University of California.
.\" All rights reserved. The Berkeley software License Agreement
.\" specifies the terms and conditions for redistribution.
.\" @(#)puman5.n 6.2 (Berkeley) %G%
Details on the components of the system
take a number of options.\*(dg
to translate Pascal programs,
We refer to them here, however, as
convention for passing options to programs on the command line,
and this convention is followed by the
As we saw in the examples above,
option related arguments consisted of the character `\-' followed
by a single character option name.
which takes a single digit value,
each option may be set on (enabled)
When an on/off valued option appears on the command line of
it inverts the default setting of that option.
enables the listing option
since it defaults off, while
disables the run time tests option
In additon to inverting the default settings of
options on the command line, it is also possible to control the
within the body of the program by using comments of a special
Here we see that the opening comment delimiter (which could also be a `(*')
is immediately followed by the character `$'.
After this `$', which signals the start of the option list,
we can place a sequence of letters and option controls, separated by `,'
\*(ddThis format was chosen because it is used by Pascal 6000-3.4.
In general the options common to both implementations are controlled
in the same way so that comment control in options is mostly
It is recommended, however, that only one control be put per comment for
maximum portability, as the Pascal 6000-3.4
implementation will ignore controls
after the first one which it does not recognize.
The most basic actions for options are to set them, thus
{$t-,p- No run-time tests, no post mortem analysis}
Notice that `+' always enables an option and `\-' always disables it,
no matter what the default is.
Thus `\-' has a different meaning in an option comment than it has on the
As shown in the examples,
normal comment text may follow the option list.
Options common to Pi, Pc, and Pix
The following options are common to both the compiler
With each option we give its default setting,
the setting it would have if it appeared on the command line,
and a sample command using the option.
Most options are on/off valued,
taking a single digit value.
Buffering of the file output \- b
option controls the buffering of the file
The default is line buffering, with flushing at
each reference to the file
and under certain other circumstances detailed in section 5
on the command line, e.g.
% \*bpi -b assembler.p\fR
causes standard output to be block buffered,
where a block is some system\-defined number of characters.
option may also be controlled in comments.
takes a single digit value rather than an on or off setting.
Any value 2 or greater causes block buffering and is equivalent
to the flag on the command line.
The option control comment setting
Include file listing \- i
option takes the name of an
to be listed while translating\*(dg.
\*(dg\*bInclude\fR files are discussed in section 5.9.
% \*bpix -i scanner.i compiler.p\fR
to make a listing of the routines in the file scanner.i, and
% \*bpix -i scanner compiler.p\fR
to make a listing of only the routine
This option is especially useful for conservation-minded programmers making
partial program listings.
option enables a listing of the program.
When specified on the command line, it causes
a header line identifying the version of the translator in use
and a line giving the modification time of the file being translated
to appear before the actual program listing.
option is pushed and popped by the
option at appropriate points in the program.
Standard Pascal only \- s
option causes many of the features of the
implementation which are not found in standard Pascal
to be diagnosed as `s' warning errors.
This option defaults off and is enabled when mentioned on the command line.
Some of the features which are diagnosed are:
and the padding of constant strings with blanks.
In addition, all letters are mapped to lower case except in
strings and characters so that the case of keywords and identifiers
option is most useful when a program is to be transported, thus
will produce warnings unless the program meets the standard.
options control the generation of tests that subrange variable
values are within bounds at run time.
defaults to generating tests and uses the option
defaults to not generating tests,
Disabling runtime tests also causes
statements to be treated as comments.\*(dd
\*(ddSee section A.1 for a description of
Suppress warning diagnostics \- w
option, which defaults on,
allows the translator to print a number of warnings about inconsistencies
it finds in the input program.
Turning this option off with a comment of the form
suppresses these usually useful diagnostics.
Generate counters for a pxp execution profile \- z
option, which defaults off,
enables the production of execution profiles.
on the command line, i.e.
or by enabling it in a comment before the
to insert operations in the interpreter code to
count the number of times each statement was executed.
was given in section 2.6;
its options are described in section 5.6.
option cannot be used on separately compiled programs.
and causes the runtime system to initiate a post-mortem
backtrace when an error occurs.
to count statements in the executing program,
enforcing a statement limit to prevent infinite loops.
on the command line disables these checks and the ability
to give this post-mortem analysis.
It does make smaller and faster programs, however.
It is also possible to control the
To prevent the post-mortem backtrace on error,
must be off at the end of the
Thus, the Pascal cross-reference program was translated with
is the name of the file containing the program to be interpreted.
If no arguments are given, then the file
If more arguments are given, they are available to the Pascal
program by using the built-ins
as described in section 4.6.
may also be invoked automatically.
In this case, whenever a Pascal object file name is given as a command,
the command will be executed with
will be converted to read
Generate assembly language \- S
The program is compiled and the assembly language
output is left in file appended .s.
No executable file is created.
Symbolic Debugger Information \- g
option causes the compiler to generate information
For a complete description of
Redirect the output file \- o
is used as the name of the output file instead of
Its typical use is to name the compiled program using
the root of the file name.
% \*bpc -o myprog myprog.p\fR
causes the compiled program to be called
Generate counters for a \*iprof\fP execution profile \- p
The compiler produces code which counts the number of times each
The profiling is based on a periodic sample taken by the
system rather than by inline counters used by
This results in less degradation in execution,
at somewhat of a loss in accuracy.
for a more complete description.
Run the object code optimizer \- O
The output of the compiler is run through
the object code optimizer.
This provides an increase in compile time in
exchange for a decrease in compiled code size
takes, on its command line, a list of options followed by the program file
name, which must end in `.p' as it must for
will produce an execution profile if any of the
options is specified on the command line.
If none of these options is specified, then
functions as a program reformatter.
It is important to note that only the
can be controlled in comments.
All other options must be specified on the command line to have any effect.
The following options are relevant to profiling with
Include the bodies of all routines in the profile \- a
normally suppresses printing the bodies of routines
which were never executed, to make the profile more compact.
This option forces all routine bodies to be printed.
Suppress declaration parts from a profile \- d
Normally a profile includes declaration parts.
on the command line suppresses declaration parts.
Eliminate include directives \- e
directives to the output when reformatting a program,
as though they were comments.
causes the contents of the specified files to be reformatted
into the output stream instead.
This is an easy way to eliminate
directives, e.g. before transporting a program.
Fully parenthesize expressions \- f
prints expressions with the minimal parenthesization necessary to
preserve the structure of the input.
to fully parenthesize expressions.
Thus the statement which prints as
with minimal parenthesization, the default, will print as
option specified on the command line.
Left justify all procedures and functions \- j
body is indented to reflect its static nesting depth.
This option prevents this nesting and can be used if the indented
output would be too wide.
Print a table summarizing procedure and function calls \- t
to print a table summarizing the number of calls to each
It may be specified in combination with the
Enable and control the profile \- z
profile option is very similar to the
listing control option of
is specified on the command line, then all arguments up to the
source file argument which ends in `.p' are taken to be the names of
files which are to be profiled.
If this list is null, then the whole file is to be profiled.
A typical command for extracting a profile of part of a large program
% \*bpxp -z test parser.i compiler.p\fR
This specifies that profiles of the routines in the file
Formatting programs using pxp
can be used to reformat programs, by using a command of the form
% \*bpxp dirty.p > clean.p\fR
Note that since the shell creates the output file `clean.p' before
executes, so `clean.p' and `dirty.p' must not be the same file.
automatically paragraphs the program, performing housekeeping
chores such as comment alignment, and
treating blank lines, lines containing exactly one blank
and lines containing only a form-feed character as though they
were comments, preserving their vertical spacing effect in the output.
distinguishes between four kinds of comments:
Left marginal comments, which begin in the first column of the
input line and are placed in the first column of an output line.
Aligned comments, which are preceded by no input tokens on the
These are aligned in the output with the running program text.
Trailing comments, which are preceded in the input line by a token with
no more than two spaces separating the token from the comment.
Right marginal comments, which are preceded in the input line
by a token from which they are separated by at least three spaces or a tab.
These are aligned down the right margin of the output,
currently to the first tab stop after the 40th column from the current
Consider the following program.
the following output is produced.
The following formatting related options are currently available in
described in the previous section may also be of interest.
to remove all comments from the input text.
A command line argument of the form
to underline all keywords in the output for enhanced readability.
Specify indenting unit \- [23456789]
uses to indent a structure statement level is 4 spaces.
By giving an argument of the form
spaces are to be used per level instead.
The cross-reference program
may be used to make cross-referenced listings of Pascal
To produce a cross-reference of the program in the file
one can execute the command:
The cross-reference is, unfortunately, not block structured.
are given in its manual section
A text inclusion facility is available with
This facility allows the interpolation of source text from other
files into the source stream of the translator.
It can be used to divide large programs into more manageable pieces
for ease in editing, listing, and maintenance.
facility is based on that of the
To trigger it you can place the character `#' in the first portion of
a line and then, after an arbitrary number of blanks or tabs,
followed by a filename enclosed in single `\(aa' or double `"' quotation
The file name may be followed by a semicolon `;' if you wish to treat
this as a pseudo-Pascal statement.
The filenames of included files must end in `.i'.
An example of the use of included files in a main program would be:
\*bprogram\fR compiler(input, output, obj);
#\*binclude\fR "globals.i"
#\*binclude\fR "scanner.i"
#\*binclude\fR "parser.i"
#\*binclude\fR "semantics.i"
pseudo-statement is encountered in the input, the lines from
the included file are interpolated into the input stream.
For the purposes of translation and runtime diagnostics and
statement numbers in the listings and post-mortem backtraces,
the lines in the included file are numbered from 1.
Nested includes are possible up to 10 deep.
See the descriptions of the
this can be used to control listing when
When a non-trivial line is encountered in the source text after an
`popped' filename is printed, in the same manner as above.
For the purposes of error diagnostics when not making a listing, the filename
will be printed before each diagnostic if the current
filename has changed since the last
Separate Compilation with Pc
A separate compilation facility is provided with the Berkeley Pascal compiler,
This facility allows programs to be divided into a number of files and
the pieces to be compiled individually,
to be linked together at some later time.
This is especially useful for large programs,
where small changes would otherwise require
time-consuming re-compilation of the entire program.
expects to be given entire Pascal programs.
option on the command line, it will accept a sequence of definitions and
declarations, and compile them into a
file, to be linked with a Pascal program at a later time.
In order that procedures and functions be available across
separately compiled files, they must be declared with the directive
This directive is similar to the directive
in that it must precede the resolution of the function or procedure,
and formal parameters and function result types must be specified
declaration and may not be specified at the resolution.
Type checking is performed across separately compiled files.
Since Pascal type defintions define unique types,
any types which are shared between separately compiled files
must be the same definition.
This seemingly impossible problem is solved using a facility similar
facility discussed above.
Definitions may be placed in files with the extension
and the files included by separately compiled files.
file defines a unique type, and all uses of a definition from the same
file define the same type.
Similarly, the facility is extended to allow the definition of
which are used between separately compiled files must be declared
and must be so declared in a
file included by any file which calls or resolves the
may only be so declared in
These files may be included only at the outermost level,
and thus define or declare global objects.
declarations (and not resolutions) are allowed in
An example of the use of included
files in a program would be:
\*bprogram\fR compiler(input, output, obj);
#\*binclude\fR "globals.h"
#\*binclude\fR "scanner.h"
#\*binclude\fR "parser.h"
#\*binclude\fR "semantics.h"
This might include in the main program
the definitions and declarations of all the global
declarations for each of the
separately compiled files for the scanner, parser and semantics.
would contain declarations of the form:
\*bfunction\fR scan(\*bvar\fR inputfile: text): token;
Then the scanner might be in a separately compiled file containing:
#\*binclude\fR "globals.h"
#\*binclude\fR "scanner.h"
which includes the same global definitions and declarations
and resolves the scanner functions and procedures declared