10.07.2015 Views

Algol 68 - ACM Digital Library

Algol 68 - ACM Digital Library

Algol 68 - ACM Digital Library

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

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 ¢ ;

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!