DIRECTORY
Commander: TYPE USING [Handle, Register],
CommandUtil: TYPE USING [PairList, Echo, Failed, Parse],
Cursors: TYPE USING [CursorType, NewCursor],
IO: TYPE USING [char, CR, Put, PutChar, PutRope, time],
PGSConDefs: TYPE USING [],
PGSOps: TYPE USING [PGSPhase, Generate, LockedSource, NoSource, BadSemantics],
Rope: TYPE USING [ROPE],
Runtime USING [GetBcdTime],
UnsafeStorage: TYPE USING [NewUZone, FreeUZone],
WindowManager: TYPE USING [WaitCursor, UnWaitCursor];
PGSInterface:
PROGRAM
IMPORTS Commander, CommandUtil, Cursors, IO, PGSOps, Runtime, UnsafeStorage, WindowManager
EXPORTS PGSConDefs = {
Main:
SAFE
PROC [cmd: Commander.Handle] =
TRUSTED {
source: Rope.ROPE;
ok, warnings: BOOL;
switches: Rope.ROPE;
args, results: CommandUtil.PairList;
zone ← UnsafeStorage.NewUZone[];
cmd.out.PutRope["Cedar 3.3 PGS of "];
cmd.out.Put[IO.time[Runtime.GetBcdTime[]], IO.char[IO.CR]];
set up command stream
BEGIN
cmd.out.PutRope["\nCommand: "];
[source, args, results, switches] ← CommandUtil.Parse[s: cmd.in
! CommandUtil.Failed => GO TO badSyntax];
CommandUtil.Echo[cmd.out, source, args, results, switches];
IF source = NIL THEN GO TO noOp;
[ok, warnings] ← PGSOps.Generate[source, args, results, switches, StartPhase,
TRUE
! PGSOps.NoSource =>
GO
TO noSource;
PGSOps.LockedSource => GO TO lockedSource;
PGSOps.BadSemantics => GO TO badSemantics];
cmd.out.PutRope["\n "];
cmd.out.PutRope[
SELECT
TRUE
FROM
~ok => "Errors logged, bad output",
warnings => "Warnings logged",
ENDCASE => "Completed successfully"];
EXITS
noOp => NULL;
noSource => cmd.out.PutRope[" -- Cannot be opened"];
lockedSource => cmd.out.PutRope[" -- Cannot be modified"];
badSyntax => cmd.out.PutRope[" -- Unparsable command"];
badSemantics => cmd.out.PutRope[" -- Illegal command"];
END;
UnsafeStorage.FreeUZone[zone]; zone ← NIL;
cmd.out.PutChar[IO.CR];
cmd.out.PutChar[IO.CR];
WindowManager.UnWaitCursor[];
WindowManager.UnWaitCursor[]};
Commander.Register["PGS", Main, "Parser generator system."];
}.