From 5bd13011cfca3ce2bee3a642d3a5a3afdc413713 Mon Sep 17 00:00:00 2001 From: Bill Joy Date: Sun, 27 Nov 1977 20:33:46 -0800 Subject: [PATCH] BSD 1 development Work on file puman/bigger.p Work on file puman/bigger2.p Work on file puman/bigger3.p Work on file puman/bigger4.p Work on file puman/bigger5.p Work on file puman/bigger6.p Work on file puman/bigger7.p Work on file puman/bigout1 Work on file puman/bigout2 Work on file puman/bigout4 Work on file puman/clash.p Work on file puman/clashout Work on file puman/bigout3 Work on file puman/commentsout Work on file puman/comments1.p Work on file puman/comments.p Work on file puman/contents.n Work on file puman/copydata.p Work on file puman/copydataout Work on file puman/csfix.c Work on file puman/data Work on file puman/digits.p Work on file puman/digitsout Work on file puman/eightout1 Work on file puman/eightout2 Work on file puman/eightout3 Work on file puman/eightqueens.p Work on file puman/eightqueens2.p Work on file puman/eof.p Work on file puman/expr.p Work on file puman/exprout Work on file puman/first.p Work on file puman/firstobjout Work on file puman/firstobjout2 Work on file puman/firstout Work on file puman/for.c Work on file puman/kat.p Work on file puman/fu.p Work on file puman/kat1.p Work on file puman/kat2.p Work on file puman/kat2out Work on file puman/kat2out2 Work on file puman/kat3.p Work on file puman/katin Work on file puman/katout Work on file puman/katscript Work on file puman/makefigs Work on file puman/mism.p Work on file puman/mismout Work on file puman/motd Work on file puman/primeout1 Work on file puman/primeout2 Work on file puman/primeout3 Work on file puman/primes Work on file puman/primes-d Work on file puman/primes.p Work on file puman/primes2.p Work on file puman/printuman Work on file puman/puman0.n Work on file puman/puman1.n Work on file puman/sin2.p Work on file puman/puman2.n Work on file puman/sinout1 Work on file puman/sin1.p Work on file puman/sinout2 Work on file puman/synerr2.p Work on file puman/synerr.p Work on file puman/synerr2out Work on file puman/synerrout Work on file puman/undefout Work on file puman/tp.n Work on file puman/tmac.p Work on file puman/undef.p Work on file puman/typequ.p Work on file puman/typequout Work on file puman/xxxxqqqout Work on file puman/puman3.n Work on file puman/xxxxqqqout2 Work on file puman/puman5.n Work on file puman/puman4.n Work on file puman/pumanA.n Synthesized-from: 1bsd --- puman/bigger.p | 24 ++ puman/bigger2.p | 24 ++ puman/bigger3.p | 24 ++ puman/bigger4.p | 26 ++ puman/bigger5.p | 26 ++ puman/bigger6.p | 26 ++ puman/bigger7.p | 26 ++ puman/bigout1 | 21 + puman/bigout2 | 7 + puman/bigout3 | 36 ++ puman/bigout4 | 3 + puman/clash.p | 9 + puman/clashout | 2 + puman/comments.p | 18 + puman/comments1.p | 18 + puman/commentsout | 21 + puman/contents.n | 105 +++++ puman/copydata.p | 15 + puman/copydataout | 25 ++ puman/csfix.c | 173 +++++++++ puman/data | 3 + puman/digits.p | 9 + puman/digitsout | 8 + puman/eightout1 | 86 +++++ puman/eightout2 | 90 +++++ puman/eightout3 | 15 + puman/eightqueens.p | 64 ++++ puman/eightqueens2.p | 64 ++++ puman/eof.p | 13 + puman/expr.p | 21 + puman/exprout | 37 ++ puman/first.p | 4 + puman/firstobjout | 2 + puman/firstobjout2 | 1 + puman/firstout | 6 + puman/for.c | 1 + puman/fu.p | 1 + puman/kat.p | 13 + puman/kat1.p | 13 + puman/kat2.p | 23 ++ puman/kat2out | 7 + puman/kat2out2 | 5 + puman/kat3.p | 23 ++ puman/katin | 2 + puman/katout | 26 ++ puman/katscript | 5 + puman/makefigs | 51 +++ puman/mism.p | 5 + puman/mismout | 11 + puman/motd | 3 + puman/primeout1 | 43 +++ puman/primeout2 | 50 +++ puman/primeout3 | 10 + puman/primes | 6 + puman/primes-d | 6 + puman/primes.p | 30 ++ puman/primes2.p | 30 ++ puman/printuman | 9 + puman/puman0.n | 120 ++++++ puman/puman1.n | 465 ++++++++++++++++++++++ puman/puman2.n | 871 +++++++++++++++++++++++++++++++++++++++++ puman/puman3.n | 714 ++++++++++++++++++++++++++++++++++ puman/puman4.n | 580 ++++++++++++++++++++++++++++ puman/puman5.n | 833 ++++++++++++++++++++++++++++++++++++++++ puman/pumanA.n | 893 +++++++++++++++++++++++++++++++++++++++++++ puman/sin1.p | 13 + puman/sin2.p | 13 + puman/sinout1 | 1 + puman/sinout2 | 1 + puman/synerr.p | 9 + puman/synerr2.p | 7 + puman/synerr2out | 23 ++ puman/synerrout | 20 + puman/tmac.p | 103 +++++ puman/tp.n | 47 +++ puman/typequ.p | 10 + puman/typequout | 2 + puman/undef.p | 13 + puman/undefout | 1 + puman/xxxxqqqout | 5 + puman/xxxxqqqout2 | 1 + 81 files changed, 6170 insertions(+) create mode 100644 puman/bigger.p create mode 100644 puman/bigger2.p create mode 100644 puman/bigger3.p create mode 100644 puman/bigger4.p create mode 100644 puman/bigger5.p create mode 100644 puman/bigger6.p create mode 100644 puman/bigger7.p create mode 100644 puman/bigout1 create mode 100644 puman/bigout2 create mode 100644 puman/bigout3 create mode 100644 puman/bigout4 create mode 100644 puman/clash.p create mode 100644 puman/clashout create mode 100644 puman/comments.p create mode 100644 puman/comments1.p create mode 100644 puman/commentsout create mode 100644 puman/contents.n create mode 100644 puman/copydata.p create mode 100644 puman/copydataout create mode 100644 puman/csfix.c create mode 100644 puman/data create mode 100644 puman/digits.p create mode 100644 puman/digitsout create mode 100644 puman/eightout1 create mode 100644 puman/eightout2 create mode 100644 puman/eightout3 create mode 100644 puman/eightqueens.p create mode 100644 puman/eightqueens2.p create mode 100644 puman/eof.p create mode 100644 puman/expr.p create mode 100644 puman/exprout create mode 100644 puman/first.p create mode 100644 puman/firstobjout create mode 100644 puman/firstobjout2 create mode 100644 puman/firstout create mode 100644 puman/for.c create mode 100644 puman/fu.p create mode 100644 puman/kat.p create mode 100644 puman/kat1.p create mode 100644 puman/kat2.p create mode 100644 puman/kat2out create mode 100644 puman/kat2out2 create mode 100644 puman/kat3.p create mode 100644 puman/katin create mode 100644 puman/katout create mode 100644 puman/katscript create mode 100755 puman/makefigs create mode 100644 puman/mism.p create mode 100644 puman/mismout create mode 100644 puman/motd create mode 100644 puman/primeout1 create mode 100644 puman/primeout2 create mode 100644 puman/primeout3 create mode 100644 puman/primes create mode 100644 puman/primes-d create mode 100644 puman/primes.p create mode 100644 puman/primes2.p create mode 100755 puman/printuman create mode 100644 puman/puman0.n create mode 100644 puman/puman1.n create mode 100644 puman/puman2.n create mode 100644 puman/puman3.n create mode 100644 puman/puman4.n create mode 100644 puman/puman5.n create mode 100644 puman/pumanA.n create mode 100644 puman/sin1.p create mode 100644 puman/sin2.p create mode 100644 puman/sinout1 create mode 100644 puman/sinout2 create mode 100644 puman/synerr.p create mode 100644 puman/synerr2.p create mode 100644 puman/synerr2out create mode 100644 puman/synerrout create mode 100644 puman/tmac.p create mode 100644 puman/tp.n create mode 100644 puman/typequ.p create mode 100644 puman/typequout create mode 100644 puman/undef.p create mode 100644 puman/undefout create mode 100644 puman/xxxxqqqout create mode 100644 puman/xxxxqqqout2 diff --git a/puman/bigger.p b/puman/bigger.p new file mode 100644 index 0000000000..d342b096ae --- /dev/null +++ b/puman/bigger.p @@ -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/puman/bigger2.p b/puman/bigger2.p new file mode 100644 index 0000000000..e0323497c7 --- /dev/null +++ b/puman/bigger2.p @@ -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/puman/bigger3.p b/puman/bigger3.p new file mode 100644 index 0000000000..c63be6853a --- /dev/null +++ b/puman/bigger3.p @@ -0,0 +1,24 @@ +\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 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(-x9 * sin(i * 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\0writeln('*') +\0\0\0\024\0\0end. diff --git a/puman/bigger4.p b/puman/bigger4.p new file mode 100644 index 0000000000..5a16ef40a3 --- /dev/null +++ b/puman/bigger4.p @@ -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/puman/bigger5.p b/puman/bigger5.p new file mode 100644 index 0000000000..5a16ef40a3 --- /dev/null +++ b/puman/bigger5.p @@ -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/puman/bigger6.p b/puman/bigger6.p new file mode 100644 index 0000000000..9ba7ceaeaf --- /dev/null +++ b/puman/bigger6.p @@ -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/puman/bigger7.p b/puman/bigger7.p new file mode 100644 index 0000000000..b4cd01d5d8 --- /dev/null +++ b/puman/bigger7.p @@ -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/puman/bigout1 b/puman/bigout1 new file mode 100644 index 0000000000..08deb3de9e --- /dev/null +++ b/puman/bigout1 @@ -0,0 +1,21 @@ + 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' Inserted keyword end matching begin on line 15 +In program graph1: + \l'(\w`E`u-\w`w`u)/2 'w\l'(\w`E`u-\w`w`u)/2 ' - constant c is never used + E - x9 undefined on line 18 + E - Round undefined on line 19 + E - h undefined on line 19 +Execution suppressed due to compilation errors diff --git a/puman/bigout2 b/puman/bigout2 new file mode 100644 index 0000000000..a52aa8e3aa --- /dev/null +++ b/puman/bigout2 @@ -0,0 +1,7 @@ +Execution begins... +Floating divide by zero + + Error at "graph1"+2 near line 17 + +Execution terminated abnormally +2 statements executed in 0.01 seconds cpu time diff --git a/puman/bigout3 b/puman/bigout3 new file mode 100644 index 0000000000..6bb15223a8 --- /dev/null +++ b/puman/bigout3 @@ -0,0 +1,36 @@ +Execution begins... + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * +Execution terminated +2550 statements executed in 0.27 seconds cpu time diff --git a/puman/bigout4 b/puman/bigout4 new file mode 100644 index 0000000000..83f67644fb --- /dev/null +++ b/puman/bigout4 @@ -0,0 +1,3 @@ +Execution begins... +Execution terminated +2550 statements executed in 0.32 seconds cpu time diff --git a/puman/clash.p b/puman/clash.p new file mode 100644 index 0000000000..4a07405d46 --- /dev/null +++ b/puman/clash.p @@ -0,0 +1,9 @@ +program clash(output); +var + i: integer; + c: char; +begin + i := 1; + c := i; + write(c, i) +end. diff --git a/puman/clashout b/puman/clashout new file mode 100644 index 0000000000..a4d46d2989 --- /dev/null +++ b/puman/clashout @@ -0,0 +1,2 @@ +E 7 - Type clash: integer is incompatible with char + ... Type of expression clashed with type of variable in assignment diff --git a/puman/comments.p b/puman/comments.p new file mode 100644 index 0000000000..b07ddfc6bd --- /dev/null +++ b/puman/comments.p @@ -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/puman/comments1.p b/puman/comments1.p new file mode 100644 index 0000000000..8e7de6c427 --- /dev/null +++ b/puman/comments1.p @@ -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/puman/commentsout b/puman/commentsout new file mode 100644 index 0000000000..5ae2ea3287 --- /dev/null +++ b/puman/commentsout @@ -0,0 +1,21 @@ +.ta 2.0i +{ 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/puman/contents.n b/puman/contents.n new file mode 100644 index 0000000000..1d6e065fa8 --- /dev/null +++ b/puman/contents.n @@ -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/puman/copydata.p b/puman/copydata.p new file mode 100644 index 0000000000..ecf237c052 --- /dev/null +++ b/puman/copydata.p @@ -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/puman/copydataout b/puman/copydataout new file mode 100644 index 0000000000..d96c42134e --- /dev/null +++ b/puman/copydataout @@ -0,0 +1,25 @@ +UNIX Pascal PI -- Version 1.0 (September 8, 1977) + +Fri Sep 9 18:49 1977 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.04 seconds cpu time diff --git a/puman/csfix.c b/puman/csfix.c new file mode 100644 index 0000000000..15ff67d012 --- /dev/null +++ b/puman/csfix.c @@ -0,0 +1,173 @@ +/* + * 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); +} + +int ibuf[259]; + +char line[160], flagee[160]; + +getline() +{ + register char *cp, c; + + for (cp = line, c = getc(ibuf); c != '\n' && c != -1; c = getc(ibuf)) + *cp++ = c; + if (c == -1) + 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/puman/data b/puman/data new file mode 100644 index 0000000000..3f9cfb50ca --- /dev/null +++ b/puman/data @@ -0,0 +1,3 @@ +line one. +line two. +line three is the end. diff --git a/puman/digits.p b/puman/digits.p new file mode 100644 index 0000000000..1e59d8dafb --- /dev/null +++ b/puman/digits.p @@ -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/puman/digitsout b/puman/digitsout new file mode 100644 index 0000000000..e2e6ea5866 --- /dev/null +++ b/puman/digitsout @@ -0,0 +1,8 @@ + 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/puman/eightout1 b/puman/eightout1 new file mode 100644 index 0000000000..c97510cc54 --- /dev/null +++ b/puman/eightout1 @@ -0,0 +1,86 @@ +UNIX Pascal PI -- Version 1.0 (September 6, 1977) + +Tue Sep 6 10:40 1977 eightqueens.p + + 1 program eightqueens(output); + 2 label 13; + 3 var i : integer; + 4 a : array [ 1..8 ] of boolean; + 5 b : array [ 2..16] of boolean; + 6 c : array [-7..7 ] of boolean; + 7 x : array [ 1..8 ] of integer; + 8 safe : boolean; + + 10 procedure print; + 11 var k, l: integer; + 12 begin + 13 writeln; + 14 writeln('*** Solution to the Eight Queens Problem ***'); + 15 writeln; + 16 for l := 1 to 8 do begin + 17 write(tab, 9 - l : 1, ' '); + 18 for k := 1 to 8 do begin + 19 if x[l] = k then + 20 write('Q ') + 21 else if odd (k + l) then + 22 write('* ') + 23 else + 24 write('- ') + 25 end; + 26 writeln + 27 end; + 28 writeln; + 29 writeln(tab, ' q q q q k k k k'); + 30 writeln(tab, ' r n b b n r'); + 31 writeln; + 32 goto 13 + 33 end ; + + 35 procedure trycol(j : integer); + 36 var i : integer; + + 38 procedure setqueen; + 39 begin a[i] := false; b[i+j] := false; c[i-j] := false; + 40 end ; + + 42 procedure removequeen; + 43 begin a[i] := true; b[i+j] := true; c[i-j] := true; + 44 end ; + + 46 begin + 47 repeat i := i+1; safe := a[i] and b[i+j] and c[i-j]; + 48 if safe then + 49 begin setqueen; x[j] := i; + 50 if j < 8 then trycol(j+1) else print; + 51 removequeen + 52 end + 53 until i = 8 + 54 end; + + 56 begin + 57 for i := 1 to 8 do a[i] := true; + 58 for i := 2 to 16 do b[i] := true; + 59 for i := -7 to 7 do c[i] := true; + 60 trycol(1); + 61 writeln('No solutions!'); + 62 halt; + 63 13: + 64 end. +Execution begins... + +*** Solution to the Eight Queens Problem *** + + 8 Q * - * - * - * + 7 * - * - Q - * - + 6 - * - * - * - Q + 5 * - * - * Q * - + 4 - * Q * - * - * + 3 * - * - * - Q - + 2 - Q - * - * - * + 1 * - * Q * - * - + + q q q q k k k k + r n b b n r + +Execution terminated +4208 statements executed in 0.52 seconds cpu time diff --git a/puman/eightout2 b/puman/eightout2 new file mode 100644 index 0000000000..47cddace90 --- /dev/null +++ b/puman/eightout2 @@ -0,0 +1,90 @@ +UNIX Pascal PXP -- Version 1.0 (September 6, 1977) + +Tue Sep 6 10:40 1977 [eightqueens.p] + +Profiled Tue Sep 6 15:24 1977 + + 1 1.---|program eightqueens(output); + 2 |label + 2 | 13; + 3 |var + 3 | i: integer; + 4 | a: array [1..8] of boolean; + 5 | b: array [2..16] of boolean; + 6 | c: array [-7..7] of boolean; + 7 | x: array [1..8] of integer; + 8 | safe: boolean; + + 10 1.---|procedure print; + 11 |var + 11 | k, l: integer; + 12 |begin + 13 | writeln; + 14 | writeln('*** Solution to the Eight Queens Problem ***'); + 15 | writeln; + 16 | for l := 1 to 8 do begin + 17 8.---| write(tab, 9 - l: 1, ' '); + 18 | for k := 1 to 8 do begin + 19 64.---| if x[l] = k then + 20 8.---| write('Q ') + 20 56.---| else if odd(k + l) then + 22 28.---| write('* ') + 22 28.---| else + 24 28.---| write('- ') + 24 64.---| end; + 27 | writeln + 27 | end; + 28 | writeln; + 29 | writeln(tab, ' q q q q k k k k'); + 30 | writeln(tab, ' r n b b n r'); + 31 | writeln; + 32 | goto 13 + 32 |end; + + 35 113.---|procedure trycol(j: integer); + 36 |var + 36 | i: integer; + + 38 113.---|procedure setqueen; + 39 |begin + 39 | a[i] := false; + 39 | b[i + j] := false; + 39 | c[i - j] := false + 39 |end; + + 42 105.---|procedure removequeen; + 43 |begin + 43 | a[i] := true; + 43 | b[i + j] := true; + 43 | c[i - j] := true + 43 |end; + + 46 113.---|begin + 46 | repeat + 47 876.---| i := i + 1; + 47 | safe := a[i] and b[i + j] and c[i - j]; + 48 | if safe then begin + 49 113.---| setqueen; + 49 | x[j] := i; + 50 | if j < 8 then + 50 112.---| trycol(j + 1) + 50 1.---| else + 50 1.---| print; + 52 113.---| removequeen + 52 | end + 52 |until i = 8 + 52 |end; + + 56 1.---|begin + 57 | for i := 1 to 8 do + 57 8.---| a[i] := true; + 58 | for i := 2 to 16 do + 58 15.---| b[i] := true; + 59 | for i := -7 to 7 do + 59 15.---| c[i] := true; + 60 | trycol(1); + 61 | writeln('No solutions!'); + 62 | halt; + 63 13: + 63 1.---| null + 63 |end. diff --git a/puman/eightout3 b/puman/eightout3 new file mode 100644 index 0000000000..a1a30b9af2 --- /dev/null +++ b/puman/eightout3 @@ -0,0 +1,15 @@ +Execution begins... +Subscript out of range + + Error at "trycol"+3 near line 49 + Called by "trycol"+4 near line 50 + Called by "trycol"+4 near line 50 + Called by "trycol"+4 near line 50 + Called by "trycol"+4 near line 50 + Called by "trycol"+4 near line 50 + Called by "trycol"+4 near line 50 + Called by "trycol"+4 near line 50 + Called by "eightque"+4 near line 60 + +Execution terminated abnormally +3917 statements executed in 0.49 seconds cpu time diff --git a/puman/eightqueens.p b/puman/eightqueens.p new file mode 100644 index 0000000000..4d170f6d4b --- /dev/null +++ b/puman/eightqueens.p @@ -0,0 +1,64 @@ +program eightqueens(output); +label 13; +var i : integer; + a : array [ 1..8 ] of boolean; + b : array [ 2..16] of boolean; + c : array [-7..7 ] of boolean; + x : array [ 1..8 ] of integer; + safe : boolean; + + procedure print; + var k, l: integer; + begin + writeln; + writeln('*** Solution to the Eight Queens Problem ***'); + writeln; + for l := 1 to 8 do begin + write(tab, 9 - l : 1, ' '); + for k := 1 to 8 do begin + if x[l] = k then + write('Q ') + else if odd (k + l) then + write('* ') + else + write('- ') + end; + writeln + end; + writeln; + writeln(tab, ' q q q q k k k k'); + writeln(tab, ' r n b b n r'); + writeln; + goto 13 + end ; + +procedure trycol(j : integer); + var i : integer; + + procedure setqueen; + begin a[i] := false; b[i+j] := false; c[i-j] := false; + end ; + + procedure removequeen; + begin a[i] := true; b[i+j] := true; c[i-j] := true; + end ; + + begin + repeat i := i+1; safe := a[i] and b[i+j] and c[i-j]; + if safe then + begin setqueen; x[j] := i; + if j < 8 then trycol(j+1) else print; + removequeen + end + until i = 8 +end; + +begin + for i := 1 to 8 do a[i] := true; + for i := 2 to 16 do b[i] := true; + for i := -7 to 7 do c[i] := true; + trycol(1); + writeln('No solutions!'); + halt; +13: +end. diff --git a/puman/eightqueens2.p b/puman/eightqueens2.p new file mode 100644 index 0000000000..11f0608bd0 --- /dev/null +++ b/puman/eightqueens2.p @@ -0,0 +1,64 @@ +program eightqueens(output); +label 13; +var i : integer; + a : array [ 1..8 ] of boolean; + b : array [ 2..16] of boolean; + c : array [-7..7 ] of boolean; + x : array [ 0..7 ] of integer; + safe : boolean; + + procedure print; + var k, l: integer; + begin + writeln; + writeln('*** Solution to the Eight Queens Problem ***'); + writeln; + for l := 1 to 8 do begin + write(tab, 9 - l : 1, ' '); + for k := 1 to 8 do begin + if x[l] = k then + write('Q ') + else if odd (k + l) then + write('* ') + else + write('- ') + end; + writeln + end; + writeln; + writeln(tab, ' q q q q k k k k'); + writeln(tab, ' r n b b n r'); + writeln; + goto 13 + end ; + +procedure trycol(j : integer); + var i : integer; + + procedure setqueen; + begin a[i] := false; b[i+j] := false; c[i-j] := false; + end ; + + procedure removequeen; + begin a[i] := true; b[i+j] := true; c[i-j] := true; + end ; + + begin + repeat i := i+1; safe := a[i] and b[i+j] and c[i-j]; + if safe then + begin setqueen; x[j] := i; + if j < 8 then trycol(j+1) else print; + removequeen + end + until i = 8 +end; + +begin + for i := 1 to 8 do a[i] := true; + for i := 2 to 16 do b[i] := true; + for i := -7 to 7 do c[i] := true; + trycol(1); + writeln('No solutions!'); + halt; +13: +end. diff --git a/puman/eof.p b/puman/eof.p new file mode 100644 index 0000000000..fd2b8c1c0a --- /dev/null +++ b/puman/eof.p @@ -0,0 +1,13 @@ +program number(input, output); +label 1; +var i: integer; +begin +while true do begin +write('number, please ?'); +if eof then +goto 1; +read(i); +writeln('that was an ', i:2); +end; +1: +end. diff --git a/puman/expr.p b/puman/expr.p new file mode 100644 index 0000000000..60109af8c7 --- /dev/null +++ b/puman/expr.p @@ -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/puman/exprout b/puman/exprout new file mode 100644 index 0000000000..c10a9e8bb1 --- /dev/null +++ b/puman/exprout @@ -0,0 +1,37 @@ +UNIX Pascal PI -- Version 1.0 (September 6, 1977) + +Thu Sep 1 21:46 1977 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 = +e 20 - Input is used but not defined in the program statement +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/puman/first.p b/puman/first.p new file mode 100644 index 0000000000..19196944e8 --- /dev/null +++ b/puman/first.p @@ -0,0 +1,4 @@ +program first(output) +begin + writeln('Hello, world!') +end. diff --git a/puman/firstobjout b/puman/firstobjout new file mode 100644 index 0000000000..0129da12e0 --- /dev/null +++ b/puman/firstobjout @@ -0,0 +1,2 @@ +Hello, world! +1 statement executed in 0.02 seconds cpu time diff --git a/puman/firstobjout2 b/puman/firstobjout2 new file mode 100644 index 0000000000..af5626b4a1 --- /dev/null +++ b/puman/firstobjout2 @@ -0,0 +1 @@ +Hello, world! diff --git a/puman/firstout b/puman/firstout new file mode 100644 index 0000000000..afba9b8d78 --- /dev/null +++ b/puman/firstout @@ -0,0 +1,6 @@ + 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 statement executed in 0.01 seconds cpu time diff --git a/puman/for.c b/puman/for.c new file mode 100644 index 0000000000..f5ce75a4ed --- /dev/null +++ b/puman/for.c @@ -0,0 +1 @@ +main(){for(;;);} diff --git a/puman/fu.p b/puman/fu.p new file mode 100644 index 0000000000..a843b69fb9 --- /dev/null +++ b/puman/fu.p @@ -0,0 +1 @@ +program x(output);begin d := a + b mod c / e end. diff --git a/puman/kat.p b/puman/kat.p new file mode 100644 index 0000000000..6d804533e0 --- /dev/null +++ b/puman/kat.p @@ -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/puman/kat1.p b/puman/kat1.p new file mode 100644 index 0000000000..33d4442c5b --- /dev/null +++ b/puman/kat1.p @@ -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/puman/kat2.p b/puman/kat2.p new file mode 100644 index 0000000000..0dbc01a125 --- /dev/null +++ b/puman/kat2.p @@ -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/puman/kat2out b/puman/kat2out new file mode 100644 index 0000000000..ebff95f242 --- /dev/null +++ b/puman/kat2out @@ -0,0 +1,7 @@ +\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.22 seconds cpu time diff --git a/puman/kat2out2 b/puman/kat2out2 new file mode 100644 index 0000000000..acccbd8c50 --- /dev/null +++ b/puman/kat2out2 @@ -0,0 +1,5 @@ +This is a line of text. +This is a line of text. +The next line contains only an end-of-file (an invisible control-d!) +The next line contains only an end-of-file (an invisible control-d!) +287 statements executed in 0.09 seconds cpu time diff --git a/puman/kat3.p b/puman/kat3.p new file mode 100644 index 0000000000..411205caf7 --- /dev/null +++ b/puman/kat3.p @@ -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/puman/katin b/puman/katin new file mode 100644 index 0000000000..220793bf91 --- /dev/null +++ b/puman/katin @@ -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/puman/katout b/puman/katout new file mode 100644 index 0000000000..9082c8e0e2 --- /dev/null +++ b/puman/katout @@ -0,0 +1,26 @@ +UNIX Pascal PI -- Version 1.0 (September 8, 1977) + +Fri Sep 9 18:49 1977 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.27 seconds cpu time diff --git a/puman/katscript b/puman/katscript new file mode 100644 index 0000000000..7e976a5945 --- /dev/null +++ b/puman/katscript @@ -0,0 +1,5 @@ +\*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.09 seconds cpu time diff --git a/puman/makefigs b/puman/makefigs new file mode 100755 index 0000000000..31b93ec183 --- /dev/null +++ b/puman/makefigs @@ -0,0 +1,51 @@ +pix -l copydata.p |* expand | csfix -d >copydataout +pi kat2.p ; px obj primes |* csfix -d >kat2out +pix -l kat.p katout +csfix -d primes-d +exit +pix primes2.p |* expand | csfix -d >primeout3 +number bigger5.p | expand | csfix -d >bigger6.p +number bigger2.p | expand | csfix -d >bigger3.p +pix bigger.p |* expand | csfix >bigout1 +pxp -z primes.p |* expand | csfix - >primeout2 +pix first.p |* expand | csfix >firstout +pi digits.p |* expand | csfix >digitsout +pi -l synerr.p |* expand | csfix >synerrout +pix -l synerr2.p |* expand | csfix >synerr2out +pi -l mism.p |* expand | csfix >mismout +px obj katin >* katscript +ed - katscript +1t1 +1s/.*/\\*b&\\fR/ +3t3 +3s/.*/\\*b&\\fR/ +w +q +px obj xxxxqqq >*xxxxqqqout +pi -p kat2.p ; px obj xxxxqqq >*xxxxqqqout2 +expand bigger.p >bigger2.p +pi -p first.p >* firstobjout2 ; px >* firstobjout2 +pi first.p >* firstobjout ; px >* firstobjout +(pix bigger7.p >/dev/null) |* expand > bigout4 +pix bigger7.p |* expand >bigout3 +pix bigger4.p |* expand >bigout2 +pxp comments.p |* expand >commentsout +expand comments.p >comments1.p +pix -p primes.p >primes +pix -l -z primes.p |* expand - | csfix - >primeout1 +pi clash.p |* expand >clashout +pi sin1.p |* expand >sinout1 +pi sin2.p |* expand >sinout2 +pi -l expr.p | expand >exprout +pi typequ.p >typequout +pix -l -z eightqueens.p |* expand >eightout1 +pxp -z eightqueens.p |* expand >eightout2 +pix eightqueens2.p |* expand >eightout3 +rm pmon.out obj +ed - commentsout +1i +.ta 3.25i +. +g/ *{/s// {/ +w +q diff --git a/puman/mism.p b/puman/mism.p new file mode 100644 index 0000000000..a690b1e7d3 --- /dev/null +++ b/puman/mism.p @@ -0,0 +1,5 @@ +program mismatch(output) +begin + writeln('***'); + { The next line is the last line in the file } + writeln diff --git a/puman/mismout b/puman/mismout new file mode 100644 index 0000000000..49792a301f --- /dev/null +++ b/puman/mismout @@ -0,0 +1,11 @@ +UNIX Pascal PI -- Version 1.0 (September 8, 1977) + +Sat Sep 10 15:18 1977 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/puman/motd b/puman/motd new file mode 100644 index 0000000000..3737fe6636 --- /dev/null +++ b/puman/motd @@ -0,0 +1,3 @@ +Cory Hall 11/70 + +For latest news do 'help news' (last updated Tuesday Aug 23) diff --git a/puman/primeout1 b/puman/primeout1 new file mode 100644 index 0000000000..b354ef94db --- /dev/null +++ b/puman/primeout1 @@ -0,0 +1,43 @@ +UNIX Pascal PI -- Version 1.0 (September 8, 1977) + +Sat Sep 10 13:19 1977 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 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/puman/primeout2 b/puman/primeout2 new file mode 100644 index 0000000000..0ce5109dcc --- /dev/null +++ b/puman/primeout2 @@ -0,0 +1,50 @@ +UNIX Pascal PXP -- Version 1.0 (September 10, 1977) + +Sat Sep 10 13:19 1977 primes.p + +Profiled Sat Sep 10 13:19 1977 + +\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/puman/primeout3 b/puman/primeout3 new file mode 100644 index 0000000000..bcb648d5ce --- /dev/null +++ b/puman/primeout3 @@ -0,0 +1,10 @@ +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\0167Subscript out of range + +\0\0\0\0\0\0\0\0Error at "primes"+8 near line 14 + +Execution terminated abnormally +941\0statements executed in 0.17 seconds cpu time diff --git a/puman/primes b/puman/primes new file mode 100644 index 0000000000..aa282aa6b8 --- /dev/null +++ b/puman/primes @@ -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/puman/primes-d b/puman/primes-d new file mode 100644 index 0000000000..8d7eb8cc51 --- /dev/null +++ b/puman/primes-d @@ -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/puman/primes.p b/puman/primes.p new file mode 100644 index 0000000000..d840390159 --- /dev/null +++ b/puman/primes.p @@ -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 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/puman/primes2.p b/puman/primes2.p new file mode 100644 index 0000000000..7693de81c4 --- /dev/null +++ b/puman/primes2.p @@ -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 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/puman/printuman b/puman/printuman new file mode 100755 index 0000000000..305eabe05c --- /dev/null +++ b/puman/printuman @@ -0,0 +1,9 @@ +pr printuman +: cp /etc/motd motd +makefigs +pr bugs +ls -cs | pr -t +ls -l | pr -t +pr makefigs +nroff contents.n +soelim puman[012345A].n | tbl | nroff diff --git a/puman/puman0.n b/puman/puman0.n new file mode 100644 index 0000000000..9f5634a684 --- /dev/null +++ b/puman/puman0.n @@ -0,0 +1,120 @@ +.so tmac.p +.RP +.TL +UNIX Pascal User's Manual +.br +Version 1.0 \- November, 1977 +.AU +William N. Joy +.AU +Susan L. Graham +.AU +Charles B. Haley\u\(dg\d +.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 +.PP +.UX +Pascal +is designed for interactive instructional use +and runs on the +.PD 45 +and +.PD +computers. +It produces interpretive code, +providing fast translation at the expense of slower execution speed. +An execution profiler and +Wirth's cross reference program are also +available with the system. +The system supports full Pascal, with the exception of +.B procedure +and +.B function +names as parameters. +The language accepted is very close to +`standard' Pascal, +with only a small number of extensions for the +.UX +system. +.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 +interpreter components +.PI , +.X , +.IX , +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 +.UX +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 +.UX +implementation of the language. +Section 2 introduces the +.UX +implementation and provides a number of basic examples. +Section 3 discusses the error diagnostics produced by the translator +.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 +.UP +system was written by Ken Thompson in early 1976. +The main features of the present system result from the work +of Charles Haley and William Joy during the latter half of 1976. +Earlier versions of this system have been in use since January, 1977. +.SH +Acknowledgement +.PP +.12 +.RM diff --git a/puman/puman1.n b/puman/puman1.n new file mode 100644 index 0000000000..d611d909c5 --- /dev/null +++ b/puman/puman1.n @@ -0,0 +1,465 @@ +.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 on the UC Berkeley +campus for information about +general features of +.UX , +.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 +On the UC Berkeley campus, documentation is available at the Computer +Center Library, room 218B Evans Hall. +The library is open from 8:00 A.M. to 5:00 P.M. Monday through Friday. +For classes in the Computer Science Division, Pascal documentation +is usually available through a department office. +The best source for general +.UX +documentation is, however, +the Computer Center Library. +.PP +Current documentation for most of the +.UX +system is also available ``on line'' at your terminal. +Details on getting such documentation interactively are given +in section 1.3 on +.UX +documentation. +.NH 2 +Computer Center short courses +.PP +For those not enrolled in Computer Science Division courses, and +who have no prior experience using +.UX , +the short-courses offered by the staff of the Computer Center +are highly recommended. +These courses are offered free of charge, and are usually held +at the beginning of each quarter. +The two most valuable short courses for the +.UX +Pascal user are the ones dealing with basic use of +.UX , +and with +.UX +text editing. +If you are unable to attend the short courses, documents +for these courses are available at the Computer Center Library, +and are recommended. +The documents are in a tutorial format, so it is possible to use them on your +own. +.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 +Communicating with UNIX +.PP +This set of documents should be read by every new +.UX +user. +The documents, written by +Ricki Blau of the Computer Center Staff, +introduce the basic use of +the +.UX +command language processor (the ``shell''), +and the most commonly used commands. +The author makes no assumptions about prior experience with +interactive computing or with +.UX . +The six documents which comprise the set +introduce most of the +.UX +system features which will be needed by +the new Pascal user in order to survive with +.UX +Pascal. +.SH +UNIX For Beginners +.PP +This document is the basic tutorial for +.UX +available with the standard system. +It is a useful introduction to +.UX +but does not provide as much explanation as +.I "Communicating with UNIX." +The document is not up-to-date +with the current status of the Berkeley system, +but is very useful as a supplement to +.I "Communicating with UNIX." +.SH +The UNIX Time Sharing System +.PP +By the primary authors of +.UX , +Dennis Ritchie and Ken Thompson, +this excellent award-winning +article appeared in the +.I "Communications of the ACM" +in July, 1974 +and describes the general features of +.UX +in an advanced setting. +It provides useful details on the design philosophy and inner +workings of the +.UX +system. +It makes interesting reading after you have experimented with the system for a +while. +.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 I consists of descriptions of most of the ``commands'' +of +.UX . +Most of the other sections have limited relevance to the user +of +.UX +Pascal, being of interest mainly to system programmers. +Portions of the manual are available from the Computer Center Library. +.PP +.UX +documentation often refers the reader to sections of the manual. +Such a reference consists of a command name and a section number. +An example of such a reference would be: +.PI +(VI). +Here +.PI +is a command name \- the Pascal interpretive translator, and `(VI)' +indicates that the command is part of Section VI of the manual. +The other pieces of the +.UX +Pascal system are the Pascal interpretive executor +.X +(VI), +the combined Pascal translator and interpretive executor +.IX +(VI), +the Pascal execution profiler +.XP +(VI), +the Pascal cross-reference generator +.I pxref +(VI), +and the filter which interprets carriage control +.I pcc +(VI). +.PP +It is possible to obtain a copy of a manual section +by using the +.I man +(VI) 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. +In addition to the documents described here, there is an implementation +of the text editor +.I teco +available locally. +No documentation on this editor is available currently however. +.SH +Text editing with UNIX +.PP +This series of documents is used for the short course given at the +Computer Center on text editing. +It can also be used for self-study, and is the best tutorial currently +available on basic text editing. +For those not in Computer Science Division courses, the associated +short course at the Computer Center on text editing is strongly recommended. +.SH +A Tutorial Introduction to the UNIX Text Editor +.PP +This document, written by Brian Kernighan of Bell Laboratories, +is the standard tutorial for the +.UX +text editor +.I ed. +This document also introduces you to the very basics of text editing, +but does not discuss using the system itself at the same time. +For this reason, this document is recommended as supplemental reading, +along with the document +.I "Text editing with UNIX." +.SH +Ex Reference Manual +.PP +The text editor +.I ex +is an enhanced version of the text editor +.I ed. +It is designed for use +by people who have not used a text editor before as well as those +experienced editor users who wish to use its new features. +This document summarizes the features of +.I ex . +For persons with little previous editor experience, the tutorials +listed above are also recommended. +.bp +.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 +.UX +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 UNIX Implementation +.PP +This section describes the documentation which is available +describing the +.UX +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 +(VI), +.PI +(VI), +.I pcc +(VI), +.X +(VI), +.I pxp +(VI), +and +.I pxref +(VI). +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 +.UX +Pascal system there are a series of +.I "Implementation Notes" +describing these details. +The +.I "PI 1.0 Implementation Notes" +describe the structure of the Pascal translator +.PI \|; +the +.I "PX 1.0 Implementation Notes" +describe the Pascal interpreter +.X \|; +and the +.I "PXP 1.0 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 +Ricki Blau +.I "Communicating With UNIX" +Computer Center and Computer Science Division +University of California, Berkeley +July, 1977. +.re +William N. Joy +.I "Ex Reference Manual \- Version 1.1" +Computer Center +University of California, Berkeley +November, 1977. +.re +James Joyce +.I "Text editing with UNIX" +Computer Center +University of California, Berkeley +July, 1977. +.re +Brian W. Kernighan +.I "A Tutorial Introduction to the UNIX Text Editor" +Bell Laboratories +Murray Hill, New Jersey. +.re +Brian W. Kernighan +.I "UNIX for Beginners" +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. +.KS +.re +Ken Thompson and Dennis M. Ritchie\*(dg +.I "UNIX Programmer's Manual \- Version 6" +Bell Laboratories +Murray Hill, New Jersey +May 1975. +.FS +\*(dgAt Berkeley a +revised version of this manual is available and to be preferred. +.FE +.KE +.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 +UNIX Pascal documents +.PP +The following documents are available from the Computer Center Library +at the University of California, Berkeley. +.nf +.re +Charles B. Haley and William N. Joy +.I "PI 1.0 Implementation Notes" +In preparation: November, 1977. +.re +William N. Joy, Susan L. Graham, and Charles B. Haley +.I "UNIX Pascal User's Manual \- Version 1.0" +November, 1977. +.re +William N. Joy +.I "PX 1.0 Implementation Notes" +In preparation: November, 1977. +.re +William N. Joy +.I "PXP 1.0 Implementation Notes" +In preparation: November, 1977. diff --git a/puman/puman2.n b/puman/puman2.n new file mode 100644 index 0000000000..28fc111d8a --- /dev/null +++ b/puman/puman2.n @@ -0,0 +1,871 @@ +.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 +(VI). +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. +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" No such file or directory +: +.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" 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. +.KS +.PP +We are ready to try +to translate and execute our program. +.LS +% \*bpix first.p\fR +.so firstout +% +.LE +.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 +:\*b!pi %\fR +!pi first.p +! +:\*bquit\fR +% +.LE +The first command issued from +.I ex +with the `!' +involved the use of the `%' character which stands in this command for +the file we are editing. +.I Ex +made this substitution, and then echoed back the expanded line +before executing the command. +When the command finished, the editor echoed the character `!' +so that we would know it was done. +.PP +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, +`obj' +will be noticed to contain a Pascal object by the shell so that the +command\*(dg: +.FS +\*(dgIt should be noted that the +`obj' +works only with a modified +shell. +This modification has been made at Berkeley. +It may not be available if you are elsewhere. +In this case you can use the syntax with +.X +specified explicitly. +.FE +.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 +(I). +Thus to name our program `hello': +.LS +% \*bmv obj hello\fR +% \*bhello\fR +Hello, world! +% \*bls\fR +first.p +hello +% +.LE +.KS +Finally we can get rid of the Pascal object code by using the +.I rm +(I) remove file command, e.g.: +.LS +% \*brm hello\fR +% \*bls\fR +first.p +% +.LE +.KE +.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. +.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 number \*(dg, +i.e.: +.FS +\*(dgIf the +.I number +program is not available, +.I lno +may be. +It is similar, but aligns the line numbers in a different, less pleasant +way. +.FE +.LS +% \*bnumber 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 +.ne 8 +.PP +If we attempt to translate and execute the program using +.IX +we get the following response: +.LS .ID +% \*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\*(dg. +.FS +\*(dgAt Berkeley, the line printer for the Cory Hall system is in Room 199B. +The line printers for the Computer Center +systems are in the basement of Evans Hall. +.FE +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 +.UX +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. +On +.UX +lower-case is preferred\*(dg, +.FS +\*(dgOne 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 +:\*b!pi %\fR +!pi bigger.p +! +:\*bquit\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. +.ne 15 +.LS .ID +% \*bnumber 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: +.ne 10 +.LS .ID +% \*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 +:\*b!pix %\fR +!pix bigger.p +.so bigout3 +! +:\*bq\fR +% +.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 +(I) 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\*(dg rather than `|', i.e.: +.FS +\*(dg +The syntax `|*' as well as `>*' and `>>*' are also local modifications at +Berkeley. +They redirect unit 2, the diagnostic output, with unit 1, the standard +output, otherwise corresponding to `|', `>', and `>>'. +This capability is not present in the standard version 6 shell, +and a different syntax is expected to be used with the standard +version 7 shell. +.FE +.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 +(I). +See +.I prof +(I) 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 .ID +.ne 20 +% \*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 .ID +.ne 10 +% \*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 +(VI) +and in sections 5.4, 5.5 and 5.10. diff --git a/puman/puman3.n b/puman/puman3.n new file mode 100644 index 0000000000..ff495a6fad --- /dev/null +++ b/puman/puman3.n @@ -0,0 +1,714 @@ +.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 +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 +(VI) +and section 5.2 below for more details. +.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.9 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 .ID +.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 .ID +% \*bpix -l synerr2.p\fR +.so synerr2out +% +.LE +Here we misspelled +.I input +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 .ID +% \*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. +.bp +.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 +.UX +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 +the translator does not associate these constants with the strings +`red', `green', and `blue' in any way. +If you wish such an association to be made, you will have to write a routine +to make it. +Note, in particular, that you can only read 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 +.bp +Expression diagnostics +.PP +The diagnostics for semantically ill-formed expressions are very explicit. +Consider this sample translation: +.LS .ID +% \*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, +.UX +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 +.UX +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 +.UX +Pascal always clears variables to 0 at +.B procedure +and +.B function +entry, 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 constant +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. +You should report the problem in any case. +Pascal system bugs cannot be fixed unless they are reported. +.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. +Generally, 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 +.UX +Pascal. +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. +.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. +If your disk space quota\*(dg is exceeded while +.PI +is creating the file +.I obj , +or if the system runs out of disk space you will be notified; +in this case you should remove unneeded files. +.FS +\*(dgDisk quotas are also a modification at Berkeley +and may not exist at your installation. +.FE +.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 +(VI). +.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. +.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 .ID +% \*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. +.SH +Panics +.PP +A small number of panics are possible with +.I px . +These should be reported to a teaching assistant or to the system +staff if they occur. diff --git a/puman/puman4.n b/puman/puman4.n new file mode 100644 index 0000000000..8280a766d9 --- /dev/null +++ b/puman/puman4.n @@ -0,0 +1,580 @@ +.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 +(I). +.LS +% \*bpix -l kat.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 .ID +% \*bcat comments.p\fR +.so comments1.p +.LE +When formatted by +.XP +the following output is produced. +.LS .ID +% \*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 +Pcc and carriage control +.PP +The +.UX +system printer driver does not implement +.SM FORTRAN +style carriage control. +Thus the function +.I page +on +.UX +does not output a character `1' +in column 1 of a line, but rather puts out a form-feed +character. +For those who wish to use carriage control, the filter +.I pcc +is available which interprets this control. +A sample usage is: +.LS +% \*bpx | pcc\fR +.LE +or +.LS +% \*bpix prog.p | pcc | lpr\fR +.LE +for printer copy. +.I Pcc +is fully described by its manual documentation +.I pcc +(VI). +.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 +(VI). +.NH 2 +Pascals +.PP +A version of Wirth's subset Pascal translator +.I pascals +is available on +.UX . +It was translated to interpreter code by +.PI +and is invoked by a command of the form: +.LS +% \*bpascals prog.p\fR +.LE +The program in the file given is translated to interpretive code +which is then immediately executed. +.I Pascals +is thus similar to +.I pix . +Only small programs can be handled. +.I Pascals +is most interesting to those wishing to study its error recovery techniques, +which are described in Wirth's book +.I "Algorithms + Data Structures = Programs" . +.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 translate- and run-time 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 +and +.B n +options of +.PI +in section 5.2 +above; +these can be used to control listing when +.B include +files are present. +.PP +.I Include +control lines are never printed in a listing. +If the +.B n +option is not set, they are replaced by a line containing +the file name and a `:' character. +This is the default setting. +If the +.B n +new page option is enabled then the +.B include +line is replaced with a banner line similar to the first line +of a listing. +This line is placed on a new page in the listing. +.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. diff --git a/puman/pumanA.n b/puman/pumanA.n new file mode 100644 index 0000000000..dc543c7f57 --- /dev/null +++ b/puman/pumanA.n @@ -0,0 +1,893 @@ +.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 +.UX +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 translator +.PI +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 +.LE +.br +.ne 8 +.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 ( { , } ) ; +.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 distinct. +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 translator 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 \-ls 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 . +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 +Multi-file programs +.PP +It is also possible to prepare programs whose parts are placed in more +than one file. +The files other than the main one are called +.B include +files and have names ending with `.i'. +The contents of an \*binclude\fR file are referenced through a pseudo-statement +of the form: +.LS +#\*binclude\fR "file.i" +.LE +The `#' character must be the first character on the line. +The file name may be delimited with `"' or `\'' characters. +Nested +.B include s +are possible up to 10 deep. +More details are given in sections 5.9 and 5.10. +.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 10 +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 32767 characters, +and sets may contain no more than 32767 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 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 the fact that the \s-2PDP\s0-11 has a 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. +.SH +Overflow +.PP +There is currently no checking for overflow on arithmetic operations at +run-time. +.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 +.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 +also does not check the semantics of +.B packed . +.FE +.SH +Features not available in UNIX Pascal +.IP +Formal parameters which are +.B procedure +or +.B function . +.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 UNIX 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. +.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/puman/sin1.p b/puman/sin1.p new file mode 100644 index 0000000000..21248836fe --- /dev/null +++ b/puman/sin1.p @@ -0,0 +1,13 @@ +program sinout(output); +begin + + + + + + + + + +write(sin(1,2)); +end. diff --git a/puman/sin2.p b/puman/sin2.p new file mode 100644 index 0000000000..4a2cc3177e --- /dev/null +++ b/puman/sin2.p @@ -0,0 +1,13 @@ +program sinout(output); +begin + + + + + + + + + +write(sin('*')); +end. diff --git a/puman/sinout1 b/puman/sinout1 new file mode 100644 index 0000000000..6620f40f94 --- /dev/null +++ b/puman/sinout1 @@ -0,0 +1 @@ +E 12 - sin takes exactly one argument diff --git a/puman/sinout2 b/puman/sinout2 new file mode 100644 index 0000000000..e0b6cd2460 --- /dev/null +++ b/puman/sinout2 @@ -0,0 +1 @@ +E 12 - sin's argument must be integer or real, not char diff --git a/puman/synerr.p b/puman/synerr.p new file mode 100644 index 0000000000..33c13e7403 --- /dev/null +++ b/puman/synerr.p @@ -0,0 +1,9 @@ +progran 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/puman/synerr2.p b/puman/synerr2.p new file mode 100644 index 0000000000..4b7be594db --- /dev/null +++ b/puman/synerr2.p @@ -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/puman/synerr2out b/puman/synerr2out new file mode 100644 index 0000000000..811249cdd9 --- /dev/null +++ b/puman/synerr2out @@ -0,0 +1,23 @@ +UNIX Pascal PI -- Version 1.0 (September 8, 1977) + +Fri Sep 9 18:50 1977 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/puman/synerrout b/puman/synerrout new file mode 100644 index 0000000000..f0ad9a7ff7 --- /dev/null +++ b/puman/synerrout @@ -0,0 +1,20 @@ +UNIX Pascal PI -- Version 1.0 (September 8, 1977) + +Fri Sep 9 18:49 1977 synerr.p + + 1 progran syn(output); +e \l'\w`w `u-\w`e `u '\l'\w` 1 `u-\w`w `u\&\(rh'\l'(\w`p`u-\w`^`u)/2 '\(ua\l'(\w`p`u-\w`^`u)/2 '\l'\w`---`u\&\(rh' Replaced identifier with a keyword program + 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/puman/tmac.p b/puman/tmac.p new file mode 100644 index 0000000000..3df7cacbd5 --- /dev/null +++ b/puman/tmac.p @@ -0,0 +1,103 @@ +'so /usr/lib/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 +.if \\n(.$=0 .DS +.if \\n(.$=1 \\$1 +.if \\n(.$>1 \\$1 "\\$2" +.if t .tr '\'`\`^\(ua-\(mi +.if t .tr _\(ul +.. +.de LE \"LE - End literal display +.DE +.tr ''``__--^^ +.. +.de UX +\s-2UNIX\s0\\$1 +.. +.de UP +\s-2UNIX\s0 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 PI +.I pi \\$1 +.. +.de XP +.I pxp \\$1 +.. +.de IX +.I pix \\$1 +.. +.de X +.I px \\$1 +.. +.de AK +The financial support of \\$1 +the National Science Foundation under grant +MCS74-07644-A03, +and the first author's work by an +.SM IBM +Fellowship +are gratefully acknowledged. +.. +.de 12 +.AK "the first and second authors' work by" +.. +.de 1A +.AK "the first author's work by" +.. +.de 2A +.AK "the second author's work by" +.. +.de RM +.rm WJ +.rm WS +.rm AK +.rm RM +.. +.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/puman/tp.n b/puman/tp.n new file mode 100644 index 0000000000..39ddfbd3bb --- /dev/null +++ b/puman/tp.n @@ -0,0 +1,47 @@ +.so tmac.p +.RP +.TL +.sp 20 +UNIX Pascal User's Manual +.br +Version 1.0 \- November, 1977 +.AU +William N. Joy +.AU +Susan L. Graham +.AU +Charles B. Haley\u\(dg\d +.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 +...AU +..Charles B. Haley +...AI +...MH +.pn 2 +.bp +.PP +.FS +\(dg Author's present address: Bell Laboratories, Murray Hill, New Jersey 07974 +.sp +.FE +.FS +\(dg Author's present address: Bell Laboratories, Murray Hill, New Jersey 07974 +.sp +.FE +.FS +\(dg Author's present address: Bell Laboratories, Murray Hill, New Jersey 07974 +.sp +.FE +.FS +\(dg Author's present address: Bell Laboratories, Murray Hill, New Jersey 07974 +.sp +.FE +.FS +\(dg Author's present address: Bell Laboratories, Murray Hill, New Jersey 07974 +.sp +.FE diff --git a/puman/typequ.p b/puman/typequ.p new file mode 100644 index 0000000000..7d080dc50d --- /dev/null +++ b/puman/typequ.p @@ -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/puman/typequout b/puman/typequout new file mode 100644 index 0000000000..46615f2790 --- /dev/null +++ b/puman/typequout @@ -0,0 +1,2 @@ +E 7 - Type clash: non-identical pointer types + ... Type of expression clashed with type of variable in assignment diff --git a/puman/undef.p b/puman/undef.p new file mode 100644 index 0000000000..2c6c15a64c --- /dev/null +++ b/puman/undef.p @@ -0,0 +1,13 @@ +program undef(output); +begin + + + + + + + + + + a := 1; +end. diff --git a/puman/undefout b/puman/undefout new file mode 100644 index 0000000000..d995cf398f --- /dev/null +++ b/puman/undefout @@ -0,0 +1 @@ +E 12 -- a is undefined diff --git a/puman/xxxxqqqout b/puman/xxxxqqqout new file mode 100644 index 0000000000..06817f9919 --- /dev/null +++ b/puman/xxxxqqqout @@ -0,0 +1,5 @@ +xxxxqqq: No such file or directory + + Error at "kat"+5 near line 11 + +4 statements executed in 0.06 seconds cpu time diff --git a/puman/xxxxqqqout2 b/puman/xxxxqqqout2 new file mode 100644 index 0000000000..79145e8748 --- /dev/null +++ b/puman/xxxxqqqout2 @@ -0,0 +1 @@ +xxxxqqq: No such file or directory -- 2.20.1