Start development on BSD 2
[unix-history] / .ref-BSD-1 / puman / puman5.n
CommitLineData
5bd13011
BJ
1.if \n(xx .bp
2.if !\n(xx \{\
3.so tmac.p \}
4.ND
5.nr H1 4
6.NH
7Details on the components of the system
8.NH 2
9Options
10.PP
11The programs
12.PI
13and
14.XP
15take a number of options.\*(dg
16.FS
17\*(dgAs
18.IX
19uses
20.PI
21to translate Pascal programs,
22it takes the options of
23.PI
24also.
25We refer to them here, however, as
26.PI
27options.
28.FE
29There is a standard
30.UX
31convention for passing options to programs on the command line,
32and this convention is followed by the
33.UP
34system programs.
35As we saw in the examples above,
36option related arguments consisted of the character `\-' followed
37by a single character option name.
38In fact, it is possible to place more than one option letter after
39a single `\-', thus
40.LS
41% \*bpi -lz foo.p\fR
42.LE
43and
44.LS
45% \*bpi -l -z foo.p\fR
46.LE
47are equivalent.
48.PP
49There are 26 options, one corresponding to each lower case letter.
50Except for the
51.B b
52option
53which takes a single digit value,
54each option may be set on (enabled)
55or off (disabled.)
56When an on/off valued option appears on the command line of
57.PI
58or
59.PX
60it inverts the default setting of that option.
61Thus
62.LS
63% \*bpi -l foo.p\fR
64.LE
65enables the listing option
66.B l ,
67since it defaults off, while
68.LS
69% \*bpi -t foo.p\fR
70.LE
71disables the run time tests option
72.B t ,
73since it defaults on.
74.PP
75In additon to inverting the default settings of
76.PI
77options on the command line, it is also possible to control the
78.PI
79options
80within the body of the program by using comments of a special
81form illustrated by
82.LS
83{$l-}
84.LE
85.PP
86Here we see that the opening comment delimiter (which could also be a `(*')
87is immediately followed by the character `$'.
88After this `$', which signals the start of the option list,
89we can place a sequence of letters and option controls, separated by `,'
90characters\*(dd.
91.FS
92\*(ddThis format was chosen because it is used by Pascal 6000-3.4.
93In general the options common to both implementations are controlled
94in the same way so that comment control in options is mostly
95portable.
96It is recommended, however, that only one control be put per comment for
97maximum portability, as the Pascal 6000-3.4
98implementation will ignore controls
99after the first one which it does not recognize.
100.FE
101The most basic actions for options are to set them, thus
102.LS
103{$l+ Enable listing}
104.LE
105or to clear them
106.LS
107{$t-,p- No run-time tests, no post mortem analysis}
108.LE
109Notice that `+' always enables an option and `\-' always disables it,
110no matter what the default is.
111Thus `\-' has a different meaning in an option comment than it has on the
112command line.
113As shown in the examples,
114normal comment text may follow the option list.
115.NH 2
116Pi (and pix)
117.PP
118We now summarize the options of
119.PI .
120These options may also be specified on the command line to
121.IX
122before the name of the file to be translated.
123Arguments to
124.IX
125after the name of the file to be translated are passed to
126the executed program run by
127.X .
128With each option we give its default setting,
129the setting it would have if it appeared on the command line,
130and a sample command using the option.
131Most options are on/off valued,
132with the
133.B b
134option
135taking a single digit value.
136.SH
137Buffering of the file output \- b
138.PP
139The
140.B b
141option controls the buffering of the file
142.I output .
143The default is line buffering, with flushing at
144each reference to the file
145.I input
146and under certain other circumstances detailed in section 5
147below.
148Mentioning
149.B b
150on the command line, e.g.
151.LS
152% \*bpi -b assembler.p\fR
153.LE
154causes standard output to be block buffered,
155where a block is 512 characters.
156The
157.B b
158option may also be controlled in comments.
159It, unique among the
160.UP
161options,
162takes a single digit value rather than an on or off setting.
163A value of 0, e.g.
164.LS
165 {$b0}
166.LE
167causes the file
168.I output
169to be unbuffered.
170Any value 2 or greater causes block buffering and is equivalent
171to the flag on the command line.
172The option control comment setting
173.B b
174must precede the
175.B program
176statement.
177.SH
178Include file listing \- i
179.PP
180The
181.B i
182option takes a list of
183.B include
184files,
185.B procedure
186and
187.B function
188names and causes these portions of the
189program to be listed while translating\*(dg.
190.FS
191\*(dg\*bInclude\fR files are discussed in section 5.9.
192.FE
193All arguments after the
194.B \-i
195flag up to the name of the file being translated,
196which ends in `.p', are in this list.
197Typical uses would be
198.LS
199% \*bpix -i scanner.i compiler.p\fR
200.LE
201to make a listing of the routines in the file scanner.i, and
202.LS
203% \*bpix -i scanner compiler.p\fR
204.LE
205to make a listing of only the routine
206.I scanner .
207This option is especially useful for conservation-minded programmers making
208partial program listings.
209.SH
210Make a listing \- l
211.PP
212The
213.B l
214option enables a listing of the program.
215The
216.B l
217option defaults off.
218When specified on the command line, it causes
219a header line identifying the version of the translator in use
220and a line giving the modification time of the file being translated
221to appear before the actual program listing.
222The
223.B l
224option is pushed and popped by the
225.B i
226option at appropriate points in the program.
227.SH
228Eject new pages for include files \- n
229.PP
230The
231.B n
232option causes
233.PI
234to eject a new page in the listing and print a header line at
235.B include
236file boundaries, providing automatic pagination control.
237To have effect, either the
238.B l
239or
240.B i
241option should also be specified,
242or the input should contain listing control in comments.
243An example would be
244.LS
245% \*bpi -in scan.i c.p\fR
246.LE
247.SH
248Post-mortem dump \- p
249.PP
250The
251.B p
252option defaults on,
253and causes the runtime system to initiate a post-mortem
254backtrace when an error occurs.
255It also cause
256.X
257to count statements in the executing program,
258enforcing a statement limit to prevent infinite loops.
259Specifying
260.B p
261on the command line disables these checks and the ability
262to give this post-mortem analysis.
263It does make smaller and faster programs, however.
264It is also possible to control the
265.B p
266option in comments.
267To prevent the post-mortem backtrace on error,
268.B p
269must be off at the end of the
270.B program
271statement.
272Thus, the Pascal cross-reference program was translated with
273.LS
274% \*bpi -pbt pxref.p\fR
275.LE
276.SH
277Standard Pascal only \- s
278.PP
279The
280.B s
281option causes many of the features of the
282.SM UNIX
283implementation which are not found in standard Pascal
284to be diagnosed as `s' warning errors.
285This option defaults off and is enabled when mentioned on the command line.
286Some of the features which are diagnosed are:
287non-standard
288.B procedure s
289and
290.B function s,
291extensions to the
292.B procedure
293.I write ,
294and the padding of constant strings with blanks.
295In addition, all letters are mapped to lower case except in
296strings and characters so that the case of keywords and identifiers
297is effectively ignored.
298The
299.B s
300option is most useful when a program is to be transported, thus
301.LS
302% \*bpi -s isitstd.p\fR
303.LE
304.SH
305Runtime tests \- t
306.PP
307The
308.B t
309option controls the generation of tests that subrange variable
310values are within bounds at run time.
311By default these tests are generated.
312If the
313.B t
314option is specified on the command line,
315or in a comment which turns it off,
316then the tests are not generated.
317Thus the first line of a program to run without tests might be
318.LS
319{$t- No runtime tests}
320.LE
321Disabling runtime tests also causes
322.B assert
323statements to be treated as comments.\*(dg
324.FS
325\*(dgSee section A.1 for a description of
326.B assert
327statements.
328.FE
329.SH
330Card image, 72 column input \- u
331.PP
332Turning the
333.B u
334option on, either on the command line
335or in a comment causes the input to be treated as
336card images with sequence numbers and truncated to 72 columns.
337Thus
338.LS
339% \*bpix -u cards.p\fR
340.LE
341.SH
342Suppress warning diagnostics \- w
343.PP
344The
345.B w
346option, which defaults on,
347allows the translator to print a number of warnings about inconsistencies
348it finds in the input program.
349Turning this option off with a comment of the form
350.LS
351{$w-}
352.LE
353or on the command line
354.LS
355% \*bpi -w tryme.p\fR
356.LE
357suppresses these usually useful diagnostics.
358.SH
359Generate counters for an execution profile \- z
360.PP
361The
362.B z
363option, which defaults off,
364enables the production of execution profiles.
365By specifying
366.B z
367on the command line, i.e.
368.LS
369% \*bpi -z foo.p\fR
370.LE
371or by enabling it in a comment before the
372.B program
373statement we cause
374.PI
375to insert operations in the interpreter code to
376count the number of times each statement was executed.
377An example of using
378.XP
379was given in section 2.6;
380its options are described in section 5.5.
381.NH 2
382Px
383.PP
384The first argument to
385.X
386is the name of the file containing the program to be interpreted.
387If no arguments are given, then the file
388.I obj
389is executed.
390If more arguments are given, they are available to the Pascal
391program by using the built-ins
392.I argc
393and
394.I argv
395as described in section 4.6.
396.ne 7
397.PP
398.I Px
399may also be invoked automatically by the shell\*(dg.
400.FS
401\*(dgThis requires a modified shell.
402Such a shell is standard at Berkeley.
403.FE
404In this case, whenever a Pascal object file name is given as a command,
405the command will be executed with
406.X
407prepended to it; that is
408.LS
409% \*bobj primes\fR
410.LE
411will be converted by the shell to read
412.LS
413% \*bpx obj primes\fR
414.LE
415This feature makes using Pascal programs much more convenient.
416.NH 2
417Pxp
418.PP
419.I Pxp
420takes, on its command line, a list of options followed by the program file
421name, which must end in `.p' as it must for
422.PI
423and
424.IX .
425.XP
426will produce an execution profile if any of the
427.B z
428.B t
429or
430.B c
431options are specified on the command line.
432If none of these options are specified, then
433.XP
434functions as a program reformatter.
435See section 5.5 for more details.
436.PP
437It is important to note that only the
438.B z
439option of
440.XP ,
441and the
442.B n ,
443.B u ,
444and
445.B w ,
446options, which are common to
447.PI
448and
449.XP
450can be controlled in comments.
451All other options must be specified on the command line to have any effect.
452.PP
453The following options are relevant to profiling with
454.XP :
455.SH
456Include the bodies of all routines in the profile \- a
457.PP
458.I Pxp
459normally suppresses printing the bodies of routines
460which were never executed, to make the profile more compact.
461This option forces all routine bodies to be printed.
462.SH
463Extract profile data from the file core \- c
464.PP
465This option causes
466.XP
467to extract the data from the file
468.I core
469in the current directory.
470This is used in debugging the Pascal system, and should not
471normally be needed.
472When an abnormal termination occurs in
473.X
474it writes the data to the file
475.I pmon.out .
476The
477.B z
478option enables profiling with data from this file.
479.SH
480Suppress declaration parts from a profile \- d
481.PP
482Normally a profile includes declaration parts.
483Specifying
484.B d
485on the command line suppresses declaration parts.
486.SH
487Eliminate include directives \- e
488.PP
489Normally,
490.XP
491preserves
492.B include
493directives to the output when reformatting a program,
494as though they were comments.
495Specifying
496.B \-e
497causes the contents of the specified files to be reformatted
498into the output stream instead.
499This is an easy way to eliminate
500.B include
501directives, e.g. before transporting a program.
502.SH
503Fully parenthesize expressions \- f
504.PP
505Normally
506.XP
507prints expressions with the minimal parenthesization necessary to
508preserve the structure of the input.
509This option causes
510.I pxp
511to fully parenthesize expressions.
512Thus the statement which prints as
513.LS
514d := a + b mod c / e
515.LE
516with minimal parenthesization, the default, will print as
517.LS
518d := a + ((b mod c) / e)
519.LE
520with the
521.B f
522option specified on the command line.
523.SH
524Left justify all procedures and functions \- j
525.PP
526Normally, each
527.B procedure
528and
529.B function
530body is indented to reflect its static nesting depth.
531This option prevents this nesting and can be used if the indented
532output would be too wide.
533.SH
534Print a table summarizing procedure and function calls \- t
535.PP
536The
537.B t
538option causes
539.XP
540to print a table summarizing the number of calls to each
541.B procedure
542and
543.B function
544in the program.
545It may be specified in combination with the
546.B z
547option, or separately.
548.SH
549Enable and control the profile \- z
550.PP
551The
552.B z
553profile option is very similar to the
554.B i
555listing control option of
556.PI .
557If
558.B z
559is specified on the command line, then all arguments up to the
560source file argument which ends in `.p' are taken to be the names of
561.B procedure s
562and
563.B function s
564or
565.B include
566files which are to be profiled.
567If this list is null, then the whole file is to be profiled.
568A typical command for extracting a profile of part of a large program
569would be
570.LS
571% \*bpxp -z test parser.i compiler.p\fR
572.LE
573This specifies that profiles of the routines in the file
574.I parser.i
575and the routine
576.I test
577are to be made.
578.NH 2
579Formatting programs using pxp
580.PP
581The program
582.XP
583can be used to reformat programs, by using a command of the form
584.LS
585% \*bpxp dirty.p > clean.p\fR
586.LE
587Note that since the shell creates the output file `clean.p' before
588.XP
589executes, so `clean.p' and `dirty.p' must not be the same file.
590.PP
591.I Pxp
592automatically paragraphs the program, performing housekeeping
593chores such as comment alignment, and
594treating blank lines, lines containing exactly one blank
595and lines containing only a form-feed character as though they
596were comments, preserving their vertical spacing effect in the output.
597.I Pxp
598distinguishes between four kinds of comments:
599.HP
600.RS
601.IP 1)
602Left marginal comments, which begin in the first column of the
603input line and are placed in the first column of an output line.
604.IP 2)
605Aligned comments, which are preceded by no input tokens on the
606input line.
607These are aligned in the output with the running program text.
608.IP 3)
609Trailing comments, which are preceded in the input line by a token with
610no more than two spaces separating the token from the comment.
611.IP 4)
612Right marginal comments, which are preceded in the input line
613by a token from which they are separated by at least three spaces or a tab.
614These are aligned down the right margin of the output,
615currently to the first tab stop after the 40th column from the current
616``left margin''.
617.RE
618.LP
619Consider the following program.
620.LS .ID
621% \*bcat comments.p\fR
622.so comments1.p
623.LE
624When formatted by
625.XP
626the following output is produced.
627.LS .ID
628% \*bpxp comments.p\fR
629.so commentsout
630%
631.LE
632The following formatting related options are currently available in
633.XP .
634The options
635.B f
636and
637.B j
638described in the previous section may also be of interest.
639.SH
640Strip comments \-s
641.PP
642The
643.B s
644option causes
645.XP
646to remove all comments from the input text.
647.SH
648Underline keywords \- \_
649.PP
650A command line argument of the form
651.B \-\_
652as in
653.LS
654% \*bpxp -_ dirty.p\fR
655.LE
656can be used to cause
657.XP
658to underline all keywords in the output for enhanced readability.
659.SH
660Specify indenting unit \- [23456789]
661.PP
662The normal unit which
663.XP
664uses to indent a structure statement level is 4 spaces.
665By giving an argument of the form
666\fB\-\fId\fR
667with
668.I d
669a digit,
6702 \(<=
671.I d
672\(<= 9
673you can specify that
674.I d
675spaces are to be used per level instead.
676.NH 2
677Pcc and carriage control
678.PP
679The
680.UX
681system printer driver does not implement
682.SM FORTRAN
683style carriage control.
684Thus the function
685.I page
686on
687.UX
688does not output a character `1'
689in column 1 of a line, but rather puts out a form-feed
690character.
691For those who wish to use carriage control, the filter
692.I pcc
693is available which interprets this control.
694A sample usage is:
695.LS
696% \*bpx | pcc\fR
697.LE
698or
699.LS
700% \*bpix prog.p | pcc | lpr\fR
701.LE
702for printer copy.
703.I Pcc
704is fully described by its manual documentation
705.I pcc
706(VI).
707.NH 2
708Pxref
709.PP
710The cross-reference program
711.I pxref
712may be used to make cross-referenced listings of Pascal
713programs.
714To produce a cross-reference of the program in the file
715`foo.p'
716one can execute the command:
717.LS
718% \*bpxref foo.p\fR
719.LE
720The cross-reference is, unfortunately, not block structured.
721Full details on
722.I pxref
723are given in its manual section
724.I pxref
725(VI).
726.NH 2
727Pascals
728.PP
729A version of Wirth's subset Pascal translator
730.I pascals
731is available on
732.UX .
733It was translated to interpreter code by
734.PI
735and is invoked by a command of the form:
736.LS
737% \*bpascals prog.p\fR
738.LE
739The program in the file given is translated to interpretive code
740which is then immediately executed.
741.I Pascals
742is thus similar to
743.I pix .
744Only small programs can be handled.
745.I Pascals
746is most interesting to those wishing to study its error recovery techniques,
747which are described in Wirth's book
748.I "Algorithms + Data Structures = Programs" .
749.NH 2
750Multi-file programs
751.PP
752A text inclusion facility is available with
753.UP .
754This facility allows the interpolation of source text from other
755files into the source stream of the translator.
756It can be used to divide large programs into more manageable pieces
757for ease in editing, listing, and maintenance.
758.PP
759The
760.B include
761facility is based on that of the
762.SM
763UNIX
764.NL
765C compiler.
766To trigger it you can place the character `#' in the first portion of
767a line and then, after an arbitrary number of blanks or tabs,
768the word
769`include'
770followed by a filename enclosed in single `\(aa' or double `"' quotation
771marks.
772The file name may be followed by a semicolon `;' if you wish to treat
773this as a pseudo-Pascal statement.
774The filenames of included files must end in `.i'.
775An example of the use of included files in a main program would be:
776.LS
777\*bprogram\fR compiler(input, output, obj);
778
779#\*binclude\fR "globals.i"
780#\*binclude\fR "scanner.i"
781#\*binclude\fR "parser.i"
782#\*binclude\fR "semantics.i"
783
784\*bbegin\fR
785 { main program }
786\*bend\fR.
787.LE
788.PP
789At the point the
790.B include
791pseudo-statement is encountered in the input, the lines from
792the included file are interpolated into the input stream.
793For the purposes of translate- and run-time diagnostics and
794statement numbers in the listings and post-mortem backtraces,
795the lines in the included file are numbered from 1.
796Nested includes are possible up to 10 deep.
797.PP
798See the descriptions of the
799.B i
800and
801.B n
802options of
803.PI
804in section 5.2
805above;
806these can be used to control listing when
807.B include
808files are present.
809.PP
810.I Include
811control lines are never printed in a listing.
812If the
813.B n
814option is not set, they are replaced by a line containing
815the file name and a `:' character.
816This is the default setting.
817If the
818.B n
819new page option is enabled then the
820.B include
821line is replaced with a banner line similar to the first line
822of a listing.
823This line is placed on a new page in the listing.
824.PP
825When a non-trivial line is encountered in the source text after an
826.B include
827finishes, the
828`popped' filename is printed, in the same manner as above.
829.PP
830For the purposes of error diagnostics when not making a listing, the filename
831will be printed before each diagnostic if the current
832filename has changed since the last
833filename was printed.