ReadCifImpl.mesa
Copyright © 1985 by Xerox Corporation. All rights reserved.
by Jim Gasbarro March 12, 1985 12:38:00 pm PST
Ripped off from: MPCControl.Mesa
Last Edited by: Gasbarro, December 18, 1985 10:35:44 am PST
McCreight, April 14, 1986 3:29:33 pm PST
DIRECTORY
CDIO, Commander, CommandTool, IntDefs, IO, IODefs, LayerFileDefs, MPCDefs, MPCParserDefs, OutputDefs, ParserDefs, ParserErrorDefs, ParserInputDefs, ReadCif, Rope, TerminalIO;
ReadCifImpl: CEDAR PROGRAM
IMPORTS
CDIO, Commander, CommandTool, IntDefs, IO, IODefs, OutputDefs, ParserDefs, ParserErrorDefs, ParserInputDefs, ReadCif, Rope, TerminalIO
EXPORTS
ReadCif =
BEGIN
designName: PUBLIC Rope.ROPE;
cifUnitsPerLambda: PUBLIC CARDINAL;
ReadCifFile: Commander.CommandProc =
BEGIN
ENABLE TerminalIO.UserAbort => {GOTO abort};
argv: CommandTool.ArgumentVector ← CommandTool.Parse[cmd: cmd
! CommandTool.Failed => {msg ← errorMsg; GO TO failed}];
fname: Rope.ROPE;
ok: BOOLEANTRUE;
errorSummary: ARRAY ParserErrorDefs.ErrorType OF CARDINALALL[0];
aborted: BOOLEANFALSE;
FOR i: NAT IN [1..argv.argc) DO
fname ← argv[i];
IF Rope.Length[fname] = 0 THEN LOOP ELSE EXIT;
ENDLOOP;
fname ← CDIO.MakeName[base: fname, ext: "cif", wDir: NIL, modifier: NIL];
IF ~OutputDefs.FinishOutput[] THEN GO TO failed; --make sure we cleaned up
IF ~ParserDefs.InitParser[] OR ~ParserInputDefs.InFromFile[fname] THEN GO TO failed;
IF ~IntDefs.InitInterpreter[] THEN GO TO failed;
ReadCif.designName ← fname;
TerminalIO.WriteRope["How many CIF units per lambda? (1 CIF unit = 0.01 microns)\n"];
ReadCif.cifUnitsPerLambda ← TerminalIO.RequestInt[">> "];
Main loop to convert CIF file
BEGIN
ENABLE
ParserErrorDefs.ParserAbort =>
BEGIN aborted ← TRUE; IODefs.WriteLine["---Parser aborted---"]; CONTINUE; END;
nStatements: INT ← 0;
DO
SELECT ParserDefs.ParseStatement[] FROM
End => BEGIN nStatements ← nStatements + 1; EXIT; END;
SemanticError, SyntaxError =>
IF ParserInputDefs.EndOfFile[] THEN aborted ← TRUE;
ENDCASE;
nStatements ← nStatements + 1;
IF nStatements MOD 100 = 0 THEN
IODefs.PostIt[IO.PutFR["CIF File: %g, Statement: %g...", IO.rope[fname], IO.int[nStatements]]];
IF ParserInputDefs.EndOfFile[] THEN
BEGIN
IODefs.WriteLine[
"Unexpected end of input file, Probably missing End command"];
aborted ← TRUE;
END;
ENDLOOP;
END; --End of Enable clause
errorSummary ← ParserErrorDefs.ErrorSummary[];
[] ← ParserDefs.FinishParser[];
ok ← ~aborted
AND
(errorSummary[Fatal] + errorSummary[FatalSyntax] + errorSummary[
FatalSemantic] + errorSummary[FatalInternal]) = 0;
IF ok THEN IntDefs.Instantiate[];
[] ← IntDefs.FinishInterpreter[];
[] ← OutputDefs.FinishOutput[];
EXITS
failed => {result ← $Failure};
abort => {result ← $Failure; msg ← "aborted"};
END;
doc: Rope.ROPE = "Chipndale command to read Cif format design files";
Commander.Register[key: "///Commands/ReadCif", proc: ReadCifFile, doc: doc];
END.