PGSInterface.Mesa
Copyright © 1985 by Xerox Corporation. All rights reserved.
Satterthwaite, October 16, 1985 4:01:31 pm PDT
Maxwell, August 9, 1983 10:50 am
Wyatt, March 29, 1984 2:57:25 pm PST
Russ Atkinson (RRA) March 19, 1985 9:57:40 am PST
DIRECTORY
BasicTime USING [GMT],
Commander USING [CommandProc, Register],
CommandUtil USING [PairList, Echo, Failed, Parse],
IO USING [PutChar, PutF, PutRope, RIS, time],
Loader USING [BCDBuildTime],
PGSOps USING [PGSPhase, Generate, LockedSource, NoSource, BadSemantics],
Rope USING [ROPE];
PGSInterface: PROGRAM
IMPORTS Commander, CommandUtil, IO, Loader, PGSOps
= {
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]];
* * * * * * HERE IT BEGINS * * * * * *
buildTime: BasicTime.GMT ~ Loader.BCDBuildTime[Main];
Main: Commander.CommandProc = TRUSTED {
PROC [cmd: Handle] RETURNS [result: REFNIL, msg: Rope.ROPENIL];
source: Rope.ROPE;
ok, warnings: BOOL;
switches: Rope.ROPE;
args, results: CommandUtil.PairList;
StartPhase: PROC [phase: PGSOps.PGSPhase] RETURNS [goOn: BOOLTRUE] = {
SELECT phase FROM
format => cmd.out.PutRope["format ... "];
lalr => cmd.out.PutRope["lalr ... "];
ENDCASE => cmd.out.PutRope["??? ... "];
};
cmd.out.PutF["Cedar 6.0 PGS of %g\n", IO.time[buildTime]];
set up command stream
BEGIN
[source, args, results, switches] ← CommandUtil.Parse[s: IO.RIS[cmd.commandLine]
! CommandUtil.Failed => GO TO badSyntax];
cmd.out.PutRope["PGS: "];
CommandUtil.Echo[cmd.out, source, args, results, switches];
IF source = NIL THEN GO TO noOp;
cmd.out.PutRope["\n "];
[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[" "];
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;
cmd.out.PutChar['\n];
};
Commander.Register["PGS", Main, "Parser generator system."];
}.