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: SIGNAL; 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. HTokenIO.mesa Copyright c 1983, 1984 by Xerox Corporation. All rights reserved. by Christian Jacobi, August 24, 1983 3:10 pm last edited by Christian Jacobi, September 19, 1985 4:05:26 am PDT Input output in tokenized form. Allows grouping of tokens to clusters with a push and a popflag. 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 -- 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 SIGNAL EncodingError if read token is not as expected; -- for emergeny error bypassing, the state may be changed in the debugger -- and the computation continued; however, normal computation considers -- EncodingError to be an ERROR, not a SIGNAL. --Attaching TokenIo to STREAMS -- while TokenIo is attached to a stream no other operations on this stream should occur -- also invalidates marks ΚJ˜codešœ ™ Kšœ Οmœ7™BKšœ,™,KšœB™B—K˜šΟk ˜ Kšžœ˜ —K˜KšΠlnœžœž œ˜Kšž˜K˜™aK™Kšœ[™[KšœB™BKšœ!™!Kšœ6™6K˜—K˜šœžœžœ ˜Kšœ žœ˜K˜—Kšœžœ˜šΟn œžœžœžœ˜1Kšœ?™?Kšœ2™2Kšœ4™4K™Kšœ žœžœ˜—K™Kš œžœžœ˜Kš  œžœžœ˜Kš  œžœ žœ˜Kš  œžœžœžœ˜"Kš  œžœ˜K˜Kš œžœ žœžœ˜2Kš  œžœžœ˜*K˜Kšœ žœ<˜Kšœžœžœ˜K˜KšœžœžœΟcE˜TK˜Kšœ#™#Kšœ%™%Kšœ)™)Kšœ2™2Kšœ™Kšœ ™ Kšœ5™5K˜—Kš  œžœžœ ˜#š  œžœ˜KšœF™FKšœT™T—K˜šœžœ˜Kšœžœ1™NKšœI™IKšœG™GKšœ/™/K™—Kš œžœžœžœ˜Kš œžœžœžœ˜!Kš œžœžœžœ˜&Kš  œžœžœžœ˜%Kš  œžœ˜˜K˜—šœ™KšœY™Y—K˜Kšœžœžœ‘˜MKšœžœ*˜3K˜Kš  œžœ žœžœ˜'š  œžœ˜K˜—Kš  œžœ žœžœ˜'š  œžœ˜Kšœ™—K˜Kšžœ˜K˜K˜—…—Œ