IPWriter.mesa
Token-level interface for writing encoded Interpress masters
Last edited by:
Doug Wyatt, March 12, 1984 1:10:10 pm PST
DIRECTORY
IO USING [STREAM],
IPBasic USING [Op, Rational],
Rope USING [ROPE];
IPWriter: CEDAR DEFINITIONS
~ BEGIN OPEN IPBasic;
ROPE: TYPE ~ Rope.ROPE;
STREAM: TYPE ~ IO.STREAM;
ErrorCode:
TYPE ~ {
ok, -- initial value for an ErrorCode
bug, -- implementation bug
unimplemented, -- operation not currently implemented
unknownEncoding, -- the requested encoding is not implemented
illegalArgument, -- invalid argument for an operation
closed -- tried to operate on a closed writer
};
Error:
ERROR[code: ErrorCode, explanation:
ROPE ←
NIL];
Writer: TYPE ~ REF WriterRep;
WriterRep:
TYPE ~
RECORD[class: Class, stream:
STREAM];
Class: TYPE ~ REF ClassRep;
ClassRep:
TYPE ~
RECORD[
encoding: ATOM ←,
putOp: PROC[writer: Writer, op: Op] ←,
putInt: PROC[writer: Writer, value: INT] ←,
putReal: PROC[writer: Writer, value: REAL] ←,
putRational: PROC[writer: Writer, value: Rational] ←,
putIdentifier: PROC[writer: Writer, rope: ROPE] ←,
putString: PROC[writer: Writer, rope: ROPE] ←,
putInsertfile: PROC[writer: Writer, rope: ROPE] ←,
putComment: PROC[writer: Writer, rope: ROPE] ←,
putAnnotation: PROC[writer: Writer, rope: ROPE] ←
];
Open:
PROC[name:
ROPE, encoding:
ATOM]
RETURNS[Writer];
Create the named file, write a header for the specified encoding, and return a Writer.
Create:
PROC[stream:
STREAM, encoding:
ATOM]
RETURNS[Writer];
Create a Writer for the given stream. (Does not write a header.)
PutHeader:
PROC[writer: Writer];
Write an Interpress header for the writer's encoding.
Close:
PROC[writer: Writer];
Close the writer's stream and prevent further calls on the writer.
PutOp:
PROC[writer: Writer, op: Op]
~ INLINE { writer.class.putOp[writer, op] };
PutInt:
PROC[writer: Writer, value:
INT]
~ INLINE { writer.class.putInt[writer, value] };
PutReal:
PROC[writer: Writer, value:
REAL]
~ INLINE { writer.class.putReal[writer, value] };
PutRational:
PROC[writer: Writer, value: Rational]
~ INLINE { writer.class.putRational[writer, value] };
PutIdentifier:
PROC[writer: Writer, rope:
ROPE]
~ INLINE { writer.class.putIdentifier[writer, rope] };
PutString:
PROC[writer: Writer, rope:
ROPE]
~ INLINE { writer.class.putString[writer, rope] };
PutComment:
PROC[writer: Writer, rope:
ROPE]
~ INLINE { writer.class.putComment[writer, rope] };
PutAnnotation:
PROC[writer: Writer, rope:
ROPE]
~ INLINE { writer.class.putAnnotation[writer, rope] };
PutInsertfile:
PROC[writer: Writer, rope:
ROPE]
~ INLINE { writer.class.putInsertfile[writer, rope] };
Register:
PROC[class: Class];
END.