GGParseIn.mesa
Copyright Ó 1986, 1988 by Xerox Corporation. All rights reserved.
Last edited by Bier on October 19, 1987 1:13:43 pm PDT
Contents: Routines for reading gargoyle data structures from a stream. Stolen from Solidviews Solidmodeler TFI3d.mesa.
Pier, March 25, 1988 4:16:24 pm PST
Bier, November 28, 1988 9:12:35 pm PST
DIRECTORY
GGCoreTypes, Imager, ImagerColor, ImagerTransformation, IO, Rope, TextNode;
GGParseIn: CEDAR DEFINITIONS =
BEGIN
BoundBox: TYPE = GGCoreTypes.BoundBox;
Color: TYPE = Imager.Color;
Point: TYPE = Imager.VEC;
SequenceOfReal: TYPE = GGCoreTypes.SequenceOfReal;
SyntaxError: SIGNAL [position: NAT, wasThere: Rope.ROPE, notThere: Rope.ROPE];
Whitespace
ReadBlank: PROC [f: IO.STREAM];
Remove from f all whitespace up to the next non-whitespace character. Do nothing if there is none.
ReadWhiteSpace: PROC [f: IO.STREAM];
Remove from f all whitespace up to the next non-whitespace character. Signal SyntaxError if there is none.
ReadHorizontalBlank: PROC [f: IO.STREAM] RETURNS [good: BOOL];
Remove from f any SP, or TAB characters until a non-(SP or TAB) character is found. Note that this leaves CR alone.
Raw Text
ReadWWord: PROC [f: IO.STREAM] RETURNS [word: Rope.ROPE];
ReadBlank[f]. Then let word be all of the characters up to the next TAB, CR, SP, comma, ], or ).
ReadWRope: PROC [f: IO.STREAM, rope: Rope.ROPE];
The next few characters on f should be rope. Remove them. Signal SyntaxError if they aren't there.
ReadChar: PROC [f: IO.STREAM, c: CHAR];
The next character on f should be c. Remove it. Signal SyntaxError if it isn't there.
ReadLine: PROC [f: IO.STREAM] RETURNS [line: Rope.ROPE];
Read all characters up to the next CR.
ReadKeyWord: PROC [f: IO.STREAM] RETURNS [keyWord: Rope.ROPE, good: BOOL];
The next few characters on f should be followed by a colon with no intervening CR's. Put these characters into keyWord. If a CR is found before a colon, let good = FALSE.
ReadListOfRope: PROC [f: IO.STREAM] RETURNS [ropeList: LIST OF Rope.ROPE];
Reads a list of words separated by commas or spaces.
Imager Types
ReadStrokeEnd: PROC [f: IO.STREAM] RETURNS [strokeEnd: Imager.StrokeEnd];
ReadStrokeJoint: PROC [f: IO.STREAM] RETURNS [strokeJoint: Imager.StrokeJoint];
ReadColor: PROC [f: IO.STREAM, version: REAL] RETURNS [color: Color];
ReadPixelArray: PROC [f: IO.STREAM] RETURNS [pa: Imager.PixelArray];
ReadText: PROC [f: IO.STREAM, version: REAL] RETURNS [text: TextNode.Ref, screenStyle: BOOL];
ReadPoint: PROC [f: IO.STREAM] RETURNS [point: Point];
ReadTransformation: PROC [f: IO.STREAM] RETURNS [transform: ImagerTransformation.Transformation];
ReadFactoredTransformation: PROC [f: IO.STREAM] RETURNS [transform: ImagerTransformation.Transformation];
ReadFactoredTransformationVEC: PROC [f: IO.STREAM] RETURNS [transform: ImagerTransformation.Transformation];
Cedar Types
ReadArrayOfReal: PROC [f: IO.STREAM] RETURNS [reals: SequenceOfReal];
Reads a list of REALs enclosed in square brackets, separated by spaces, tabs, commas, or semi-colons. For instance [3.5, 2.6, 1, 4. 3.0 ] returns a list of 5 real numbers.
ReadBool: PROC [f: IO.STREAM, version: REAL] RETURNS [truth: BOOL, good: BOOL];
For files made after 8701.26, we expect T or F. Before, we expect TRUE or FALSE. If this is not found, good = FALSE.
ReadWNAT: PROC [f: IO.STREAM] RETURNS [n: NAT];
ReadWCARD: PROC [f: IO.STREAM] RETURNS [n: CARD];
ReadBlank[f]. Then interpret the following characters and digits as a natural number. Stops at period, CR, SP, ], comma, and : .
ReadWReal: PROC [f: IO.STREAM] RETURNS [r: REAL];
ReadScalarButtonValues: PROC [f: IO.STREAM, version: REAL] RETURNS [names: LIST OF Rope.ROPE, values: LIST OF REAL, on: LIST OF BOOL];
Reads a list of button values separated by spaces and ending with CR. A button value has the format [BOOL REAL ROPE] where BOOL is the letter T or F and ROPE is an optional rope for display of the REAL. Positions in each list are corresponding button value, name, and ON value for the button.
ReadBlank[f]. Then interpret the following characters and digits as a real number. Stops at ), ], CR, SP, and TAB.
Gargoyle Core Types
ReadBox: PROC [f: IO.STREAM] RETURNS [box: BoundBox];
END.