NPGSInterface.mesa
Copyright Ó 1985, 1986, 1988 by Xerox Corporation. All rights reserved.
Satterthwaite, October 16, 1985 4:01:31 pm PDT
Maxwell, August 9, 1983 10:50 am
Russ Atkinson (RRA) March 17, 1988 9:57:33 am PST
Doug Wyatt, December 18, 1986 1:45:31 pm PST
JKF February 6, 1989 12:12:29 pm PST
Michael Plass, December 10, 1992 10:48 pm PST
DIRECTORY
BasicTime USING [GMT],
Commander USING [CommandProc, Register],
NPGSCommandUtil USING [PairList, Echo, Failed, ParseCommand],
IO,
Loader USING [BCDBuildTime],
NPGSOps USING [NPGSPhase, Generate, LockedSource, NoSource, BadSemantics],
Rope USING [ROPE];
NPGSInterface:
CEDAR PROGRAM
IMPORTS Commander, NPGSCommandUtil, IO, Loader, NPGSOps
= {
buildTime: BasicTime.GMT ~ Loader.BCDBuildTime[Main];
Main: Commander.CommandProc = {
PROC [cmd: Handle] RETURNS [result: REF ¬ NIL, msg: Rope.ROPE ¬ NIL];
source: Rope.ROPE;
ok, warnings: BOOL;
switches: Rope.ROPE;
args, results: NPGSCommandUtil.PairList;
StartPhase:
PROC [phase: NPGSOps.NPGSPhase]
RETURNS [goOn:
BOOL ¬
TRUE] = {
SELECT phase
FROM
format => cmd.out.PutRope["format ... "];
lalr => cmd.out.PutRope["lalr ... "];
ENDCASE => cmd.out.PutRope["??? ... "];
cmd.out.PutF1["Cedar 10.1 NPGS of %g\n", IO.time[buildTime]];
set up command stream
BEGIN
[source, args, results, switches] ¬ NPGSCommandUtil.ParseCommand[s:
IO.
RIS[cmd.commandLine]
! NPGSCommandUtil.Failed => GO TO badSyntax];
cmd.out.PutRope["NPGS: "];
NPGSCommandUtil.Echo[cmd.out, source, args, results, switches];
IF source = NIL THEN GO TO noOp;
cmd.out.PutRope["\n "];
[ok, warnings] ¬ NPGSOps.Generate[source, args, results, switches, StartPhase,
TRUE
! NPGSOps.NoSource =>
GO
TO noSource;
NPGSOps.LockedSource => GO TO lockedSource;
NPGSOps.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[key: "NPGS", proc: Main, doc: "Parser generator system. Switches: -c => use CUSP extensions, -m => generate Mesa (vs. Cedar) source code"];
}.