-
Notifications
You must be signed in to change notification settings - Fork 84
/
pl-0.scroll
90 lines (81 loc) · 2.14 KB
/
pl-0.scroll
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
import ../code/conceptPage.scroll
id pl-0
name PL/0
appeared 1976
creators Niklaus Wirth
tags pl
fileType text
centralPackageRepositoryCount 0
country Switzerland
originCommunity Eidgenössische Technische Hochschule Zürich
reference https://web.archive.org/web/20060712015332/http://www.cs.rochester.edu/courses/254/PLzero/guide.pdf
wikipedia https://en.wikipedia.org/wiki/PL/0
example
VAR x, y, z, q, r, n, f;
PROCEDURE multiply;
VAR a, b;
BEGIN
a := x;
b := Y;
z := 0;
WHILE b > 0 DO
BEGIN
IF ODD b THEN z := z + a;
a := 2 * a;
b := b / 2
END
END;
PROCEDURE divide;
VAR w;
BEGIN
r := x;
q := 0;
w := y;
WHILE w <= r DO w := 2 * w;
WHILE w > y DO
BEGIN
q := 2 * q;
w := w / 2;
IF w <= r THEN
BEGIN
r := r - w;
q := q + 1
END
END
END;
PROCEDURE gcd;
VAR f, g;
BEGIN
f := x;
g := y;
WHILE f # g DO
BEGIN
IF f < g THEN g := g - f;
IF g < f THEN f := f - g
END;
z := f
END;
PROCEDURE fact;
BEGIN
IF n > 1 THEN
BEGIN
f := n * f;
n := n - 1;
CALL fact
END
END;
BEGIN
?x; ?y; CALL multiply; !z;
?x; ?y; CALL divide; !q; !r;
?x; ?y; CALL gcd; !z;
?n; f := 1; CALL fact; !f
END.
related pl-i pascal lex yacc python modula-2 csp isbn
summary PL/0 is a programming language, intended as an educational programming language, that is similar to but much simpler than Pascal, a general-purpose programming language. It serves as an example of how to construct a compiler. It was originally introduced in the book, Algorithms + Data Structures = Programs, by Niklaus Wirth in 1976. It features quite limited language constructs: there are no real numbers, very few basic arithmetic operations and no control-flow constructs other than "if" and "while" blocks. While these limitations make writing real applications in this language impractical, it helps the compiler remain compact and simple.
pageId 507221
created 2004
backlinksCount 26
revisionCount 133
dailyPageViews 40
appeared 1976
hopl https://hopl.info/showlanguage.prx?exp=2592