IOClasses.mesa
Copyright © 1985 by Xerox Corporation. All rights reserved.
MBrown on October 25, 1983 8:06 pm
Russ Atkinson (RRA) February 2, 1985 1:01:19 pm PST
Beach, February 27, 1985 10:35:59 am PST
DIRECTORY
IO USING [STREAM];
IOClasses: CEDAR DEFINITIONS
= BEGIN
STREAM: TYPE ~ IO.STREAM;
Pipe (class $Pipe)
CreatePipe: PROC [bufferByteCount: NAT ← 256] RETURNS [push, pull: STREAM];
Creates a pipe, that is, an output stream push and an input stream pull such that the byte sequence written to push can be read from pull. Closing push terminates the sequence. The parameter bufferByteCount specifies the (approximate) maximum number of bytes that can be written to push and not yet read from pull at any instant of time. Typically, one process does the pushing and another process does the pulling.
Copy
Copy: PROC [from, to: STREAM, closeFrom, closeTo: BOOLTRUE,
bufferByteCount: NAT ← 256];
Copies the sequence produced by input stream from to output stream to. If closeFrom, performs from.Close[] when the transfer is complete; if closeTo, performs to.Close[] at that time. Does not catch IO.Error. The parameter bufferByteCount specifies the (approximate) maximum number of bytes that will be read from from and not written to to at any instant of time. (Copy is the "dual" of a pipe.)
Comment-filtered Input stream (class $CommentFilter)
CreateCommentFilterStream: PROC [input: STREAM] RETURNS [STREAM];
Creates a input stream s on top of stream such that any comments are filtered out. A comment is a sequence of characters beginning with -- and ending with -- or IO.CR. When s.GetChar[] reads a comment that ends in IO.CR from stream, it returns IO.CR; a comment that ends in -- returns IO.SP. (A comment must produce some character from s so that the comment serves as a separator between tokens.)
The character sequence produced by stream must follow Cedar conventions for string and character literals: "" and ' for quoting strings and characters, and \ as an escape character for certain characters (particularly ") within such literals. For instance, the character sequence "-- a string literal --" does not contain a comment and is passed through unchanged, while the character sequence '\"-- a comment -- " a string literal " does contain a comment and the sub-sequence -- a comment -- is translated into IO.SP.
Concatenated input stream (Class $Concatenated)
CreateCatInputStream: PROC [input1, input2: STREAM] RETURNS [STREAM];
Creates an input stream s such that the byte sequence produced by s is the byte sequence produced by input1, followed by the byte sequence produced by input2. For instance, CreateAppendedInputStream[IO.RIS[rope1], IO.RIS[rope2]] is equivalent to IO.RIS[rope1.Cat[rope2]].
Dribble Output stream (Class $Dribble)
CreateDribbleOutputStream: PROC [output1, output2: STREAM] RETURNS [STREAM];
Creates an output stream s such that each operation performed on s will be performed in turn on output1 and output2. For instance, s.PutChar[c] is equivalent to { output1.PutChar[c]; output2.PutChar[c] }.
END.