BSD 4 development
authorBill Joy <wnj@ucbvax.Berkeley.EDU>
Sat, 8 Nov 1980 09:02:59 +0000 (01:02 -0800)
committerBill Joy <wnj@ucbvax.Berkeley.EDU>
Sat, 8 Nov 1980 09:02:59 +0000 (01:02 -0800)
Work on file usr/doc/pascal/bigger3.p
Work on file usr/doc/pascal/bigger2.p
Work on file usr/doc/pascal/bigger.p
Work on file usr/doc/pascal/bigger4.p
Work on file usr/doc/pascal/bigger5.p
Work on file usr/doc/pascal/bigger7.p
Work on file usr/doc/pascal/bigger6.p
Work on file usr/doc/pascal/bigout1
Work on file usr/doc/pascal/bigout2
Work on file usr/doc/pascal/bigout3
Work on file usr/doc/pascal/bigout4
Work on file usr/doc/pascal/billdelta
Work on file usr/doc/pascal/clash.p
Work on file usr/doc/pascal/comments.p
Work on file usr/doc/pascal/clashout
Work on file usr/doc/pascal/contents.n
Work on file usr/doc/pascal/commentsout
Work on file usr/doc/pascal/comments1.p
Work on file usr/doc/pascal/copydata.p
Work on file usr/doc/pascal/copydataout
Work on file usr/doc/pascal/data
Work on file usr/doc/pascal/csfix.c
Work on file usr/doc/pascal/digits.p
Work on file usr/doc/pascal/expr.p
Work on file usr/doc/pascal/exprout
Work on file usr/doc/pascal/digitsout
Work on file usr/doc/pascal/errs
Work on file usr/doc/pascal/first.p
Work on file usr/doc/pascal/firstobjout
Work on file usr/doc/pascal/firstout
Work on file usr/doc/pascal/firstobjout2
Work on file usr/doc/pascal/kat2.p
Work on file usr/doc/pascal/fixcomments
Work on file usr/doc/pascal/flags
Work on file usr/doc/pascal/kat.p
Work on file usr/doc/pascal/kat2out
Work on file usr/doc/pascal/fixkatscript
Work on file usr/doc/pascal/katout
Work on file usr/doc/pascal/kat3.p
Work on file usr/doc/pascal/katin
Work on file usr/doc/pascal/katscript
Work on file usr/doc/pascal/mism.p
Work on file usr/doc/pascal/makefile
Work on file usr/doc/pascal/motd
Work on file usr/doc/pascal/makefile.bak
Work on file usr/doc/pascal/mismout
Work on file usr/doc/pascal/pc.1.dist
Work on file usr/doc/pascal/pc.1.sue
Work on file usr/doc/pascal/pc.1.peter
Work on file usr/doc/pascal/primeout1
Work on file usr/doc/pascal/primeout2
Work on file usr/doc/pascal/primes
Work on file usr/doc/pascal/primeout3
Work on file usr/doc/pascal/primes-d
Work on file usr/doc/pascal/primes2.p
Work on file usr/doc/pascal/puman0.n
Work on file usr/doc/pascal/primes.p
Work on file usr/doc/pascal/puman1.n
Work on file usr/doc/pascal/puman2.n
Work on file usr/doc/pascal/puman3.n
Work on file usr/doc/pascal/puman4.n
Work on file usr/doc/pascal/puman5.n
Work on file usr/doc/pascal/pumanA.n
Work on file usr/doc/pascal/sin1.p
Work on file usr/doc/pascal/sin2.p
Work on file usr/doc/pascal/sinout1
Work on file usr/doc/pascal/sinout2
Work on file usr/doc/pascal/synerr2out
Work on file usr/doc/pascal/tmac.p
Work on file usr/doc/pascal/synerr2.p
Work on file usr/doc/pascal/synerr.p
Work on file usr/doc/pascal/synerrout
Work on file usr/doc/pascal/typequ.p
Work on file usr/doc/pascal/xxxxqqqout
Work on file usr/doc/pascal/typequout
Work on file usr/doc/pascal/xxxxqqqout2

Synthesized-from: CSRG//cd1/4.0

76 files changed:
usr/doc/pascal/bigger.p [new file with mode: 0644]
usr/doc/pascal/bigger2.p [new file with mode: 0644]
usr/doc/pascal/bigger3.p [new file with mode: 0644]
usr/doc/pascal/bigger4.p [new file with mode: 0644]
usr/doc/pascal/bigger5.p [new file with mode: 0644]
usr/doc/pascal/bigger6.p [new file with mode: 0644]
usr/doc/pascal/bigger7.p [new file with mode: 0644]
usr/doc/pascal/bigout1 [new file with mode: 0644]
usr/doc/pascal/bigout2 [new file with mode: 0644]
usr/doc/pascal/bigout3 [new file with mode: 0644]
usr/doc/pascal/bigout4 [new file with mode: 0644]
usr/doc/pascal/billdelta [new file with mode: 0644]
usr/doc/pascal/clash.p [new file with mode: 0644]
usr/doc/pascal/clashout [new file with mode: 0644]
usr/doc/pascal/comments.p [new file with mode: 0644]
usr/doc/pascal/comments1.p [new file with mode: 0644]
usr/doc/pascal/commentsout [new file with mode: 0644]
usr/doc/pascal/contents.n [new file with mode: 0644]
usr/doc/pascal/copydata.p [new file with mode: 0644]
usr/doc/pascal/copydataout [new file with mode: 0644]
usr/doc/pascal/csfix.c [new file with mode: 0644]
usr/doc/pascal/data [new file with mode: 0644]
usr/doc/pascal/digits.p [new file with mode: 0644]
usr/doc/pascal/digitsout [new file with mode: 0644]
usr/doc/pascal/errs [new file with mode: 0644]
usr/doc/pascal/expr.p [new file with mode: 0644]
usr/doc/pascal/exprout [new file with mode: 0644]
usr/doc/pascal/first.p [new file with mode: 0644]
usr/doc/pascal/firstobjout [new file with mode: 0644]
usr/doc/pascal/firstobjout2 [new file with mode: 0644]
usr/doc/pascal/firstout [new file with mode: 0644]
usr/doc/pascal/fixcomments [new file with mode: 0644]
usr/doc/pascal/fixkatscript [new file with mode: 0644]
usr/doc/pascal/flags [new file with mode: 0644]
usr/doc/pascal/kat.p [new file with mode: 0644]
usr/doc/pascal/kat2.p [new file with mode: 0644]
usr/doc/pascal/kat2out [new file with mode: 0644]
usr/doc/pascal/kat3.p [new file with mode: 0644]
usr/doc/pascal/katin [new file with mode: 0644]
usr/doc/pascal/katout [new file with mode: 0644]
usr/doc/pascal/katscript [new file with mode: 0644]
usr/doc/pascal/makefile [new file with mode: 0644]
usr/doc/pascal/makefile.bak [new file with mode: 0644]
usr/doc/pascal/mism.p [new file with mode: 0644]
usr/doc/pascal/mismout [new file with mode: 0644]
usr/doc/pascal/motd [new file with mode: 0644]
usr/doc/pascal/pc.1.dist [new file with mode: 0644]
usr/doc/pascal/pc.1.peter [new file with mode: 0644]
usr/doc/pascal/pc.1.sue [new file with mode: 0644]
usr/doc/pascal/primeout1 [new file with mode: 0644]
usr/doc/pascal/primeout2 [new file with mode: 0644]
usr/doc/pascal/primeout3 [new file with mode: 0644]
usr/doc/pascal/primes [new file with mode: 0644]
usr/doc/pascal/primes-d [new file with mode: 0644]
usr/doc/pascal/primes.p [new file with mode: 0644]
usr/doc/pascal/primes2.p [new file with mode: 0644]
usr/doc/pascal/puman0.n [new file with mode: 0644]
usr/doc/pascal/puman1.n [new file with mode: 0644]
usr/doc/pascal/puman2.n [new file with mode: 0644]
usr/doc/pascal/puman3.n [new file with mode: 0644]
usr/doc/pascal/puman4.n [new file with mode: 0644]
usr/doc/pascal/puman5.n [new file with mode: 0644]
usr/doc/pascal/pumanA.n [new file with mode: 0644]
usr/doc/pascal/sin1.p [new file with mode: 0644]
usr/doc/pascal/sin2.p [new file with mode: 0644]
usr/doc/pascal/sinout1 [new file with mode: 0644]
usr/doc/pascal/sinout2 [new file with mode: 0644]
usr/doc/pascal/synerr.p [new file with mode: 0644]
usr/doc/pascal/synerr2.p [new file with mode: 0644]
usr/doc/pascal/synerr2out [new file with mode: 0644]
usr/doc/pascal/synerrout [new file with mode: 0644]
usr/doc/pascal/tmac.p [new file with mode: 0644]
usr/doc/pascal/typequ.p [new file with mode: 0644]
usr/doc/pascal/typequout [new file with mode: 0644]
usr/doc/pascal/xxxxqqqout [new file with mode: 0644]
usr/doc/pascal/xxxxqqqout2 [new file with mode: 0644]

