166van Wijngaarden, et al.ALGOL <strong>68</strong> Revised Report167a)proc put = (ref file f, [ ] union (outtype, proc (ref file) void) x) void :if opened of f thenfor i to upb xdo case set write mood (f); set char mood (f); x [i] in(proc (ref file) void pf): pf (f) ,(outtype ot):begin[ ] simplout y = straightout ot;~proc L real cony = (L real r) string :float (r, L real width + L exp width + 4,L real width - 1, L exp width + 1) ~;for j to upb ydo case y [j ] in(union (number, ~ L comply) nc):begin string s : =case nc in(Lint k): whole (k, Lint width + 1) ~ ,{(L real r): Lreal conv(r)~,(L compl z): L real cony (re z) + "._1"+ L real cony (ira z)esac;ref ref pos cpos = cpos off, int n = upb s;whilenext pos (f);(n > c of book bounds (f) I undefined);c of cpos + (c of cpos = 1 I n I n + 1) >c of book bounds (f) + 1do (- (line mended off) (f) l put (f, newline));set write mood (f)od;(c of cpos ~ 1 I "._" plusto s);for k to upb s do put char (f, s [ k ]) odend ¢ numeric ¢,(bool b): (next pos (f); put char (f, (b I flip[ flop))),(L bits lb):for k to L bits widthdoput (f, (L Foflb) [k]) od~,(char k): (next pos (f); put char (f, k)),([ ] char ss):for k from Iwb ss to upb ssdo next pos (f); put char (f, ss [ k ]) odesac odendesac odelse undefinedfl;b)c)proc 9 put char = (ref file f, char char) void :if opened off ^ - line ended (f)then ref pos cpos = cpos off, lpos = lpos of book off;set char mood (f); set write mood (f);ref int p = p of cpos, l = I of cpos, c = c of cpos;char k; bool found : = false;case text of fin(text): (k := char; found := true),(flextext):for i to upb F of conv off while - founddo struct (char internal, external) key = (F of cony of f) [ i l;(internal of key = char I k : = external of key;found := true)odesac;if found thencase text of fin(texttl): tl [p] ill [c] :=k,(flextext t2): t2 [p] [l] [c] := kesac;c+:= 1;if cpos beyond lpos then lpos : = cposelif - set possible (f) ^ pos (p of lpos, I of lpos, 1) beyond cposthen lpos := cpos;(compressible (f) lc the size of the line and page containing the logicalend of the book and of all subsequent lines andpages may be increased {e.g., to the sizes withwhich the book was originally established(10.3.1.4.cc) or to the sizes implied by maxpos ofchan off} c)flelse k : = ". ";if - (char error mended off) (f, k)then undefined; k : = "."fi;check pos (f); put char (f, k)fielse undefinedfi ¢ write mood is still set ¢ ;proc 9 next pos = (ref file f) void :(- get good line (f, read mood off) I undefined)¢ the line is now good {lO.3.1.6.dd} and the read/write mood isas on entry ¢ ;
1<strong>68</strong>10.3.3.2. Formatless inputvan Wijngaarden, et al.[For formatless input, get (a) and read (10.5.l.e) may be used. Valuesfrom the book are assigned to each straightened name N from the data listas follows:aa) If the mode of N is specified by refL int, then first, the book issearched for the first character that is not a space (finding good positionson subsequent lines as necessary); next, the largest string is read fromthe book that could be "indited" (10.3.4.1.l.kk) under the control of somepicture of the form +n(kl)"."n(k2)dd or n(k2)dd (where kl and k2 yieldarbitrary nonnegative integers); this string is converted to an integer andassigned to N; if the conversion is unsuccessful, the event routinecorresponding to on value error is called.bb) If the mode of N is specified by refL real, then first, the book issearched for the first character that is not a space (finding good positionson subsequent lines as necessary); next, the largest string is read fromthe book that could be indited under the control of some picture of theform + n(kl)"._" n(k2)d or n(k2)d followed by . n(k3)d d or by ds., possiblyfollowed again by e n(k4)"." + n(k5)"." n(k6)d d or by e n(k5)"." n(k6)d d;this string is converted to a real number and assigned to N; if theconversion is unsuccessful, the event routine corresponding to on valueerror is called.cc) If the mode of N is specified by refL compl, then first, a realnumber is input (as in bb) and assigned to the first subname of N; next,the book is searched for the first character that is not a space; next, acharacter is input and, if it is not ".L" or "i", then the event routinecorresponding to on char error (10.3.1.3.cc) is called, the suggestion being"J_"; finally, a real number is input and assigned to the second subnameof N.dd) If the mode of N is specified by refbool, then first, the book issearched for the first character that is not a space (finding good positionson subsequent lines as necessary); next, a character is read; if thischaracter is the same as that yielded by flip (flop), then true (false) isassigned to N; otherwise, the event routine corresponding to on char erroris called, the suggestion being flop.ee) If the mode of N is specified by refL bits, then input takes place(as in dd) to the subnames of N one after the other (with new lines beingtaken as required).ff) If the mode of N is specified by ref char, then first, if the currentline is exhausted, a good position is found on a subsequent line; next, acharacter is read and assigned to N.gg) If the mode of N is specified by ref[ ] char, then input takes place(as in if) to the subnames of N one after the other (with new lines beingtaken as required)./ALGOL <strong>68</strong> Revised Report 169hh) If the mode of N is specified by refstring, then characters are readuntil either(i) a character is encountered which is contained in the stringassociated with the file by a call of the routine make term, or(ii) the current line is exhausted, whereupon the event routinecorresponding to on line end (or, where appropriate, to on page end, onphysical file end or on logical file end) is called; if the event routinemoves the current position to a good position (see 10.3.3), then input ofcharacters is resumed.The string consisting of the characters read is assigned to N (note that, ifthe current line has already been exhausted, or if the current position is atthe start of an empty line or outside the logical file, then an empty stringis assigned to N).}a) proc get = (ref file f, [ ] union tintype, proc (ref file) void) x) void :if opened off thenfor i to upb xdo case set read mood (f); set char mood (f); x [i] in(proc (ref file) void pf): pf (f) ,(intype it):begin[ ] simplin y = straightin it; char k; bool k emPtY;op ? = (string s) bool :¢ true if the next character, if any, in the current lineis contained in 's' (the character is assigned to 'k')and false otherwise ¢ilk empty ^ (line ended (f) v logical file ended (f))then falseelse (k empty l get char (f, k));k empty := char in string (k, Ioc int, s)fi;op ? = (char c) bool : ? string (c);prio ! -- 8;op ! = (string s, char c) char:¢ expects a character contained in 's'; if the characterread is not in 's', the event routine corresponding to'on char error' is called with the suggestion 'c'¢if (k empty I. check pos (f); get char (f, k));k empty : = true;char in string (k, Ioc int, s)then kelse char sugg : = c;if (char error mended of f) (f, sugg) then(char in string (sugg, Ioc int, s)I suggI undefined; c)
- Page 2 and 3:
van Wijngaarden, et al.1.1.4.2. Par
- Page 4:
Acknowledgements{Habent sua fata li
- Page 8 and 9:
14 van Wijngaarden, et al.0.3.4. Mo
- Page 10 and 11:
. . . . . . . 4 " ' 0 . . . . . . .
- Page 12 and 13:
22 van Wijngaarden, et al.• let P
- Page 14 and 15:
26 van Wijngaarden, et al.{Since so
- Page 16 and 17:
30 van Wijngaarden, et aLloperandfo
- Page 18 and 19:
34 van Wijngaarden, et al.j) WHETHE
- Page 20 and 21:
38 van Wijngaarden, et al.A protono
- Page 22 and 23:
42 van Wijngaarden, et al.d) If N i
- Page 24 and 25:
46 van Wijngaarden, et al.c) {There
- Page 26 and 27:
50 van Wijngaarden, et al.c) The ph
- Page 28 and 29:
54 van Wijngaarden, et al.3.1.1. Sy
- Page 30 and 31:
58 van Wijngaarden, et al.where (RO
- Page 32 and 33:
62 van Wijngaarden, et al.1) SOlD N
- Page 34 and 35: 66 van Wijngaarden, et al.ALGOL 68
- Page 36 and 37: 70 van Wijngaarden, et el.For each
- Page 38 and 39: 74 van Wijngaarden, et al.If 'MODE"
- Page 40 and 41: 78 J van Wijngaarden, et al.C) SECO
- Page 42 and 43: 82 van Wijngaarden, et al.ALGOL 68
- Page 44 and 45: 86 van Wijngaarden. et al.ALGOL 68
- Page 46 and 47: 90 van Wijngaarden, et al.5.4.4.1.
- Page 48 and 49: 94van Wijngaarden, et al.ALGOL 68 R
- Page 50 and 51: 98 van Wijngaarden, et al.Assignati
- Page 52 and 53: 102 van Wijngaarden, et at.{A nest,
- Page 54 and 55: 106 van Wijngaarden, et al.'HEAD's
- Page 56 and 57: 110 van Wijngaarden, et al.ALGOL 68
- Page 58 and 59: 114van Wijngaarden, et al.ALGOL 68
- Page 60 and 61: 118 van Wijngaarden, et al.ALGOL 68
- Page 62 and 63: 122 van Wijngaarden, et al.style ii
- Page 64 and 65: 126 van Wijngaarden, et al.b) The c
- Page 66 and 67: 130van Wijngaarden, et al.ALGOL 68
- Page 68 and 69: 134van Wijngaarden, et al.ALGOL 68
- Page 70 and 71: 138d)e)f)g)h)i)J)k)1)m)n)van Wijnga
- Page 72 and 73: 142 van Wijngaarden, et al.physics
- Page 74 and 75: 146 van Wijngaarden, et al.gg) On s
- Page 76 and 77: 150van Wijngaarden, et al.ALGOL 68
- Page 78 and 79: 154/van Wijngaarden, et al.ALGOL 68
- Page 80 and 81: 158 van Wijngaarden, et el.fi;ref p
- Page 82 and 83: 162van Wijngaarden, et al.ALGOL 68
- Page 86 and 87: 170/van Wijngaarden, etal.ALGOL 68
- Page 88 and 89: 174J)K)L)M)N)O)P)a)b)c)d)e)van Wijn
- Page 90 and 91: 178/van Wijngaarden, et al.ALGOL 68
- Page 92 and 93: 182 van Wijngaarden, et al.• let
- Page 94 and 95: 186van Wijngaarden, et al./ALGOL 68
- Page 96 and 97: 190 van Wijngaarden, etal.composed
- Page 98 and 99: 194h)i)J)van Wijngaa(rden, et al.pr
- Page 100 and 101: 198 van Wijngaarden, et al.¢ strin
- Page 102 and 103: 202tvan Wijngaarden, et al.ALGOL 68
- Page 104 and 105: 206 van Wijngaa~den. et al.10.3.6.1
- Page 106 and 107: 210 van Wijngaarden, et al.!ALGOL 6
- Page 108 and 109: 214 van Wijngaarden, et al.inoperat
- Page 110 and 111: 218fvan Wijngaarden, et al.¢ move
- Page 112 and 113: 222 van Wijngaarden, etaL{overflow}
- Page 114 and 115: 226 van Wijngaarden, et al.ALGOL 68
- Page 116 and 117: 230max int 10.2.1.cmax real 10.2.l.
- Page 118 and 119: 234 van Wijngaarden, et al.ALGOL 68