blob: 9391dc036d4be5083ae57e1c5f8d1d3b561acf88 (
plain)
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
|
EX06: An example in which Pascal program text is rearranged to form an ADT.
This example achieves what EX05 does, but without additive macros.
@!******************************
@O@<ex06.out@>==@{@-
program adt(input,output);
@<Types@>
@<Variables@>
@<Procedures@>
begin startproc; end.
@}
@$@<Types@>==@{@-
@<Buffer type@>
@<Complex type@>
@}
@$@<Variables@>==@{@-
@<Buffer variable@>
@}
@$@<Procedures@>==@{@-
@<Buffer procedures@>
@<Complex procedures@>
@}
@!******************************
@$@<Buffer type@>==@{@-
type buffer_type = record
length : integer;
buf : array[1..100] of char;
end;
@}
@$@<Buffer variable@>==@{@-
bigbuf : buffer_type;
@}
@$@<Buffer procedures@>==@{@-
procedure buf_init(var b : buffer_type) {Body of buf_init}
procedure buf_add(var b : buffer_type; ch : char) {Body of buf_add}
procedure buf_get(var b : buffer_type; var ch : char) {Body of buf_get}
@}
@!******************************
@$@<Complex type@>==@{@-
type complex_type = record r,i : real; end;
@}
@$@<Complex procedures@>+=@{@-
procedure cm_set(var c: complex_type; a,b : real) {Body of cm_set}
procedure cm_add(a,b : complex_type; var c: complex_type) {Body of cm_add}
{Other procedures and functions}
@}
|