ExampleDriver.Mesa
Copyright Ó 1987 by Xerox Corporation. All rights reserved.
Bill Jackson (bj) April 22, 1987 2:41:09 am PDT
DIRECTORY
Commander USING [CommandProc, Register],
IO USING [int, PutF],
OneCasabaParser USING [GetReportStream],
Rope USING [ROPE],
ThreeC4Support USING [GetReportStream],
ExampleATDef USING [ExpressionNode],
ExampleParserDef USING [ParseOneStream];
ExampleDriver:
CEDAR
MONITOR
IMPORTS Commander, IO, OneCasabaParser, ThreeC4Support, ExampleParserDef ~ {
ROPE: TYPE ~ Rope.ROPE;
debugFlags: CARDINAL ← 0;
ExampleProc: Commander.CommandProc ~ {
ENABLE {
ThreeC4Support.GetReportStream => RESUME[cmd.out];
OneCasabaParser.GetReportStream => { result ← $Failure; RESUME[cmd.out] };
};
root: ExampleATDef.ExpressionNode;
result ← $Success; -- bad assumption?
root ← NARROW[ExampleParserDef.ParseOneStream[cmd.in, debugFlags, cmd.out]];
IF ( result = $Failure )
THEN {
IO.PutF[cmd.out, "Syntax Errors Detected.\n"];
}
ELSE {
value: INT;
IO.PutF[cmd.out, "No Syntax Errors Detected.\n"];
value ← root.procs.Evaluate[root];
IO.PutF[cmd.out, "And the value is: %g.\n", IO.int[value]];
};
};
exampledoc: ROPE ~ " < file\n\tWhere the contents of file is an interesting expression";
Commander.Register["Example", ExampleProc, exampledoc];
}...