diff --git a/usr/doc/pascal/bigger.p b/usr/doc/pascal/bigger.p
new file mode 100644 (file)
index 0000000..d342b09
--- /dev/null
@@ -0,0 +1,24 @@
+(*
+ * Graphic representation of a function
+ *    f(x) = exp(-x) * sin(2 * pi * x)
+ *)
+program graph1(output);
+const
+       d = 0.0625;   (* 1/16, 16 lines for interval [x, x+1] *)
+       s = 32;       (* 32 character width for interval [x, x+1]
+       h = 34;       (* Character position of x-axis *)
+       c = 6.28138;  (* 2 * pi *)
+       lim = 32;
+var
+       x, y: real;
+       i, n: integer;
+begin
+       for i := 0 to lim begin
+               x := d / i;
+               y := exp(-x9 * sin(i * x);
+               n := Round(s * y) + h;
+               repeat
+                       write(' ');
+                       n := n - 1
+               writeln('*')
+end.
diff --git a/usr/doc/pascal/bigger2.p b/usr/doc/pascal/bigger2.p
new file mode 100644 (file)
index 0000000..e032349
--- /dev/null
@@ -0,0 +1,24 @@
+(*
+ * Graphic representation of a function
+ *    f(x) = exp(-x) * sin(2 * pi * x)
+ *)
+program graph1(output);
+const
+        d = 0.0625;   (* 1/16, 16 lines for interval [x, x+1] *)
+        s = 32;       (* 32 character width for interval [x, x+1]
+        h = 34;       (* Character position of x-axis *)
+        c = 6.28138;  (* 2 * pi *)
+        lim = 32;
+var
+        x, y: real;
+        i, n: integer;
+begin
+        for i := 0 to lim begin
+                x := d / i;
+                y := exp(-x9 * sin(i * x);
+                n := Round(s * y) + h;
+                repeat
+                        write(' ');
+                        n := n - 1
+                writeln('*')
+end.
diff --git a/usr/doc/pascal/bigger3.p b/usr/doc/pascal/bigger3.p
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/usr/doc/pascal/bigger4.p b/usr/doc/pascal/bigger4.p
new file mode 100644 (file)
index 0000000..5a16ef4
--- /dev/null
@@ -0,0 +1,26 @@
+(*
+ * Graphic representation of a function
+ *    f(x) = exp(-x) * sin(2 * pi * x)
+ *)
+program graph1(output);
+const
+       d = 0.0625;   (* 1/16, 16 lines for interval [x, x+1] *)
+       s = 32;       (* 32 character width for interval [x, x+1] *)
+       h = 34;       (* Character position of x-axis *)
+       c = 6.28138;  (* 2 * pi *)
+       lim = 32;
+var
+       x, y: real;
+       i, n: integer;
+begin
+       for i := 0 to lim do begin
+               x := d / i;
+               y := exp(-x) * sin(c * x);
+               n := round(s * y) + h;
+               repeat
+                       write(' ');
+                       n := n - 1
+               until n = 0;
+               writeln('*')
+       end
+end.
diff --git a/usr/doc/pascal/bigger5.p b/usr/doc/pascal/bigger5.p
new file mode 100644 (file)
index 0000000..5a16ef4
--- /dev/null
@@ -0,0 +1,26 @@
+(*
+ * Graphic representation of a function
+ *    f(x) = exp(-x) * sin(2 * pi * x)
+ *)
+program graph1(output);
+const
+       d = 0.0625;   (* 1/16, 16 lines for interval [x, x+1] *)
+       s = 32;       (* 32 character width for interval [x, x+1] *)
+       h = 34;       (* Character position of x-axis *)
+       c = 6.28138;  (* 2 * pi *)
+       lim = 32;
+var
+       x, y: real;
+       i, n: integer;
+begin
+       for i := 0 to lim do begin
+               x := d / i;
+               y := exp(-x) * sin(c * x);
+               n := round(s * y) + h;
+               repeat
+                       write(' ');
+                       n := n - 1
+               until n = 0;
+               writeln('*')
+       end
+end.
diff --git a/usr/doc/pascal/bigger6.p b/usr/doc/pascal/bigger6.p
new file mode 100644 (file)
index 0000000..9ba7cea
--- /dev/null
@@ -0,0 +1,26 @@
+\0\0\0\0\01\0\0(*
+\0\0\0\0\02\0\0\0* Graphic representation of a function
+\0\0\0\0\03\0\0\0*    f(x) = exp(-x) * sin(2 * pi * x)
+\0\0\0\0\04\0\0\0*)
+\0\0\0\0\05\0\0program graph1(output);
+\0\0\0\0\06\0\0const
+\0\0\0\0\07\0\0\0\0\0\0\0\0\0\0d = 0.0625;   (* 1/16, 16 lines for interval [x, x+1] *)
+\0\0\0\0\08\0\0\0\0\0\0\0\0\0\0s = 32;       (* 32 character width for interval [x, x+1] *)
+\0\0\0\0\09\0\0\0\0\0\0\0\0\0\0h = 34;       (* Character position of x-axis *)
+\0\0\0\010\0\0\0\0\0\0\0\0\0\0c = 6.28138;  (* 2 * pi *)
+\0\0\0\011\0\0\0\0\0\0\0\0\0\0lim = 32;
+\0\0\0\012\0\0var
+\0\0\0\013\0\0\0\0\0\0\0\0\0\0x, y: real;
+\0\0\0\014\0\0\0\0\0\0\0\0\0\0i, n: integer;
+\0\0\0\015\0\0begin
+\0\0\0\016\0\0\0\0\0\0\0\0\0\0for i := 0 to lim do begin
+\0\0\0\017\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0x := d / i;
+\0\0\0\018\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0y := exp(-x) * sin(c * x);
+\0\0\0\019\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0n := round(s * y) + h;
+\0\0\0\020\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0repeat
+\0\0\0\021\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0write(' ');
+\0\0\0\022\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0n := n - 1
+\0\0\0\023\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0until n = 0;
+\0\0\0\024\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0writeln('*')
+\0\0\0\025\0\0\0\0\0\0\0\0\0\0end
+\0\0\0\026\0\0end.
diff --git a/usr/doc/pascal/bigger7.p b/usr/doc/pascal/bigger7.p
new file mode 100644 (file)
index 0000000..b4cd01d
--- /dev/null
@@ -0,0 +1,26 @@
+(*
+ * Graphic representation of a function
+ *    f(x) = exp(-x) * sin(2 * pi * x)
+ *)
+program graph1(output);
+const
+       d = 0.0625;   (* 1/16, 16 lines for interval [x, x+1] *)
+       s = 32;       (* 32 character width for interval [x, x+1] *)
+       h = 34;       (* Character position of x-axis *)
+       c = 6.28138;  (* 2 * pi *)
+       lim = 32;
+var
+       x, y: real;
+       i, n: integer;
+begin
+       for i := 0 to lim do begin
+               x := d * i;
+               y := exp(-x) * sin(c * x);
+               n := round(s * y) + h;
+               repeat
+                       write(' ');
+                       n := n - 1
+               until n = 0;
+               writeln('*')
+       end
+end.
diff --git a/usr/doc/pascal/bigout1 b/usr/doc/pascal/bigout1
new file mode 100644 (file)
index 0000000..c460c46
--- /dev/null
@@ -0,0 +1,17 @@
+Tue Oct 14 21:37 1980  bigger.p:
+     9          h = 34;       (* Character position of x-axis *)
+w \l'\w`     9          h = 34;       (`u-\w`w `u\&\(rh'\l'(\w`*`u-\w`^`u)/2 '\(ua\l'(\w`*`u-\w`^`u)/2 '\l'\w`---`u\&\(rh' (* in a (* ... *) comment
+    16          for i := 0 to lim begin
+e \l'\w`w `u-\w`e `u '\l'\w`    16          for i := 0 to lim `u-\w`w `u\&\(rh'\l'(\w`b`u-\w`^`u)/2 '\(ua\l'(\w`b`u-\w`^`u)/2 '\l'\w`---`u\&\(rh' Inserted keyword do
+    18                  y := exp(-x9 * sin(i * x);
+E \l'\w`w `u-\w`E `u '\l'\w`    18                  y := exp(-`u-\w`w `u\&\(rh'\l'(\w`x`u-\w`^`u)/2 '\(ua\l'(\w`x`u-\w`^`u)/2 '\l'\w`---`u\&\(rh' Undefined variable
+e \l'\w`w `u-\w`e `u '\l'\w`    18                  y := exp(-x9 * sin(i * x)`u-\w`w `u\&\(rh'\l'(\w`;`u-\w`^`u)/2 '\(ua\l'(\w`;`u-\w`^`u)/2 '\l'\w`---`u\&\(rh' Inserted ')'
+    19                  n := Round(s * y) + h;
+E \l'\w`w `u-\w`E `u '\l'\w`    19                  n := `u-\w`w `u\&\(rh'\l'(\w`R`u-\w`^`u)/2 '\(ua\l'(\w`R`u-\w`^`u)/2 '\l'\w`---`u\&\(rh' Undefined function
+E \l'\w`w `u-\w`E `u '\l'\w`    19                  n := Round(s * y) + `u-\w`w `u\&\(rh'\l'(\w`h`u-\w`^`u)/2 '\(ua\l'(\w`h`u-\w`^`u)/2 '\l'\w`---`u\&\(rh' Undefined variable
+    23                  writeln('*')
+e \l'\w`w `u-\w`e `u '\l'\w`    23                  `u-\w`w `u\&\(rh'\l'(\w`w`u-\w`^`u)/2 '\(ua\l'(\w`w`u-\w`^`u)/2 '\l'\w`---`u\&\(rh' Inserted ';'
+    24  end.
+E \l'\w`w `u-\w`E `u '\l'\w`    24  `u-\w`w `u\&\(rh'\l'(\w`e`u-\w`^`u)/2 '\(ua\l'(\w`e`u-\w`^`u)/2 '\l'\w`---`u\&\(rh' Expected keyword until
+E \l'\w`w `u-\w`E `u '\l'\w`    24  end.`u-\w`w `u\&\(rh'\l'(\w`.`u-\w`^`u)/2 '\(ua\l'(\w`.`u-\w`^`u)/2 '\l'\w`---`u\&\(rh' Unexpected end-of-file - QUIT
+Execution suppressed due to compilation errors
diff --git a/usr/doc/pascal/bigout2 b/usr/doc/pascal/bigout2
new file mode 100644 (file)
index 0000000..3fcf6e9
--- /dev/null
@@ -0,0 +1,9 @@
+Execution begins...
+
+
+Floating point division error
+
+        Error in "graph1"+2 near line 17.
+Execution terminated abnormally.
+
+2 statements executed in 0.05 seconds cpu time.
diff --git a/usr/doc/pascal/bigout3 b/usr/doc/pascal/bigout3
new file mode 100644 (file)
index 0000000..82239fc
--- /dev/null
@@ -0,0 +1,37 @@
+Execution begins...
+                                  *
+                                              *
+                                                      *
+                                                           *
+                                                           *
+                                                        *
+                                                  *
+                                          *
+                                  *
+                           *
+                      *
+                   *
+                   *
+                     *
+                         *
+                             *
+                                  *
+                                      *
+                                         *
+                                           *
+                                           *
+                                          *
+                                        *
+                                     *
+                                  *
+                               *
+                              *
+                             *
+                            *
+                             *
+                               *
+                                *
+                                  *
+Execution terminated.
+
+2550 statements executed in 0.30 seconds cpu time.
diff --git a/usr/doc/pascal/bigout4 b/usr/doc/pascal/bigout4
new file mode 100644 (file)
index 0000000..490a681
--- /dev/null
@@ -0,0 +1,4 @@
+Execution begins...
+Execution terminated.
+
+2550 statements executed in 0.37 seconds cpu time.
diff --git a/usr/doc/pascal/billdelta b/usr/doc/pascal/billdelta
new file mode 100644 (file)
index 0000000..a3e68cd
--- /dev/null
@@ -0,0 +1,84 @@
+From bill  Thu Oct 23 08:48:12 1980
+To: graham mckusick peter
+Subject: pascal users manual
+
+i looked it over yesterday, and noticed the following:
+
+1. on the first 2 pages the support/address things are given twice...
+see the old copy, i snowpaked or fudged to get them on only one.
+
+2. section 1.6 should say
+       Ex Reference Manual \- Version 3.5
+   dated
+       October, 1980
+   and
+       An Introduction to the C shell (Revised)
+   dated
+       October, 1980
+   and the programmers manual reference should say, after December, 1978:
+       (Virtual VAX/11 Version,
+        U.C. Berkeley
+        Berkeley, Ca.
+        November, 1980.)
+
+3. 2.1 if i say
+       % ex first.p
+   and first.p doesn't exist it says
+       [New file]
+   not No such file or directory
+   It also says this when you write out the file.
+
+4. in the example
+       % pix first.p
+   the output is missing
+
+5. in the example after ``If we now use the UNIX ls list files command''
+   the display is indented too much.
+
+6. 2.4-- why is there extra white space between the line
+       Execution terminated abnormally.
+   and the line
+       2 statements executed...
+   This is a stupid incompatibility between the VAX and the 11.
+   There is no reason to put in this extra linefeed.
+   This is a manual for both vax and 11...
+
+7. 3.3 in the section Out of Memory it says ``very large (10000) line
+   programs.''  10000 lines isnt ``very large''; 25000 lines is very large.
+
+8. 3.4 program errors.  once again a gratuiutous incompatibility with pdp-11.
+   there are 2 extra line-feeds before ``subscript out of range''... see the
+   output in the old version of the manual... i would prefer that these
+   incompatibilities (which are only stylistic) be removed.
+
+9. In the footnote in this section about 65k bytes for each variable...
+   does this apply to pc also?
+
+10. the times of the examples in 4.1 &c are very high (2* slower than
+   those reported before... either overhead is not being accounted properly
+   or the load on the machine was very hight skewing the times... try
+   rerunning the examples when the machine is lightly loaded...)
+
+11. 4.6 there are a bunch of extra blank lines in the examples at the
+   end, incompatible in output format with pdp-11.
+
+12. 5.8 this section should be deleted
+
+13. 5.10 this section should be deleted
+
+14. A.1 Enum type i/o -- how can an enumerated type value be out of
+   range?
+
+15. Separate compilation... pascal doesnt have ``modules''.
+
+16. Option control -- sh
+       % pi -ls foo.p 
+    should say
+       % pi -l -s foo.p
+
+Thats all... ill read it again, more carefully if you point me at the
+old and new sources so i can use diff to read faster.
+       bill
+
+
+
diff --git a/usr/doc/pascal/clash.p b/usr/doc/pascal/clash.p
new file mode 100644 (file)
index 0000000..4a07405
--- /dev/null
@@ -0,0 +1,9 @@
+program clash(output);
+var
+       i: integer;
+       c: char;
+begin
+       i := 1;
+       c := i;
+       write(c, i)
+end.
diff --git a/usr/doc/pascal/clashout b/usr/doc/pascal/clashout
new file mode 100644 (file)
index 0000000..ea09a71
--- /dev/null
@@ -0,0 +1,3 @@
+Tue Oct 14 21:37 1980  clash.p:
+E 7 - Type clash: integer is incompatible with char
+  ... Type of expression clashed with type of variable in assignment
diff --git a/usr/doc/pascal/comments.p b/usr/doc/pascal/comments.p
new file mode 100644 (file)
index 0000000..b07ddfc
--- /dev/null
@@ -0,0 +1,18 @@
+{ This is a left marginal comment. }
+program hello(output);
+var i : integer; {This is a trailing comment}
+j : integer;   {This is a right marginal comment}
+k : array [ 1..10] of array [1..10] of integer;        {Marginal, but past the margin}
+{
+  An aligned, multi-line comment
+  which explains what this program is
+  all about
+}
+begin
+i := 1; {Trailing i comment}
+{A left marginal comment}
+ {An aligned comment}
+j := 1;                {Right marginal comment}
+k[1] := 1;
+writeln(i, j, k[1])
+end.
diff --git a/usr/doc/pascal/comments1.p b/usr/doc/pascal/comments1.p
new file mode 100644 (file)
index 0000000..8e7de6c
--- /dev/null
@@ -0,0 +1,18 @@
+{ This is a left marginal comment. }
+program hello(output);
+var i : integer; {This is a trailing comment}
+j : integer;    {This is a right marginal comment}
+k : array [ 1..10] of array [1..10] of integer; {Marginal, but past the margin}
+{
+  An aligned, multi-line comment
+  which explains what this program is
+  all about
+}
+begin
+i := 1; {Trailing i comment}
+{A left marginal comment}
+ {An aligned comment}
+j := 1;         {Right marginal comment}
+k[1] := 1;
+writeln(i, j, k[1])
+end.
diff --git a/usr/doc/pascal/commentsout b/usr/doc/pascal/commentsout
new file mode 100644 (file)
index 0000000..afc089e
--- /dev/null
@@ -0,0 +1,21 @@
+.ta 3.25i
+{ This is a left marginal comment. }
+
+program hello(output);
+var
+    i: integer; {This is a trailing comment}
+    j: integer;        {This is a right marginal comment}
+    k: array [1..10] of array [1..10] of integer;       {Marginal, but past the margin}
+{
+  An aligned, multi-line comment
+  which explains what this program is
+  all about
+}
+begin
+    i := 1; {Trailing i comment}
+{A left marginal comment}
+    {An aligned comment}
+    j := 1;    {Right marginal comment}
+    k[1] := 1;
+    writeln(i, j, k[1])
+end.
diff --git a/usr/doc/pascal/contents.n b/usr/doc/pascal/contents.n
new file mode 100644 (file)
index 0000000..1d6e065
--- /dev/null
@@ -0,0 +1,105 @@
+.if !\n(xx .so /usr/lib/tmac.s
+.nr LL 6.5i
+.TL
+UNIX Pascal User's Manual
+.br
+Version 1.0 \- November, 1977
+.LP
+.ds CF "- \\n(PN -
+.ds CH
+.af PN i
+.ce
+.I
+.LG
+.LG
+Table of Contents
+.NL
+.R
+.sp .5i
+.KS
+.ta 5.75i
+.tc .
+.nf
+.KE
+.KS
+Introduction   \0\01
+.KE
+.sp 2
+.KS
+.B
+1.  Sources of Information     \0\02
+.R
+.sp
+ .1   Where to get documentation       \0\02
+ .2   Computer Center short courses    \0\02
+ .3   Documentation describing UNIX    \0\02
+ .4   Text editing documents   \0\03
+ .5   Pascal documents \- the language \0\04
+ .6   Pascal documents \- the UNIX implementation      \0\04
+ .7   References       \0\05
+.KE
+.sp 2
+.KS
+.B
+2.  Basic UNIX Pascal  \0\07
+.R
+.sp
+ .1   A first program  \0\07
+ .2   A larger program \010
+ .3   Correcting the first errors      \011
+ .4   Executing the second example     \014
+ .5   Formatting the program listing   \016
+ .6   Execution profiling      \016
+.KE
+.sp 2
+.KS
+.B
+3. Error diagnostics   \020
+.R
+.sp
+ .1   Translator syntax errors \020
+ .2   Translator semantic errors       \023
+ .3   Translator panics, i/o errors    \027
+ .4   Run-time errors  \027
+.KE
+.sp 2
+.KS
+.B
+4.  Input/output       \029
+.R
+.sp
+ .1   Introduction     \029
+ .2   Eof and eoln     \030
+ .3   More about eoln  \031
+ .4   Output buffering \032
+ .5   Files, reset and rewrite \032
+ .6   Argc and argv    \033
+.KE
+.sp 2
+.KS
+.B
+5.  Details on components of the system        \036
+.R
+.sp
+ .1   Options  \036
+ .2   Pi (and pix)     \037
+ .3   Px       \039
+ .4   Pxp      \039
+ .5   Formatting programs using pxp    \040
+ .6   Pcc and carriage control \042
+ .7   Pxref    \042
+ .8   Pascals  \042
+ .9   Multi-file programs      \042
+.KE
+.sp 2
+.KS
+.B
+A.  Appendix to Wirth's Pascal Report  \044
+.R
+.sp
+ .1   Extensions to the language Pascal        \045
+ .2   Resolution of the undefined specifications       \045
+ .3   Restrictions and limitations     \048
+ .4   Added types, operators, procedures and functions \048
+ .5   Remarks on standard and portable Pascal  \050
+.KE
diff --git a/usr/doc/pascal/copydata.p b/usr/doc/pascal/copydata.p
new file mode 100644 (file)
index 0000000..ecf237c
--- /dev/null
@@ -0,0 +1,15 @@
+program copydata(data, output);
+var
+    ch: char;
+    data: text;
+begin
+    reset(data);
+    while not eof(data) do begin
+       while not eoln(data) do begin
+           read(data, ch);
+           write(ch)
+       end;
+       readln(data);
+       writeln
+    end
+end { copydata }.
diff --git a/usr/doc/pascal/copydataout b/usr/doc/pascal/copydataout
new file mode 100644 (file)
index 0000000..c45bb4c
--- /dev/null
@@ -0,0 +1,26 @@
+Berkeley Pascal PI -- Version 2.0 (Sat Oct 18 21:01:54 1980)
+
+Tue Oct 14 21:37 1980  copydata.p
+
+\0\0\0\0\01\0\0program copydata(data, output);
+\0\0\0\0\02\0\0var
+\0\0\0\0\03\0\0\0\0\0\0ch: char;
+\0\0\0\0\04\0\0\0\0\0\0data: text;
+\0\0\0\0\05\0\0begin
+\0\0\0\0\06\0\0\0\0\0\0reset(data);
+\0\0\0\0\07\0\0\0\0\0\0while not eof(data) do begin
+\0\0\0\0\08\0\0\0\0\0\0\0\0\0\0while not eoln(data) do begin
+\0\0\0\0\09\0\0\0\0\0\0\0\0\0\0\0\0\0\0read(data, ch);
+\0\0\0\010\0\0\0\0\0\0\0\0\0\0\0\0\0\0write(ch)
+\0\0\0\011\0\0\0\0\0\0\0\0\0\0end;
+\0\0\0\012\0\0\0\0\0\0\0\0\0\0readln(data);
+\0\0\0\013\0\0\0\0\0\0\0\0\0\0writeln
+\0\0\0\014\0\0\0\0\0\0end
+\0\0\0\015\0\0end { copydata }.
+Execution begins...
+line one.
+line two.
+line three is the end.
+Execution terminated.
+
+134\0statements executed in 0.08 seconds cpu time.
diff --git a/usr/doc/pascal/csfix.c b/usr/doc/pascal/csfix.c
new file mode 100644 (file)
index 0000000..e78e472
--- /dev/null
@@ -0,0 +1,172 @@
+#include <stdio.h>
+/*
+ * csfix - fix constant spacing for error message flags in troff
+ *
+ * Bill Joy UCB September 11, 1977
+ *
+ * This would be better written in snobol!
+ *
+ * Normally fixes error flags in a pi listing
+ * Optional - causes fixing of '---' and initial blank widthin a pxp profile.
+ */
+
+char   flag, dflag;
+
+main(argc, argv)
+       int argc;
+       char *argv[];
+{
+
+       argc--, argv++;
+       if (argc > 0 && argv[0][0] == '-' && argv[0][1] == 'd')
+               dflag++, argc--, argv++;
+       if (argc > 0 && argv[0][0] == '-')
+               flag++, argc--, argv++;
+       if (argc != 0) {
+               write(2, "Usage: csfix\n", 13);
+               exit(1);
+       }
+       while (getline()) {
+               if (errline()) {
+                       flag ? fixpxp() : reformat();
+                       continue;
+               }
+               if (flag) {
+                       fixdigits();
+                       continue;
+               }
+               if (spwarn())
+                       continue;
+               if (nontriv())
+                       save();
+               if (dflag)
+                       fixdigits();
+               else
+                       putline();
+       }
+       exit(0);
+}
+
+char   line[160], flagee[160];
+
+getline()
+{
+       register char *cp, c;
+
+       for (cp = line, c = getchar(); c != '\n' && c != EOF; c = getchar())
+               *cp++ = c;
+       if (c == EOF)
+               return (0);
+       *cp = 0;
+       return (1);
+}
+
+errline()
+{
+       register int i;
+       register char *cp;
+
+       for (cp = line; cp[0] && cp[1] && cp[2]; cp++)
+               if (cp[0] == '-' && cp[1] == '-' && cp[2] == '-')
+                       return (1);
+       return (0);
+}
+
+reformat()
+{
+       register char *cp, c, *tail;
+
+       printf("%2.2s", line);
+       if (line[0] != 'w')
+               printf("\\l'\\w`w `u-\\w`%2.2s`u '", line);
+       for (cp = line; *cp != 0 && *cp != '^'; cp++)
+               continue;
+       tail = cp + 1;
+       if (cp[-1] == '\b' && cp[-2] == '|')
+               cp =- 2;
+       c = flagee[cp - line];
+       flagee[cp - line] = 0;
+       printf("\\l'\\w`%s`u-\\w`w `u\\&\\(rh'", flagee);
+       flagee[cp - line] = c;
+       printf("\\l'(\\w`%c`u-\\w`^`u)/2 '", c);
+       printf("\\(ua");
+       printf("\\l'(\\w`%c`u-\\w`^`u)/2 '", c);
+       printf("\\l'\\w`---`u\\&\\(rh'%s\n", tail+3);
+}
+
+nontriv()
+{
+
+       switch (line[0]) {
+               case 'E':
+               case 'e':
+               case 'w':
+               case 's':
+               case 0:
+                       return (0);
+       }
+       return (1);
+}
+
+save()
+{
+
+       strcpy(flagee, line);
+}
+
+putline()
+{
+
+       printf("%s\n", flag ? digitty(0) : line);
+}
+
+spwarn()
+{
+
+       if (line[0] != ' ' || line[1] != ' ' || line[2] != 'w')
+               return (0);
+       printf("  \\l'(\\w`E`u-\\w`w`u)/2 'w\\l'(\\w`E`u-\\w`w`u)/2 '");
+       printf(&line[3]);
+       printf("\n");
+       return (1);
+}
+
+fixpxp()
+{
+       register char *cp;
+
+       for (cp = line; *cp != '-'; cp++)
+               continue;
+       *cp = 0;
+       printf("%s\\l'\\w`\\0\\0\\0\\0`u-\\w`.`u\\&\\(rh'%s\n", digitty(1), cp + 3);
+}
+
+digitty(yup)
+       char yup;
+{
+       register char *cp, *dp, *lp;
+
+       for (lp = line; *lp && *lp != '|'; lp++)
+               continue;
+       if (yup == 0 && !*lp)
+               return (line);
+       for (cp = line, dp = flagee; cp < lp; cp++)
+               if (*cp == ' ')
+                       *dp++ = '\\', *dp++ = '0';
+               else
+                       *dp++ = *cp;
+       strcpy(dp, cp);
+       return (flagee);
+}
+
+fixdigits()
+{
+       register char *cp, c;
+
+       for (cp = line; *cp == ' ' || *cp >= '0' && *cp <= '9'; cp++)
+               continue;
+       c = *cp, *cp = 0;
+       digitty(1);
+       *cp = c;
+       printf("%s%s\n", flagee, cp);
+}
diff --git a/usr/doc/pascal/data b/usr/doc/pascal/data
new file mode 100644 (file)
index 0000000..3f9cfb5
--- /dev/null
@@ -0,0 +1,3 @@
+line one.
+line two.
+line three is the end.
diff --git a/usr/doc/pascal/digits.p b/usr/doc/pascal/digits.p
new file mode 100644 (file)
index 0000000..1e59d8d
--- /dev/null
@@ -0,0 +1,9 @@
+program digits(output);
+var r: real;
+begin
+r := 0.;
+r := .0;
+r := 1.e10;
+r := .05e-10;
+writeln(r)
+end.
diff --git a/usr/doc/pascal/digitsout b/usr/doc/pascal/digitsout
new file mode 100644 (file)
index 0000000..5e7fcca
--- /dev/null
@@ -0,0 +1,9 @@
+Tue Oct 14 21:37 1980  digits.p:
+     4  r := 0.;
+e \l'\w`w `u-\w`e `u '\l'\w`     4  r := 0.`u-\w`w `u\&\(rh'\l'(\w`;`u-\w`^`u)/2 '\(ua\l'(\w`;`u-\w`^`u)/2 '\l'\w`---`u\&\(rh' Digits required after decimal point
+     5  r := .0;
+e \l'\w`w `u-\w`e `u '\l'\w`     5  r := `u-\w`w `u\&\(rh'\l'(\w`.`u-\w`^`u)/2 '\(ua\l'(\w`.`u-\w`^`u)/2 '\l'\w`---`u\&\(rh' Digits required before decimal point
+     6  r := 1.e10;
+e \l'\w`w `u-\w`e `u '\l'\w`     6  r := 1.`u-\w`w `u\&\(rh'\l'(\w`e`u-\w`^`u)/2 '\(ua\l'(\w`e`u-\w`^`u)/2 '\l'\w`---`u\&\(rh' Digits required after decimal point
+     7  r := .05e-10;
+e \l'\w`w `u-\w`e `u '\l'\w`     7  r := `u-\w`w `u\&\(rh'\l'(\w`.`u-\w`^`u)/2 '\(ua\l'(\w`.`u-\w`^`u)/2 '\l'\w`---`u\&\(rh' Digits required before decimal point
diff --git a/usr/doc/pascal/errs b/usr/doc/pascal/errs
new file mode 100644 (file)
index 0000000..e3e5442
--- /dev/null
@@ -0,0 +1,2 @@
+soelim puman?.n | tbl | csh -cf '/usr/ucb/vtroff -t -x >lpr'
+vpr -t lpr
diff --git a/usr/doc/pascal/expr.p b/usr/doc/pascal/expr.p
new file mode 100644 (file)
index 0000000..60109af
--- /dev/null
@@ -0,0 +1,21 @@
+program x(output);
+var
+       a: set of char;
+       b: Boolean;
+       c: (red, green, blue);
+       p: ^ integer;
+       A: alfa;
+       B: packed array [1..5] of char;
+begin
+       b := true;
+       c := red;
+       new(p);
+       a := [];
+       A := 'Hello, yellow';
+       b := a and b;
+       a := a * 3;
+       if input < 2 then writeln('boo');
+       if p <= 2 then writeln('sure nuff');
+       if A = B then writeln('same');
+       if c = true then writeln('hue''s and color''s')
+end.
diff --git a/usr/doc/pascal/exprout b/usr/doc/pascal/exprout
new file mode 100644 (file)
index 0000000..90c5b15
--- /dev/null
@@ -0,0 +1,36 @@
+Berkeley Pascal PI -- Version 2.0 (Sat Oct 18 21:01:54 1980)
+
+Tue Oct 14 21:37 1980  expr.p
+
+     1  program x(output);
+     2  var
+     3          a: set of char;
+     4          b: Boolean;
+     5          c: (red, green, blue);
+     6          p: ^ integer;
+     7          A: alfa;
+     8          B: packed array [1..5] of char;
+     9  begin
+    10          b := true;
+    11          c := red;
+    12          new(p);
+    13          a := [];
+    14          A := 'Hello, yellow';
+    15          b := a and b;
+    16          a := a * 3;
+    17          if input < 2 then writeln('boo');
+    18          if p <= 2 then writeln('sure nuff');
+    19          if A = B then writeln('same');
+    20          if c = true then writeln('hue''s and color''s')
+    21  end.
+E 14 - Constant string too long
+E 15 - Left operand of and must be Boolean, not set
+E 16 - Cannot mix sets with integers and reals as operands of *
+E 17 - files may not participate in comparisons
+E 18 - pointers and integers cannot be compared - operator was <=
+E 19 - Strings not same length in = comparison
+E 20 - scalars and Booleans cannot be compared - operator was =
+In program x:
+  w - constant green is never used
+  w - constant blue is never used
+  w - variable B is used but never set
diff --git a/usr/doc/pascal/first.p b/usr/doc/pascal/first.p
new file mode 100644 (file)
index 0000000..1919694
--- /dev/null
@@ -0,0 +1,4 @@
+program first(output)
+begin
+       writeln('Hello, world!')
+end.
diff --git a/usr/doc/pascal/firstobjout b/usr/doc/pascal/firstobjout
new file mode 100644 (file)
index 0000000..99e78e3
--- /dev/null
@@ -0,0 +1,3 @@
+Hello, world!
+
+1 statements executed in 0.02 seconds cpu time.
diff --git a/usr/doc/pascal/firstobjout2 b/usr/doc/pascal/firstobjout2
new file mode 100644 (file)
index 0000000..af5626b
--- /dev/null
@@ -0,0 +1 @@
+Hello, world!
diff --git a/usr/doc/pascal/firstout b/usr/doc/pascal/firstout
new file mode 100644 (file)
index 0000000..d4b4516
--- /dev/null
@@ -0,0 +1,8 @@
+Tue Oct 14 21:37 1980  first.p:
+     2  begin
+e \l'\w`w `u-\w`e `u '\l'\w`     2  `u-\w`w `u\&\(rh'\l'(\w`b`u-\w`^`u)/2 '\(ua\l'(\w`b`u-\w`^`u)/2 '\l'\w`---`u\&\(rh' Inserted ';'
+Execution begins...
+Hello, world!
+Execution terminated.
+
+1 statements executed in 0.02 seconds cpu time.
diff --git a/usr/doc/pascal/fixcomments b/usr/doc/pascal/fixcomments
new file mode 100644 (file)
index 0000000..5201c8f
--- /dev/null
@@ -0,0 +1,6 @@
+1i
+.ta 3.25i
+.
+g/           *{/s//    {/
+w
+q
diff --git a/usr/doc/pascal/fixkatscript b/usr/doc/pascal/fixkatscript
new file mode 100644 (file)
index 0000000..7394819
--- /dev/null
@@ -0,0 +1,6 @@
+1t1
+1s/.*/\\*b&\\fR/
+3t3
+3s/.*/\\*b&\\fR/
+w
+q
diff --git a/usr/doc/pascal/flags b/usr/doc/pascal/flags
new file mode 100644 (file)
index 0000000..2a6d58b
--- /dev/null
@@ -0,0 +1,26 @@
+I am working on the section about options. As soon as you have
+stablized them, please pass them on to me. As a start I have
+listed what I perceive to be the list. Please modify and return.
+
+Option         Used by         Function
+  a            pix             separate args to px
+  b            pi, pc, pix     buffer for ``output''
+  c            pc              generate .o file
+  d            pc              internal debugging
+  e            pc              passed to ``ld''
+  g            pc              generate ``sdb'' info
+  i            pi, pc, pix     selective listing
+  l            pi, pc, pix     generate full listing (-lx passed to ``ld'')
+  n            pc              passed to ``ld''
+  o            pc              rename a.out
+  p            pc              generate ``prof'' style profiling
+  s            pi, pc, pix     warnings on standard Pascal
+  w            pi, pc, pix     other warnings
+  x            pc              passed to ``ld''
+  y            pi, pc, pix     dump symbol table
+  z            pi, pc, pix     generate ``pxp'' style profiling
+  C            pi, pc, pix     generate runtime tests
+  O            pc              optimize
+  S            pi, pc, pix     generate ``obj'' (pi and pix) or .s (pc)
+
+                       -Kirk
diff --git a/usr/doc/pascal/kat.p b/usr/doc/pascal/kat.p
new file mode 100644 (file)
index 0000000..6d80453
--- /dev/null
@@ -0,0 +1,13 @@
+program kat(input, output);
+var
+    ch: char;
+begin
+    while not eof do begin
+       while not eoln do begin
+           read(ch);
+           write(ch)
+       end;
+       readln;
+       writeln
+    end
+end { kat }.
diff --git a/usr/doc/pascal/kat2.p b/usr/doc/pascal/kat2.p
new file mode 100644 (file)
index 0000000..0dbc01a
--- /dev/null
@@ -0,0 +1,23 @@
+program kat(input, output);
+var
+    ch: char;
+    i: integer;
+    name: packed array [1..100] of char;
+begin
+    i := 1;
+    repeat
+       if i < argc then begin
+           argv(i, name);
+           reset(input, name);
+           i := i + 1
+       end;
+       while not eof do begin
+           while not eoln do begin
+               read(ch);
+               write(ch)
+           end;
+           readln;
+           writeln
+       end
+    until i >= argc
+end { kat }.
diff --git a/usr/doc/pascal/kat2out b/usr/doc/pascal/kat2out
new file mode 100644 (file)
index 0000000..c845e47
--- /dev/null
@@ -0,0 +1,8 @@
+\0\0\0\0\02\0\0\0\0\03\0\0\0\0\05\0\0\0\0\07\0\0\0\011\0\0\0\013\0\0\0\017\0\0\0\019\0\0\0\023\0\0\0\029
+\0\0\0\031\0\0\0\037\0\0\0\041\0\0\0\043\0\0\0\047\0\0\0\053\0\0\0\059\0\0\0\061\0\0\0\067\0\0\0\071
+\0\0\0\073\0\0\0\079\0\0\0\083\0\0\0\089\0\0\0\097\0\0\0101\0\0\0103\0\0\0107\0\0\0109\0\0\0113
+\0\0\0127\0\0\0131\0\0\0137\0\0\0139\0\0\0149\0\0\0151\0\0\0157\0\0\0163\0\0\0167\0\0\0173
+\0\0\0179\0\0\0181\0\0\0191\0\0\0193\0\0\0197\0\0\0199\0\0\0211\0\0\0223\0\0\0227\0\0\0229
+
+
+930\0statements executed in 0.18 seconds cpu time.
diff --git a/usr/doc/pascal/kat3.p b/usr/doc/pascal/kat3.p
new file mode 100644 (file)
index 0000000..411205c
--- /dev/null
@@ -0,0 +1,23 @@
+program kat(input, output);
+var
+    ch: char;
+    i: integer;
+    name: packed array [1..100] of char;
+begin
+    i := 1;
+    repeat
+        if i < argc then begin
+            argv(i, name);
+            reset(input, name);
+            i := i + 1
+        end;
+        while not eof do begin
+            while not eoln do begin
+                read(ch);
+                write(ch)
+            end;
+            readln;
+            writeln
+        end
+    until i >= argc
+end { kat }.
diff --git a/usr/doc/pascal/katin b/usr/doc/pascal/katin
new file mode 100644 (file)
index 0000000..220793b
--- /dev/null
@@ -0,0 +1,2 @@
+This is a line of text.
+The next line contains only an end-of-file (an invisible control-d!)
diff --git a/usr/doc/pascal/katout b/usr/doc/pascal/katout
new file mode 100644 (file)
index 0000000..d54ed9e
--- /dev/null
@@ -0,0 +1,27 @@
+Berkeley Pascal PI -- Version 2.0 (Sat Oct 18 21:01:54 1980)
+
+Tue Oct 14 21:38 1980  kat.p
+
+\0\0\0\0\01\0\0program kat(input, output);
+\0\0\0\0\02\0\0var
+\0\0\0\0\03\0\0\0\0\0\0ch: char;
+\0\0\0\0\04\0\0begin
+\0\0\0\0\05\0\0\0\0\0\0while not eof do begin
+\0\0\0\0\06\0\0\0\0\0\0\0\0\0\0while not eoln do begin
+\0\0\0\0\07\0\0\0\0\0\0\0\0\0\0\0\0\0\0read(ch);
+\0\0\0\0\08\0\0\0\0\0\0\0\0\0\0\0\0\0\0write(ch)
+\0\0\0\0\09\0\0\0\0\0\0\0\0\0\0end;
+\0\0\0\010\0\0\0\0\0\0\0\0\0\0readln;
+\0\0\0\011\0\0\0\0\0\0\0\0\0\0writeln
+\0\0\0\012\0\0\0\0\0\0end
+\0\0\0\013\0\0end { kat }.
+Execution begins...
+\0\0\0\0\02\0\0\0\0\03\0\0\0\0\05\0\0\0\0\07\0\0\0\011\0\0\0\013\0\0\0\017\0\0\0\019\0\0\0\023\0\0\0\029
+\0\0\0\031\0\0\0\037\0\0\0\041\0\0\0\043\0\0\0\047\0\0\0\053\0\0\0\059\0\0\0\061\0\0\0\067\0\0\0\071
+\0\0\0\073\0\0\0\079\0\0\0\083\0\0\0\089\0\0\0\097\0\0\0101\0\0\0103\0\0\0107\0\0\0109\0\0\0113
+\0\0\0127\0\0\0131\0\0\0137\0\0\0139\0\0\0149\0\0\0151\0\0\0157\0\0\0163\0\0\0167\0\0\0173
+\0\0\0179\0\0\0181\0\0\0191\0\0\0193\0\0\0197\0\0\0199\0\0\0211\0\0\0223\0\0\0227\0\0\0229
+
+Execution terminated.
+
+925\0statements executed in 0.15 seconds cpu time.
diff --git a/usr/doc/pascal/katscript b/usr/doc/pascal/katscript
new file mode 100644 (file)
index 0000000..f3ac809
--- /dev/null
@@ -0,0 +1,6 @@
+\*bThis is a line of text.\fR
+This is a line of text.
+\*bThe next line contains only an end-of-file (an invisible control-d!)\fR
+The next line contains only an end-of-file (an invisible control-d!)
+
+287 statements executed in 0.03 seconds cpu time.
diff --git a/usr/doc/pascal/makefile b/usr/doc/pascal/makefile
new file mode 100644 (file)
index 0000000..b251e35
--- /dev/null
@@ -0,0 +1,88 @@
+# This makefile assumes that csh is running the figures
+DEV = -x
+SEC = ?
+FIGURES=\
+       firstout firstobjout firstobjout2\
+       bigger2.p bigger3.p bigout1 bigger6.p bigout2 bigout3 bigout4\
+       primeout1 primeout2\
+       digitsout synerrout synerr2out\
+       mismout clashout sinout1 sinout2\
+       exprout typequout primeout3\
+       katout copydataout kat2out katscript xxxxqqqout xxxxqqqout2\
+       primes primes-d\
+       comments1.p commentsout
+puman: ${FIGURES}
+       soelim puman${SEC}.n | tbl | csh -cf '/usr/ucb/vtroff -t ${DEV} >lpr'
+       vpr -t lpr
+csfix:
+       cc -O csfix.c -o csfix
+firstout: first.p csfix
+       -csh -cf 'pix first.p |& expand | csfix >firstout'
+firstobjout: first.p
+       -csh -cf 'pi first.p >& firstobjout ; px >& firstobjout'
+firstobjout2: first.p
+       -csh -cf 'pi -p first.p >& firstobjout2 ; px >& firstobjout2'
+bigger2.p: bigger.p
+       -expand bigger.p >bigger2.p
+bigger3.p: bigger2.p csfix
+       cat -n bigger2.p | expand | csfix -d >bigger3.p
+bigout1: bigger.p csfix
+       -csh -cf 'pix bigger.p |& expand | csfix  >bigout1'
+bigger6.p: bigger5.p csfix
+       cat -n bigger5.p | expand | csfix -d >bigger6.p
+bigout2: bigger4.p
+       -csh -cf 'pix bigger4.p |& expand >bigout2'
+bigout3: bigger7.p
+       -csh -cf 'pix bigger7.p |& expand >bigout3'
+bigout4: bigger7.p
+       -csh -cf '(pix bigger7.p >/dev/null) |& expand > bigout4'
+primeout1: primes.p csfix
+       -csh -cf 'pix -l -z primes.p |& expand | csfix - >primeout1'
+primeout2: primes.p csfix
+       -csh -cf 'pxp -z primes.p |& expand | csfix - >primeout2'
+digitsout: digits.p csfix
+       -csh -cf 'pi digits.p |& expand | csfix >digitsout'
+synerrout: synerr.p csfix
+       -csh -cf 'pi -l synerr.p |& expand | csfix >synerrout'
+synerr2out: synerr2.p csfix
+       -csh -cf 'pix -l synerr2.p |& expand | csfix >synerr2out'
+mismout: mism.p csfix
+       -csh -cf 'pi -l mism.p |& expand | csfix >mismout'
+clashout: clash.p
+       -csh -cf 'pi clash.p |& expand >clashout'
+sinout1: sin1.p
+       -csh -cf 'pi sin1.p |& expand >sinout1'
+sinout2: sin2.p
+       -csh -cf 'pi sin2.p |& expand >sinout2'
+exprout: expr.p
+       -pi -l expr.p | expand >exprout
+typequout: typequ.p
+       -pi typequ.p >typequout
+primeout3: primes2.p csfix
+       -csh -cf 'pix primes2.p |& expand | csfix -d >primeout3'
+katout: kat.p csfix primes
+       -csh -cf 'pix -l kat.p <primes |& expand | csfix -d >katout'
+copydataout: copydata.p csfix
+       -csh -cf 'pix -l copydata.p |& expand | csfix -d >copydataout'
+kat2out: kat2.p
+       -csh -cf 'pi kat2.p ; obj primes |& csfix -d >kat2out'
+xxxxqqqout: kat2.p
+       -pi kat2.p
+       -csh -cf 'obj xxxxqqq >& xxxxqqqout'
+xxxxqqqout2: kat2.p
+       -pi -p kat2.p
+       -csh -cf 'obj xxxxqqq >& xxxxqqqout2'
+primes: primes.p
+       -pix -p primes.p > primes
+primes-d: primes
+       csfix -d <primes >primes-d
+katscript: katin
+       -csh -cf 'pi kat2.p ; obj katin >& katscript'
+       -ed - katscript < fixkatscript
+comments1.p: comments.p
+       -expand comments.p >comments1.p
+commentsout: comments.p
+       -csh -cf 'pxp comments.p |& expand >commentsout'
+       -ed - commentsout < fixcomments
+clean:
+       -rm csfix pmon.out obj lpr ${FIGURES}
diff --git a/usr/doc/pascal/makefile.bak b/usr/doc/pascal/makefile.bak
new file mode 100644 (file)
index 0000000..3338732
--- /dev/null
@@ -0,0 +1,86 @@
+# This makefile assumes that csh is running the figures
+SEC = ?
+FIGURES=\
+       firstout firstobjout firstobjout2\
+       bigger2.p bigger3.p bigout1 bigger6.p bigout2 bigout3 bigout4\
+       primeout1 primeout2\
+       digitsout synerrout synerr2out\
+       mismout clashout sinout1 sinout2\
+       exprout typequout primeout3\
+       katout copydataout kat2out katscript xxxxqqqout xxxxqqqout2\
+       primes primes-d\
+       comments1.p commentsout
+puman: ${FIGURES}
+       soelim puman${SEC}.n | tbl | csh /usr/ucb/vtroff
+csfix:
+       cc -O csfix.c -o csfix
+firstout: first.p csfix
+       pix first.p |& expand | csfix >firstout
+firstobjout: first.p
+       csh -c 'pi first.p >& firstobjout ; px >& firstobjout'
+firstobjout2: first.p
+       pi -p first.p >& firstobjout2 ; px >& firstobjout2
+bigger2.p: bigger.p
+       -expand bigger.p >bigger2.p
+bigger3.p: bigger2.p csfix
+       number bigger2.p | expand | csfix -d >bigger3.p
+bigout1: bigger.p csfix
+       pix bigger.p |& expand | csfix  >bigout1
+bigger6.p: bigger5.p csfix
+       number bigger5.p | expand | csfix -d >bigger6.p
+bigout2: bigger4.p
+       pix bigger4.p |& expand >bigout2
+bigout3: bigger7.p
+       pix bigger7.p |& expand >bigout3
+bigout4: bigger7.p
+       (pix bigger7.p >/dev/null) |& expand > bigout4
+primeout1: primes.p csfix
+       pix -l -z primes.p |& expand | csfix - >primeout1
+primeout2: primes.p csfix
+       pxp -z primes.p |& expand | csfix - >primeout2
+digitsout: digits.p csfix
+       pi digits.p |& expand | csfix >digitsout
+synerrout: synerr.p csfix
+       pi -l synerr.p |& expand | csfix >synerrout
+synerr2out: synerr2.p csfix
+       pix -l synerr2.p |& expand | csfix >synerr2out
+mismout: mism.p csfix
+       pi -l mism.p |& expand | csfix >mismout
+clashout: clash.p
+       pi clash.p |& expand >clashout
+sinout1: sin1.p
+       pi sin1.p |& expand >sinout1
+sinout2: sin2.p
+       pi sin2.p |& expand >sinout2
+exprout: expr.p
+       pi -l expr.p | expand >exprout
+typequout: typequ.p
+       -pi typequ.p >typequout
+primeout3: primes2.p csfix
+       pix primes2.p |& expand | csfix -d >primeout3
+katout: kat.p csfix primes
+       pix -l kat.p <primes |& expand | csfix -d >katout
+copydataout: copydata.p csfix
+       pix -l copydata.p |& expand | csfix -d >copydataout
+kat2out: kat2.p
+       -pi kat2.p ; px obj primes |& csfix -d >kat2out
+xxxxqqqout: kat2.p
+       -pi kat2.p
+       -px obj xxxxqqq >& xxxxqqqout
+xxxxqqqout2: kat2.p
+       pi -p kat2.p
+       -px obj xxxxqqq >& xxxxqqqout2
+primes: primes.p
+       pix -p primes.p > primes
+primes-d: primes
+       csfix -d <primes >primes-d
+katscript: katin
+       px obj katin >& katscript
+       -ed - katscript < fixkatscript
+comments1.p: comments.p
+       -expand comments.p >comments1.p
+commentsout: comments.p
+       pxp comments.p |& expand >commentsout
+       -ed - commentsout < fixcomments
+clean:
+       -rm csfix pmon.out obj ${FIGURES}
diff --git a/usr/doc/pascal/mism.p b/usr/doc/pascal/mism.p
new file mode 100644 (file)
index 0000000..a690b1e
--- /dev/null
@@ -0,0 +1,5 @@
+program mismatch(output)
+begin
+       writeln('***');
+       { The next line is the last line in the file }
+       writeln
diff --git a/usr/doc/pascal/mismout b/usr/doc/pascal/mismout
new file mode 100644 (file)
index 0000000..6873cde
--- /dev/null
@@ -0,0 +1,11 @@
+Berkeley Pascal PI -- Version 2.0 (Sat Oct 18 21:01:54 1980)
+
+Tue Oct 14 21:38 1980  mism.p
+
+     1  program mismatch(output)
+     2  begin
+e \l'\w`w `u-\w`e `u '\l'\w`     2  `u-\w`w `u\&\(rh'\l'(\w`b`u-\w`^`u)/2 '\(ua\l'(\w`b`u-\w`^`u)/2 '\l'\w`---`u\&\(rh' Inserted ';'
+     3          writeln('***');
+     4          { The next line is the last line in the file }
+     5          writeln
+E \l'\w`w `u-\w`E `u '\l'\w`     5          writeln`u-\w`w `u\&\(rh'\l'(\w` `u-\w`^`u)/2 '\(ua\l'(\w` `u-\w`^`u)/2 '\l'\w`---`u\&\(rh' Unexpected end-of-file - QUIT
diff --git a/usr/doc/pascal/motd b/usr/doc/pascal/motd
new file mode 100644 (file)
index 0000000..fbb69ce
--- /dev/null
@@ -0,0 +1,3 @@
+Cory Hall 11/70
+
+Type 'msgs' for latest system messages (Megabyte of memory installed)
diff --git a/usr/doc/pascal/pc.1.dist b/usr/doc/pascal/pc.1.dist
new file mode 100644 (file)
index 0000000..e2d2862
--- /dev/null
@@ -0,0 +1,189 @@
+.TH PC 1
+.UC 4
+.SH NAME
+pc \- Pascal compiler
+.SH SYNOPSIS
+.B pc
+[ option ] [
+.B \-i
+name ...
+] name ...
+.SH DESCRIPTION
+.I Pc
+is a Pascal compiler.  It accepts several types of arguments:
+Arguments whose names end with .p
+are taken to be Pascal source files; they are compiled and each  
+object file is left on the file whose name is that of the source with
+`.o' substituted for `.p'.
+If a single-file Pascal program is specified,
+it is compiled and loaded,
+and the `.o' is deleted.
+.PP
+A program may be separated into more than one file by placing common
+definitions in header files with extension `.h'.  Functions and
+procedures may be declared \fBexternal\fR (much like they would be
+declared \fBforward\fR) in these header files.  So that reasonable header
+files may be constructed, the restriction that \fBconst\fR, \fBtype\fR,
+\fBvar\fR and \fBprocedure\fR and \fBfunction\fR \fBexternal\fR
+declarations must appear only once and in this order is relaxed.
+.PP
+Exactly one of the separately compiled files must supply a \fBprogram\fR.
+The rest of the files
+must consist of procedures and functions which nest within the main
+program.  The compiler checks that consistent usage has been made of objects
+declared in header files, so that type checking is not
+inadvertantly subverted due to separate compilation.  External procedures
+may be used at the top level (i.e. procedures written in C); value and
+var paramters are mapped to C conventions in the obvious way.  See the
+Berkeley Pascal User's Manual for details.
+.PP
+The following options have the same meaning as in
+.IR cc (1)
+and
+.IR f77 (1).
+See
+.IR ld (1)
+for load-time options.
+.TP 6
+.B \-c
+Suppress loading and produce `.o' files for the source file.
+.TP 6
+.B \-g
+Have the compiler produce additional symbol table information for
+.IR sdb (1).
+.TP 6
+.BR \-w
+Suppress warning messages.
+.TP 6
+.B \-p
+Prepare object files for profiling, see
+.IR  prof (1).
+.TP 6
+.SM
+.B \-O
+Invoke an
+object-code improver.
+.TP 6
+.SM
+.B \-S
+Compile the named program, and leave the
+assembler-language output on the corresponding file suffixed `.s'.
+(No `.o' is created.).
+.TP 6
+.BR \-o " output"
+Name the final output file
+.I output
+instead of
+.I a.out.
+.PP
+The following options are peculiar to
+.IR pc .
+.TP 6
+.B \-C
+Compile code to perform runtime checks,
+verify
+.B assert
+statements,
+and initialize all variables to zero as in
+.IR pi .
+.TP 6
+.B  \-b
+Block buffer the file
+.I output.
+.TP 6
+.B  \-i
+Produce a listing for
+the specified procedures, functions and
+.B include
+files.
+.TP 6
+.B  \-l
+Make a program listing during translation.
+.TP 6
+.B  \-s
+Accept standard Pascal only;
+non-standard constructs cause warning diagnostics.
+.TP 6
+.B  \-z
+Allow execution profiling with
+.I pxp
+by generating statement counters, and arranging for the
+creation of the profile data file
+.I pmon.out
+when the resulting object is executed.
+.PP
+Other arguments
+are taken
+to be either loader option arguments, or
+.IR pc
+compatible object programs, typically produced by an earlier run,
+or perhaps libraries of
+.IR pc
+compatible routines.
+These programs, together with the results of any
+compilations specified, are loaded (in the order
+given) to produce an executable program.
+Certain flags can also be controlled in comments within the program
+as described in the
+.I "Berkeley Pascal User's Manual."
+.SH FILES
+.ta 2.5i
+file.p pascal source files
+.br
+file.h \fBinclude\fR file(s)
+.br
+/usr/lib/pc[01]        compiler and code generator
+.br
+/usr/lib/pc2   procedure/function integrator (inline-expansion)
+.br
+/lib/c2        peephole optimizer
+.br
+/usr/lib/pc3   separate compilation consistency checker
+.br
+/usr/lib/pc2.0strings  text of the error messages
+.br
+/usr/lib/how_pc        basic usage explanation
+.br
+/usr/lib/libpc.a       intrinsic functions and I/O library
+.br
+/usr/lib/libm.a        math library
+.br
+/lib/lib[ac].a standard libraries, see intro (3)
+.SH "SEE ALSO"
+Berkeley Pascal User's Manual
+.br
+pi(1),
+pxp(1),
+pxref(1),
+sdb(1)
+.SH DIAGNOSTICS
+For a basic explanation do
+.IP
+.B pc
+.PP
+See 
+.IR pi (1).
+for an explanation of the error message format.
+Internal errors cause messages containing the word SNARK.
+.SH AUTHORS
+Charles B. Haley, William N. Joy, and Ken Thompson
+.br
+Retargetted to the second pass of the portable
+.IR C
+compiler by Peter Kessler
+.br
+Runtime library and inline optimizer by M. Kirk McKusick
+.br
+Separate conpilation consistency checking by Louise Madrid
+.SH BUGS
+Formal parameters which are procedures and functions are not supported.
+.PP
+The keyword
+.B packed
+is recognized but has no effect.
+.PP
+Because the -s option is used by the compiler,
+it is not possible to pass the strip option to the loader.
+Thus programs which are to be stripped, must be run through 
+.IR strip (1)
+after the are compiled.
diff --git a/usr/doc/pascal/pc.1.peter b/usr/doc/pascal/pc.1.peter
new file mode 100644 (file)
index 0000000..fe3e7c7
--- /dev/null
@@ -0,0 +1,240 @@
+.TH PC 1
+.UC 4
+.SH NAME
+pc \- Pascal compiler
+.SH SYNOPSIS
+.B pc
+[ option ] [
+.B \-i
+name ...
+] name ...
+.SH DESCRIPTION
+.I Pc
+is a Pascal compiler.
+If given an argument file ending with
+.BR .p ,
+it will compile the file 
+and load it
+into an executable file called, by default,
+.IR a.out .
+.PP
+A program may be separated into more than one 
+.B .p
+file.
+.I Pc
+will compile a number of argument
+.B .p
+files into object files (with
+the extension
+.B .o
+in place of
+.BR .p ).
+Object files may then be loaded 
+into an executable
+.I a.out
+file.
+Exactly one object file must supply a 
+.B program
+statement to successfully create an executable a.out file.
+The rest of the files must consist only of 
+declarations which logically nest within the program.
+References to objects shared between separately compiled files
+are allowed if the objects are declared in
+.BR include d
+header files, whose names must end with
+.BR .h .
+Header files may only be included at the outermost level,
+and thus declare only globally available objects.
+To allow
+.BR function s
+and
+.BR procedure s
+to be declared, an
+.B external
+directive has been added, whose use is similar to the
+.B forward
+directive but restricted to appear only in
+.B .h
+files.
+.B Function
+and 
+.B procedure
+bodies may not appear in
+.B .h
+files.
+A binding phase of the compiler checks that declarations
+are used consistently, to enforce the type checking rules of Pascal.
+.PP
+Object files 
+created by other language processors may be loaded together with
+object files created by 
+.IR pc .
+The
+.BR function s
+and
+.BR procedure s
+they define must have been declared
+in
+.B .h
+files included by all the
+.B .p
+files which call those
+routines.
+Calling conventions are as in C,
+with
+.B var
+parameters passed by address.
+.PP
+See the Berkeley Pascal User's Manual for details.
+.PP
+The following options have the same meaning as in
+.IR cc (1)
+and
+.IR f77 (1).
+See
+.IR ld (1)
+for load-time options.
+.TP 6
+.B \-c
+Suppress loading and produce `.o' file(s) from source file(s).
+.TP 6
+.B \-g
+Have the compiler produce additional symbol table information for
+.IR sdb (1).
+.TP 6
+.BR \-w
+Suppress warning messages.
+.TP 6
+.B \-p
+Prepare object files for profiling, see
+.IR  prof (1).
+.TP 6
+.SM
+.B \-O
+Invoke an
+object-code improver.
+.TP 6
+.SM
+.B \-S
+Compile the named program, and leave the
+assembler-language output on the corresponding file suffixed `.s'.
+(No `.o' is created.).
+.TP 6
+.BR \-o " output"
+Name the final output file
+.I output
+instead of
+.I a.out.
+.PP
+The following options are peculiar to
+.IR pc .
+.TP 6
+.B \-C
+Compile code to perform runtime checks,
+verify
+.B assert
+statements,
+and initialize all variables to zero as in
+.IR pi .
+.TP 6
+.B  \-b
+Block buffer the file
+.I output.
+.TP 6
+.B  \-i
+Produce a listing for
+the specified procedures, functions and
+.B include
+files.
+.TP 6
+.B  \-l
+Make a program listing during translation.
+.TP 6
+.B  \-s
+Accept standard Pascal only;
+non-standard constructs cause warning diagnostics.
+.TP 6
+.B  \-z
+Allow execution profiling with
+.I pxp
+by generating statement counters, and arranging for the
+creation of the profile data file
+.I pmon.out
+when the resulting object is executed.
+.PP
+Other arguments
+are taken
+to be loader option arguments,
+perhaps libraries of
+.IR pc
+compatible routines.
+Certain flags can also be controlled in comments within the program
+as described in the
+.I "Berkeley Pascal User's Manual."
+.SH FILES
+.ta 2.5i
+file.p pascal source files
+.br
+/usr/lib/pc0   compiler
+.br
+/lib/f1        code generator
+.br
+/usr/lib/pc2   runtime integrator (inline expander)
+.br
+/lib/c2        peephole optimizer
+.br
+/usr/lib/pc3   separate compilation consistency checker
+.br
+/usr/lib/pc2.0strings  text of the error messages
+.br
+/usr/lib/how_pc        basic usage explanation
+.br
+/usr/lib/libpc.a       intrinsic functions and I/O library
+.br
+/usr/lib/libm.a        math library
+.br
+/lib/libc.a    standard libraries, see \fIintro\fP(3)
+.SH "SEE ALSO"
+Berkeley Pascal User's Manual
+.br
+pi(1),
+pxp(1),
+pxref(1),
+sdb(1)
+.SH DIAGNOSTICS
+For a basic explanation do
+.IP
+.B pc
+.PP
+See 
+.IR pi (1).
+for an explanation of the error message format.
+Internal errors cause messages containing the word SNARK.
+.SH AUTHORS
+Charles B. Haley, William N. Joy, and Ken Thompson
+.br
+Retargetted to the second pass of the portable
+.IR C
+compiler by Peter Kessler
+.br
+Runtime library and inline optimizer by M. Kirk McKusick
+.br
+Separate compilation consistency checking by Louise Madrid
+.SH BUGS
+The keyword
+.B packed
+is recognized but has no effect.
+.PP
+The binder is not as strict as described here,
+with regard to the rules about external declarations only
+in `.h' files and including `.h' files only at the outermost level.
+It will be made to perform these checks in its next incarnation,
+so users are warned not to be sloppy at the risk of losing their programs.
+.PP
+The \-z flag doesn't work for separately compiled files.
+.PP
+Because the -s option is used by the compiler,
+it is not possible to pass the strip option to the loader.
+Thus programs which are to be stripped, must be run through 
+.IR strip (1)
+after the are compiled.
diff --git a/usr/doc/pascal/pc.1.sue b/usr/doc/pascal/pc.1.sue
new file mode 100644 (file)
index 0000000..2a49633
--- /dev/null
@@ -0,0 +1,238 @@
+.TH PC 1
+.UC 4
+.SH NAME
+pc \- Pascal compiler
+.SH SYNOPSIS
+.B pc
+[ option ] [
+.B \-i
+name ...
+] name ...
+.SH DESCRIPTION
+.I Pc
+is a Pascal compiler.
+It accepts several types of files as arguments.
+Files whose names have the form
+.IR name .p
+are taken to be Pascal source files;
+they are compiled and each  
+object file is left in a corresponding file
+.IR name .o
+Files whose names have the form
+.IR name .o
+are passed through to the binding phase of the compiler.
+If only a single `.p' file is specified,
+it is compiled and loaded,
+and the `.o' file is deleted.
+Files whose name  have the form
+.IR name .s
+are treated exactly as `.p' files,
+except that they are assembled as assembler-language source
+rather than being compiled as Pascal source.
+.PP
+Portions of a Pascal program which constitute
+a sequence of \fBlabel\fR, \fBconst\fR and \fBtype\fR definitions,
+\fBvar\fR, \fBprocedure\fR and \fBfunction\fR declarations
+can be grouped together as a
+.B segment
+and separately compiled into a `.o' file.
+If more than one separately segment
+uses the same global definition or declaration,
+then that definition or declaration must be contained
+in a separate header file with the extension `.h',
+rather than in one of the segments.
+Each Pascal source segment using the common defintion or declaration
+must \fBinclude\fR the header file containing it.
+In the header files, functions and procedures to be separately compiled
+are declared \fBexternal\fR in much the same way that they are
+declared \fBforward\fR in a single file Pascal program.
+The full procedure or function declaration is contained in a segment.
+.I Pc
+treats source files containing \fBinclude\fRd header files as if
+the \fBlabel\fR, \fBconst\fR, \fBtype\fR, \fBvar\fR, \fBprocedure\fR and
+\fBfunction\fR sections of the headers were merged with the corresponding
+sections in the segment.
+Reordering or multiple instances of these sections causes a
+warning message but compilation continues.
+.PP
+Segments which are not programs, i.e., have no program body,
+can be compiled using the 
+.B \-c
+option, which inhibits the binding/loading phase.
+If that option is not used, exactly one of the files given in the
+argument list must supply a \fBprogram\fR.
+The other files are segments which are logically merged into the
+program and which provide routine bodies for all the
+\fBprocedure\fRs and \fBfunction\fRs which were declared
+\fBexternal\fR.
+External routines written in
+.I C
+may also be used;
+value and var parameters are mapped to
+.I C
+conventions in the
+obvious way.
+.PP
+The binding phase insures that the segments make consistent use
+of definitions from header files, by checking that all segments
+are compiled with the same version of each header file.
+Consequently, separate compilation cannot subvert the type
+consistency rules of Pascal.
+The binding/loading phase produces an executable file,
+which is named
+.B a.out
+unless renamed by the 
+.B \-o
+option.
+.PP
+Further details are contained in the
+.IR "Berkeley Pascal User's Manual" .
+.PP
+The following options have the same meaning as in
+.IR cc (1)
+and
+.IR f77 (1).
+See
+.IR ld (1)
+for load-time options.
+.TP 6
+.B \-c
+Suppress loading and produce `.o' files for the source file.
+.TP 6
+.B \-g
+Have the compiler produce additional symbol table information for
+.IR sdb (1).
+.TP 6
+.BR \-w
+Suppress warning messages.
+.TP 6
+.B \-p
+Prepare object files for profiling, see
+.IR  prof (1).
+.TP 6
+.SM
+.B \-O
+Invoke an
+object-code improver.
+.TP 6
+.SM
+.B \-S
+Compile the named program, and leave the
+assembler-language output on the corresponding file suffixed `.s'.
+(No `.o' is created.).
+.TP 6
+.BR \-o " output"
+Name the final output file
+.I output
+instead of
+.I a.out.
+.PP
+The following options are peculiar to
+.IR pc .
+.TP 6
+.B \-C
+Compile code to perform runtime checks,
+verify
+.B assert
+statements,
+and initialize all variables to zero as in
+.IR pi .
+.TP 6
+.B  \-b
+Block buffer the file
+.I output.
+.TP 6
+.B  \-i
+Produce a listing for
+the specified procedures, functions and
+.B include
+files.
+.TP 6
+.B  \-l
+Make a program listing during translation.
+.TP 6
+.B  \-s
+Accept standard Pascal only;
+non-standard constructs cause warning diagnostics.
+.TP 6
+.B  \-z
+Allow execution profiling with
+.I pxp
+by generating statement counters, and arranging for the
+creation of the profile data file
+.I pmon.out
+when the resulting object is executed.
+.PP
+Other arguments
+are taken
+to be either loader option arguments, or
+.I pc
+compatible object programs, typically produced by an earlier run,
+or perhaps libraries of
+.I pc
+compatible routines.
+These programs, together with the results of any
+compilations specified, are loaded (in the order
+given) to produce an executable program.
+Certain flags can also be controlled in comments within the program
+as described in the
+.I "Berkeley Pascal User's Manual."
+.SH FILES
+.ta 2i
+file.p pascal source files
+.br
+file.h \fBinclude\fR file(s)
+.br
+/usr/lib/pc[01]        compiler and code generator
+.br
+/usr/lib/pc2   procedure/function integrator (inline-expansion)
+.br
+/lib/c2        peephole optimizer
+.br
+/usr/lib/pc3   separate compilation consistency checker
+.br
+/usr/lib/pc2.0strings  text of the error messages
+.br
+/usr/lib/how_pc        basic usage explanation
+.br
+/usr/lib/libpc.a       intrinsic functions and I/O library
+.br
+/usr/lib/libm.a        math library
+.br
+/lib/libc.a    standard library, see intro (3)
+.SH "SEE ALSO"
+Berkeley Pascal User's Manual
+.br
+pi(1),
+pxp(1),
+pxref(1),
+sdb(1)
+.SH DIAGNOSTICS
+For a basic explanation do
+.IP
+.B pc
+.PP
+See 
+.IR pi (1).
+for an explanation of the error message format.
+Internal errors cause messages containing the word SNARK.
+.SH AUTHORS
+Charles B. Haley, William N. Joy, and Ken Thompson
+.br
+Retargetted to the second pass of the portable
+.I C
+compiler by Peter Kessler
+.br
+Runtime library and inline optimizer by M. Kirk McKusick
+.br
+Separate compilation consistency checking by Louise Madrid
+.SH BUGS
+The keyword
+.B packed
+is recognized but has no effect.
+.PP
+Because the -s option is used by the compiler,
+it is not possible to pass the strip option to the loader.
+Thus programs which are to be stripped, must be run through 
+.IR strip (1)
+after they are compiled.
diff --git a/usr/doc/pascal/primeout1 b/usr/doc/pascal/primeout1
new file mode 100644 (file)
index 0000000..2f258c0
--- /dev/null
@@ -0,0 +1,44 @@
+Berkeley Pascal PI -- Version 2.0 (Sat Oct 18 21:01:54 1980)
+
+Tue Oct 14 21:38 1980  primes.p
+
+\0\0\0\0\01\0\0program primes(output);
+\0\0\0\0\02\0\0const n = 50; n1 = 7; (*n1 = sqrt(n)*)
+\0\0\0\0\03\0\0var i,k,x,inc,lim,square,l: integer;
+\0\0\0\0\04\0\0\0\0\0\0prim: boolean;
+\0\0\0\0\05\0\0\0\0\0\0p,v: array[1..n1] of integer;
+\0\0\0\0\06\0\0begin
+\0\0\0\0\07\0\0\0\0\0write(2:6, 3:6); l := 2;
+\0\0\0\0\08\0\0\0\0\0x := 1; inc := 4; lim := 1; square := 9;
+\0\0\0\0\09\0\0\0\0\0for i := 3 to n do
+\0\0\0\010\0\0\0\0\0begin (*find next prime*)
+\0\0\0\011\0\0\0\0\0\0\0\0repeat x := x + inc; inc := 6-inc;
+\0\0\0\012\0\0\0\0\0\0\0\0\0\0\0if square <= x then
+\0\0\0\013\0\0\0\0\0\0\0\0\0\0\0\0\0\0begin lim := lim+1;
+\0\0\0\014\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0v[lim] := square; square := sqr(p[lim+1])
+\0\0\0\015\0\0\0\0\0\0\0\0\0\0\0\0\0\0end ;
+\0\0\0\016\0\0\0\0\0\0\0\0\0\0\0k := 2; prim := true;
+\0\0\0\017\0\0\0\0\0\0\0\0\0\0\0while prim and (k<lim) do
+\0\0\0\018\0\0\0\0\0\0\0\0\0\0\0begin k := k+1;
+\0\0\0\019\0\0\0\0\0\0\0\0\0\0\0\0\0\0if v[k] < x then v[k] := v[k] + 2*p[k];
+\0\0\0\020\0\0\0\0\0\0\0\0\0\0\0\0\0\0prim := x <> v[k]
+\0\0\0\021\0\0\0\0\0\0\0\0\0\0\0end
+\0\0\0\022\0\0\0\0\0\0\0\0until prim;
+\0\0\0\023\0\0\0\0\0\0\0\0if i <= n1 then p[i] := x;
+\0\0\0\024\0\0\0\0\0\0\0\0write(x:6); l := l+1;
+\0\0\0\025\0\0\0\0\0\0\0\0if l = 10 then
+\0\0\0\026\0\0\0\0\0\0\0\0\0\0\0begin writeln; l := 0
+\0\0\0\027\0\0\0\0\0\0\0\0\0\0\0end
+\0\0\0\028\0\0\0\0\0end ;
+\0\0\0\029\0\0\0\0\0writeln;
+\0\0\0\030\0\0end .
+Execution begins...
+\0\0\0\0\02\0\0\0\0\03\0\0\0\0\05\0\0\0\0\07\0\0\0\011\0\0\0\013\0\0\0\017\0\0\0\019\0\0\0\023\0\0\0\029
+\0\0\0\031\0\0\0\037\0\0\0\041\0\0\0\043\0\0\0\047\0\0\0\053\0\0\0\059\0\0\0\061\0\0\0\067\0\0\0\071
+\0\0\0\073\0\0\0\079\0\0\0\083\0\0\0\089\0\0\0\097\0\0\0101\0\0\0103\0\0\0107\0\0\0109\0\0\0113
+\0\0\0127\0\0\0131\0\0\0137\0\0\0139\0\0\0149\0\0\0151\0\0\0157\0\0\0163\0\0\0167\0\0\0173
+\0\0\0179\0\0\0181\0\0\0191\0\0\0193\0\0\0197\0\0\0199\0\0\0211\0\0\0223\0\0\0227\0\0\0229
+
+Execution terminated.
+
+1404\0statements executed in 0.17 seconds cpu time.
diff --git a/usr/doc/pascal/primeout2 b/usr/doc/pascal/primeout2
new file mode 100644 (file)
index 0000000..1afc636
--- /dev/null
@@ -0,0 +1,50 @@
+Berkeley Pascal PXP -- Version 1.1 (May 7, 1979)
+
+Tue Oct 14 21:38 1980  primes.p
+
+Profiled Tue Oct 21 18:48 1980
+
+\0\0\0\0\01\0\0\0\0\0\0\0\01.\l'\w`\0\0\0\0`u-\w`.`u\&\(rh'|program primes(output);
+\0\0\0\0\02\0\0\0\0\0\0\0\0\0\0\0\0\0|const
+\0\0\0\0\02\0\0\0\0\0\0\0\0\0\0\0\0\0|    n = 50;
+\0\0\0\0\02\0\0\0\0\0\0\0\0\0\0\0\0\0|    n1 = 7; (*n1 = sqrt(n)*)
+\0\0\0\0\03\0\0\0\0\0\0\0\0\0\0\0\0\0|var
+\0\0\0\0\03\0\0\0\0\0\0\0\0\0\0\0\0\0|    i, k, x, inc, lim, square, l: integer;
+\0\0\0\0\04\0\0\0\0\0\0\0\0\0\0\0\0\0|    prim: boolean;
+\0\0\0\0\05\0\0\0\0\0\0\0\0\0\0\0\0\0|    p, v: array [1..n1] of integer;
+\0\0\0\0\06\0\0\0\0\0\0\0\0\0\0\0\0\0|begin
+\0\0\0\0\07\0\0\0\0\0\0\0\0\0\0\0\0\0|    write(2: 6, 3: 6);
+\0\0\0\0\07\0\0\0\0\0\0\0\0\0\0\0\0\0|    l := 2;
+\0\0\0\0\08\0\0\0\0\0\0\0\0\0\0\0\0\0|    x := 1;
+\0\0\0\0\08\0\0\0\0\0\0\0\0\0\0\0\0\0|    inc := 4;
+\0\0\0\0\08\0\0\0\0\0\0\0\0\0\0\0\0\0|    lim := 1;
+\0\0\0\0\08\0\0\0\0\0\0\0\0\0\0\0\0\0|    square := 9;
+\0\0\0\0\09\0\0\0\0\0\0\0\0\0\0\0\0\0|    for i := 3 to n do begin (*find next prime*)
+\0\0\0\0\09\0\0\0\0\0\0\0\0\0\0\048.\l'\w`\0\0\0\0`u-\w`.`u\&\(rh'|    repeat
+\0\0\0\011\0\0\0\0\0\0\0\0\0\0\0\0\0\0\076.\l'\w`\0\0\0\0`u-\w`.`u\&\(rh'|    x := x + inc;
+\0\0\0\011\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0|    inc := 6 - inc;
+\0\0\0\012\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0|    if square <= x then begin
+\0\0\0\013\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\05.\l'\w`\0\0\0\0`u-\w`.`u\&\(rh'|    lim := lim + 1;
+\0\0\0\014\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0|    v[lim] := square;
+\0\0\0\014\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0|    square := sqr(p[lim + 1])
+\0\0\0\014\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0|    end;
+\0\0\0\016\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0|    k := 2;
+\0\0\0\016\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0|    prim := true;
+\0\0\0\017\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0|    while prim and (k < lim) do begin
+\0\0\0\018\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0157.\l'\w`\0\0\0\0`u-\w`.`u\&\(rh'|    k := k + 1;
+\0\0\0\019\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0|    if v[k] < x then 
+\0\0\0\019\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\042.\l'\w`\0\0\0\0`u-\w`.`u\&\(rh'|    v[k] := v[k] + 2 * p[k];
+\0\0\0\020\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0|    prim := x <> v[k]
+\0\0\0\020\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0|    end
+\0\0\0\020\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0|until prim;
+\0\0\0\023\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0|    if i <= n1 then 
+\0\0\0\023\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\05.\l'\w`\0\0\0\0`u-\w`.`u\&\(rh'|    p[i] := x;
+\0\0\0\024\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0|    write(x: 6);
+\0\0\0\024\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0|    l := l + 1;
+\0\0\0\025\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0|    if l = 10 then begin
+\0\0\0\026\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\05.\l'\w`\0\0\0\0`u-\w`.`u\&\(rh'|    writeln;
+\0\0\0\026\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0|    l := 0
+\0\0\0\026\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0|    end
+\0\0\0\026\0\0\0\0\0\0\0\0\0\0\0\0\0|    end;
+\0\0\0\029\0\0\0\0\0\0\0\0\0\0\0\0\0|    writeln
+\0\0\0\029\0\0\0\0\0\0\0\0\0\0\0\0\0|end.
diff --git a/usr/doc/pascal/primeout3 b/usr/doc/pascal/primeout3
new file mode 100644 (file)
index 0000000..ab23aaa
--- /dev/null
@@ -0,0 +1,12 @@
+Execution begins...
+\0\0\0\0\02\0\0\0\0\03\0\0\0\0\05\0\0\0\0\07\0\0\0\011\0\0\0\013\0\0\0\017\0\0\0\019\0\0\0\023\0\0\0\029
+\0\0\0\031\0\0\0\037\0\0\0\041\0\0\0\043\0\0\0\047\0\0\0\053\0\0\0\059\0\0\0\061\0\0\0\067\0\0\0\071
+\0\0\0\073\0\0\0\079\0\0\0\083\0\0\0\089\0\0\0\097\0\0\0101\0\0\0103\0\0\0107\0\0\0109\0\0\0113
+\0\0\0127\0\0\0131\0\0\0137\0\0\0139\0\0\0149\0\0\0151\0\0\0157\0\0\0163\0\0\0167
+
+Subscript out of range
+
+\0\0\0\0\0\0\0\0Error in "primes"+8 near line 14.
+Execution terminated abnormally.
+
+941\0statements executed in 0.50 seconds cpu time.
diff --git a/usr/doc/pascal/primes b/usr/doc/pascal/primes
new file mode 100644 (file)
index 0000000..aa282aa
--- /dev/null
@@ -0,0 +1,6 @@
+     2     3     5     7    11    13    17    19    23    29
+    31    37    41    43    47    53    59    61    67    71
+    73    79    83    89    97   101   103   107   109   113
+   127   131   137   139   149   151   157   163   167   173
+   179   181   191   193   197   199   211   223   227   229
+
diff --git a/usr/doc/pascal/primes-d b/usr/doc/pascal/primes-d
new file mode 100644 (file)
index 0000000..8d7eb8c
--- /dev/null
@@ -0,0 +1,6 @@
+\0\0\0\0\02\0\0\0\0\03\0\0\0\0\05\0\0\0\0\07\0\0\0\011\0\0\0\013\0\0\0\017\0\0\0\019\0\0\0\023\0\0\0\029
+\0\0\0\031\0\0\0\037\0\0\0\041\0\0\0\043\0\0\0\047\0\0\0\053\0\0\0\059\0\0\0\061\0\0\0\067\0\0\0\071
+\0\0\0\073\0\0\0\079\0\0\0\083\0\0\0\089\0\0\0\097\0\0\0101\0\0\0103\0\0\0107\0\0\0109\0\0\0113
+\0\0\0127\0\0\0131\0\0\0137\0\0\0139\0\0\0149\0\0\0151\0\0\0157\0\0\0163\0\0\0167\0\0\0173
+\0\0\0179\0\0\0181\0\0\0191\0\0\0193\0\0\0197\0\0\0199\0\0\0211\0\0\0223\0\0\0227\0\0\0229
+
diff --git a/usr/doc/pascal/primes.p b/usr/doc/pascal/primes.p
new file mode 100644 (file)
index 0000000..d840390
--- /dev/null
@@ -0,0 +1,30 @@
+program primes(output);
+const n = 50; n1 = 7; (*n1 = sqrt(n)*)
+var i,k,x,inc,lim,square,l: integer;
+    prim: boolean;
+    p,v: array[1..n1] of integer;
+begin
+   write(2:6, 3:6); l := 2;
+   x := 1; inc := 4; lim := 1; square := 9;
+   for i := 3 to n do
+   begin (*find next prime*)
+      repeat x := x + inc; inc := 6-inc;
+         if square <= x then
+            begin lim := lim+1;
+               v[lim] := square; square := sqr(p[lim+1])
+            end ;
+         k := 2; prim := true;
+         while prim and (k<lim) do
+         begin k := k+1;
+            if v[k] < x then v[k] := v[k] + 2*p[k];
+            prim := x <> v[k]
+         end
+      until prim;
+      if i <= n1 then p[i] := x;
+      write(x:6); l := l+1;
+      if l = 10 then
+         begin writeln; l := 0
+         end
+   end ;
+   writeln;
+end .
diff --git a/usr/doc/pascal/primes2.p b/usr/doc/pascal/primes2.p
new file mode 100644 (file)
index 0000000..7693de8
--- /dev/null
@@ -0,0 +1,30 @@
+program primes(output);
+const n = 50; n1 = 6; (*n1 = sqrt(n)*)
+var i,k,x,inc,lim,square,l: integer;
+    prim: boolean;
+    p,v: array[1..n1] of integer;
+begin
+   write(2:6, 3:6); l := 2;
+   x := 1; inc := 4; lim := 1; square := 9;
+   for i := 3 to n do
+   begin (*find next prime*)
+      repeat x := x + inc; inc := 6-inc;
+         if square <= x then
+            begin lim := lim+1;
+               v[lim] := square; square := sqr(p[lim+1])
+            end ;
+         k := 2; prim := true;
+         while prim and (k<lim) do
+         begin k := k+1;
+            if v[k] < x then v[k] := v[k] + 2*p[k];
+            prim := x <> v[k]
+         end
+      until prim;
+      if i <= n1 then p[i] := x;
+      write(x:6); l := l+1;
+      if l = 10 then
+         begin writeln; l := 0
+         end
+   end ;
+   writeln;
+end .
diff --git a/usr/doc/pascal/puman0.n b/usr/doc/pascal/puman0.n
new file mode 100644 (file)
index 0000000..cfd2ef4
--- /dev/null
@@ -0,0 +1,128 @@
+.so tmac.p
+.RP
+.TL
+Berkeley Pascal User's Manual
+.br
+Version 2.0 \- October 1980
+.AU
+William N. Joy*
+.AU
+Susan L. Graham*
+.AU
+Charles B. Haley**
+.AI
+Computer Science Division
+.if n Department of Electrical Engineering
+.if n and Computer Science
+.if t Department of Electrical Engineering and Computer Science
+University of California, Berkeley
+Berkeley, California  94720
+...AI
+...MH
+.AB
+.FS
+\s-2(C)\s0 1977, 1979, 1980 William N. Joy, Susan L. Graham, Charles B. Haley
+.FE
+.FS
+* The financial support of the first and second authors' work by
+the National Science Foundation under grants
+MCS74-07644-A03 and MCS78-07291,
+and the first author's work by an
+.SM IBM
+Graduate Fellowship
+are gratefully acknowledged.
+.FE
+.FS
+** Author's current address: S & B Associates, 1110 Centennial Ave., Piscataway, NJ  08854
+.FE
+.PP
+Berkeley
+Pascal
+is designed for interactive instructional use
+and runs on the \s-2PDP\s0/11 and \s-2VAX\s0/11 computers.
+Interpretive code is produced,
+providing fast translation at the expense of slower execution speed.
+There is also a fully compatible compiler for the \s-2VAX\s0/11.
+An execution profiler and
+Wirth's cross reference program are also
+available with the system.
+.PP
+The system supports full Pascal.
+The language accepted is 
+`standard' Pascal,
+and a small number of extensions.
+There is an option to suppress the extensions.
+The extensions include a separate compilation facility
+and the ability to link to object modules
+produced from other source languages.
+.PP
+The
+.UM
+gives a list of sources relating to the
+.UX
+system, the Pascal language, and the
+.UP
+system.
+Basic usage examples are provided for the Pascal components
+.PI ,
+.X ,
+.IX ,
+.PC ,
+and
+.XP .
+Errors commonly encountered in these programs are discussed.
+Details are given of special considerations due to the
+interactive implementation.
+A number of examples are provided including many dealing with
+input/output.  An appendix supplements Wirth's
+.I "Pascal Report"
+to form the full definition of the Berkeley implementation of the language.
+.AE
+.ND
+.SH
+'if n 'ND
+Introduction
+.PP
+The
+.UP
+.UM
+consists of five major sections and an appendix.
+In section 1 we give sources of information about 
+.UX ,
+about the programming
+language Pascal, and about the
+Berkeley
+implementation of the language.
+Section 2 introduces the
+Berkeley
+implementation and provides a number of tutorial examples.
+Section 3 discusses the error diagnostics produced by the translators
+.PC
+and
+.PI ,
+and the runtime interpreter
+.X .
+Section 4 describes input/output with special attention given to features
+of the interactive implementation and to features unique to
+.UX .
+Section 5 gives details on the components of the system
+and explanation of all relevant options.
+The
+.UM
+concludes with an appendix to Wirth's
+.I "Pascal Report"
+with which it forms a precise definition of the implementation.
+.SH
+History of the implementation
+.PP
+The first
+Berkeley
+system was written by Ken Thompson in early 1976.
+The main features of the present system were implemented by
+Charles Haley and William Joy during the latter half of 1976.
+Earlier versions of this system have been in use since January, 1977.
+.PP
+The system was moved to the \s-2VAX\s0-11
+by Peter Kessler and Kirk McKusick
+with the porting of the interpreter in the spring of 1979,
+and the implementation of the compiler in the summer of 1980.
diff --git a/usr/doc/pascal/puman1.n b/usr/doc/pascal/puman1.n
new file mode 100644 (file)
index 0000000..ae4b6aa
--- /dev/null
@@ -0,0 +1,430 @@
+.if \n(xx .bp
+.if !\n(xx \{\
+.so tmac.p \}
+.if n 'ND
+'nr H1 0
+.NH
+Sources of information
+.PP
+This section lists the resources available
+for information about
+general features of
+.UX ,
+text editing,
+the Pascal language,
+and the
+.UP
+implementation,
+concluding with a list of references.
+The available documents include both so-called standard documents \-
+those distributed with all
+.UX
+system \-
+and documents (such as this one) written at Berkeley.
+.NH 2
+Where to get documentation
+.PP
+Current documentation for most of the
+.UX
+system is available ``on line'' at your terminal.
+Details on getting such documentation interactively are given
+in section 1.3.
+.NH 2
+Documentation describing UNIX
+.PP
+The following documents are those recommended as tutorial and
+reference material about the
+.UX
+system.
+We give the documents with the introductory and tutorial materials
+first, the reference materials last.
+.SH
+UNIX For Beginners \- Second Edition
+.PP
+This document is the basic tutorial for 
+.UX
+available with the standard system.
+.SH
+Communicating with UNIX
+.PP
+This is also a basic tutorial on the system and assumes
+no previous familiarity
+with computers; it was written at Berkeley.
+.SH
+An introduction to the C shell
+.PP
+This document introduces
+.I csh,
+the shell in common use at Berkeley, and provides a good deal of general
+description about the way in which the system functions.
+It provides a useful glossary of terms used in discussing the system.
+.SH
+UNIX Programmer's Manual
+.PP
+This manual is the major source of details on the components of the
+.UX
+system.
+It consists of an Introduction,
+a permuted index,
+and eight command sections.
+Section 1 consists of descriptions of most of the ``commands''
+of
+.UX .
+Most of the other sections have limited relevance to the user
+of
+Berkeley
+Pascal, being of interest mainly to system programmers.
+.PP
+U\s-2NIX\s0
+documentation often refers the reader to sections of the manual.
+Such a reference consists of a command name and a section number or name.
+An example of such a reference would be:
+.I ed
+(1).
+Here
+.I ed
+is a command name \- the standard
+.UX
+text editor, and `(1)' indicates that its documentation is in section 1 of the
+manual.
+.PP
+The pieces of the
+Berkeley
+Pascal system are
+.I pi
+(1),
+.X
+(1),
+the combined Pascal translator and interpretive executor
+.IX
+(1),
+the Pascal compiler
+.PC
+(1),
+the Pascal execution profiler
+.XP
+(1),
+and
+the Pascal cross-reference generator
+.I pxref
+(1).
+.PP
+It is possible to obtain a copy of a manual section
+by using the
+.I man
+(1) command.
+To get the Pascal documentation just described one could issue the
+command:
+.LS
+% \*bman pi\fP
+.LE
+to the shell.
+The user input here is shown in
+.B "bold face" ;
+the `% ',
+which was printed by the shell as a prompt,
+is not.
+Similarly the command:
+.LS
+% \*bman man\fP
+.LE
+asks the
+.I man
+command to describe itself.
+.NH 2
+Text editing documents
+.PP
+The following documents introduce the various
+.UX
+text editors.
+Most Berkeley users use a version of the text editor
+.I ex;
+either
+.I edit,
+which is a version of
+.I ex
+for new and casual users,
+.I ex
+itself,
+or
+.I vi
+(visual) which focuses on the display editing portion of
+.I ex.
+.SH
+A Tutorial Introduction to the UNIX Text Editor
+.PP
+This document, written by Brian Kernighan of Bell Laboratories,
+is a tutorial for the standard
+.UX
+text editor
+.I ed.
+It introduces you to the basics of text editing,
+and provides enough information to meet day-to-day editing needs,
+for
+.I ed
+users.
+.SH
+Edit: A tutorial
+.PP
+This introduces the use of
+.I edit,
+an editor similar to
+.I ed
+which provides a more hospitable environment for beginning users.
+.SH
+Ex/edit Command Summary
+.PP
+This summarizes the features of the editors
+.I ex
+and
+.I edit
+in a concise form.  If you have used a line oriented editor before
+this summary alone may be enough to get you started.
+.SH
+Ex Reference Manual \- Version 3.5
+.PP
+A complete reference on the features of
+.I ex
+and
+.I edit.
+.SH
+An Introduction to Display Editing with Vi
+.PP
+.I Vi
+is a display oriented text editor.  It can be used on most any \s-2CRT\s0
+terminal,
+and uses the screen as a window into the file you are editing.  Changes
+you make to the file are reflected in what you see.  This manual serves
+both as an introduction to editing with
+.I vi
+and a reference manual.
+.SH
+Vi Quick Reference
+.PP
+This reference card is a handy quick guide to
+.I vi;
+you should get one when you get the introduction to
+.I vi.
+.NH 2
+Pascal documents \- The language
+.PP
+This section describes the documents on the Pascal language
+which are likely to be most useful to the
+Berkeley
+Pascal user.
+Complete references for these documents are given in section 1.7.
+.SH
+Pascal User Manual
+.PP
+By Kathleen Jensen and Niklaus Wirth, the
+.I "User Manual"
+provides a tutorial introduction to the features
+of the language Pascal,
+and serves as an excellent quick-reference to the language.
+The reader with no familiarity with Algol-like languages 
+may prefer one of the Pascal text books listed below,
+as they provide more examples and explanation.
+Particularly important here are pages 116-118 which define the syntax
+of the language.
+Sections 13 and 14 and Appendix F pertain only to the
+6000-3.4 implementation of Pascal.
+.SH
+Pascal Report
+.PP
+By Niklaus Wirth, this document is bound with the
+.I "User Manual."
+It is the guiding reference for implementors and the fundamental
+definition of the language.
+Some programmers find this report too concise to be of practical use,
+preferring the
+.I "User Manual"
+as a reference.
+.SH
+Books on Pascal
+.PP
+Several good books which teach Pascal or use it as a medium are
+available.
+The books by Wirth
+.I "Systematic Programming"
+and
+.I "Algorithms + Data Structures = Programs"
+use Pascal as a vehicle for teaching programming and data structure
+concepts respectively.
+They are both recommended.
+Other books on Pascal are listed in the references below.
+.NH 2
+Pascal documents \- The Berkeley Implementation
+.PP
+This section describes the documentation which is available
+describing the
+Berkeley
+implementation of Pascal.
+.SH
+User's Manual
+.PP
+The document you are reading is the 
+.I "User's Manual"
+for
+.UP .
+We often refer the reader to the
+Jensen-Wirth
+.I "User Manual"
+mentioned above,
+a different document with a similar name.
+.SH
+Manual sections
+.PP
+The sections relating to Pascal in the
+.I "UNIX Programmer's Manual"
+are
+.IX
+(1),
+.PI
+(1),
+.PC
+(1),
+.X
+(1),
+.I pxp
+(1),
+and
+.I pxref
+(1).
+These sections give a description of each program,
+summarize the available options,
+indicate files used by the program,
+give basic information on the diagnostics produced 
+and include a list of known bugs.
+.SH
+Implementation notes
+.PP
+For those interested in the internal organization of the
+Berkeley
+Pascal system there are a series of
+.I "Implementation Notes"
+describing these details.
+The
+.I "Berkeley Pascal PXP Implementation Notes"
+describe the Pascal interpreter
+.X \|;
+and the
+.I "Berkeley Pascal PX Implementation Notes"
+describe the structure of the
+execution profiler
+.I pxp .
+.br
+.ne 8
+.NH 2
+References
+.de re
+.sp
+.IP
+'nf
+..
+.SH
+UNIX Documents
+.re
+.I "Communicating With UNIX"
+Computer Center
+University of California, Berkeley
+January, 1978.
+.re
+.I "Edit: a tutorial"
+Ricki Blau and James Joyce
+Computing Services Division, Computing Affairs
+University of California, Berkeley
+January, 1978.
+.re
+.I "Ex/edit Command Summary"
+Computer Center
+University of California, Berkeley
+August, 1978.
+.re
+.I "Ex Reference Manual \- Version 3.5"
+.I "An Introduction to Display Editing with Vi"
+.I "Vi Quick Reference"
+William Joy
+Computer Science Division
+Department of Electrical Engineering and Computer Science
+University of California, Berkeley
+October, 1980.
+.re
+.I "An Introduction to the C shell (Revised)"
+William Joy
+Computer Science Division
+Department of Electrical Engineering and Computer Science
+University of California, Berkeley
+October, 1980.
+.re
+Brian W. Kernighan
+.I "UNIX for Beginners \- Second Edition"
+Bell Laboratories
+Murray Hill, New Jersey.
+.re
+Brian W. Kernighan
+.I "A Tutorial Introduction to the UNIX Text Editor"
+Bell Laboratories
+Murray Hill, New Jersey.
+.re
+Dennis M. Ritchie and Ken Thompson
+.I "The UNIX Time Sharing System"
+Communications of the ACM
+July 1974
+365-378.
+.re
+B. W. Kernighan and M. D. McIlroy
+.I "UNIX Programmer's Manual \- Seventh Edition"
+Bell Laboratories
+Murray Hill, New Jersey
+December, 1978.
+(Virtual VAX/11 Version,
+ U. C. Berkeley
+ Berkeley, Ca.
+ November, 1980.)
+.ne 12
+.SH
+Pascal Language Documents
+.re
+Conway, Gries and Zimmerman
+.I "A Primer on PASCAL"
+Winthrop, Cambridge Mass.
+1976, 433 pp.
+.re
+Kathleen Jensen and Niklaus Wirth
+.I "Pascal \- User Manual and Report"
+Springer-Verlag, New York.
+1975, 167 pp.
+.re
+C. A. G. Webster
+.I "Introduction to Pascal"
+Heyden and Son, New York
+1976, 129pp.
+.re
+Niklaus Wirth
+.I "Algorithms + Data structures = Programs"
+Prentice-Hall, New York.
+1976, 366 pp.
+.re
+Niklaus Wirth
+.I "Systematic Programming"
+Prentice-Hall, New York.
+1973, 169 pp.
+.SH
+Berkeley Pascal documents
+.PP
+The following documents are available from the Computer Center Library
+at the University of California, Berkeley.
+.nf
+.re
+William N. Joy, Susan L. Graham, and Charles B. Haley
+.I "Berkeley Pascal User's Manual \- Version 2.0"
+October 1980.
+.re
+William N. Joy
+.I "Berkeley Pascal PX Implementation Notes"
+Version 1.1, April 1979.
+(Vax-11 Version 2.0 By Kirk McKusick, December, 1979)
+.re
+William N. Joy
+.I "Berkeley Pascal PXP Implementation Notes"
+Version 1.1, April 1979.
diff --git a/usr/doc/pascal/puman2.n b/usr/doc/pascal/puman2.n
new file mode 100644 (file)
index 0000000..f270779
--- /dev/null
@@ -0,0 +1,826 @@
+.if \n(xx .bp
+.if !\n(xx \{\
+.so tmac.p \}
+'if n 'ND
+.nr H1 1
+.NH
+Basic UNIX Pascal
+.PP
+The following sections
+explain the basics of using
+.UP .
+In examples here we use the text editor
+.I ex 
+(1).
+Users of the text editor
+.I ed
+should have little trouble following these examples,
+as
+.I ex
+is similar to
+.I ed .
+We use
+.I ex
+because it
+allows us to make clearer examples.\(dg
+.FS
+\(dg Users with \s-2CRT\s0 terminals should find the editor
+.I vi
+more pleasant to use;
+we do not show its use here because its display oriented nature
+makes it difficult to illustrate.
+.FE
+The new
+.UX
+user will find it helpful to read one of the text editor documents
+described in section 1.4 before continuing with this section.
+.NH 2
+A first program
+.PP
+To prepare a program for
+.UP
+we first need to have an account on
+.UX
+and to `login'
+to the system on this account.
+These procedures are described in the documents
+.I "Communicating with UNIX" 
+and
+.I "UNIX for Beginners".
+.PP
+Once we are logged in we need to choose a name for our program;
+let us call it `first' as this is the first example.
+We must also choose a name for the file in which the program will be stored.
+The
+.UP
+system requires that programs reside in files which have names ending with
+the sequence `.p' so we will call our file `first.p'.
+.PP
+A sample editing session to create this file would begin:
+.LS
+% \*bex first.p\fR
+"first.p" [New file]
+:
+.LE
+We didn't expect the file to exist, so the error diagnostic doesn't
+bother us.
+The editor now knows the name of the file we are creating.
+The `:' prompt indicates that it is ready for command input.
+We can add the text for our program using the `append'
+command as follows.
+.LS
+:\*bappend\fR
+.B
+program first(output)
+begin
+       writeln('Hello, world!')
+end.
+\&.
+.R
+:
+.LE
+The line containing the single `\*b.\fR' character here indicated
+the end of the appended text.
+The `:' prompt indicates that
+.I ex
+is ready for another command.
+As the editor operates in a temporary work space we must now store the contents
+of this work space in the file `first.p'
+so we can use the Pascal 
+translator and executor
+.IX
+on it.
+.LS
+:\*bwrite\fR
+"first.p" [New file] 4 lines, 59 characters
+:\*bquit\fR
+% 
+.LE
+We wrote out the file from the edit buffer here with the
+`write'
+command, and
+.I ex
+indicated the number of lines and characters written.
+We then quit the editor, and now have a prompt from the shell.\(dd
+.FS
+\(dd Our examples here assume you are using
+.I csh.
+.FE
+.KS
+.PP
+We are ready to try
+to translate and execute our program.
+.DS
+.tr '\(aa^\(ua
+% \*bpix first.p\fR
+.so firstout
+.tr ''^^
+%
+.DE
+.KE
+.PP
+The translator first printed a syntax error diagnostic.
+The number 2 here indicates that the rest of the line is an image
+of the second line of our program.
+The translator is saying that it expected to find a `;' before the
+keyword
+.B begin
+on this line.
+If we look at the Pascal syntax charts in the Jensen-Wirth
+.I "User Manual" ,
+or at some of the sample programs therein, we will see that
+we have omitted the terminating `;' of the
+.B program 
+statement on the first
+line of our program.
+.PP
+One other thing to notice about the error diagnostic is the letter `e'
+at the beginning.
+It stands for `error',
+indicating that our input was not legal Pascal.
+The fact that it is an `e' rather than an `E'
+indicates that the translator managed to recover from this error well
+enough that generation of code and execution could take place.
+Execution is possible whenever no fatal `E' errors
+occur during translation.
+The other classes of diagnostics are `w' warnings,
+which do not necessarily indicate errors in the program,
+but point out inconsistencies which are likely to be due to program bugs,
+and `s' standard-Pascal violations.\*(dg
+.FS
+\*(dgThe standard Pascal warnings occur only when the associated
+.B s
+translator option is enabled.
+The
+.B s
+option is discussed in sections 5.1 and A.6 below.
+Warning diagnostics are discussed at the end of section 3.2,
+the associated
+.B w
+option is described in section 5.2.
+.FE
+.PP
+After completing the translation of the program to interpretive code,
+the Pascal system indicates that execution of the translated program began.
+The output from the execution of the program then appeared.
+At program termination, the Pascal runtime system indicated the
+number of statements executed, and the amount of cpu time
+used, with the resolution of the latter being 1/60'th of a second.
+.PP
+Let us now fix the error in the program and translate it to a permanent
+object code file
+.I obj
+using
+.PI .
+The program
+.PI
+translates Pascal programs but stores the object code instead of executing it\*(dd.
+.FS
+\*(ddThis script indicates some other useful approaches to debugging
+Pascal programs.
+As in
+.I ed
+we can shorten commands in
+.I ex
+to an initial prefix of the command name as we did
+with the
+.I substitute
+command here.
+We have also used the `!' shell escape command here to execute other
+commands with a shell without leaving the editor.
+.FE
+.LS
+% \*bex first.p\fR
+"first.p" 4 lines, 59 characters
+:\*b1 print\fR
+program first(output)
+:\*bs/$/;\fR
+program first(output);
+:\*bwrite\fR
+"first.p" 4 lines, 60 characters
+:\*bquit\fR
+% \*bpi first.p\fR
+%
+.LE
+If we now use the
+.UX
+.I ls
+list files command we can see what files we have:
+.LS
+% \*bls\fR
+first.p
+obj
+%
+.LE
+The file `obj' here contains the Pascal interpreter code.
+We can execute this by typing:
+.LS
+% \*bpx obj\fR
+.so firstobjout
+%
+.LE
+Alternatively, the command:
+.LS
+% \*bobj\fR
+.LE
+will have the same effect.
+Some examples of different ways to execute the program follow.
+.LS
+% \*bpx\fR
+.so firstobjout
+% \*bpi -p first.p\fR
+% \*bpx obj\fR
+.so firstobjout2
+% \*bpix -p first.p\fR
+.so firstobjout2
+%
+.LE
+.PP
+Note that
+.I px
+will assume that `obj' is the file we wish to execute
+if we don't tell it otherwise.
+The last two translations use the
+.B \-p
+no-post-mortem option to eliminate
+execution statistics and
+`Execution begins'
+and
+`Execution terminated'
+messages.
+See section 5.2 for more details.
+If we now look at the files in our directory we will see:
+.LS
+% \*bls\fR
+first.p
+obj
+%
+.LE
+We can give our object program a name other than `obj' by using the move
+command
+.I mv
+(1).
+Thus to name our program `hello':
+.LS
+% \*bmv obj hello\fR
+% \*bhello\fR
+Hello, world!
+% \*bls\fR
+first.p
+hello
+%
+.LE
+Finally we can get rid of the Pascal object code by using the
+.I rm
+(1) remove file command, e.g.:
+.LS
+% \*brm hello\fR
+% \*bls\fR
+first.p
+%
+.LE
+.PP
+For small programs which are being developed
+.IX
+tends to be more convenient to use than
+.PI
+and
+.X .
+Except for absence of the
+.I obj
+file after a
+.IX
+run,
+a
+.IX
+command is equivalent to a
+.PI
+command followed by a
+.X
+command.
+For larger programs,
+where a number of runs testing different parts of the program are
+to be made,
+.PI
+is useful as this
+.I obj
+file can be executed any desired number of times.
+.. >>> INSERT SECTION FOR PC <<<
+.NH 2
+A larger program
+.PP
+Suppose that we have used the editor to put a larger program
+in the file `bigger.p'.
+We can list this program with line numbers by using the program
+.I cat -n
+i.e.:
+.LS
+% \*bcat -n bigger.p\fR
+.so bigger3.p
+%
+.LE
+This program is similar to program 4.9 on page 30 of the
+Jensen-Wirth
+.I "User Manual" .
+A number of problems have been introduced into this example for
+pedagogical reasons.
+.br
+.PP
+If we attempt to translate and execute the program using
+.IX
+we get the following response:
+.LS
+% \*bpix bigger.p\fR
+.so bigout1
+%
+.LE
+.PP
+Since there were fatal `E' errors in our program,
+no code was generated and execution was necessarily suppressed.
+One thing which would be useful at this point is a listing of the
+program with the error messages.
+We can get this by using the command:
+.LS
+% \*bpi -l bigger.p\fR
+.LE
+There is no point in using
+.IX
+here, since we know there are fatal errors in the program.
+This command will produce the output at our terminal.
+If we are at a terminal which does not produce a hard copy
+we may wish to print this
+listing off-line on a line printer.
+We can do this with the command:
+.LS
+% \*bpi -l bigger.p | lpr\fR
+.LE
+.PP
+In the next few sections we will illustrate various aspects of the
+Berkeley
+Pascal system by correcting this program.
+.NH 2
+Correcting the first errors
+.PP
+Most of the errors which occurred in this program were
+.I syntactic
+errors, those in the format and structure of the program rather than
+its content.
+Syntax errors are flagged by printing the offending line, and then a line
+which flags the location at which an error was detected.
+The flag line also gives an explanation
+stating either a possible cause of the error,
+a simple action which can be taken to recover from the error so
+as to be able to continue the analysis,
+a symbol which was expected at the point of error,
+or an indication that the input was `malformed'.
+In the last case, the recovery may skip ahead in the input
+to a point where analysis of the program can continue.
+.PP
+In this example,
+the first error diagnostic indicates that the translator detected
+a comment within a comment.
+While this is not considered an error in `standard'
+Pascal, it usually corresponds to an error in the program which
+is being translated.
+In this case, we have accidentally omitted the trailing `*)' of the comment
+on line 8.
+We can begin an editor session to correct this problem by doing:
+.LS
+% \*bex bigger.p\fR
+"bigger.p" 24 lines, 512 characters
+:\*b8s/$/ *)\fR
+        s = 32;       (* 32 character width for interval [x, x+1] *)
+:
+.LE
+.PP
+The second diagnostic, given after line 16,
+indicates that the keyword
+.B do
+was expected before the keyword
+.B begin
+in the
+.B for
+statement.
+If we examine the
+.I statement
+syntax chart on page 118 of the
+Jensen-Wirth
+.I "User Manual"
+we will discover that
+.B do
+is a necessary part of the
+.B for
+statement.
+Similarly, we could have referred to section C.3 of the
+Jensen-Wirth
+.I "User Manual"
+to learn about the
+.B for
+statement and gotten the same information there.
+It is often useful to refer to these syntax charts and to the
+relevant sections of this book.
+.PP
+We can correct this problem by first scanning for the keyword
+.B for
+in the file and then substituting the keyword
+.B do
+to appear in front of the keyword
+.B begin
+there.
+Thus:
+.LS
+:\*b/for\fR
+       for i := 0 to lim begin
+:\*bs/begin/do &\fR
+       for i := 0 to lim do begin
+:
+.LE
+The next error in the program is easy to pinpoint.
+On line 18, we didn't hit the shift key and got a `9'
+instead of a `)'.
+The translator diagnosed that `x9'
+was an undefined variable and, later,
+that a `)' was missing in the statement.
+It should be stressed that
+.PI
+is not suggesting that you should insert a `)' before the `;'.
+It is only indicating that making this change will help it to be able to
+continue analyzing the program so as to be able to diagnose further
+errors.
+You must then determine the true cause of the error and make the
+appropriate correction to the source text.
+.PP
+This error also illustrates the fact that one error in the input may lead
+to multiple error diagnostics.
+.I Pi
+attempts
+to give only one diagnostic for each error,
+but single errors in the input sometimes appear to be more than
+one error.
+It is also the case that
+.PI
+may not detect an error when it occurs, but may detect it later in
+the input.
+This would have happened
+in this example if we had typed `x' instead of `x9'.
+.PP
+The translator next detected, on line 19, that the function
+.I Round
+and the variable
+.I h
+were undefined.
+It does not know about
+.I Round
+because
+.UP
+normally distinguishes between upper and lower case.\*(dg
+.FS
+\*(dgIn ``standard'' Pascal no distinction is made based on case.
+.FE
+On
+.UX
+lower-case is preferred\*(dd,
+.FS
+\*(ddOne good reason for using lower-case is that it is easier to type.
+.FE
+and all keywords and built-in
+.B procedure
+and
+.B function
+names are composed of lower-case letters,
+just as they are in the Jensen-Wirth
+.I "Pascal Report" .
+Thus we need to use the function
+.I round
+here.
+As far as
+.I h
+is concerned,
+we can see why it is undefined if we look back to line 9
+and note that its definition was lost in the non-terminated
+comment.
+This diagnostic need not, therefore, concern us.
+.PP
+The next error which occurred in the program caused the translator
+to insert a `;' before the statement calling
+.I writeln
+on line 23.
+If we examine the program around the point of error we will see
+that the actual error is that the keyword
+.B until
+and an associated expression have been omitted here.
+Note that the diagnostic from the translator does not indicate the actual
+error, and is somewhat misleading.
+The translator made the correction which seemed to be most plausible.
+As the omission of a `;' character is a common mistake,
+the translator chose to indicate this as a possible fix here.
+It later detected that the keyword
+.B until
+was missing, but not until it saw the keyword
+.B end
+on line 24.
+The combination of these diagnostics indicate to us the true problem.
+.PP
+The final syntactic error message indicates that the translator needed an
+.B end
+keyword to match the
+.B begin 
+at line 15.
+Since the
+.B end
+at line 24 is supposed to match this
+.B begin ,
+we can infer that another
+.B begin
+must have been mismatched, and have matched this
+.B end .
+Thus we see that we need an
+.B end
+to match the
+.B begin
+at line 16,
+and to appear before the final
+.B end .
+We can make these corrections:
+.LS
+:\*b/x9/s//x)\fR
+                y := exp(-x) * sin(i * x);
+:\*b+s/Round/round\fR
+                n := round(s * y) + h;
+:\*b/write\fR
+                        write(' ');
+:\*b/\fR
+                writeln('*')
+:\*binsert\fR
+                \*buntil n = 0;\fR
+\&\*b.\fR
+:\*b$\fR
+end.
+:\*binsert\fR
+        \*bend\fR
+\&\*b.\fR
+:
+.LE
+.PP
+At the end of each
+.B procedure
+or
+.B function
+and the end of the
+.B program
+the translator summarizes references to undefined variables
+and improper usages of variables.
+It also gives
+warnings about potential errors.
+In our program, the summary errors do not indicate any further problems
+but the warning that
+.I c
+is unused is somewhat suspicious.
+Examining the program we see that the constant was intended
+to be used in the expression which is an argument to
+.I sin ,
+so we can correct this expression, and translate the program.
+We have now made a correction for each diagnosed error
+in our program.
+.LS
+:\*b?i ?s//c /\fR
+               y := exp(-x) * sin(c * x);
+:\*bwrite\fR
+"bigger.p" 26 lines, 538 characters
+:\*bquit\fR
+% \*bpi bigger.p\fR
+%
+.LE
+It should be noted that the translator suppresses warning
+diagnostics for a particular
+.B procedure ,
+.B function
+or the main
+.B program
+when it finds severe syntax errors in that part of the source
+text.
+This is to prevent possibly confusing and
+incorrect warning diagnostics from being produced.
+Thus these warning diagnostics may not appear in a program with
+bad syntax errors until these errors are corrected.
+.KS
+.PP
+We are now ready to execute our program for the first
+time.
+We will do so in the next section after giving a listing
+of the corrected program for reference purposes.
+.LS
+% \*bcat -n bigger.p\fR
+.so bigger6.p
+%
+.LE
+.NH 2
+Executing the second example
+.PP
+We are now ready to execute the second example.
+The following output was produced by our first run.
+.LS
+% \*bpx\fR
+.so bigout2
+%
+.LE
+Here the interpreter is presenting us with a runtime error diagnostic.
+It detected a `division by zero' at line 17.
+Examining line 17, we see that we have written
+the statement `x := d / i' instead of `x := d * i'.
+We can correct this and rerun the program:
+.LS
+% \*bex bigger.p\fR
+"bigger.p" 26 lines, 538 characters
+:\*b17\fR
+        x := d / i
+:\*bs'/'*\fR
+        x := d * i
+:\*bwrite\fR
+"bigger.p" 26 lines, 538 characters
+:\*bq\fR
+% \*bpix bigger.p\fR
+.so bigout3
+%
+.LE
+.KS
+.PP
+This appears to be the output we wanted.
+We could now save the output in a file if we wished by using the shell
+to redirect the output:
+.LS
+% \*bpx > graph\fR
+.LE
+.KE
+We can use
+.I cat
+(1) to see the contents of the file graph.
+We can also make a listing of the graph on the line printer without
+putting it into a file, e.g.
+.LS
+% \*bpx | lpr\fR
+.so bigout4
+%
+.LE
+Note here that the statistics lines came out on our terminal.
+The statistics line comes out on the diagnostic output (unit 2.)
+There are two ways to get rid of the statistics line.
+We can redirect the statistics message to the printer using the
+syntax `|\|&' to the shell rather than `|', i.e.:
+.LS
+% \*bpx |\|& lpr\fR
+%
+.LE
+or we can translate the program with the
+.B p
+option disabled on the command line as we did above.
+This will disable all post-mortem dumping including the statistics line,
+thus:
+.LS
+% \*bpi -p bigger.p\fR
+% \*bpx | lpr\fR
+%
+.LE
+This option also disables the statement limit which normally guards
+against infinite looping.
+You should not use it until your program is debugged.
+Also if
+.B p
+is specified and an error occurs, you will
+not get run time diagnostic information to help you
+determine what the problem is.
+.NH 2
+Formatting the program listing
+.PP
+It is possible to use special lines within the source text of a program
+to format the program listing.
+An empty line (one with no characters on it) corresponds to a
+`space' macro in an assembler, leaving a completely blank line
+without a line number.
+A line containing only a control-l (form-feed) character
+will cause a page eject in the listing with the corresponding line number
+suppressed.
+This corresponds to an `eject' pseudo-instruction.
+See also section 5.2 for details on the
+.B n
+and
+.B i
+options of
+.PI .
+.NH 2
+Execution profiling
+.PP
+An execution profile consists of a structured listing of (all or part of)
+a program with information about the number of times each statement in
+the program was executed for a particular run of the program.
+These profiles can be used for several purposes.
+In a program which was abnormally terminated due to excessive looping
+or recursion or by a program fault, the counts can facilitate location
+of the error.
+Zero counts mark portions of the program which were not executed;
+during the early debugging stages they should prompt new test data or
+a re-examination of the program logic.
+The profile is perhaps most valuable, however, in drawing
+attention to the (typically small)
+portions of the program that dominate execution time.
+This information can be used for source level optimization.
+.SH
+An example
+.PP
+A prime number is a number which is divisible only by itself and the
+number one.
+The program
+.I primes ,
+written by Niklaus Wirth,
+determines the first few prime numbers.
+In translating the program we have specified the
+.B z
+option to
+.IX .
+This option causes the translator to generate counters and count instructions
+sufficient in number to determine the number of times each statement in the
+program was executed.\*(dg
+.FS
+\*(dgThe counts
+are completely accurate only in the absence of runtime errors and nonlocal
+.B goto
+statements.
+This is not generally a problem, however, as in structured programs
+nonlocal
+.B goto
+statements occur infrequently,
+and counts are incorrect after abnormal termination only when the
+.I "upward look"
+described below to get a count passes a suspended call point.
+.FE
+When execution of the program completes, either normally or abnormally,
+this count data is written to the file
+.I pmon.out
+in the current directory.\*(dd
+.FS
+\*(dd\c
+.I Pmon.out
+has a name similar to
+.I mon.out
+the monitor file produced by the profiling facility of the C compiler
+.I cc
+(1).
+See
+.I prof
+(1) for a discussion of the C compiler profiling facilities.
+.FE
+It is then possible to prepare an execution profile by giving
+.XP
+the name of the file associated with this data, as was done in the following
+example.
+.LS
+% \*bpix -l -z primes.p\fR
+.so primeout1
+%
+.LE
+.SH
+Discussion
+.PP
+The header lines of the outputs of
+.IX
+and
+.XP
+in this example indicate the version of the translator and execution
+profiler in use at the time this example was prepared.
+The time given with the file name (also on the header line)
+indicates the time of last modification of the program source file.
+This time serves to
+.I "version stamp"
+the input program.
+.I Pxp
+also indicates the time at which the profile data was gathered.
+.LS
+% \*bpxp -z primes.p\fR
+.so primeout2
+%
+.LE
+.KE
+.PP
+To determine the number of times a statement was executed,
+one looks to the left of the statement and finds the corresponding
+vertical bar `|'.
+If this vertical bar is labelled with a count then that count gives the 
+number of times the statement was executed.
+If the bar is not labelled, we look up in the listing to find the first
+`|' which directly above the original one which has a count and that
+is the answer.
+Thus, in our example,
+.I k
+was incremented 157 times on line 18,
+while the
+.I write
+procedure call on line 24 was executed 48 times as given by the count
+on the
+.B repeat .
+.PP
+More information on
+.I pxp
+can be found in its manual section
+.XP
+(1)
+and in sections 5.4, 5.5 and 5.10.
diff --git a/usr/doc/pascal/puman3.n b/usr/doc/pascal/puman3.n
new file mode 100644 (file)
index 0000000..100a67f
--- /dev/null
@@ -0,0 +1,721 @@
+.if \n(xx .bp
+.if !\n(xx \{\
+.so tmac.p \}
+.if n 'ND
+.nr H1 2
+.NH
+Error diagnostics
+.PP
+This section of the
+.UM
+discusses the error diagnostics of the programs
+.PI ,
+.PC
+and
+.X .
+.I Pix
+is a simple but useful program which invokes
+.PI
+and
+.X
+to do all the real processing.
+See its manual section
+.IX
+(1)
+and section 5.2 below for more details.
+All the diagnostics given by
+.PI
+will also be given by
+.PC .
+.NH 2
+Translator syntax errors
+.PP
+A few comments on the general nature of the syntax errors usually
+made by Pascal programmers
+and the recovery mechanisms of the current translator may help in using
+the system.
+.SH
+Illegal characters
+.PP
+Characters such as `$', `!', and `@' are not part of the language Pascal.
+If they are found in the source program,
+and are not part of a constant string, a constant character, or a comment,
+they are considered to be
+`illegal characters'.
+This can happen if you leave off an opening string quote `\(aa'.
+Note that the character `"', although used in English to quote strings,
+is not used to quote strings in Pascal.
+Most non-printing characters in your input are also illegal except
+in character constants and character strings.
+Except for the tab and form feed characters,
+which are used to ease formatting of the program,
+non-printing characters in the input file print as the character `?'
+so that they will show in your listing.
+.SH
+String errors
+.PP
+There is no character string of length 0 in Pascal.
+Consequently the input `\(aa\(aa' is not acceptable.
+Similarly, encountering an end-of-line after an opening string quote `\(aa'
+without encountering the matching closing quote yields the diagnostic
+``Unmatched \(aa for string''.
+It is permissible to use the character `#'
+instead of `\''
+to delimit character and constant strings for portability reasons.
+For this reason, a spuriously placed `#' sometimes causes the diagnostic
+about unbalanced quotes.
+Similarly, a `#' in column one is used when preparing programs which are to
+be kept in multiple files.
+See section 5.11 for details.
+.SH
+Comments in a comment, non-terminated comments
+.PP
+As we saw above, these errors are usually caused by leaving off a comment
+delimiter.
+You can convert parts of your program to comments
+without generating this diagnostic
+since there are two different kinds of comments \- those delimited by
+`{' and `}', and those delimited by `(*' and `*)'.
+Thus consider:
+.LS
+{ This is a comment enclosing a piece of program
+a := functioncall;     (* comment within comment *)
+procedurecall;
+lhs := rhs;            (* another comment *)
+}
+.LE
+.PP
+By using one kind of comment exclusively in your program you can use
+the other delimiters when you need to
+``comment out''
+parts of your program\*(dg.
+.FS
+\*(dgIf you wish to transport your program,
+especially to the 6000-3.4 implementation,
+you should use the character sequence `(*' to delimit comments.
+For transportation over the
+.I rcslink
+to Pascal 6000-3.4, the character `#' should be used to delimit characters
+and constant strings.
+.FE
+In this way you will also allow the translator to help by detecting
+statements accidentally placed within comments.
+.PP
+If a comment does not terminate before the end of the input file,
+the translator will point to the beginning of the comment,
+indicating that the comment is not terminated.
+In this case processing will terminate immediately.
+See the discussion of ``QUIT'' below.
+.SH
+Digits in numbers
+.PP
+This part of the language is a minor nuisance.
+Pascal requires digits in real numbers both before and after the decimal
+point.
+Thus the following statements, which look quite reasonable to
+.SM
+FORTRAN
+.NL
+users, generate diagnostics in Pascal:
+.LS
+.so digitsout
+.LE
+These same constructs are also illegal as input to the Pascal interpreter
+.I px .
+.SH
+Replacements, insertions, and deletions
+.PP
+When a syntax error is encountered in the input text,
+the parser invokes an error recovery procedure.
+This procedure examines the input text immediately after the point
+of error and considers a set of simple corrections to see whether they
+will allow the analysis to continue.
+These corrections involve replacing an input token with a different
+token,
+inserting a token,
+or replacing an input token with a different token.
+Most of these changes will not cause fatal syntax errors.
+The exception is the insertion of or replacement with a symbol
+such as an identifier or a number;
+in this case the recovery makes no attempt to determine
+.I which
+identifier or
+.I what 
+number should be inserted,
+hence these are considered fatal syntax errors.
+.PP
+Consider the following example.
+.LS
+% \*bpix -l synerr.p\fR
+.tr --
+.so synerrout
+%
+.LE
+The only surprise here may be that Pascal does not have an exponentiation
+operator, hence the complaint about `**'.
+This error illustrates that, if you assume that the language has a feature
+which it does not, the translator diagnostic may not indicate this,
+as the translator is unlikely to recognize the construct you supply.
+.SH
+Undefined or improper identifiers
+.PP
+If an identifier is encountered in the input but is undefined,
+the error recovery will replace it with an identifier of the
+appropriate class.
+Further references to this identifier will be summarized at the
+end of the containing
+.B procedure
+or
+.B function
+or at the end of the
+.B program
+if the reference occurred in the main program.
+Similarly,
+if an identifier is used in an inappropriate way,
+e.g. if a
+.B type
+identifier is used in an assignment statement,
+or if a simple variable
+is used where a
+.B record
+variable is required,
+a diagnostic will be produced and an identifier of the appropriate
+type inserted.
+Further incorrect references to this identifier will be flagged only
+if they involve incorrect use in a different way,
+with all incorrect uses being summarized in the same way as undefined
+variable uses are.
+.SH
+Expected symbols, malformed constructs
+.PP
+If none of the above mentioned corrections appear reasonable, the
+error recovery will examine the input 
+to the left of the point of error to see if there is only one symbol
+which can follow this input.
+If this is the case, the recovery will print a diagnostic which
+indicates that the given symbol was `Expected'.
+.PP
+In cases where none of these corrections resolve the problems
+in the input,
+the recovery may issue a diagnostic that indicates that the
+input is ``malformed''.
+If necessary, the translator may then skip forward in the input to
+a place where analysis can continue.
+This process may cause some errors in the text to be missed.
+.PP
+Consider the following example:
+.LS
+% \*bpix -l synerr2.p\fR
+.so synerr2out
+%
+.LE
+Here we misspelled
+.I output
+and gave a
+.SM FORTRAN
+style variable declaration
+which the translator diagnosed as a `Malformed declaration'.
+When, on line 6, we used `(' and `)' for subscripting
+(as in
+.SM FORTRAN )
+rather than the `[' and `]' which are used in Pascal,
+the translator noted that
+.I a
+was not defined as a
+.B procedure .
+This occurred because
+.B procedure
+and
+.B function
+argument lists are delimited by parentheses in Pascal.
+As it is not permissible to assign to procedure calls the translator
+diagnosed a malformed statement at the point of assignment.
+.SH
+Expected and unexpected end-of-file, ``QUIT''
+.PP
+If the translator finds a complete program, but there is more non-comment text
+in the input file, then it will indicate that an end-of-file was expected.
+This situation may occur after a bracketing error, or if too many
+.B end s
+are present in the input.
+The message may appear
+after the recovery says that it
+``Expected \`.\'\|''
+since `.' is the symbol that terminates a program.
+.PP
+If severe errors in the input prohibit further processing
+the translator may produce a diagnostic followed by ``QUIT''.
+One example of this was given above \-
+a non-terminated comment;
+another example is a line which is longer than 160
+characters.
+Consider also the following example.
+.LS
+% \*bpix -l mism.p\fR
+.so mismout
+%
+.LE
+.NH 2
+Translator semantic errors
+.PP
+The extremely large number of semantic diagnostic messages which the translator
+produces make it unreasonable to discuss each message or group of messages
+in detail.
+The messages are, however, very informative.
+We will here explain the typical formats and the terminology used in the error
+messages so that you will be able to make sense out of them.
+In any case in which a diagnostic is not completely comprehensible you can
+refer to the
+.I "User Manual"
+by Jensen and Wirth for examples.
+.SH
+Format of the error diagnostics
+.PP
+As we saw in the example program above, the error diagnostics from
+the Pascal translator include the number of a line in the text of the program
+as well as the text of the error message.
+While this number is most often the line where the error occurred, it
+is occasionally the number of a line containing a bracketing keyword
+like
+.B end
+or
+.B until .
+In this case, the diagnostic may refer to the previous statement.
+This occurs because of the method the translator uses for sampling line
+numbers.
+The absence of a trailing `;' in the previous statement causes the line
+number corresponding to the
+.B end
+or
+.B until .
+to become associated with the statement.
+As Pascal is a free-format language, the line number associations
+can only be approximate and may seem arbitrary to some users.
+This is the only notable exception, however, to reasonable associations.
+.SH
+Incompatible types
+.PP
+Since Pascal is a strongly typed language, many semantic errors manifest
+themselves as type errors.
+These are called `type clashes' by the translator.
+The types allowed for various operators in the language are summarized on page
+108 of the
+Jensen-Wirth
+.I "User Manual" .
+It is important to know that the Pascal translator, in its diagnostics,
+distinguishes between the following type `classes':
+.br
+.ne 8
+.TS
+center;
+lew(10) le le le le.
+array  Boolean char    file    integer
+pointer        real    record  scalar  string
+.TE
+These words are plugged into a great number of error messages.
+Thus, if you tried to assign an
+.I integer
+value to a
+.I char
+variable you would receive a diagnostic like the following:
+.LS
+.so clashout
+.LE
+In this case, one error produced a two line error message.
+If the same error occurs more than once, the same explanatory
+diagnostic will be given each time.
+.SH
+Scalar
+.PP
+The only class whose meaning is not self-explanatory is 
+`scalar'.
+Scalar has a precise meaning in the
+Jensen-Wirth
+.I "User Manual"
+where, in fact, it refers to
+.I char ,
+.I integer ,
+.I real ,
+and
+.I Boolean
+types as well as the enumerated types.
+For the purposes of the Pascal translator,
+scalar
+in an error message refers to a user-defined, enumerated
+type, such as
+.I ops
+in the example above or
+.I color
+in
+.LS
+\*btype\fP color = (red, green, blue)
+.LE
+For integers, the more explicit denotation
+.I integer
+is used.
+Although it would be correct, in the context of the
+.I "User Manual"
+to refer to an integer variable as a
+.I scalar
+variable
+.PI
+prefers the more specific identification.
+.SH
+Function and procedure type errors
+.PP
+For built-in procedures and functions, two kinds of errors occur.
+If the routines are called with the wrong number of arguments a message similar to:
+.LS
+.so sinout1
+.LE
+is given.
+If the type of the argument is wrong, a message like
+.LS
+.so sinout2
+.LE
+is produced.
+A few functions and procedures implemented in Pascal 6000-3.4 are
+diagnosed as unimplemented in
+Berkeley
+Pascal, notably those related to
+.B segmented 
+files.
+.SH
+Can't read and write scalars, etc.
+.PP
+The messages which state that scalar (user-defined) types
+cannot be written to and from files are often mysterious.
+It is in fact the case that if you define
+.LS
+\*btype\fP color = (red, green, blue)
+.LE
+``standard'' Pascal does not associate these constants with the strings
+`red', `green', and `blue' in any way.
+An extension has been added which allows enumerated types
+to be read and written, 
+however if the program is to be portable,
+you will have to write your own routines to perform these functions.
+Standard Pascal only allows the reading of characters, integers and real
+numbers from text files.
+You cannot read strings or Booleans.
+It is possible to make a
+.LS
+\*bfile of\fP color
+.LE
+but the representation is binary rather than string.
+.SH
+Expression diagnostics
+.PP
+The diagnostics for semantically ill-formed expressions are very explicit.
+Consider this sample translation:
+.LS
+% \*bpi -l expr.p\fP
+.so exprout
+%
+.LE
+This example is admittedly far-fetched, but illustrates that the error
+messages are sufficiently clear to allow easy determination of the
+problem in the expressions.
+.SH
+Type equivalence
+.PP
+Several diagnostics produced by the Pascal translator complain about
+`non-equivalent types'.
+In general,
+Berkeley
+Pascal considers variables to have the same type only if they were
+declared with the same constructed type or with the same type identifier.
+Thus, the variables
+.I x
+and
+.I y
+declared as
+.LS
+\*bvar\fP
+    x: ^ integer;
+    y: ^ integer;
+.LE
+do not have the same type.
+The assignment
+.LS
+x := y
+.LE
+thus produces the diagnostics:
+.LS
+.so typequout
+.LE
+Thus it is always necessary to declare a type such as
+.LS
+\*btype\fP intptr = ^ integer;
+.LE
+and use it to declare
+.LS
+\*bvar\fP x: intptr; y: intptr;
+.LE
+Note that if we had initially declared
+.LS
+\*bvar\fP x, y: ^ integer;
+.LE
+then the assignment statement would have worked.
+The statement
+.LS
+x^ := y^
+.LE
+is allowed in either case.
+Since the parameter to a
+.B procedure
+or
+.B function
+must be declared with a
+type identifier rather than a constructed type,
+it is always necessary, in practice,
+to declare any type which will be used in this way.
+.SH
+Unreachable statements
+.PP
+Berkeley
+Pascal flags unreachable statements.
+Such statements usually correspond to errors in the program logic.
+Note that a statement is considered to be reachable
+if there is a potential path of control,
+even if it can never be taken.
+Thus, no diagnostic is produced for the statement:
+.LS
+\*bif\fP false \*bthen\fP
+    writeln('impossible!')
+.LE
+.SH
+Goto's into structured statements
+.PP
+The translator detects and complains about
+.B goto
+statements which transfer control into structured statements (\c
+.B for ,
+.B while ,
+etc.)
+It does not allow such jumps, nor does it allow branching from the
+.B then
+part of an
+.B if
+statement into the
+.B else
+part.
+Such checks are made only within the body of a single procedure or
+function.
+.SH
+Unused variables, never set variables
+.PP
+Although
+.PI
+always clears variables to 0 at
+.B procedure
+and
+.B function
+entry,
+.PC
+does not unless runtime checking is enabled using the
+.B C
+option.
+It is
+.B not
+good programming practice to rely on this initialization.
+To discourage this practice, and to help detect errors in program logic,
+.PI
+flags as a `w' warning error:
+.IP
+.RS
+.HP 1)
+Use of a variable which is never assigned a value.
+.IP 2)
+A variable which is declared but never used, distinguishing
+between those variables for which values are computed but which are never
+used, and those completely unused.
+.RE
+.LP
+In fact, these diagnostics are applied to all declared items.
+Thus a
+.B const
+or a
+.B procedure
+which is declared but never used is flagged.
+The
+.B w
+option of
+.PI
+may be used to suppress these warnings;
+see sections 5.1 and 5.2.
+.NH 2
+Translator panics, i/o errors
+.SH
+Panics
+.PP
+One class of error which rarely occurs, but which causes termination
+of all processing when it does is a panic.
+A panic indicates a translator-detected internal inconsistency.
+A typical panic message is:
+.LS
+snark (rvalue) line=110 yyline=109
+Snark in pi
+.LE
+If you receive such a message, the translation will be quickly and perhaps
+ungracefully terminated.
+You should contact a teaching assistant or a member of the system staff,
+after saving a copy of your program for later inspection.
+If you were making changes to an existing program when the problem
+occurred, you may
+be able to work around the problem by ascertaining which change caused the
+.I snark
+and making a different change or correcting an error in the program.
+A small number of panics are possible in
+.X .
+All panics should be reported to a teaching assistant or systems
+staff so that they can be fixed.
+.SH
+Out of memory
+.PP
+The only other error which will abort translation when no errors are
+detected is running out of memory.
+All tables in the translator, with the exception of the parse stack,
+are dynamically allocated, and can grow to take up the full available
+process space of 64000 bytes on the \s-2PDP\s0-11.  On the \s-2VAX\s0-11,
+table sizes are extremely generous and very large (25000) line programs
+have been easily accommodated.  For the \s-2PDP\s0\-11, it is
+generally true that
+the size of the largest translatable program is directly related to
+.B procedure
+and
+.B function
+size.
+A number of non-trivial Pascal programs, including
+some with more than 2000 lines and 2500 statements
+have been translated and interpreted using
+Berkeley
+Pascal on \s-2PDP\s0-11's.
+Notable among these are the Pascal-S
+interpreter,
+a large set of programs for automated generation of
+code generators,
+and a general context-free parsing program which has been used to
+parse sentences with a grammar for a superset of English.
+In general,
+very large programs should be translated using
+.PC
+and the separate compilation facility.
+.PP
+If you receive an out of space message from the translator 
+during translation of a large
+.B procedure
+or
+.B function
+or one containing a large number of string constants
+you may yet be able
+to translate your program if you break this one
+.B procedure
+or
+.B function
+into several routines.
+.SH
+I/O errors
+.PP
+Other errors which you may encounter when running
+.PI
+relate to input-output.
+If
+.PI
+cannot open the file you specify,
+or if the file is empty,
+you will be so informed.
+.NH 2
+Run-time errors
+.PP
+We saw, in our second example, a run-time error.
+We here give the general description of run-time errors.
+The more unusual interpreter error messages are explained
+briefly in the manual section for
+.I px 
+(1).
+.SH
+Start-up errors
+.PP
+These errors occur when the object file to be executed is not available
+or appropriate.
+Typical errors here are caused by the specified object file not existing,
+not being a Pascal object, or being inaccessible to the user.
+.SH
+Program execution errors
+.PP
+These errors occur when the program interacts with the Pascal runtime
+environment in an inappropriate way.
+Typical errors are values or subscripts out of range,
+bad arguments to built-in functions,
+exceeding the statement limit because of an infinite loop,
+or running out of memory\*(dd.
+.FS
+\*(ddThe checks for running out of memory are not foolproof and there
+is a chance that the interpreter will fault, producing a core image
+when it runs out of memory.
+This situation occurs very rarely.
+.FE
+The interpreter will produce a backtrace after the error occurs,
+showing all the active routine calls,
+unless the
+.B p
+option was disabled when the program was translated.
+Unfortunately, no variable values are given and no way of extracting them
+is available.*
+.FS
+* On the \s-2VAX\s0-11, each variable
+is restricted to allocate at most 65000 bytes of storage (this is a
+\s-2PDP\s0-11ism that has survived to the \s-2VAX\s0.)
+.FE
+.PP
+As an example of such an error, assume that we have accidentally
+declared the constant
+.I n1
+to be 6, instead of 7
+on line 2 of the program primes as given in section 2.6 above.
+If we run this program we get the following response.
+.LS
+% \*bpix primes.p\fP
+.so primeout3
+%
+.LE
+.PP
+Here the interpreter indicates that the program terminated
+abnormally due to a subscript out of range near line 14,
+which is eight lines into the body of the program primes.
+.SH
+Interrupts
+.PP
+If the program is interrupted while executing
+and the
+.B p
+option was not specified,
+then a backtrace will be printed.\*(dg
+.FS
+\*(dgOccasionally, the Pascal system will be in an inconsistent
+state when this occurs,
+e.g. when an interrupt terminates a
+.B procedure
+or
+.B function
+entry or exit.
+In this case, the backtrace will only contain the current line.
+A reverse call order list of procedures will not be given.
+.FE
+The file
+.I pmon.out
+of profile information will be written if the program was translated
+with the
+.B z
+option enabled to
+.PI
+or
+.IX .
+.SH
+I/O interaction errors
+.PP
+The final class of interpreter errors results from inappropriate
+interactions with files, including the user's terminal.
+Included here are bad formats for integer and real numbers (such as
+no digits after the decimal point) when reading.
diff --git a/usr/doc/pascal/puman4.n b/usr/doc/pascal/puman4.n
new file mode 100644 (file)
index 0000000..c5e09a1
--- /dev/null
@@ -0,0 +1,577 @@
+.if \n(xx .bp
+.if !\n(xx \{\
+.so tmac.p \}
+.nr H1 3
+.if n 'ND
+.NH
+Input/output
+.PP
+This section describes features of the Pascal input/output environment,
+with special consideration of the features peculiar to an
+interactive implementation.
+.NH 2
+Introduction
+.PP
+Our first sample programs, in section 2, used the file
+.I output .
+We gave examples there of redirecting the output to a file and to the line
+printer using the shell.
+Similarly, we can read the input from a file or another program.
+Consider the following Pascal program which is similar to the program
+.I cat 
+(1).
+.LS
+% \*bpix -l kat.p <primes\fR
+.so katout
+%
+.LE
+Here we have used the shell's syntax to redirect the program input from
+a file in
+.I primes
+in which we had placed the output of our prime number program of section 2.6.
+It is also possible to
+`pipe' input to this program much as we piped input
+to the line printer daemon
+.I lpr
+(1)
+before.
+Thus, the same output as above would be produced by
+.LS
+% \*bcat primes | pix -l kat.p\fR
+.LE
+.PP
+All of these examples use the shell to control the input and output
+from files.
+One very simple way to associate Pascal files with named
+.UX
+files is to place the file name in the
+.B program
+statement.
+For example, suppose we have previously created the file
+.I data.
+We then use it as input to another version of a listing program.
+.LS
+% \*bcat data\fR
+.so data
+% \*bpix -l copydata.p\fR
+.so copydataout
+%
+.LE
+By mentioning the file
+.I data
+in the
+.B program
+statement, we have indicated that we wish it
+to correspond to the
+.UX
+file
+.I data .
+Then, when we
+`reset(data)',
+the Pascal system opens our file `data' for reading.
+More sophisticated, but less portable, examples of using
+.UX
+files will be given in sections 4.5 and 4.6.
+There is a portability problem even with this simple example.
+Some Pascal systems attach meaning to the ordering of the file in the
+.B program
+statement file list.
+.UP
+does not do so.
+.NH 2
+Eof and eoln
+.PP
+An extremely common problem encountered by new users of Pascal, especially
+in the interactive environment offered by
+.UX ,
+relates to the definitions of
+.I eof
+and
+.I eoln .
+These functions are supposed to be defined at the beginning of execution of
+a Pascal program, indicating whether the input device is at the end of a
+line or the end of a file.
+Setting
+.I eof
+or
+.I eoln
+actually corresponds to an implicit read in which the input is
+inspected, but no input is ``used up''.
+In fact, there is no way the system can know whether the input is
+at the end-of-file or the end-of-line unless it attempts to read a line from it.
+If the input is from a previously created file,
+then this reading can take place without run-time action by the user.
+However, if the input is from a terminal, then the input
+is what the user types.\*(dg
+If the system were to do an initial read
+automatically at the beginning of program execution,
+and if the input were a terminal,
+the user would have to type some input before execution could begin.
+.FS
+\*(dgIt is not possible to determine whether the input is
+a terminal, as the input may appear to be a file but actually be a
+.I pipe,
+the output of a program which is reading from the terminal.
+.FE
+This would make it impossible for the program to begin by prompting
+for input or printing a herald.
+.PP
+.UP
+has been designed so that an initial read is not necessary.
+At any given time, the Pascal system may or may not know whether the
+end-of-file or end-of-line conditions are true.
+Thus, internally, these functions can have three values \-
+true, false, and ``I don't know yet; if you ask me I'll have to
+find out''.
+All files remain in this last, indeterminate state until the Pascal
+program requires a value for
+.I eof
+or
+.I eoln
+either explicitly or implicitly, e.g. in a call to
+.I read .
+The important point to note here is that if you force the Pascal
+system to determine whether the input is at the end-of-file or the end-of-line,
+it will be necessary for it to attempt to read from the input.
+.PP
+Thus consider the following example code
+.LS
+\*bwhile not\fP eof \*bdo\fP \*bbegin\fP
+    write('number, please? ');
+    read(i);
+    writeln('that was a ', i: 2)
+\*bend\fP
+.LE
+At first glance, this may be appear to be a correct program
+for requesting, reading and echoing numbers.
+Notice, however, that the
+.B while
+loop asks whether
+.I eof
+is true
+.I before
+the request is printed.
+This will force the Pascal system to decide whether the input is at the
+end-of-file.
+The Pascal system will give no messages;
+it will simply wait for the user to type a line.
+By producing the desired prompting before testing
+.I eof,
+the following code avoids this problem:
+.LS
+write('number, please ?');
+\*bwhile not\fP eof \*bdo\fP \*bbegin\fP
+    read(i);
+    writeln('that was a ', i:2);
+    write('number, please ?')
+\*bend\fP
+.LE
+The user must still type a line before the
+.B while
+test is completed, but the prompt will ask for it.
+This example, however, is still not correct.
+To understand why, it is first necessary to know, as we will discuss below,
+that there is a blank character at the end of each line in a Pascal text
+file.
+The
+.I read
+procedure, when reading integers or real numbers,
+is defined so that,
+if there are only blanks left in the file,
+it will return a zero value and set the end-of-file condition.
+If, however, there is a number remaining in the file, the end-of-file
+condition will not be set even if it is the last number, as
+.I read
+never reads the blanks after the number, and there is always at least
+one blank.
+Thus the modified code will still put out a spurious
+.LS
+that was a 0
+.LE
+at the end of a session with it when the end-of-file is reached.
+The simplest way to correct the problem in this example is to use the procedure
+.I readln
+instead of
+.I read
+here.
+In general, unless we test the end-of-file condition both before and
+after calls to
+.I read
+or
+.I readln ,
+there will be inputs for which our program will attempt
+to read past end-of-file.
+.NH 2
+More about eoln
+.PP
+To have a good understanding of when
+.I eoln
+will be true it is necessary to know that in any file
+there is a special character indicating end-of-line,
+and that, in effect, the Pascal system always reads one character ahead of the 
+Pascal
+.I read
+commands.\*(dg
+.FS
+\*(dgIn Pascal terms,
+`read(ch)'
+corresponds to
+`ch := input^; get(input)'
+.FE
+For instance,
+in response to `read(ch)',
+the system sets
+.I ch
+to the current input character and gets the next input character.
+If the current input character is the last character of the line,
+then the next input character from the file is the new-line character,
+the normal
+.UX
+line separator.
+When the read routine gets the new-line character,
+it replaces that character by a blank
+(causing every line to end with a blank)
+and sets
+.I eoln
+to true.
+.I Eoln
+will be true as soon as we read the last character of the line and
+.B before
+we read the blank character corresponding to the end of line.
+Thus it is almost always a mistake to write a program which deals with
+input in the following way:
+.LS
+read(ch);
+\*bif\fP eoln \*bthen\fP
+    \fIDone with line\fP
+\*belse\fP
+    \fINormal processing\fP
+.LE
+as this will almost surely have the effect of ignoring the last character
+in the line.
+The `read(ch)' belongs as part of the normal processing.
+.PP
+Given this framework, it is not hard to explain the function of a
+.I readln
+call, which is defined as:
+.LS
+\*bwhile not\fP eoln \*bdo\fP
+    get(input);
+get(input);
+.LE
+This advances the file until the blank corresponding to the end-of-line
+is the current input symbol and then discards this blank.
+The next character available from
+.I read
+will therefore be the first character of the next line,
+if one exists.
+.NH 2
+Output buffering
+.PP
+A final point about Pascal input-output must be noted here.
+This concerns the buffering of the file
+.I output .
+It is extremely inefficient for the Pascal system to send each character
+to the user's terminal as the program generates it for output;
+even less efficient if the output is the input of another
+program such as the line printer daemon
+.I lpr
+(1).
+To gain efficiency, the Pascal system ``buffers'' the output characters
+(i.e. it saves them in memory until the buffer is full and then emits
+the entire buffer in one system interaction.)
+However, to allow interactive prompting to work as in the example given
+above, this prompt must be printed before the Pascal system waits for a
+response.
+For this reason, Pascal normally prints all the output which has
+been generated for the file
+.I output
+whenever
+.HP
+.RS
+.IP 1)
+A
+.I writeln
+occurs, or
+.IP 2)
+The program reads from the terminal, or
+.IP 3)
+The procedure
+.I message
+or
+.I flush
+is called.
+.RE
+.LP
+Thus, in the code sequence
+.ne 5
+.LS
+\*bfor\fP i := 1 to 5 \*bdo begin\fP
+    write(i: 2);
+    \fICompute a lot with no output\fP
+\*bend;\fP
+writeln
+.LE
+the output integers will not print until the
+.I writeln
+occurs.
+The delay can be somewhat disconcerting, and you should be aware 
+that it will occur.
+By setting the
+.B b
+option to 0 before the
+.B program
+statement by inserting a comment of the form
+.LS
+(*$b0*)
+.LE
+we can cause
+.I output
+to be completely unbuffered, with a corresponding horrendous degradation
+in program efficiency.
+Option control in comments is discussed in section 5.
+.NH 2
+Files, reset, and rewrite
+.PP
+It is possible to use extended forms of the built-in functions
+.I reset
+and
+.I rewrite
+to get more general associations of
+.UX
+file names with Pascal file variables.
+When a file other than
+.I input
+or
+.I output
+is to be read or written, then the reading or writing must be preceded
+by a
+.I reset
+or
+.I rewrite
+call.
+In general, if the Pascal file variable has never been used before,
+there will be no
+.UX
+filename associated with it.
+As we saw in section 2.9,
+by mentioning the file in the
+.B program
+statement,
+we could cause a
+.UX
+file with the same name as the Pascal variable to be associated with it.
+If we do not mention a file in the
+.B program
+statement and use it for the first time with the statement
+.LS
+reset(f)
+.LE
+or
+.LS
+rewrite(f)
+.LE
+then the Pascal system will generate a temporary name of the form
+`tmp.x'
+for some character `x',
+and associate this
+.UX
+file name name with the Pascal file.
+The first such generated name will be `tmp.1'
+and the names continue by incrementing their last character through the
+.SM ASCII
+set.
+The advantage of using such temporary files is that they are automatically
+.I remove d
+by the Pascal system as soon as they become inaccessible.
+They are not removed, however, if a runtime error causes termination
+while they are in scope.
+.PP
+To cause a particular
+.UX
+pathname to be associated with a Pascal file variable
+we can give that name in the
+.I reset
+or
+.I rewrite
+call, e.g. we could have associated the Pascal file
+.I data
+with the file
+`primes'
+in our example in section 3.1 by doing:
+.LS
+reset(data, 'primes')
+.LE
+instead of a simple
+.LS
+reset(data)
+.LE
+In this case it is not essential to mention `data'
+in the program statement, but it is still a good idea
+because is serves as an aid to program documentation.
+The second parameter to
+.I reset
+and
+.I rewrite
+may be any string value, including a variable.
+Thus the names of 
+.UX
+files to be associated with Pascal file variables can be read
+in at run time.
+Full details on file name/file variable associations are given in
+section A.3.
+.NH 2
+Argc and argv
+.PP
+Each
+.UX
+process receives a variable
+length sequence of arguments each of which is a variable length
+character string.
+The built-in function
+.I argc
+and the built-in procedure
+.I argv
+can be used to access and process these arguments.
+The value of the function
+.I argc
+is the number of arguments to the process.
+By convention,
+the arguments are treated as an array,
+and indexed from 0 to
+.I argc \-1,
+with the zeroth argument being the name of the program being executed.
+The rest of the
+arguments are those passed to the command on the command line.
+Thus, the command
+.LS
+% \*bobj  /etc/motd  /usr/dict/words hello\fR
+.LE
+will invoke the program in the file
+.I obj
+with
+.I argc
+having a value of 4.
+The zeroth element accessed by
+.I argv
+will be `obj', the first `/etc/motd', etc.
+.PP
+Pascal does not provide variable size arrays, nor does it allow
+character strings of varying length.
+For this reason,
+.I argv
+is a procedure and has the syntax
+.LS
+argv(i, a)
+.LE
+where
+.I i
+is an integer and
+.I a
+is a string variable.
+This procedure call assigns the (possibly truncated or blank padded)
+.I i \|'th
+argument of the current process to the string variable
+.I a .
+The file manipulation routines
+.I reset
+and
+.I rewrite
+will strip trailing blanks from their optional second arguments
+so that this blank padding is not a problem in the usual case
+where the arguments are file names.
+.PP
+We are now ready to give a
+Berkeley
+Pascal program `kat',
+based on that given in section 3.1 above,
+which can be used with the same syntax as the
+.UX
+system program
+.I cat
+(1).
+.LS
+% \*bcat kat.p\fR
+.so kat3.p
+%
+.LE
+Note that the
+.I reset
+call to the file
+.I input
+here, which is necessary for a clear program,
+may be disallowed on other systems.
+As this program deals mostly with
+.I argc
+and
+.I argv
+and
+.UX
+system dependent considerations,
+portability is of little concern.
+.PP
+If this program is in the file `kat.p', then we can do
+.LS
+% \*bpi kat.p\fR
+% \*bmv obj kat\fR
+% \*bkat primes\fR
+.so kat2out
+% \*bkat\fR
+.so katscript
+%
+.LE
+Thus we see that, if it is given arguments, `kat' will,
+like
+.I cat,
+copy each one in turn.
+If no arguments are given, it copies from the standard input.
+Thus it will work as it did before, with
+.LS
+% \*bkat < primes\fR
+.LE
+now equivalent to
+.LS
+% \*bkat primes\fR
+.LE
+although the mechanisms are quite different in the two cases.
+Note that if `kat' is given a bad file name, for example:
+.LS
+% \*bkat xxxxqqq\fR
+.so xxxxqqqout
+%
+.LE
+it will give a diagnostic and a post-mortem control flow backtrace
+for debugging.
+If we were going to use `kat', we might want to translate it
+differently, e.g.:
+.LS
+% \*bpi -pb kat.p\fR
+% \*bmv obj kat\fR
+.LE
+Here we have disabled the post-mortem statistics printing, so
+as not to get the statistics or the full traceback on error.
+The
+.B b
+option will cause the system to block buffer the input/output so that
+the program will run more efficiently on large files.
+We could have also specified the
+.B t
+option to turn off runtime tests if that was felt to be a speed hindrance
+to the program.
+Thus we can try the last examples again:
+.LS
+% \*bkat xxxxqqq\fR
+.so xxxxqqqout2
+% \*bkat primes\fR
+.so primes-d
+%
+.LE
+.PP
+The interested reader may wish to try writing a program which
+accepts command line arguments like
+.PI
+does, using
+.I argc
+and
+.I argv
+to process them.
diff --git a/usr/doc/pascal/puman5.n b/usr/doc/pascal/puman5.n
new file mode 100644 (file)
index 0000000..bc4e3b7
--- /dev/null
@@ -0,0 +1,908 @@
+.if \n(xx .bp
+.if !\n(xx \{\
+.so tmac.p \}
+.ND
+.nr H1 4
+.NH
+Details on the components of the system
+.NH 2
+Options
+.PP
+The programs
+.PI ,
+.PC ,
+and
+.XP
+take a number of options.\*(dg
+.FS
+\*(dgAs
+.IX
+uses
+.PI
+to translate Pascal programs,
+it takes the options of
+.PI
+also.
+We refer to them here, however, as
+.PI
+options.
+.FE
+There is a standard
+.UX
+convention for passing options to programs on the command line,
+and this convention is followed by the
+.UP
+system programs.
+As we saw in the examples above,
+option related arguments consisted of the character `\-' followed
+by a single character option name.
+.PP
+Except for the
+.B b
+option
+which takes a single digit value,
+each option may be set on (enabled)
+or off (disabled.)
+When an on/off valued option appears on the command line of
+.PI
+or
+.PX
+it inverts the default setting of that option.
+Thus
+.LS
+% \*bpi -l foo.p\fR
+.LE
+enables the listing option
+.B l ,
+since it defaults off, while
+.LS
+% \*bpi -t foo.p\fR
+.LE
+disables the run time tests option
+.B t ,
+since it defaults on.
+.PP
+In additon to inverting the default settings of
+.PI
+options on the command line, it is also possible to control the
+.PI
+options 
+within the body of the program by using comments of a special
+form illustrated by
+.LS
+{$l-}
+.LE
+.PP
+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 `,'
+characters\*(dd.
+.FS
+\*(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
+portable.
+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.
+.FE
+The most basic actions for options are to set them, thus
+.LS
+{$l+ Enable listing}
+.LE
+or to clear them
+.LS
+{$t-,p- No run-time tests, no post mortem analysis}
+.LE
+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
+command line.
+As shown in the examples,
+normal comment text may follow the option list.
+.NH 2
+Options common to Pi, Pc, and Pix
+.PP
+The following options are common to both the compiler
+and the interpreter.
+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,
+with the
+.B b
+option
+taking a single digit value.
+.SH
+Buffering of the file output \- b
+.PP
+The
+.B b
+option controls the buffering of the file
+.I output .
+The default is line buffering, with flushing at
+each reference to the file
+.I input
+and under certain other circumstances detailed in section 5
+below.
+Mentioning
+.B b
+on the command line, e.g.
+.LS
+% \*bpi -b assembler.p\fR
+.LE
+causes standard output to be block buffered,
+where a block is some system\-defined number of characters.
+The
+.B b
+option may also be controlled in comments.
+It, unique among the
+.UP
+options,
+takes a single digit value rather than an on or off setting.
+A value of 0, e.g.
+.LS
+       {$b0}
+.LE
+causes the file
+.I output
+to be unbuffered.
+Any value 2 or greater causes block buffering and is equivalent
+to the flag on the command line.
+The option control comment setting
+.B b
+must precede the
+.B program
+statement.
+.SH
+Include file listing \- i
+.PP
+The
+.B i
+option takes the name of an
+.B include
+file,
+.B procedure
+or
+.B function
+name and causes it
+to be listed while translating\*(dg.
+.FS
+\*(dg\*bInclude\fR files are discussed in section 5.9.
+.FE
+Typical uses would be
+.LS
+% \*bpix -i scanner.i compiler.p\fR
+.LE
+to make a listing of the routines in the file scanner.i, and
+.LS
+% \*bpix -i scanner compiler.p\fR
+.LE
+to make a listing of only the routine
+.I scanner .
+This option is especially useful for conservation-minded programmers making
+partial program listings.
+.SH
+Make a listing \- l
+.PP
+The
+.B l
+option enables a listing of the program.
+The
+.B l
+option defaults off.
+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.
+The
+.B l
+option is pushed and popped by the
+.B i
+option at appropriate points in the program.
+.SH
+Standard Pascal only \- s
+.PP
+The
+.B s
+option causes many of the features of the
+.SM UNIX
+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:
+non-standard
+.B procedure s
+and
+.B function s,
+extensions to the
+.B procedure
+.I write ,
+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
+is effectively ignored.
+The
+.B s
+option is most useful when a program is to be transported, thus
+.LS
+% \*bpi -s isitstd.p\fR
+.LE
+will produce warnings unless the program meets the standard.
+.SH
+Runtime tests \- t and C
+.PP
+These
+options control the generation of tests that subrange variable
+values are within bounds at run time.
+.PI
+defaults to generating tests and uses the option
+.B t
+to disable them.
+.PC
+defaults to not generating tests,
+and uses the option
+.B C
+to enable them.
+Disabling runtime tests also causes
+.B assert
+statements to be treated as comments.\*(dd
+.FS
+\*(ddSee section A.1 for a description of
+.B assert
+statements.
+.FE
+.SH
+Suppress warning diagnostics \- w
+.PP
+The
+.B 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
+.LS
+{$w-}
+.LE
+or on the command line
+.LS
+% \*bpi -w tryme.p\fR
+.LE
+suppresses these usually useful diagnostics.
+.SH
+Generate counters for a pxp execution profile \- z
+.PP
+The
+.B z
+option, which defaults off,
+enables the production of execution profiles.
+By specifying
+.B z
+on the command line, i.e.
+.LS
+% \*bpi -z foo.p\fR
+.LE
+or by enabling it in a comment before the
+.B program
+statement causes
+.PI
+and
+.PC
+to insert operations in the interpreter code to
+count the number of times each statement was executed.
+An example of using
+.XP
+was given in section 2.6;
+its options are described in section 5.6.
+Note that the
+.B z
+option cannot be used on separately compiled programs.
+.NH 2
+Options available in Pi
+.SH
+Post-mortem dump \- p
+.PP
+The
+.B p
+option defaults on,
+and causes the runtime system to initiate a post-mortem
+backtrace when an error occurs.
+It also cause
+.X
+to count statements in the executing program,
+enforcing a statement limit to prevent infinite loops.
+Specifying
+.B p
+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
+.B p
+option in comments.
+To prevent the post-mortem backtrace on error,
+.B p
+must be off at the end of the
+.B program
+statement.
+Thus, the Pascal cross-reference program was translated with
+.LS
+% \*bpi -pbt pxref.p\fR
+.LE
+.NH 2
+Options available in Px
+.PP
+The first argument to
+.X
+is the name of the file containing the program to be interpreted.
+If no arguments are given, then the file
+.I obj
+is executed.
+If more arguments are given, they are available to the Pascal
+program by using the built-ins
+.I argc
+and
+.I argv
+as described in section 4.6.
+.ne 7
+.PP
+.I Px
+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
+.X
+prepended to it; that is
+.LS
+% \*bobj primes\fR
+.LE
+will be converted to read
+.LS
+% \*bpx obj primes\fR
+.LE
+.NH 2
+Options available in Pc
+.SH
+Generate assembly language \- S
+.PP
+The program is compiled and the assembly language
+output is left in file appended .s.
+Thus
+.LS
+% \*bpc -S foo.p\fR
+.LE
+creates a file
+.I foo.s .
+No executable file is created.
+.SH
+Symbolic Debugger Information \- g
+.PP
+The
+.B g
+option causes the compiler to generate information
+needed by
+.I sdb (1)
+the symbolic debugger.
+For a complete description of
+.I sdb
+see Volume 2c of the
+.UX
+Reference Manual.
+.SH
+Redirect the output file \- o
+.PP
+The
+.I name
+argument after the
+.B -o
+is used as the name of the output file instead of
+.I a.out .
+Its typical use is to name the compiled program using
+the root of the file name.
+Thus:
+.LS
+% \*bpc -o myprog myprog.p\fR
+.LE
+causes the compiled program to be called
+.I myprog .
+.SH
+Generate counters for a \*iprof\fP execution profile \- p
+.PP
+The compiler produces code which counts the number of times each
+routine is called.
+The profiling is based on a periodic sample taken by the
+system rather than by inline counters used by
+.XP .
+This results in less degradation in execution,
+at somewhat of a loss in accuracy.
+See
+.I prof (1)
+for a more complete description.
+.SH
+Run the object code optimizer \- O
+.PP
+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
+and execution time.
+.NH 2
+Options available in Pxp
+.PP
+.I Pxp
+takes, on its command line, a list of options followed by the program file
+name, which must end in `.p' as it must for
+.PI ,
+.PC ,
+and
+.IX .
+.I Pxp
+will produce an execution profile if any of the
+.B z ,
+.B t
+or
+.B c
+options is specified on the command line.
+If none of these options is specified, then
+.XP
+functions as a program reformatter.
+.PP
+It is important to note that only the
+.B z
+and
+.B w
+options of
+.XP ,
+which are common to
+.PI ,
+.PC ,
+and
+.XP
+can be controlled in comments.
+All other options must be specified on the command line to have any effect.
+.PP
+The following options are relevant to profiling with
+.XP :
+.SH
+Include the bodies of all routines in the profile \- a
+.PP
+.I Pxp
+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.
+.SH
+Suppress declaration parts from a profile \- d
+.PP
+Normally a profile includes declaration parts.
+Specifying
+.B d
+on the command line suppresses declaration parts.
+.SH
+Eliminate include directives \- e
+.PP
+Normally,
+.XP
+preserves
+.B include
+directives to the output when reformatting a program,
+as though they were comments.
+Specifying
+.B \-e
+causes the contents of the specified files to be reformatted
+into the output stream instead.
+This is an easy way to eliminate
+.B include
+directives, e.g. before transporting a program.
+.SH
+Fully parenthesize expressions \- f
+.PP
+Normally
+.XP
+prints expressions with the minimal parenthesization necessary to
+preserve the structure of the input.
+This option causes
+.I pxp
+to fully parenthesize expressions.
+Thus the statement which prints as
+.LS
+d := a + b mod c / e
+.LE
+with minimal parenthesization, the default, will print as
+.LS
+d := a + ((b mod c) / e)
+.LE
+with the
+.B f
+option specified on the command line.
+.SH
+Left justify all procedures and functions \- j
+.PP
+Normally, each
+.B procedure
+and
+.B function
+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.
+.SH
+Print a table summarizing procedure and function calls \- t
+.PP
+The
+.B t
+option causes
+.XP
+to print a table summarizing the number of calls to each
+.B procedure
+and
+.B function
+in the program.
+It may be specified in combination with the
+.B z
+option, or separately.
+.SH
+Enable and control the profile \- z
+.PP
+The
+.B z
+profile option is very similar to the
+.B i
+listing control option of
+.PI .
+If
+.B z
+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
+.B procedure s
+and
+.B function s
+or
+.B include
+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
+would be
+.LS
+% \*bpxp -z test parser.i compiler.p\fR
+.LE
+This specifies that profiles of the routines in the file
+.I parser.i
+and the routine
+.I test
+are to be made.
+.NH 2
+Formatting programs using pxp
+.PP
+The program
+.XP
+can be used to reformat programs, by using a command of the form
+.LS
+% \*bpxp dirty.p > clean.p\fR
+.LE
+Note that since the shell creates the output file `clean.p' before
+.XP
+executes, so `clean.p' and `dirty.p' must not be the same file.
+.PP
+.I Pxp
+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.
+.I Pxp
+distinguishes between four kinds of comments:
+.HP
+.RS
+.IP 1)
+Left marginal comments, which begin in the first column of the
+input line and are placed in the first column of an output line.
+.IP 2)
+Aligned comments, which are preceded by no input tokens on the
+input line.
+These are aligned in the output with the running program text.
+.IP 3)
+Trailing comments, which are preceded in the input line by a token with
+no more than two spaces separating the token from the comment.
+.IP 4)
+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
+``left margin''.
+.RE
+.LP
+Consider the following program.
+.LS
+% \*bcat comments.p\fR
+.so comments1.p
+.LE
+When formatted by
+.XP
+the following output is produced.
+.LS
+% \*bpxp comments.p\fR
+.so commentsout
+%
+.LE
+The following formatting related options are currently available in
+.XP .
+The options
+.B f
+and
+.B j
+described in the previous section may also be of interest.
+.SH
+Strip comments \-s
+.PP
+The
+.B s
+option causes
+.XP
+to remove all comments from the input text.
+.SH
+Underline keywords \- \_
+.PP
+A command line argument of the form
+.B \-\_
+as in
+.LS
+% \*bpxp -_ dirty.p\fR
+.LE
+can be used to cause
+.XP
+to underline all keywords in the output for enhanced readability.
+.SH
+Specify indenting unit \- [23456789]
+.PP
+The normal unit which
+.XP
+uses to indent a structure statement level is 4 spaces.
+By giving an argument of the form
+\fB\-\fId\fR
+with
+.I d
+a digit,
+2 \(<=
+.I d
+\(<= 9
+you can specify that
+.I d
+spaces are to be used per level instead.
+.NH 2
+Pxref
+.PP
+The cross-reference program
+.I pxref
+may be used to make cross-referenced listings of Pascal
+programs.
+To produce a cross-reference of the program in the file
+`foo.p'
+one can execute the command:
+.LS
+% \*bpxref foo.p\fR
+.LE
+The cross-reference is, unfortunately, not block structured.
+Full details on
+.I pxref
+are given in its manual section
+.I pxref
+(1).
+.NH 2
+Multi-file programs
+.PP
+A text inclusion facility is available with
+.UP .
+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.
+.PP
+The
+.B include
+facility is based on that of the
+.SM
+UNIX
+.NL
+C compiler.
+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,
+the word
+`include'
+followed by a filename enclosed in single `\(aa' or double `"' quotation
+marks.
+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:
+.LS
+\*bprogram\fR compiler(input, output, obj);
+
+#\*binclude\fR "globals.i"
+#\*binclude\fR "scanner.i"
+#\*binclude\fR "parser.i"
+#\*binclude\fR "semantics.i"
+
+\*bbegin\fR
+    { main program }
+\*bend\fR.
+.LE
+.PP
+At the point the
+.B include
+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.
+.PP
+See the descriptions of the
+.B i
+option of
+.PI
+in section 5.2
+above;
+this can be used to control listing when
+.B include
+files are present.
+.PP
+When a non-trivial line is encountered in the source text after an
+.B include
+finishes, the
+`popped' filename is printed, in the same manner as above.
+.PP
+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
+filename was printed.
+.NH 2
+Separate Compilation with Pc
+.PP
+A separate compilation facility is provided with the Berkeley Pascal compiler,
+.PC .
+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.
+.PP
+Normally,
+.PC
+expects to be given entire Pascal programs.
+However, if given the
+.B \-c
+option on the command line, it will accept a sequence of definitions and
+declarations, and compile them into a
+.B .o
+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
+.B external .
+This directive is similar to the directive
+.B forward
+in that it must precede the resolution of the function or procedure,
+and formal parameters and function result types must be specified
+at the
+.B external
+declaration and may not be specified at the resolution.
+.PP
+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
+to the
+.B include
+facility discussed above.
+Definitions may be placed in files with the extension
+.B .h
+and the files included by separately compiled files.
+Each definition from a 
+.B .h
+file defines a unique type, and all uses of a definition from the same 
+.B .h
+file define the same type.
+Similarly, the facility is extended to allow the definition of 
+.B const s
+and the declaration of
+.B label s,
+.B var s,
+and
+.B external
+.B function s
+and
+.B procedure s.
+Thus
+.B procedure s
+and
+.B function s
+which are used between separately compiled files must be declared
+.B external ,
+and must be so declared in a
+.B .h
+file included by any file which calls or resolves the 
+.B function
+or 
+.B procedure .
+Conversely,
+.B function s
+and
+.B procedure s
+declared
+.B external
+may only be so declared in 
+.B .h
+files.
+These files may be included only at the outermost level,
+and thus define or declare global objects.
+Note that since only
+.B external
+.B function
+and
+.B procedure
+declarations (and not resolutions) are allowed in
+.B .h
+files, statically nested
+.B function s
+and
+.B procedure s
+can not be declared
+.B external .
+.PP
+An example of the use of included
+.B .h
+files in a program would be:
+.LS
+\*bprogram\fR compiler(input, output, obj);
+
+#\*binclude\fR "globals.h"
+#\*binclude\fR "scanner.h"
+#\*binclude\fR "parser.h"
+#\*binclude\fR "semantics.h"
+
+\*bbegin\fR
+    { main program }
+\*bend\fR.
+.LE
+.PP
+This might include in the main program
+the definitions and declarations of all the global 
+.B label s,
+.B const s,
+.B type s and
+.B var s
+from the file globals.h,
+and the
+.B external
+.B function
+and
+.B procedure
+declarations for each of the
+separately compiled files for the scanner, parser and semantics.
+The header file
+.I scanner.h
+would contain declarations of the form:
+.LS
+\*btype\fR
+    token = \*brecord\fR
+       { token fields }
+    \*bend\fR;
+
+\*bfunction\fR scan(\*bvar\fR inputfile: text): token;
+    \*bexternal\fR;
+.LE
+.ne 15
+Then the scanner might be in a separately compiled file containing:
+.LS
+#\*binclude\fR "globals.h"
+#\*binclude\fR "scanner.h"
+
+\*bfunction\fR scan;
+\*bbegin\fR
+    { scanner code }
+\*bend\fR;
+.LE
+which includes the same global definitions and declarations
+and resolves the scanner functions and procedures declared
+.B external
+in the file scanner.h.
diff --git a/usr/doc/pascal/pumanA.n b/usr/doc/pascal/pumanA.n
new file mode 100644 (file)
index 0000000..2e48d21
--- /dev/null
@@ -0,0 +1,923 @@
+.if \n(xx .bp
+.if !\n(xx \{\
+.so tmac.p \}
+.ND
+.nr H1 0
+.af H1 A
+.NH 
+Appendix to Wirth's Pascal Report
+.PP
+This section is an appendix to
+the definition of the Pascal language in Niklaus Wirth's
+.I "Pascal Report"
+and, with that Report, precisely defines the
+Berkeley
+implementation.
+This appendix includes a summary of extensions to the language,
+gives the ways in which the undefined specifications were resolved,
+gives limitations and restrictions of the current implementation,
+and lists the added functions and procedures available.
+It concludes with a list of differences with the commonly available
+Pascal 6000\-3.4 implementation,
+and some comments on standard and portable Pascal.
+.NH 2
+Extensions to the language Pascal
+.PP
+This section defines non-standard language constructs available in
+.UP .
+The
+.B s
+standard Pascal option of the translators
+.PI
+and
+.PC
+can be used to detect these extensions in programs which are to be transported.
+.SH
+String padding
+.PP
+.UP
+will pad constant strings with blanks in expressions and as
+value parameters to make them as long as is required.
+The following is a legal
+.UP
+program:
+.LS
+\*bprogram\fP x(output);
+\*bvar\fP z : \*bpacked\fP \*barray\fP [ 1 .. 13 ] \*bof\fP char;
+\*bbegin\fP
+    z := 'red';
+    writeln(z)
+\*bend\fP;
+.LE
+The padded blanks are added on the right.
+Thus the assignment above is equivalent to:
+.LS
+z := 'red          '
+.LE
+which is standard Pascal.
+.SH
+Octal constants, octal and hexadecimal write
+.PP
+Octal constants may be given as a sequence of octal digits followed
+by the character `b' or `B'.
+The forms
+.LS
+write(a:n \*boct\fP)
+.LE
+and
+.LS
+write(a:n \*bhex\fP)
+.LE
+cause the internal representation of
+expression
+.I a,
+which must be Boolean, character, integer, pointer, or a user-defined enumerated
+type,
+to be written in octal or hexadecimal respectively.
+.SH
+Assert statement
+.PP
+An
+.B assert
+statement causes a
+.I Boolean
+expression to be evaluated
+each time the statement is executed.
+A runtime error results if any of the expressions evaluates to be 
+.I false .
+The
+.B assert
+statement is treated as a comment if run-time tests are disabled.
+The syntax for
+.B assert
+is:
+.LS
+\*bassert\fP <expr>
+.LE
+.SH
+Enumerated type input-output
+.PP
+Enumerated types may be read and written.
+On output the string name associated with the enumerated
+value is output.
+If the value is out of range,
+a runtime error occurs.
+On input an identifier is read and looked up
+in a table of names associated with the
+type of the variable, and
+the appropriate internal value is assigned to the variable being
+read.
+If the name is not found in the table
+a runtime error occurs.
+.SH
+Structure returning functions
+.PP
+An extension has been added which allows functions 
+to return arbitrary sized structures rather than just
+scalars as in the standard.
+.SH
+Separate compilation
+.PP
+The compiler
+.PC
+has been extended to allow separate compilation of programs.
+Procedures and functions declared at the global level
+may be compiled separately.
+Type checking of calls to separately compiled routines is performed
+at load time to insure that the program as a whole
+is consistent.
+See section 5.10 for details.
+.NH 2
+Resolution of the undefined specifications
+.SH
+File name \- file variable associations
+.PP
+Each Pascal file variable is associated with a named
+.UX
+file.
+Except for
+.I input
+and
+.I output,
+which are
+exceptions to some of the rules, a name can become associated
+with a file in any of three ways:
+.IP "\ \ \ \ \ 1)" 10
+If a global Pascal file variable appears in the
+.B program
+statement
+then it is associated with
+.UX
+file of the same name.
+.IP "\ \ \ \ \ 2)"
+If a file was reset or rewritten using the
+extended two-argument form of
+.I reset
+or
+.I rewrite
+then the given name
+is associated.
+.IP "\ \ \ \ \ 3)"
+If a file which has never had
+.UX
+name associated
+is reset or rewritten without specifying a name
+via the second argument, then a temporary name
+of the form `tmp.x'
+is associated with the file.
+Temporary names start with
+`tmp.1' and continue by incrementing the last character in the
+.SM
+USASCII
+.NL
+ordering.
+Temporary files are removed automatically
+when their scope is exited.
+.SH
+The program statement
+.PP
+The syntax of the
+.B program
+statement is:
+.LS
+\*bprogram\fP <id> ( <file id> { , <file id > } ) ;
+.LE
+The file identifiers (other than
+.I input
+and
+.I output )
+must be declared as variables of
+.B file
+type in the global declaration part.
+.SH
+The files input and output
+.PP
+The formal parameters
+.I input
+and
+.I output
+are associated with the
+.UX
+standard input and output and have a
+somewhat special status.
+The following rules must be noted:
+.IP "\ \ \ \ \ 1)" 10
+The program heading
+.B must
+contains the formal parameter
+.I output.
+If
+.I input
+is used, explicitly or implicitly, then it must
+also be declared here.
+.IP "\ \ \ \ \ 2)"
+Unlike all other files, the
+Pascal files
+.I input
+and
+.I output
+must not be defined in a declaration,
+as their declaration is automatically:
+.LS
+\*bvar\fP input, output: text
+.LE
+.IP "\ \ \ \ \ 3)"
+The procedure
+.I reset
+may be used on
+.I input.
+If no
+.UX
+file name has ever been associated with
+.I input,
+and no file name is given, then an attempt will be made
+to `rewind'
+.I input.
+If this fails, a run time
+error will occur.
+.I Rewrite
+calls to output act as for any other file, except that
+.I output
+initially has no associated file.
+This means that a simple
+.LS
+rewrite(output)
+.LE
+associates a temporary name with
+.I output.
+.SH
+Details for files
+.PP
+If a file other than
+.I input
+is to be read,
+then reading must be initiated by a call to the
+procedure
+.I reset
+which causes the Pascal system to attempt to open the
+associated
+.UX
+file for reading.
+If this fails, then a runtime error occurs.
+Writing of a file other than
+.I output
+must be initiated by a
+.I rewrite
+call,
+which causes the Pascal system to create the associated
+.UX
+file and
+to then open the file for writing only.
+.SH
+Buffering
+.PP
+The buffering for
+.I output
+is determined by the value of the
+.B b
+option
+at the end of the
+.B program
+statement.
+If it has its default value 1,
+then
+.I output
+is
+buffered in blocks of up to 512 characters,
+flushed whenever a writeln occurs
+and at each reference to the file
+.I input.
+If it has the value 0,
+.I output
+is unbuffered.
+Any value of
+2 or more gives block buffering without line or
+.I input
+reference flushing.
+All other output files are always buffered in blocks of 512 characters.
+All output buffers are flushed when the files are closed at scope exit,
+whenever the procedure
+.I message
+is called, and can be flushed using the
+built-in procedure
+.I flush.
+.PP
+An important point for an interactive implementation is the definition
+of `input\(ua'.
+If
+.I input
+is a teletype, and the Pascal system reads a character at the beginning
+of execution to define `input\(ua', then no prompt could be printed
+by the program before the user is required to type some input.
+For this reason, `input\(ua' is not defined by the system until its definition
+is needed, reading from a file occurring only when necessary.
+.SH
+The character set
+.PP
+Seven bit
+.SM USASCII
+is the character set used on
+.UX .
+The standard Pascal
+symbols `and', 'or', 'not', '<=', '>=', '<>',
+and the uparrow `\(ua' (for pointer qualification)
+are recognized.\*(dg
+.FS
+\*(dgOn many terminals and printers, the up arrow is represented
+as a circumflex `^'.
+These are not distinct characters, but rather different graphic
+representations of the same internal codes.
+.FE
+Less portable are the 
+synonyms tilde `~'
+for
+.B not ,
+`&' for
+.B and ,
+and `|' for
+.B or .
+.PP
+Upper and lower case are considered to be distinct.\*(st
+.FS
+\*(stThe proposed standard for Pascal considers them to be the same.
+.FE
+Keywords and built-in
+.B procedure
+and
+.B function
+names are
+composed of all lower case letters.
+Thus the identifiers GOTO and GOto are distinct both from each other and
+from the keyword
+\*bgoto\fP.
+The standard type `boolean' is also available as `Boolean'.
+.PP
+Character strings and constants may be delimited by the character
+`\''
+or by the character `#';
+the latter is sometimes convenient when programs are to be transported.
+Note that the `#' character has special meaning 
+.up
+when it is the first character on a line \- see
+.I "Multi-file programs"
+below.
+.SH
+The standard types
+.PP
+The standard type
+.I integer
+is conceptually defined as
+.LS
+\*btype\fP integer = minint .. maxint;
+.LE
+.I Integer
+is implemented with 32 bit twos complement arithmetic.
+Predefined constants of type
+.I integer
+are:
+.LS
+\*bconst\fP maxint = 2147483647; minint = -2147483648;
+.LE
+.PP
+The standard type
+.I char
+is conceptually defined as
+.LS
+\*btype\fP char = minchar .. maxchar;
+.LE
+Built-in character constants are `minchar' and `maxchar', `bell' and `tab';
+ord(minchar) = 0, ord(maxchar) = 127.
+.PP
+The type
+.I real
+is implemented using 64 bit floating point arithmetic.
+The floating point arithmetic is done in `rounded' mode, and
+provides approximately 17 digits of precision
+with numbers as small as 10 to the negative 38th power and as large as
+10 to the 38th power.
+.SH
+Comments
+.PP
+Comments can be delimited by either `{' and `}' or by `(*' and `*)'.
+If the character `{' appears in a comment delimited by `{' and `}',
+a warning diagnostic is printed.
+A similar warning will be printed if the sequence `(*' appears in
+a comment delimited by `(*' and `*)'.
+The restriction implied by this warning is not part of standard Pascal,
+but detects many otherwise subtle errors.
+.SH
+Option control
+.PP
+Options of the translators may be controlled
+in two distinct ways.
+A number of options may appear on the command line invoking the translator.
+These options are given as one or more strings of letters preceded by the
+character `\-' and cause the default setting of
+each given option to be changed.
+This method of communication of options is expected to predominate
+for
+.UX .
+Thus the command
+.LS
+% \*bpi \-l \-s foo.p\fR
+.LE
+translates the file foo.p with the listing option enabled (as it normally
+is off), and with only standard Pascal features available.
+.PP
+If more control over the portions of the program where options are enabled is
+required, then option control in comments can and should be used.
+The
+format for option control in comments is identical to that used in Pascal
+6000\-3.4.
+One places the character `$' as the first character of the comment
+and follows it by a comma separated list of directives.
+Thus an equivalent to the command line example given above would be:
+.LS
+{$l+,s+ listing on, standard Pascal}
+.LE
+as the first line of the program.
+The `l'
+option is more appropriately specified on the command line,
+since it is extremely unlikely in an interactive environment
+that one wants a listing of the program each time it is translated.
+.PP
+Directives consist of a letter designating the option,
+followed either by a `+' to turn the option on, or by a `\-' to turn the
+option off.
+The
+.B b
+option takes a single digit instead of
+a `+' or `\-'.
+.SH
+Notes on the listings
+.PP
+The first page of a listing
+includes a banner line indicating the version and date of generation of
+.PI
+or
+.PC .
+It also
+includes the
+.UX
+path name supplied for the source file and the date of
+last modification of that file.
+.PP
+Within the body of the listing, lines are numbered consecutively and
+correspond to the line numbers for the editor.
+Currently, two special
+kinds of lines may be used to format the listing:
+a line consisting of a form-feed
+character, control-l, which causes a page
+eject in the listing, and a line with
+no characters which causes the line number to be suppressed in the listing,
+creating a truly blank line.
+These lines thus correspond to `eject' and `space' macros found in many
+assemblers.
+Non-printing characters are printed as the character `?' in the listing.\*(dg
+.FS
+\*(dgThe character generated by a control-i indents
+to the next `tab stop'.
+Tab stops are set every 8 columns in
+.UX .
+Tabs thus provide a quick way of indenting in the program.
+.FE
+.SH
+The standard procedure write
+.PP
+If no minimum field length parameter is specified
+for a
+.I write,
+the following default
+values are assumed:
+.KS
+.TS
+center;
+l n.
+integer        10
+real   22
+Boolean        length of `true' or `false'
+char   1
+string length of the string
+oct    11
+hex    8
+.TE
+.KE
+The end of each line in a text file should be explicitly
+indicated by `writeln(f)', where `writeln(output)' may be written
+simply as `writeln'.
+For
+.UX ,
+the built-in function `page(f)' puts a single
+.SM ASCII
+form-feed character on the output file.
+For programs which are to be transported the filter
+.I pcc
+can be used to interpret carriage control, as
+.UX
+does not normally do so.
+.NH 2
+Restrictions and limitations
+.SH
+Files
+.PP
+Files cannot be members of files or members of dynamically
+allocated structures.
+.SH
+Arrays, sets and strings
+.PP
+The calculations involving array subscripts and set elements
+are done with 16 bit arithmetic.
+This
+restricts the types over which arrays and sets may be defined.
+The lower bound of such a range must be greater than or equal to
+\-32768, and the upper bound less than 32768.
+In particular, strings may have any length from 1 to 65535 characters,
+and sets may contain no more than 65535 elements.
+.SH
+Line and symbol length
+.PP
+There is no intrinsic limit on the length of identifiers.
+Identifiers
+are considered to be distinct if they differ
+in any single position over their entire length.
+There is a limit, however, on the maximum input
+line length.
+This limit is quite generous however, currently exceeding 160
+characters.
+.SH
+Procedure and function nesting and program size
+.PP
+At most 20 levels of 
+.B procedure 
+and 
+.B function 
+nesting are allowed.
+There is no fundamental, translator defined limit on the size of the
+program which can be translated.
+The ultimate limit is supplied by the
+hardware and thus, on the \s-2PDP\s0-11,
+by the 16 bit address space.
+If
+one runs up against the `ran out of memory' diagnostic the program may yet
+translate if smaller procedures are used, as a lot of space is freed
+by the translator at the completion of each 
+.B procedure
+or
+.B function
+in the current
+implementation.
+.PP
+On the \s-2VAX\s0-11, there is an implementation defined limit
+of 65536 bytes per variable.
+There is no limit on the number of variables.
+.SH
+Overflow
+.PP
+There is currently no checking for overflow on arithmetic operations at
+run-time on the \s-2PDP\s0-11.
+Overflow checking is performed on the \s-2VAX\s0-11 by the hardware.
+.br
+.ne 15
+.NH 2
+Added types, operators, procedures and functions
+.SH
+Additional predefined types
+.PP
+The type
+.I alfa
+is predefined as:
+.LS
+\*btype\fP alfa = \*bpacked\fP \*barray\fP [ 1..10 ] \*bof\fP \*bchar\fP
+.LE
+.PP
+The type
+.I intset
+is predefined as:
+.LS
+\*btype\fP intset = \*bset of\fP 0..127
+.LE
+In most cases the context of an expression involving a constant
+set allows the translator to determine the type of the set, even though the
+constant set itself may not uniquely determine this type.
+In the
+cases where it is not possible to determine the type of the set from
+local context, the expression type defaults to a set over the entire base
+type unless the base type is integer\*(dg.
+.FS
+\*(dgThe current translator makes a special case of the construct
+`if ... in [ ... ]' and enforces only the more lax restriction
+on 16 bit arithmetic given above in this case.
+.FE
+In the latter case the type defaults to the current
+binding of
+.I intset,
+which must be ``type set of (a subrange of) integer'' at that point.
+.PP
+Note that if 
+.I intset 
+is redefined via:
+.LS
+\*btype\fP intset = \*bset of\fP 0..58;
+.LE
+then the default integer set is the implicit
+.I intset 
+of
+Pascal 6000\-3.4
+.SH
+Additional predefined operators
+.PP
+The relationals `<' and `>' of proper set
+inclusion are available.
+With
+.I a
+and
+.I b
+sets, note that
+.LS
+(\*bnot\fR (\fIa\fR < \fIb\fR)) <> (\fIa\fR >= \fIb\fR)
+.LE
+As an example consider the sets
+.I a
+= [0,2]
+and
+.I b
+= [1].
+The only relation true between these sets is `<>'.
+.SH
+Non-standard procedures
+.IP argv(i,a) 25
+where
+.I i 
+is an integer and
+.I a
+is a string variable
+assigns the (possibly truncated or blank padded)
+.I i \|'th
+argument
+of the invocation of the current
+.UX
+process to the variable
+.I a .
+The range of valid
+.I i
+is
+.I 0
+to
+.I argc\-1 .
+.IP date(a) 
+assigns the current date to the alfa variable 
+.I a
+in the format `dd mmm yy ', where `mmm' is the first
+three characters of the month, i.e. `Apr'.
+.IP flush(f) 
+writes the output buffered for Pascal file
+.I f
+into the associated
+.UX
+file.
+.IP halt 
+terminates the execution of the program with
+a control flow backtrace.
+.IP linelimit(f,x)\*(dd
+.FS
+\*(ddCurrently ignored by pdp-11
+.X .
+.FE
+with
+.I f 
+a textfile and
+.I x 
+an integer expression
+causes
+the program to be abnormally terminated if more than
+.I x 
+lines are
+written on file
+.I f .
+If
+.I x 
+is less than 0 then no limit is imposed.
+.IP message(x,...) 
+causes the parameters, which have the format of those
+to the
+built-in
+.B procedure
+.I write,
+to be written unbuffered on the diagnostic unit 2,
+almost always the user's terminal.
+.IP null
+a procedure of no arguments which does absolutely nothing.
+It is useful as a place holder,
+and is generated by
+.XP
+in place of the invisible empty statement.
+.IP remove(a) 
+where
+.I a 
+is a string causes the
+.UX
+file whose
+name is
+.I a, 
+with trailing blanks eliminated, to be removed.
+.IP reset(f,a) 
+where
+.I a 
+is a string causes the file whose name
+is
+.I a 
+(with blanks trimmed) to be associated with
+.I f 
+in addition
+to the normal function of
+.I reset.
+.IP rewrite(f,a) 
+is analogous to `reset' above.
+.IP stlimit(i)
+where
+.I i 
+is an integer sets the statement limit to be
+.I i 
+statements.
+Specifying the
+.B p
+option to
+.I pc
+disables statement limit counting.
+.IP time(a) 
+causes the current time in the form `\ hh:mm:ss\ ' to be
+assigned to the alfa variable
+.I a.
+.SH
+Non-standard functions
+.IP argc 25
+returns the count of arguments when the Pascal program
+was invoked.
+.I Argc
+is always at least 1.
+.IP card(x) 
+returns the cardinality of the set
+.I x, 
+i.e. the
+number of elements contained in the set.
+.IP clock 
+returns an integer which is the number of central processor
+milliseconds of user time used by this process.
+.IP expo(x) 
+yields the integer valued exponent of the floating-point
+representation of
+.I x ;
+expo(\fIx\fP) = entier(log2(abs(\fIx\fP))).
+.IP random(x) 
+where
+.I x 
+is a real parameter, evaluated but otherwise
+ignored, invokes a linear congruential random number generator.
+Successive seeds are generated as (seed*a + c) mod m and
+the new random number is a normalization of the seed to the range 0.0 to 1.0;
+a is 62605, c is 113218009, and m is
+536870912.
+The initial seed
+is 7774755.
+.IP seed(i) 
+where
+.I i 
+is an integer sets the random number generator seed
+to
+.I i 
+and returns the previous seed.
+Thus seed(seed(i))
+has no effect except to yield value
+.I i.
+.IP sysclock
+an integer function of no arguments returns the number of central processor
+milliseconds of system time used by this process.
+.IP undefined(x) 
+a Boolean function.
+Its argument is a real number and
+it always returns false.
+.IP wallclock 
+an integer function of no arguments returns the time
+in seconds since 00:00:00 GMT January 1, 1970.
+.NH 2
+Remarks on standard and portable Pascal
+.PP
+It is occasionally desirable to prepare Pascal programs which will be
+acceptable at other Pascal installations.
+While certain system dependencies are bound to creep in,
+judicious design and programming practice can usually eliminate
+most of the non-portable usages.
+Wirth's
+.I "Pascal Report"
+concludes with a standard for implementation and program exchange.
+.PP
+In particular, the following differences may cause trouble when attempting
+to transport programs between this implementation and Pascal 6000\-3.4.
+Using the
+.B s
+translator option may serve to indicate many problem areas.\*(dg
+.FS
+\*(dgThe
+.B s
+option does not, however, check that identifiers differ
+in the first 8 characters.
+.I Pi
+and
+.PC
+also do not check the semantics of
+.B packed .
+.FE
+.SH
+Features not available in Berkeley Pascal
+.IP
+Segmented files and associated functions and procedures.
+.IP
+The function
+.I trunc 
+with two arguments.
+.IP
+Arrays whose indices exceed the capacity of 16 bit arithmetic.
+.SH
+Features available in Berkeley Pascal but not in Pascal 6000-3.4
+.IP
+The procedures
+.I  reset 
+and
+.I  rewrite 
+with file names.
+.IP
+The functions
+.I argc,
+.I seed,
+.I sysclock,
+and
+.I wallclock.
+.IP
+The procedures
+.I argv,
+.I flush,
+and
+.I remove.
+.IP
+.I Message
+with arguments other than character strings.
+.IP
+.I Write
+with keyword
+.B hex .
+.IP
+The
+.B assert
+statement.
+.IP
+Reading and writing of enumerated types.
+.IP
+Allowing functions to return structures.
+.IP
+Separate compilation of programs.
+.IP
+Comparison of records.
+.SH
+Other problem areas
+.PP
+Sets and strings are more general in \*
+.UP ;
+see the restrictions given in
+the 
+Jensen-Wirth
+.I "User Manual"
+for details on the 6000\-3.4 restrictions.
+.PP
+The character set differences may cause problems,
+especially the use of the function
+.I chr,
+characters as arguments to
+.I ord,
+and comparisons of characters,
+since the character set ordering
+differs between the two machines.
+.PP
+The Pascal 6000\-3.4 compiler uses a less strict notion of type equivalence.
+In
+.UP ,
+types are considered identical only if they are represented
+by the same type identifier.
+Thus, in particular, unnamed types are unique
+to the variables/fields declared with them.
+.PP
+Pascal 6000\-3.4 doesn't recognize our option
+flags, so it is wise to
+put the control of
+.UP
+options to the end of option lists or, better
+yet, restrict the option list length to one.
+.PP
+For Pascal 6000\-3.4 the ordering of files in the program statement has
+significance.
+It is desirable to place
+.I input 
+and
+.I output 
+as the first two files in the
+.B program
+statement.
diff --git a/usr/doc/pascal/sin1.p b/usr/doc/pascal/sin1.p
new file mode 100644 (file)
index 0000000..2124883
--- /dev/null
@@ -0,0 +1,13 @@
+program sinout(output);
+begin
+
+
+
+
+
+
+
+
+
+write(sin(1,2));
+end.
diff --git a/usr/doc/pascal/sin2.p b/usr/doc/pascal/sin2.p
new file mode 100644 (file)
index 0000000..4a2cc31
--- /dev/null
@@ -0,0 +1,13 @@
+program sinout(output);
+begin
+
+
+
+
+
+
+
+
+
+write(sin('*'));
+end.
diff --git a/usr/doc/pascal/sinout1 b/usr/doc/pascal/sinout1
new file mode 100644 (file)
index 0000000..153cbc3
--- /dev/null
@@ -0,0 +1,2 @@
+Tue Oct 14 21:38 1980  sin1.p:
+E 12 - sin takes exactly one argument
diff --git a/usr/doc/pascal/sinout2 b/usr/doc/pascal/sinout2
new file mode 100644 (file)
index 0000000..5235fd6
--- /dev/null
@@ -0,0 +1,2 @@
+Tue Oct 14 21:38 1980  sin2.p:
+E 12 - sin's argument must be integer or real, not char
diff --git a/usr/doc/pascal/synerr.p b/usr/doc/pascal/synerr.p
new file mode 100644 (file)
index 0000000..ff9b237
--- /dev/null
@@ -0,0 +1,9 @@
+program syn(output);
+var i, j are integer;
+begin
+       for j :* 1 to 20 begin
+               write(j);
+               i = 2 ** j;
+               writeln(i))
+       end
+end.
diff --git a/usr/doc/pascal/synerr2.p b/usr/doc/pascal/synerr2.p
new file mode 100644 (file)
index 0000000..4b7be59
--- /dev/null
@@ -0,0 +1,7 @@
+program synerr2(input,outpu);
+integer a(10)
+begin
+       read(b);
+       for c := 1 to 10 do
+               a(c) := b * c;
+end.
diff --git a/usr/doc/pascal/synerr2out b/usr/doc/pascal/synerr2out
new file mode 100644 (file)
index 0000000..72770eb
--- /dev/null
@@ -0,0 +1,23 @@
+Berkeley Pascal PI -- Version 2.0 (Sat Oct 18 21:01:54 1980)
+
+Tue Oct 14 21:38 1980  synerr2.p
+
+     1  program synerr2(input,outpu);
+     2  integer a(10)
+E \l'\w`w `u-\w`E `u '\l'\w`     2  `u-\w`w `u\&\(rh'\l'(\w`i`u-\w`^`u)/2 '\(ua\l'(\w`i`u-\w`^`u)/2 '\l'\w`---`u\&\(rh' Malformed declaration
+     3  begin
+     4          read(b);
+E \l'\w`w `u-\w`E `u '\l'\w`     4          read(`u-\w`w `u\&\(rh'\l'(\w`b`u-\w`^`u)/2 '\(ua\l'(\w`b`u-\w`^`u)/2 '\l'\w`---`u\&\(rh' Undefined variable
+     5          for c := 1 to 10 do
+E \l'\w`w `u-\w`E `u '\l'\w`     5          for `u-\w`w `u\&\(rh'\l'(\w`c`u-\w`^`u)/2 '\(ua\l'(\w`c`u-\w`^`u)/2 '\l'\w`---`u\&\(rh' Undefined variable
+     6                  a(c) := b * c;
+E \l'\w`w `u-\w`E `u '\l'\w`     6                  `u-\w`w `u\&\(rh'\l'(\w`a`u-\w`^`u)/2 '\(ua\l'(\w`a`u-\w`^`u)/2 '\l'\w`---`u\&\(rh' Undefined procedure
+E \l'\w`w `u-\w`E `u '\l'\w`     6                  a(c) `u-\w`w `u\&\(rh'\l'(\w`:`u-\w`^`u)/2 '\(ua\l'(\w`:`u-\w`^`u)/2 '\l'\w`---`u\&\(rh' Malformed statement
+     7  end.
+E 1 - File outpu listed in program statement but not declared
+e 1 - The file output must appear in the program statement file list
+In program synerr2:
+  E - a undefined on line 6
+  E - b undefined on line 4
+  E - c undefined on lines 5 6
+Execution suppressed due to compilation errors
diff --git a/usr/doc/pascal/synerrout b/usr/doc/pascal/synerrout
new file mode 100644 (file)
index 0000000..9887f83
--- /dev/null
@@ -0,0 +1,19 @@
+Berkeley Pascal PI -- Version 2.0 (Sat Oct 18 21:01:54 1980)
+
+Tue Oct 21 23:51 1980  synerr.p
+
+     1  program syn(output);
+     2  var i, j are integer;
+e \l'\w`w `u-\w`e `u '\l'\w`     2  var i, j `u-\w`w `u\&\(rh'\l'(\w`a`u-\w`^`u)/2 '\(ua\l'(\w`a`u-\w`^`u)/2 '\l'\w`---`u\&\(rh' Replaced identifier with a ':'
+     3  begin
+     4          for j :* 1 to 20 begin
+e \l'\w`w `u-\w`e `u '\l'\w`     4          for j :`u-\w`w `u\&\(rh'\l'(\w`*`u-\w`^`u)/2 '\(ua\l'(\w`*`u-\w`^`u)/2 '\l'\w`---`u\&\(rh' Replaced '*' with a '='
+e \l'\w`w `u-\w`e `u '\l'\w`     4          for j :* 1 to 20 `u-\w`w `u\&\(rh'\l'(\w`b`u-\w`^`u)/2 '\(ua\l'(\w`b`u-\w`^`u)/2 '\l'\w`---`u\&\(rh' Inserted keyword do
+     5                  write(j);
+     6                  i = 2 ** j;
+e \l'\w`w `u-\w`e `u '\l'\w`     6                  i `u-\w`w `u\&\(rh'\l'(\w`=`u-\w`^`u)/2 '\(ua\l'(\w`=`u-\w`^`u)/2 '\l'\w`---`u\&\(rh' Inserted ':'
+E \l'\w`w `u-\w`E `u '\l'\w`     6                  i = 2 *`u-\w`w `u\&\(rh'\l'(\w`*`u-\w`^`u)/2 '\(ua\l'(\w`*`u-\w`^`u)/2 '\l'\w`---`u\&\(rh' Inserted identifier
+     7                  writeln(i))
+E \l'\w`w `u-\w`E `u '\l'\w`     7                  writeln(i)`u-\w`w `u\&\(rh'\l'(\w`)`u-\w`^`u)/2 '\(ua\l'(\w`)`u-\w`^`u)/2 '\l'\w`---`u\&\(rh' Deleted ')'
+     8          end
+     9  end.
diff --git a/usr/doc/pascal/tmac.p b/usr/doc/pascal/tmac.p
new file mode 100644 (file)
index 0000000..066bcd5
--- /dev/null
@@ -0,0 +1,79 @@
+'so /usr/lib/tmac/tmac.s
+.if t .tr \(rh-
+.if t .tr *\(**=\(eq/\(sl+\(pl
+.bd S B 3
+.de SM
+.if "\\$1"" .ps -2
+.if !"\\$1"" \s-2\\$1\s0\\$2
+..
+.de LG
+.if "\\$1"" .ps +2
+.if !"\\$1"" \s+2\\$a\s0\\$2
+..
+.de HP
+.nr pd \\n(PD
+.nr PD 0
+.if \\n(.$=0 .IP
+.if \\n(.$=1 .IP "\\$1"
+.if \\n(.$>=2 .IP "\\$1" "\\$2"
+.nr PD \\n(pd
+.rm pd
+..
+.de LS         \"LS - Literal display, ASCII, constant spaced DS
+.XD
+.ID
+.nf
+.if t .tr '\'`\`^\(ua-\(mi
+.if t .tr _\(ul
+..
+.de LE         \"LE - End literal display
+.DE
+.tr ''``__--^^
+..
+.de UP
+Berkeley Pascal\\$1
+..
+.de PD
+\s-2PDP\s0
+.if \\n(.$=0 11/70
+.if \\n(.$>0 11/\\$1
+..
+.de DK
+Digital Equipment Corporation\\$1
+..
+.de IN
+.I
+.if \\n(.$<2 \\$1 1.0 Implementation Notes
+.if \\n(.$>=2 \\$1 1.0 Implementation Notes\\c
+.R
+.if \\n(.$>=2 \\$2
+..
+.de UM
+.I
+User's Manual
+.R
+..
+.de PC
+.I pc \\$1
+..
+.de PI
+.I pi \\$1
+..
+.de XP
+.I pxp \\$1
+..
+.de IX
+.I pix \\$1
+..
+.de X
+.I px \\$1
+..
+.if n .ds dg +
+.if t .ds dg \(dg
+.if n .ds dd *
+.if t .ds dd \(dd
+.if n .nr FM 1.12i
+.if t .ds b \\fB
+.if n .ds b \\fI
+.ds i \\fI
+.nr xx 1
diff --git a/usr/doc/pascal/typequ.p b/usr/doc/pascal/typequ.p
new file mode 100644 (file)
index 0000000..7d080dc
--- /dev/null
@@ -0,0 +1,10 @@
+program x(output);
+var
+       x: ^ integer;
+       y: ^ integer;
+begin
+       new(y);
+       x := y;
+       x^ := 1;
+       x := x;
+end.
diff --git a/usr/doc/pascal/typequout b/usr/doc/pascal/typequout
new file mode 100644 (file)
index 0000000..593af45
--- /dev/null
@@ -0,0 +1,3 @@
+Tue Oct 14 21:38 1980  typequ.p:
+E 7 - Type clash: non-identical pointer types
+  ... Type of expression clashed with type of variable in assignment
diff --git a/usr/doc/pascal/xxxxqqqout b/usr/doc/pascal/xxxxqqqout
new file mode 100644 (file)
index 0000000..bb8006e
--- /dev/null
@@ -0,0 +1,7 @@
+
+
+Could not open xxxxqqq: No such file or directory
+
+       Error in "kat"+5 near line 11.
+
+4 statements executed in 0.02 seconds cpu time.
diff --git a/usr/doc/pascal/xxxxqqqout2 b/usr/doc/pascal/xxxxqqqout2
new file mode 100644 (file)
index 0000000..4a6e286
--- /dev/null
@@ -0,0 +1,5 @@
+
+
+Could not open xxxxqqq: No such file or directory
+
+       Error in "kat"