file PGSInterface.Mesa
last modified by Satterthwaite, January 10, 1983 4:21 pm
Last Edited by: Maxwell, August 9, 1983 10:50 am
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 = {
scratch region and scratch zone management
zone: PUBLIC UNCOUNTED ZONENIL;
cursor management
preCursor: Cursors.CursorType ← Cursors.NewCursor[
[0, 0, 0, 0, 76b, 146b, 300b, 4300b, 76336b, 4304b, 314b, 164b, 0, 0, 0, 0]];
pgsCursor: Cursors.CursorType ← Cursors.NewCursor[
[37000b, 63000b, 140000b, 140010b, 157174b, 142010b, 146000b, 72000b,
0b, 177777b, 111111b, 177777b, 111111b, 177777b, 111111b, 177777b]];
StartPhase: PROC [phase: PGSOps.PGSPhase] RETURNS [goOn: BOOLTRUE] = {
SELECT phase FROM
$format => WindowManager.WaitCursor[preCursor];
$lalr => WindowManager.WaitCursor[pgsCursor];
ENDCASE};
* * * * * * HERE IT BEGINS * * * * * *
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."];
}.