<> <> <> <> DIRECTORY AbstractTypesDef USING[ProgramNode], Commander USING[CommandProc, Register], FS USING[Error, StreamOpen], IO USING[rope, RIS, STREAM, Close, EndOfStream, GetTokenRope, IDProc, PutF, PutFR], OneCasabaParser USING[GetReportStream], OneCasabaParserImpl USING [UnRecoverableSyntaxError], Rope USING[ROPE, Cat, Length, Replace], SiroccoParserDef USING[ParseOneStream], SiroccoPrivate USING [AquireState, Collapse, EndItAll, GenAuxDefs, GenAuxImpl, GenCImpl, GenDefs, GenSImpl, Handle, Object, TABLES], ThreeC4Support USING[GetReportStream]; SiroccoDriver: CEDAR PROGRAM IMPORTS SiroccoParserDef, Commander, FS, IO, OneCasabaParser, OneCasabaParserImpl, Rope, SiroccoPrivate, ThreeC4Support ~ { OPEN SiroccoPrivate; <> ROPE: TYPE ~ Rope.ROPE; <> debugFlags: CARDINAL _ 0; <> <<>> Sirocco: Commander.CommandProc ~ { h: Handle; commandLineStream: IO.STREAM _ IO.RIS[cmd.commandLine]; errorFlag: BOOLEAN _ FALSE; root: AbstractTypesDef.ProgramNode; rootName: ROPE; sourceStream: IO.STREAM; specName: ROPE; tables: TABLES; h _ NEW [Object]; rootName _ IO.GetTokenRope[commandLineStream, IO.IDProc ! IO.EndOfStream => { rootName _ NIL; CONTINUE } ].token; specName _ Rope.Cat[rootName, ".cr"]; IO.Close[commandLineStream]; sourceStream _ FS.StreamOpen[specName ! FS.Error => IF (error.group = user) THEN { msg _ IO.PutFR["%g", IO.rope[error.explanation]]; GOTO ERRMSG2; } ]; root _ NARROW[SiroccoParserDef.ParseOneStream[sourceStream, debugFlags, cmd.out ! OneCasabaParser.GetReportStream => { errorFlag _ TRUE; IO.PutF[cmd.out, "\nSyntax Error in %g: ", IO.rope[specName]]; RESUME[cmd.out] }; OneCasabaParserImpl.UnRecoverableSyntaxError => { errorFlag _ TRUE; IO.PutF[cmd.out, "\nSyntax Error in %g : ", IO.rope[specName]]; GOTO ERRMSG; } ]]; IO.Close[sourceStream]; IF (errorFlag) THEN GOTO ERRMSG; tables _ root.procs.MakeSymbolTable[root ! OneCasabaParser.GetReportStream => { errorFlag _ TRUE; IO.PutF[cmd.out, "\nSyntax Error %g!:\n", IO.rope[specName]]; RESUME[cmd.out] }; ThreeC4Support.GetReportStream => { errorFlag _ TRUE; RESUME[cmd.out] }; EndItAll => { IO.PutF[cmd.out, "\nMission Aborted, need help.... "]; errorFlag _ TRUE; GOTO ERRMSG; }; AquireState => { RESUME[h]; }; ]; { ENABLE AquireState => { RESUME[h]; }; prefixLength: INT _ Rope.Length[h.programKey]; outfilePrefix: ROPE _ Rope.Replace[h.programKey, (prefixLength-1), prefixLength]; Finished: PROC [r: ROPE] ~ { IO.PutF[cmd.out, "\t%g%g\n", IO.rope[outfilePrefix], IO.rope[r] ]; }; IO.PutF[cmd.out, "Files Written:\n"]; Collapse[]; Finished[".Tables"]; GenDefs[]; Finished[".Mesa"]; Finished["Init.Mesa"]; GenAuxDefs[]; Finished["Aux.Mesa"]; GenAuxImpl[]; Finished["AuxImpl.Mesa"]; GenCImpl[]; Finished["ClientImpl.Mesa"]; GenSImpl[]; Finished["ServerImpl.Mesa"]; }; EXITS ERRMSG => { result _ $Failure; msg _ "Call Cobra!"; }; ERRMSG2 => { result _ $Failure; }; }; <
> Commander.Register["///Commands/Sirocco", Sirocco]; }...