DIRECTORY CIFParser, FS, IO, Rope; CIFPrintImpl: CEDAR PROGRAM IMPORTS CIFParser, FS, IO, Rope ~ BEGIN Print: PUBLIC PROC [cifName: Rope.ROPE] RETURNS [errMsg: Rope.ROPE] ~ { cifFile, printFile: IO.STREAM; printReg: CIFParser.Registration; cifFile _ FS.StreamOpen[Rope.Concat[cifName, ".cif"], read ! FS.Error => IF error.group#bug THEN { errMsg _ error.explanation; GOTO Exit; } ]; printFile _ FS.StreamOpen[Rope.Concat[cifName, ".cifPrint"], create ! FS.Error => IF error.group#bug THEN { errMsg _ error.explanation; GOTO Exit; } ]; printReg _ NEW[CIFParser.RegistrationRec _ [ defDelete: DefDelete, defStart: DefStart, defFinish: DefFinish, polygon: Polygon, box: Box, roundFlash: RoundFlash, wire: Wire, layer: Layer, call: Call, userExtension: UserExtension, comment: Comment, data: printFile ]]; CIFParser.Parse[cifFile, printReg ! CIFParser.Error => errMsg _ IO.PutFR["%g @ %g\n", IO.rope[msg], IO.int[IO.GetIndex[cifFile]]]]; IO.PutF[printFile, "E ;\n"]; IO.Close[printFile]; EXITS Exit => {}; }; DefDelete: PROC[i: CARD, data: REF ANY] ~ { printFile: IO.STREAM ~ NARROW[data]; IO.PutF[printFile, "Define Delete #%d;\n", IO.card[i]]; }; DefStart: PROC[i, a, b: CARD, data: REF ANY] ~ { printFile: IO.STREAM ~ NARROW[data]; IO.PutF[printFile, "Define Start #%d with ratio %d/%d;\n", IO.card[i], IO.card[a], IO.card[b]]; }; DefFinish: PROC[data: REF ANY] ~ { printFile: IO.STREAM ~ NARROW[data]; IO.PutF[printFile, "Define Finish;\n"]; }; Polygon: PROC[p: CIFParser.Path, data: REF ANY] ~ { printFile: IO.STREAM ~ NARROW[data]; IO.PutF[printFile, "Polygon "]; PrintPath[printFile, p]; IO.PutF[printFile, ";\n"]; }; Box: PROC[l, w: CARD, c, d: CIFParser.Point, data: REF ANY] ~ { printFile: IO.STREAM ~ NARROW[data]; IO.PutF[printFile, "Box length: %d, width: %w, center: [%d, %d]", IO.card[l], IO.card[w], IO.int[c.x], IO.int[c.y]]; IF d#[1, 0] THEN IO.PutF[printFile, ", direction: [%d, %d]", IO.int[d.x], IO.int[d.y]]; IO.PutF[printFile, ";\n"] }; RoundFlash: PROC[d: CARD, c: CIFParser.Point, data: REF ANY] ~ { printFile: IO.STREAM ~ NARROW[data]; IO.PutF[printFile, "Roundflash of diameter %d at [%d, %d];\n", IO.card[d], IO.int[c.x], IO.int[c.y]] }; Wire: PROC[w: CARD, p: CIFParser.Path, data: REF ANY] ~ { printFile: IO.STREAM ~ NARROW[data]; IO.PutF[printFile, "Wire of width %d : ", IO.card[w]]; PrintPath[printFile, p]; IO.PutF[printFile, ";\n"]; }; Layer: PROC[n: Rope.ROPE, data: REF ANY] ~ { printFile: IO.STREAM ~ NARROW[data]; IO.PutF[printFile, "Layer name: %g;\n", IO.rope[n]] }; Call: PROC[s: CARD, t: CIFParser.Transformation, data: REF ANY] ~ { printFile: IO.STREAM ~ NARROW[data]; IO.PutF[printFile, "Call symbol #%d with ", IO.card[s]]; PrintTransformation[printFile, t]; IO.PutF[printFile, ";\n"]; }; UserExtension: PROC[u: CARD, t: Rope.ROPE, data: REF ANY] ~ { printFile: IO.STREAM ~ NARROW[data]; IO.PutF[printFile, "%d %g;\n", IO.card[u], IO.rope[t]] }; Comment: PROC[c: Rope.ROPE, data: REF ANY] ~ { printFile: IO.STREAM ~ NARROW[data]; IO.PutF[printFile, "%g;\n", IO.rope[c]] }; PrintPath: PROC [printFile: IO.STREAM, p: CIFParser.Path] ~ { IO.PutF[printFile, "[%d, %d]", IO.int[p.first.x], IO.int[p.first.y]]; p _ p.rest; UNTIL p=NIL DO IO.PutF[printFile, ", [%d, %d]", IO.int[p.first.x], IO.int[p.first.y]]; p _ p.rest; ENDLOOP; }; PrintTransformation: PROC [printFile: IO.STREAM, t: CIFParser.Transformation] ~ { UNTIL t=NIL DO SELECT t.first.t FROM translation => IO.PutF[printFile, "Translation of [%d, %d]", IO.int[t.first.p.x], IO.int[t.first.p.y]]; rotation => IO.PutF[printFile, "Rotation to [%d, %d]", IO.int[t.first.p.x], IO.int[t.first.p.y]]; xSym => IO.PutF[printFile, "Mirror along X"]; ySym => IO.PutF[printFile, "Mirror along Y"]; ENDCASE => ERROR; t _ t.rest; ENDLOOP; }; END. CIFPrintImpl.mesa Copyright Σ 1987 by Xerox Corporation. All rights reserved. Christian Le Cocq, September 10, 1987 3:06:41 pm PDT Pretty print of CIF files, but above all test of the CIF Parser. EXPORTS Export Description of the procedure. ΚΛ˜codešœ™Kšœ<™šœ œœ˜&Kšœ˜Kšœ˜ K˜—K˜—šœ œ9˜Gšœ œœ˜&Kšœ˜Kšœ˜ K˜—K˜—šœ œ˜,Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ ˜ Kšœ˜Kšœ ˜ Kšœ ˜ Kšœ ˜ Kšœ˜Kšœ˜Kšœ˜Kšœ˜—Kšœƒ˜ƒKšœ˜Kšœ˜Kšœ ˜K˜K™—š Ÿ œœœœœ˜+Kšœ œœœ˜$Kšœ)œ ˜7K˜K˜—š Ÿœœ œœœ˜0Kšœ œœœ˜$Kšœ9œ œ œ ˜_K˜K˜—šŸ œœœœ˜"Kšœ œœœ˜$Kšœ'˜'K˜K˜—šŸœœœœ˜3Kšœ œœœ˜$Kšœ˜Kšœ˜Kšœ˜K˜K˜—š Ÿœœœœœ˜?Kšœ œœœ˜$šœ?˜AKšœ œ œ œ ˜2—Kš œ œœ*œ œ ˜WKšœ˜K˜K˜—š Ÿ œœœœœ˜@Kšœ œœœ˜$Kšœ=œ œ œ ˜dK˜K˜—š Ÿœœœœœ˜9Kšœ œœœ˜$Kšœ(œ ˜6Kšœ˜Kšœ˜K˜K˜—šŸœœœœ˜,Kšœ œœœ˜$Kšœ1˜3K˜K˜—š Ÿœœœ%œœ˜CKšœ œœœ˜$Kšœ*œ ˜8Kšœ"˜"Kšœ˜K˜K˜—š Ÿ œœœœœ˜=Kšœ œœœ˜$Kšœœ˜6K˜K˜—šŸœœœœ˜.Kšœ œœœ˜$Kšœ%˜'K˜K˜—šŸ œœ œœ˜=Kšœœœ˜EKšœ ˜ šœœ˜Kšœœœ˜GKšœ ˜ Kšœ˜—K˜K˜—šŸœœ œœ"˜Qšœœ˜šœ ˜Kšœœ,œœ˜gKšœ œ)œœ˜bKšœ œ#˜.Kšœ œ#˜.Kšœœ˜—K˜ Kšœ˜—K˜——K˜Kšœ˜—…—΄