DIRECTORY IO, Rope; TokenIO: CEDAR DEFINITIONS = BEGIN Mark: TYPE = REF MarkRep; MarkRep: TYPE; WritingStopped: SIGNAL; StopWriting: PROC [] = INLINE {stopWriting_TRUE}; stopWriting: PRIVATE BOOL; WriteInt: PROC [i: INT]; WriteAtom: PROC [a: ATOM]; WriteRope: PROC [r: Rope.ROPE]; WritePushFlag: PROC [a: ATOM_NIL]; WritePopFlag: PROC []; MarkAndWriteInt: PROC [value: INT] RETURNS [Mark]; UpdateMark: PROC [mark: Mark, value: INT]; TokenType: TYPE = {atom, int, rope, pushFlag, popFlag, endOfStream, error}; Token: TYPE = RECORD [ kind: TokenType, ref: REF_NIL -- either ATOM, Rope.ROPE, REF INT or NIL (Rope.ROPE or NIL if error) ]; ReadToken: PROC [] RETURNS [Token]; ReadAgain: PROC []; EncodingError: ERROR; ReadInt: PROC [] RETURNS [INT]; ReadAtom: PROC [] RETURNS [ATOM]; ReadRope: PROC [] RETURNS [Rope.ROPE]; ReadPushFlag: PROC [] RETURNS [ATOM]; ReadPopFlag: PROC []; Error: ERROR[why: Err, explanation: Rope.ROPE]; -- only on Attach or Release Err: TYPE = {alreadyAttached, wrongVersion, other}; AttachReader: PROC [stream: IO.STREAM]; ReleaseReader: PROC []; AttachWriter: PROC [stream: IO.STREAM]; ReleaseWriter: PROC []; END. ð-- TokenIO.mesa -- by Christian Jacobi August 24, 1983 3:10 pm -- last edited by Christian Jacobi January 31, 1984 11:29 am -- causes next call of Write or Update to signal WritingStopped -- (inside monitorlock; may be resumed or aborted) -- AttachWriter invalidates a call of WritingStopped -- inline for speed reason only -- kind = atom => ISTYPE[ref, ATOM] -- kind = int => ISTYPE[ref, REF INT] -- kind = rope => ISTYPE[ref, Rope.ROPE] -- kind = pushFlag => ref=NIL or ISTYPE[ref, ATOM] -- kind = popFlag => ref=NIL -- kind = endOfStream => ref=NIL -- kind = error => ref=NIL OR ISTYPE[ref, Rope.ROPE] -- cause next call of ReadToken to get the same value as the last read -- works only one level deep (reads again only the last value returned by ReadToken) -- all read procedures ERROR EncodingError if read token is not as expected -- Attaching TokenIo to STREAMS -- while TokenIo is attached to a stream no other operations on this -- stream should occur -- also invalidates marks -- the routines may generate some standard IO signals and errors, however, -- as few as possible -- the Rope NIL and the Rope "" may read back correctly or exchanged -- the ATOM NIL reads back correctly; -- the ATOM "$" may be read back correctly or as NIL ATOM ʘJšœ™Jšœ.™.Jšœ<™