<<>> <> <> <> <> <> <> <> DIRECTORY BasicTime USING [GMT], Commander USING [CommandProc, Register], NPGSCommandUtil USING [PairList, Echo, Failed, ParseCommand], IO USING [PutChar, PutF, PutRope, RIS, time], 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 = { <> 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.PutF["Cedar 7.0 NPGS of %g\n", IO.time[buildTime]]; <> 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"]; }.