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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
|
TANGLE change file for VM/CMS and MVS.
Copyright (C) 1984 by David Fuchs. All rights are reserved.
@x banner line
@d banner=='This is TANGLE, Version 2.8'
@y
@d banner=='This is TANGLE, VM/CMS Version 2.8'
@d term_in==tty_in
@d term_out==tty_out
@z
@x debug switch
@d debug==@{ {change this to `$\\{debug}\equiv\null$' when debugging}
@d gubed==@t@>@} {change this to `$\\{gubed}\equiv\null$' when debugging}
@y
@d debug==@{
@d gubed==@t@>@}
@z
@x statistics switch
@d stat==@{ {change this to `$\\{stat}\equiv\null$'
when gathering usage statistics}
@d tats==@t@>@} {change this to `$\\{tats}\equiv\null$'
when gathering usage statistics}
@y
@d stat==
@d tats==
@z
@x compiler directives
@{@&$C-,A+,D-@} {no range check, catch arithmetic overflow, no debug overhead}
@!debug @{@&$C+,D+@}@+ gubed {but turn everything on when debugging}
@y
{It seems impossible to turn CHECK and DEBUG on and off easily given
how Tangle and VS/PASCAL work}
@z
@x otherwise clause
@d othercases == others: {default for cases not listed explicitly}
@y
@d othercases == otherwise {default for cases not listed explicitly}
@z
@x packing
@!ASCII_code=0..127; {seven-bit numbers, a subrange of the integers}
@y
@!ASCII_code=packed 0..127; {seven-bit numbers, a subrange of the integers}
@z
@x EBCDIC
@d last_text_char=127 {ordinal number of the largest element of |text_char|}
@y
@d last_text_char=255 {ordinal number of the largest element of |text_char|}
@z
@x text files
@!text_file=packed file of text_char;
@y
@!text_file=text;
@z
@x terminal output
rewrite(term_out,'TTY:'); {send |term_out| output to the terminal}
@y
rewrite(term_out); {often redirected to the user's terminal}
@z
@x update terminal buffer
@d update_terminal == break(term_out) {empty the terminal output buffer}
@y
@d update_terminal == do_nothing
@z
@x pack buffer
@<Globals...@>=@!buffer: array[0..buf_size] of ASCII_code;
@y
@<Globals...@>=@!buffer: packed array[0..buf_size] of ASCII_code;
@z
@x input_ln optimization
@p function input_ln(var f:text_file):boolean;
{inputs a line or returns |false|}
var final_limit:0..buf_size; {|limit| without trailing blanks}
begin limit:=0; final_limit:=0;
if eof(f) then input_ln:=false
else begin while not eoln(f) do
begin buffer[limit]:=xord[f^]; get(f);
incr(limit);
if buffer[limit-1]<>" " then final_limit:=limit;
if limit=buf_size then
begin while not eoln(f) do get(f);
decr(limit); {keep |buffer[buf_size]| empty}
print_nl('! Input line too long'); loc:=0; error;
@.Input line too long@>
end;
end;
read_ln(f); limit:=final_limit; input_ln:=true;
end;
end;
@y
@p function input_ln(var f:text_file):boolean;
{inputs a line or returns |false|}
var i:0..buf_size;
@!temp_buf:string(buf_size);
begin
limit:=0;
if eof(f) then input_ln:=false
else begin
read(f,temp_buf);
limit:=@=length@>(trim(temp_buf));
if not eoln(f) then begin
print_nl('! Input line too long'); loc:=0; error;
@.Input line too long@>
end
else read_ln(f);
if limit>0 then for i:=0 to limit-1 do
buffer(.i.):=xord(.temp_buf(.i+1.).);
input_ln:=true;
end;
end;
@z
@x packing
@!eight_bits=0..255; {unsigned one-byte quantity}
@!sixteen_bits=0..65535; {unsigned two-byte quantity}
@y
@!eight_bits=packed 0..255; {unsigned one-byte quantity}
@!sixteen_bits=packed 0..65535; {unsigned two-byte quantity}
@z
@x EBCDIC
double_dot: begin out_contrib[1]:="."; out_contrib[2]:="."; send_out(str,2);
end;
@y
double_dot: begin out_contrib[1]:="."; out_contrib[2]:="."; send_out(str,2);
end;
"^": begin out_contrib[1]:="@@"; send_out(str,1);
end;
"[": begin out_contrib[1]:="("; out_contrib[2]:="."; send_out(str,2);
end;
"]": begin out_contrib[1]:="."; out_contrib[2]:=")"; send_out(str,2);
end;
@z
@x
"@@","[","\","]","^","_","`","{","|"
@y
"@@","\","_","`","{","|"
@z
@x
reset(term_in,'TTY:','/I'); {open |term_in| as the terminal, don't do a |get|}
@y
{reset(term_in,'INTERACTIVE'); {open |term_in|, don't do a |get|}}
@=termin@>(term_in); {don't ask me why the above line didn't work!}
@z
@x set return code
case history of
@y
retcode(4*history); {set return code}
case history of
@z
|