CIFParser.mesa
Copyright Ó 1987 by Xerox Corporation. All rights reserved.
written by Ch. Le Cocq, September 10, 1987
Christian Le Cocq, September 16, 1987 10:38:44 am PDT
Parser of the CIF (Caltech Intermediate Form) format stream.
CIF is a standard of chip layout description. See Mead & Conway pp 115-127.
DIRECTORY
IO USING [STREAM],
Rope USING [ROPE];
CIFParser: CEDAR DEFINITIONS
~ BEGIN
Point: TYPE ~ RECORD[x, y: INT];
Path: TYPE ~ LIST OF Point;
Transformations
Transformation: TYPE ~ LIST OF TransformationRec;
TransformationRec: TYPE ~ RECORD[t: TransfType, p: Point]; --never NIL
TransfType: TYPE ~ {translation, rotation, xSym, ySym, error};
TMatrix: TYPE ~ RECORD[a11, a21, a31, a12, a22, a32, a33: REAL]; --IntTransDefs.mesa compatible
Simple Transformation handling package:
TransfToMatrix: PROC [t: Transformation] RETURNS [m: TMatrix];
MatMult: PROC [m1, m2: TMatrix] RETURNS [mProd: TMatrix];
TransformPt: PROC [m: TMatrix, p: Point] RETURNS [newP: Point];
IsOrthogonalTransform: PROC [m: TMatrix] RETURNS [BOOL];
The calling program provides one proc for each CIF command.
Registration: TYPE ~ REF RegistrationRec;
RegistrationRec: TYPE ~ RECORD [
defDelete:  PROC[i: CARD, data: REF ANY],
defStart:  PROC[i, a, b: CARD, data: REF ANY],
defFinish:  PROC[data: REF ANY],
polygon:  PROC[p: Path, data: REF ANY],
box:  PROC[l, w: CARD, c, d: Point, data: REF ANY],
roundFlash: PROC[d: CARD, c: Point, data: REF ANY],
wire:  PROC[w: CARD, p: Path, data: REF ANY],
layer:  PROC[n: Rope.ROPE, data: REF ANY],
call:  PROC[s: CARD, t: Transformation, data: REF ANY],
userExtension: PROC[u: CARD, t: Rope.ROPE, data: REF ANY],
comment:  PROC[c: Rope.ROPE, data: REF ANY],
data:  REF ANY-- user data ignored by the Parser
];
Parse: PROC [cifStream: IO.STREAM, reg: Registration];
calls the various registred procs with the relevant argument for each CIF command.
Error: ERROR [msg: Rope.ROPE, cifFile: IO.STREAM];
syntax error
ClientError: ERROR [clientMsg: Rope.ROPE];
Is mapped into Error[Rope.Cat["client error: ", clientMsg], cifFile]. Convenient way for the client registred procs to raise an error (for instance "unknown layer").
END.