Debian Codegraph @

tests/ex05.fw

raw
1 EX05: An example in which Pascal program text is rearranged to form an ADT.
2 This example demonstrates the use of additive macros.
3
4 @!******************************
5
6 @O@<ex05.out@>==@{@-
7 program adt(input,output);
8 @<Types@>
9 @<Variables@>
10 @<Procedures@>
11 begin startproc; end.
12 @}
13
14 @!******************************
15
16 @$@<Types@>+=@{@-
17 type buffer_type =
18 record
19 length : integer;
20 buf : array[1..100] of char;
21 end;
22 @}
23
24 @$@<Variables@>+=@{@-
25 bigbuf : buffer_type;
26 @}
27
28 @$@<Procedures@>+=@{@-
29 procedure buf_init (var b : buffer_type ) {Body of buf_init}
30 procedure buf_add (var b : buffer_type; ch : char) {Body of buf_add}
31 procedure buf_get (var b : buffer_type; var ch : char) {Body of buf_get}
32 @}
33
34 @!******************************
35
36 @$@<Types@>+=@{@-
37 type complex_type = record r,i : real; end;
38 @}
39
40 @$@<Procedures@>+=@{@-
41 procedure cm_set (var c: complex_type; a,b: real) {Body of cm_set}
42 procedure cm_add (a,b: complex_type; var c: complex_type) {Body of cm_add}
43 {Other procedures and functions}
44 @}
45
46 @!******************************
47
48 {...more pieces of program...}
49
50 @!******************************